Search in sources :

Example 1 with GrImportContributor

use of org.jetbrains.plugins.groovy.lang.resolve.GrImportContributor in project intellij-community by JetBrains.

the class GroovyImportHelper method getImplicitlyImportedPackages.

public static LinkedHashSet<String> getImplicitlyImportedPackages(@NotNull GroovyFile file) {
    final LinkedHashSet<String> result = new LinkedHashSet<>();
    ContainerUtil.addAll(result, GroovyFileBase.IMPLICITLY_IMPORTED_PACKAGES);
    for (GrImportContributor contributor : GrImportContributor.EP_NAME.getExtensions()) {
        result.addAll(ContainerUtil.mapNotNull(contributor.getImports(file), i -> i.getType() == ImportType.STAR ? i.getName() : null));
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PsiScopeProcessor(com.intellij.psi.scope.PsiScopeProcessor) GrImportStatement(org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement) ResolveState(com.intellij.psi.ResolveState) ContainerUtil(com.intellij.util.containers.ContainerUtil) GroovyFileBase(org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase) GrImportContributor(org.jetbrains.plugins.groovy.lang.resolve.GrImportContributor) Nullable(org.jetbrains.annotations.Nullable) PsiClass(com.intellij.psi.PsiClass) PsiElement(com.intellij.psi.PsiElement) ImportType(org.jetbrains.plugins.groovy.lang.resolve.ImportType) NotNull(org.jetbrains.annotations.NotNull) GroovyFile(org.jetbrains.plugins.groovy.lang.psi.GroovyFile) LinkedHashSet(java.util.LinkedHashSet) GrImportContributor(org.jetbrains.plugins.groovy.lang.resolve.GrImportContributor)

Aggregations

PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 ResolveState (com.intellij.psi.ResolveState)1 PsiScopeProcessor (com.intellij.psi.scope.PsiScopeProcessor)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 LinkedHashSet (java.util.LinkedHashSet)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 GroovyFile (org.jetbrains.plugins.groovy.lang.psi.GroovyFile)1 GroovyFileBase (org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase)1 GrImportStatement (org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement)1 GrImportContributor (org.jetbrains.plugins.groovy.lang.resolve.GrImportContributor)1 ImportType (org.jetbrains.plugins.groovy.lang.resolve.ImportType)1