From c51d9f8282c7f7380ea045a4fb4021c2b645dbfe Mon Sep 17 00:00:00 2001 From: jimkyndemeyer Date: Sun, 31 Mar 2019 10:18:35 +0200 Subject: [PATCH] Include fragments defined in the currently edited scratch files in fragment completion (#164) --- .../lang/jsgraphql/ide/project/GraphQLPsiSearchHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/com/intellij/lang/jsgraphql/ide/project/GraphQLPsiSearchHelper.java b/src/main/com/intellij/lang/jsgraphql/ide/project/GraphQLPsiSearchHelper.java index eb6c30fe..149aef0f 100644 --- a/src/main/com/intellij/lang/jsgraphql/ide/project/GraphQLPsiSearchHelper.java +++ b/src/main/com/intellij/lang/jsgraphql/ide/project/GraphQLPsiSearchHelper.java @@ -44,6 +44,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.GlobalSearchScopesCore; import com.intellij.psi.search.scope.packageSet.NamedScope; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.testFramework.LightVirtualFile; import com.intellij.util.Processor; import com.intellij.util.indexing.FileBasedIndex; @@ -183,8 +184,8 @@ public List getKnownFragmentDefinitions(PsiElement sc final List fragmentDefinitions = Lists.newArrayList(); GlobalSearchScope schemaScope = getSchemaScope(scopedElement); if (GraphQLFileType.isGraphQLScratchFile(myProject, getVirtualFile(scopedElement.getContainingFile()))) { - // include the fragments in the currently edited scratch file - schemaScope = schemaScope.union(GlobalSearchScope.fileScope(scopedElement.getContainingFile())); + // include the fragments defined in the currently edited scratch file (scratch files don't appear to be indexed) + fragmentDefinitions.addAll(PsiTreeUtil.getChildrenOfTypeAsList(scopedElement.getContainingFile().getOriginalFile(), GraphQLFragmentDefinition.class)); } final PsiManager psiManager = PsiManager.getInstance(myProject);