From dd537e6dc38ea7ebdcb7b706fbfe45bd2287e489 Mon Sep 17 00:00:00 2001 From: Jim Meyer Date: Tue, 16 Aug 2016 15:24:21 +0200 Subject: [PATCH] - 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) --- .../JSGraphQLNodeLanguageServiceInstance.java | 18 ++++++++---------- .../schema/psi/JSGraphQLSchemaFile.java | 10 ++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/com/intellij/lang/jsgraphql/languageservice/JSGraphQLNodeLanguageServiceInstance.java b/src/main/com/intellij/lang/jsgraphql/languageservice/JSGraphQLNodeLanguageServiceInstance.java index 1dc00e96..8877b7a9 100644 --- a/src/main/com/intellij/lang/jsgraphql/languageservice/JSGraphQLNodeLanguageServiceInstance.java +++ b/src/main/com/intellij/lang/jsgraphql/languageservice/JSGraphQLNodeLanguageServiceInstance.java @@ -15,8 +15,9 @@ import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.ide.plugins.PluginManager; -import com.intellij.javascript.nodejs.NodeDetectionUtil; -import com.intellij.javascript.nodejs.NodeSettingsUtil; +import com.intellij.javascript.nodejs.interpreter.NodeJsInterpreter; +import com.intellij.javascript.nodejs.interpreter.NodeJsInterpreterManager; +import com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter; import com.intellij.lang.jsgraphql.JSGraphQLDebugUtil; import com.intellij.lang.jsgraphql.ide.project.JSGraphQLLanguageUIProjectService; import com.intellij.openapi.application.Application; @@ -84,14 +85,11 @@ public JSGraphQLNodeLanguageServiceInstance(@NotNull Project project) { } public static String getNodeInterpreter(Project project) { - String interpreterPath = NodeSettingsUtil.getInterpreterPath(project); - if(interpreterPath == null) { - File interpreterInPath = NodeDetectionUtil.findInterpreterInPath(); - if(interpreterInPath != null) { - interpreterPath = interpreterInPath.getAbsolutePath(); - } - } - return interpreterPath; + final NodeJsInterpreter nodeJsInterpreter = NodeJsInterpreterManager.getInstance(project).getDefault(); + if(nodeJsInterpreter instanceof NodeJsLocalInterpreter) { + return ((NodeJsLocalInterpreter) nodeJsInterpreter).getInterpreterSystemDependentPath(); + } + return null; } private void createProcessHandler() { diff --git a/src/main/com/intellij/lang/jsgraphql/schema/psi/JSGraphQLSchemaFile.java b/src/main/com/intellij/lang/jsgraphql/schema/psi/JSGraphQLSchemaFile.java index eebceab8..e98b9118 100644 --- a/src/main/com/intellij/lang/jsgraphql/schema/psi/JSGraphQLSchemaFile.java +++ b/src/main/com/intellij/lang/jsgraphql/schema/psi/JSGraphQLSchemaFile.java @@ -10,6 +10,7 @@ import com.intellij.extapi.psi.PsiFileBase; import com.intellij.lang.jsgraphql.schema.JSGraphQLSchemaFileType; import com.intellij.lang.jsgraphql.schema.JSGraphQLSchemaLanguage; +import com.intellij.lang.jsgraphql.schema.ide.project.JSGraphQLSchemaLanguageProjectService; import com.intellij.openapi.fileTypes.FileType; import com.intellij.psi.FileViewProvider; import com.intellij.psi.search.ProjectScope; @@ -41,4 +42,13 @@ public String toString() { return "GraphQL Schema File"; } + @Override + public boolean isPhysical() { + if(Boolean.TRUE.equals(getVirtualFile().getUserData(JSGraphQLSchemaLanguageProjectService.IS_GRAPHQL_SCHEMA_VIRTUAL_FILE))) { + // indicate that the psi file that backs the "GraphQL Schemas" project tree node is considered non-physical. + // this hides it from PSI file intentions etc. + return false; + } + return super.isPhysical(); + } } \ No newline at end of file