Skip to content

Commit a0e56c0

Browse files
committed
Made GraphQL language injection compatible with new PSI for tagged templates in IDEA 2017.1 EAP (#60)
1 parent 2ca8f4f commit a0e56c0

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.5.1 (2017-02-12)
2+
3+
Fixes:
4+
5+
- 2017.1 EAP Not detecting Relay.QL usage (#60)
6+
17
## 1.5.0 (2017-01-29)
28

39
Features:

resources/META-INF/plugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<idea-plugin version="2">
1111
<id>com.intellij.lang.jsgraphql</id>
1212
<name>JS GraphQL</name>
13-
<version>1.5.0</version>
13+
<version>1.5.1</version>
1414
<vendor>Jim Kynde Meyer - [email protected]</vendor>
1515

1616
<description><![CDATA[
@@ -29,6 +29,7 @@
2929

3030
<change-notes><![CDATA[
3131
<ul>
32+
<li>1.5.1: Compatible with IntelliJ IDEA 2017.1 EAP tagged template expressions.</li>
3233
<li>1.5.0: Language Service 1.4.0 based on graphql 0.9.1 and codemirror-graphql 0.6.2. Experimental support for GraphQL Endpoint Language (.graphqle)</li>
3334
<li>1.4.4: Fixes Assertion failed: Caret model is in its update process.</li>
3435
<li>1.4.3: GraphQL configuration page for indentation. Language Service 1.3.2: Object literal for variables in getFragment closes Relay.QL template expression.</li>

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,16 @@ public static boolean isJSGraphQLLanguageInjectionTarget(PsiElement host, @Nulla
8080
if (host instanceof JSStringTemplateExpression && host instanceof PsiLanguageInjectionHost) {
8181
JSStringTemplateExpression template = (JSStringTemplateExpression) host;
8282
// check if we're a Relay.QL or graphql tagged template
83-
final PsiElement firstChild = template.getFirstChild();
84-
if (firstChild instanceof JSReferenceExpression) {
85-
final String tagText = firstChild.getText();
83+
JSReferenceExpression tagExpression = null;
84+
if(template.getFirstChild() instanceof JSReferenceExpression) {
85+
// up to version 2016.X
86+
tagExpression = (JSReferenceExpression) template.getFirstChild();
87+
} else if(template.getPrevSibling() instanceof JSReferenceExpression) {
88+
// from version 2017.1
89+
tagExpression = (JSReferenceExpression) template.getPrevSibling();
90+
}
91+
if (tagExpression != null) {
92+
final String tagText = tagExpression.getText();
8693
if (SUPPORTED_TAG_NAMES.contains(tagText)) {
8794
if (envRef != null) {
8895
envRef.set(getEnvironmentFromTemplateTag(tagText, host));

src/main/com/intellij/lang/jsgraphql/ide/notifications/JSGraphQLConfigEditorNotificationProvider.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88
package com.intellij.lang.jsgraphql.ide.notifications;
99

10-
import com.google.common.collect.Sets;
1110
import com.intellij.ide.util.PropertiesComponent;
1211
import com.intellij.lang.jsgraphql.JSGraphQLFileType;
1312
import com.intellij.lang.jsgraphql.JSGraphQLParserDefinition;
@@ -26,16 +25,13 @@
2625
import com.intellij.openapi.fileEditor.FileEditor;
2726
import com.intellij.openapi.fileEditor.FileEditorManager;
2827
import com.intellij.openapi.module.Module;
29-
import com.intellij.openapi.module.ModuleManager;
3028
import com.intellij.openapi.project.Project;
3129
import com.intellij.openapi.util.Key;
3230
import com.intellij.openapi.vfs.VirtualFile;
3331
import com.intellij.psi.search.GlobalSearchScope;
3432
import com.intellij.ui.EditorNotificationPanel;
3533
import com.intellij.ui.EditorNotifications;
3634
import com.intellij.ui.EditorNotifications.Provider;
37-
import com.intellij.util.containers.ContainerUtil;
38-
import com.intellij.webcore.ui.ModuleSelectionDialog;
3935
import org.jetbrains.annotations.NotNull;
4036
import org.jetbrains.annotations.Nullable;
4137

0 commit comments

Comments
 (0)