Skip to content

Commit dd537e6

Browse files
committed
- Indicate that the schema file in the tree view is non-physical to prevent conflicts with Kotlin PSI file intention (#18)
- Switched from deprecated NodeJS Utils to NodeJsInterpreterManager to ensure compatibility with 2016.x versions (cherry picked from commit 6137f80)
1 parent c37c134 commit dd537e6

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/main/com/intellij/lang/jsgraphql/languageservice/JSGraphQLNodeLanguageServiceInstance.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
import com.intellij.execution.process.ProcessOutputTypes;
1616
import com.intellij.ide.plugins.IdeaPluginDescriptor;
1717
import com.intellij.ide.plugins.PluginManager;
18-
import com.intellij.javascript.nodejs.NodeDetectionUtil;
19-
import com.intellij.javascript.nodejs.NodeSettingsUtil;
18+
import com.intellij.javascript.nodejs.interpreter.NodeJsInterpreter;
19+
import com.intellij.javascript.nodejs.interpreter.NodeJsInterpreterManager;
20+
import com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter;
2021
import com.intellij.lang.jsgraphql.JSGraphQLDebugUtil;
2122
import com.intellij.lang.jsgraphql.ide.project.JSGraphQLLanguageUIProjectService;
2223
import com.intellij.openapi.application.Application;
@@ -84,14 +85,11 @@ public JSGraphQLNodeLanguageServiceInstance(@NotNull Project project) {
8485
}
8586

8687
public static String getNodeInterpreter(Project project) {
87-
String interpreterPath = NodeSettingsUtil.getInterpreterPath(project);
88-
if(interpreterPath == null) {
89-
File interpreterInPath = NodeDetectionUtil.findInterpreterInPath();
90-
if(interpreterInPath != null) {
91-
interpreterPath = interpreterInPath.getAbsolutePath();
92-
}
93-
}
94-
return interpreterPath;
88+
final NodeJsInterpreter nodeJsInterpreter = NodeJsInterpreterManager.getInstance(project).getDefault();
89+
if(nodeJsInterpreter instanceof NodeJsLocalInterpreter) {
90+
return ((NodeJsLocalInterpreter) nodeJsInterpreter).getInterpreterSystemDependentPath();
91+
}
92+
return null;
9593
}
9694

9795
private void createProcessHandler() {

src/main/com/intellij/lang/jsgraphql/schema/psi/JSGraphQLSchemaFile.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.intellij.extapi.psi.PsiFileBase;
1111
import com.intellij.lang.jsgraphql.schema.JSGraphQLSchemaFileType;
1212
import com.intellij.lang.jsgraphql.schema.JSGraphQLSchemaLanguage;
13+
import com.intellij.lang.jsgraphql.schema.ide.project.JSGraphQLSchemaLanguageProjectService;
1314
import com.intellij.openapi.fileTypes.FileType;
1415
import com.intellij.psi.FileViewProvider;
1516
import com.intellij.psi.search.ProjectScope;
@@ -41,4 +42,13 @@ public String toString() {
4142
return "GraphQL Schema File";
4243
}
4344

45+
@Override
46+
public boolean isPhysical() {
47+
if(Boolean.TRUE.equals(getVirtualFile().getUserData(JSGraphQLSchemaLanguageProjectService.IS_GRAPHQL_SCHEMA_VIRTUAL_FILE))) {
48+
// indicate that the psi file that backs the "GraphQL Schemas" project tree node is considered non-physical.
49+
// this hides it from PSI file intentions etc.
50+
return false;
51+
}
52+
return super.isPhysical();
53+
}
4454
}

0 commit comments

Comments
 (0)