File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed
src/main/com/intellij/lang/jsgraphql/ide/injection/javascript Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change 2222import com .intellij .psi .PsiElement ;
2323import com .intellij .psi .PsiFile ;
2424import com .intellij .psi .PsiRecursiveElementVisitor ;
25+ import com .intellij .psi .util .PsiTreeUtil ;
2526import org .jetbrains .annotations .Nullable ;
2627
2728import java .util .Set ;
@@ -86,15 +87,8 @@ public void visitElement(PsiElement element) {
8687 public static boolean isJSGraphQLLanguageInjectionTarget (PsiElement host , @ Nullable Ref <String > envRef ) {
8788 if (host instanceof JSStringTemplateExpression ) {
8889 JSStringTemplateExpression template = (JSStringTemplateExpression ) host ;
89- // check if we're a Relay.QL or graphql tagged template
90- JSReferenceExpression tagExpression = null ;
91- if (template .getFirstChild () instanceof JSReferenceExpression ) {
92- // up to version 2016.X
93- tagExpression = (JSReferenceExpression ) template .getFirstChild ();
94- } else if (template .getPrevSibling () instanceof JSReferenceExpression ) {
95- // from version 2017.1
96- tagExpression = (JSReferenceExpression ) template .getPrevSibling ();
97- }
90+ // check if we're a graphql tagged template
91+ final JSReferenceExpression tagExpression = PsiTreeUtil .getPrevSiblingOfType (template , JSReferenceExpression .class );
9892 if (tagExpression != null ) {
9993 final String tagText = tagExpression .getText ();
10094 if (SUPPORTED_TAG_NAMES .contains (tagText )) {
You can’t perform that action at this time.
0 commit comments