Skip to content

Commit

Permalink
Include fragments defined in the currently edited scratch files in fr…
Browse files Browse the repository at this point in the history
…agment completion (#164)
  • Loading branch information
jimkyndemeyer committed Mar 31, 2019
1 parent 86e0b5e commit c51d9f8
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -183,8 +184,8 @@ public List<GraphQLFragmentDefinition> getKnownFragmentDefinitions(PsiElement sc
final List<GraphQLFragmentDefinition> 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);
Expand Down

0 comments on commit c51d9f8

Please sign in to comment.