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 22
22
import com .intellij .psi .PsiElement ;
23
23
import com .intellij .psi .PsiFile ;
24
24
import com .intellij .psi .PsiRecursiveElementVisitor ;
25
+ import com .intellij .psi .util .PsiTreeUtil ;
25
26
import org .jetbrains .annotations .Nullable ;
26
27
27
28
import java .util .Set ;
@@ -86,15 +87,8 @@ public void visitElement(PsiElement element) {
86
87
public static boolean isJSGraphQLLanguageInjectionTarget (PsiElement host , @ Nullable Ref <String > envRef ) {
87
88
if (host instanceof JSStringTemplateExpression ) {
88
89
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 );
98
92
if (tagExpression != null ) {
99
93
final String tagText = tagExpression .getText ();
100
94
if (SUPPORTED_TAG_NAMES .contains (tagText )) {
You can’t perform that action at this time.
0 commit comments