1818import com .intellij .psi .util .PsiTreeUtil ;
1919import org .jetbrains .annotations .NotNull ;
2020import pl .thedeem .intellij .dpl .style .DPLCodeStyleSettings ;
21+ import pl .thedeem .intellij .dql .DQLFileType ;
2122import pl .thedeem .intellij .dql .psi .DQLElementFactory ;
2223import pl .thedeem .intellij .dql .psi .DQLMultilineString ;
2324import pl .thedeem .intellij .dql .psi .DQLTypes ;
@@ -41,9 +42,14 @@ public class DQLPostFormatProcessor implements PostFormatProcessor {
4142 public @ NotNull TextRange processText (@ NotNull PsiFile hostFile , @ NotNull TextRange range , @ NotNull CodeStyleSettings settings ) {
4243 Project project = hostFile .getProject ();
4344 DQLCodeStyleSettings dqlSettings = settings .getCustomSettings (DQLCodeStyleSettings .class );
44- final PsiDocumentManager documentManager = PsiDocumentManager .getInstance (project );
45- processInjectedHosts (hostFile , range , settings , documentManager , project , dqlSettings );
45+
46+ // Process only for DQL files or injected fragments
47+ if (!hostFile .getFileType ().equals (DQLFileType .INSTANCE )) {
48+ return range ;
49+ }
4650 processComments (hostFile , range , dqlSettings );
51+ processInjectedHosts (hostFile , range , settings , project , dqlSettings );
52+
4753 return range ;
4854 }
4955
@@ -87,12 +93,12 @@ private void processInjectedHosts(
8793 @ NotNull PsiFile hostFile ,
8894 @ NotNull TextRange range ,
8995 @ NotNull CodeStyleSettings settings ,
90- @ NotNull PsiDocumentManager documentManager ,
9196 @ NotNull Project project ,
9297 @ NotNull DQLCodeStyleSettings dqlSettings
9398 ) {
94- InjectedLanguageManager injector = InjectedLanguageManager .getInstance (project );
95- CodeStyleManager styleManager = CodeStyleManager .getInstance (project );
99+ final PsiDocumentManager documentManager = PsiDocumentManager .getInstance (project );
100+ final InjectedLanguageManager injector = InjectedLanguageManager .getInstance (project );
101+ final CodeStyleManager styleManager = CodeStyleManager .getInstance (project );
96102 Collection <PsiFile > injectedFiles = findInjectionHosts (hostFile , injector , range , settings );
97103 if (injectedFiles .isEmpty ()) {
98104 return ;
0 commit comments