Skip to content

Commit c51d9f8

Browse files
committed
Include fragments defined in the currently edited scratch files in fragment completion (#164)
1 parent 86e0b5e commit c51d9f8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/com/intellij/lang/jsgraphql/ide/project/GraphQLPsiSearchHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.intellij.psi.search.GlobalSearchScope;
4545
import com.intellij.psi.search.GlobalSearchScopesCore;
4646
import com.intellij.psi.search.scope.packageSet.NamedScope;
47+
import com.intellij.psi.util.PsiTreeUtil;
4748
import com.intellij.testFramework.LightVirtualFile;
4849
import com.intellij.util.Processor;
4950
import com.intellij.util.indexing.FileBasedIndex;
@@ -183,8 +184,8 @@ public List<GraphQLFragmentDefinition> getKnownFragmentDefinitions(PsiElement sc
183184
final List<GraphQLFragmentDefinition> fragmentDefinitions = Lists.newArrayList();
184185
GlobalSearchScope schemaScope = getSchemaScope(scopedElement);
185186
if (GraphQLFileType.isGraphQLScratchFile(myProject, getVirtualFile(scopedElement.getContainingFile()))) {
186-
// include the fragments in the currently edited scratch file
187-
schemaScope = schemaScope.union(GlobalSearchScope.fileScope(scopedElement.getContainingFile()));
187+
// include the fragments defined in the currently edited scratch file (scratch files don't appear to be indexed)
188+
fragmentDefinitions.addAll(PsiTreeUtil.getChildrenOfTypeAsList(scopedElement.getContainingFile().getOriginalFile(), GraphQLFragmentDefinition.class));
188189
}
189190

190191
final PsiManager psiManager = PsiManager.getInstance(myProject);

0 commit comments

Comments
 (0)