Skip to content

Commit 7cc0aee

Browse files
committed
Revert "Trigger GraphQL language injection for builder APIs ending with supported tag (#112)"
This reverts commit d314843
1 parent d314843 commit 7cc0aee

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

src/main/com/intellij/lang/jsgraphql/ide/editor/JSGraphQLLineMarkerProvider.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import java.util.Collection;
2525
import java.util.List;
2626

27-
import static com.intellij.lang.jsgraphql.ide.injection.JSGraphQLLanguageInjectionUtil.*;
28-
2927
public class JSGraphQLLineMarkerProvider implements LineMarkerProvider {
3028

3129
@Nullable
@@ -48,21 +46,20 @@ private LineMarkerInfo createLineMarkerInfo(PsiElement element, Ref<String> envR
4846
final String tooltip;
4947
final String url;
5048
boolean configureGQL = false;
51-
final String environment = envRef.get();
52-
if(RELAY_ENVIRONMENT.equals(environment)) {
49+
if(JSGraphQLLanguageInjectionUtil.RELAY_ENVIRONMENT.equals(envRef.get())) {
5350
icon = JSGraphQLIcons.Logos.Relay;
5451
tooltip = "Relay GraphQL Template";
5552
url = "https://facebook.github.io/relay/docs/api-reference-relay-ql.html";
56-
} else if(GRAPHQL_ENVIRONMENT.equals(environment) || GRAPHQL_TEMPLATE_ENVIRONMENT.equals(environment)) {
53+
} else if(JSGraphQLLanguageInjectionUtil.GRAPHQL_ENVIRONMENT.equals(envRef.get())) {
5754
icon = JSGraphQLIcons.Logos.GraphQL;
5855
tooltip = "GraphQL";
5956
url = "http://graphql.org/";
60-
} else if(APOLLO_ENVIRONMENT.equals(environment)) {
57+
} else if(JSGraphQLLanguageInjectionUtil.APOLLO_ENVIRONMENT.equals(envRef.get())) {
6158
icon = JSGraphQLIcons.Logos.Apollo;
6259
tooltip = "Apollo Client GraphQL Template";
6360
url = "http://docs.apollostack.com/apollo-client/core.html";
6461
configureGQL = true;
65-
} else if(LOKKA_ENVIRONMENT.equals(environment)) {
62+
} else if(JSGraphQLLanguageInjectionUtil.LOKKA_ENVIRONMENT.equals(envRef.get())) {
6663
icon = JSGraphQLIcons.Logos.Lokka;
6764
tooltip = "Lokka GraphQL Template";
6865
url = "https://github.com/kadirahq/lokka";

src/main/com/intellij/lang/jsgraphql/ide/injection/JSGraphQLLanguageInjectionUtil.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import com.google.common.collect.Sets;
1111
import com.intellij.ide.util.PropertiesComponent;
12-
import com.intellij.lang.javascript.psi.JSExpression;
1312
import com.intellij.lang.javascript.psi.JSFile;
1413
import com.intellij.lang.javascript.psi.JSReferenceExpression;
1514
import com.intellij.lang.javascript.psi.ecma6.JSStringTemplateExpression;
@@ -43,7 +42,6 @@ public class JSGraphQLLanguageInjectionUtil {
4342

4443

4544
public static final String GRAPHQL_ENVIRONMENT = "graphql";
46-
public static final String GRAPHQL_TEMPLATE_ENVIRONMENT = "graphql-template";
4745
public static final String RELAY_ENVIRONMENT = "relay";
4846
public static final String APOLLO_ENVIRONMENT = "apollo";
4947
public static final String LOKKA_ENVIRONMENT = "lokka";
@@ -95,14 +93,8 @@ public static boolean isJSGraphQLLanguageInjectionTarget(PsiElement host, @Nulla
9593
tagExpression = (JSReferenceExpression) template.getPrevSibling();
9694
}
9795
if (tagExpression != null) {
98-
String tagText = tagExpression.getText();
99-
boolean isSupportedTag = SUPPORTED_TAG_NAMES.contains(tagText);
100-
if(!isSupportedTag && tagExpression.getQualifier() != null && tagExpression.getReferenceNameElement() != null) {
101-
// also allow builder patterns to trigger injection, e.g. 'builder.foo.bar.graphql``'
102-
tagText = tagExpression.getReferenceNameElement().getText();
103-
isSupportedTag = SUPPORTED_TAG_NAMES.contains(tagText);
104-
}
105-
if (isSupportedTag) {
96+
final String tagText = tagExpression.getText();
97+
if (SUPPORTED_TAG_NAMES.contains(tagText)) {
10698
if (envRef != null) {
10799
envRef.set(getEnvironmentFromTemplateTag(tagText, host));
108100
}
@@ -118,13 +110,6 @@ public static String getEnvironmentFromTemplateTag(String tagText, PsiElement ho
118110
return RELAY_ENVIRONMENT;
119111
}
120112
if (GRAPHQL_TEMPLATE_TAG.equals(tagText) || GRAPHQL_EXPERIMENTAL_TEMPLATE_TAG.equals(tagText)) {
121-
if(host instanceof JSStringTemplateExpression) {
122-
final JSExpression[] arguments = ((JSStringTemplateExpression) host).getArguments();
123-
if(arguments.length > 0) {
124-
// one or more placeholders inside the tagged template text, so consider it templated graphql
125-
return GRAPHQL_TEMPLATE_ENVIRONMENT;
126-
}
127-
}
128113
return GRAPHQL_ENVIRONMENT;
129114
}
130115
if (GQL_TEMPLATE_TAG.equals(tagText)) {

0 commit comments

Comments
 (0)