Search in sources :

Example 26 with PerlNamespaceDefinitionElement

use of com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement in project Perl5-IDEA by Camelcade.

the class PerlUtil method processImportedEntities.

/**
 * Processing use statements in the namespace or file and processing all imports found
 *
 * @param namespace Root element to start searching from
 */
public static void processImportedEntities(@NotNull PerlNamespaceDefinitionElement namespace, @NotNull PerlNamespaceEntityProcessor<PerlExportDescriptor> processor) {
    for (PsiElement element : PerlPsiUtil.collectUseStatements(namespace)) {
        PerlUseStatement useStatement = (PerlUseStatement) element;
        String packageName = useStatement.getPackageName();
        if (packageName != null) {
            for (PerlExportDescriptor entry : useStatement.getPackageProcessor().getImports(useStatement)) {
                ProgressManager.checkCanceled();
                processor.process(packageName, entry);
            }
        }
    }
    PerlImportsProvider.processProviders(namespace, provider -> {
        for (PerlExportDescriptor descriptor : provider.getImports()) {
            if (!processor.process(namespace.getPackageName(), descriptor)) {
                return false;
            }
        }
        return true;
    });
}
Also used : PerlExportDescriptor(com.perl5.lang.perl.extensions.packageprocessor.PerlExportDescriptor) PerlUseStatement(com.perl5.lang.perl.psi.PerlUseStatement) PsiElement(com.intellij.psi.PsiElement)

Example 27 with PerlNamespaceDefinitionElement

use of com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement in project Perl5-IDEA by Camelcade.

the class PerlArrayUtil method getImportedArraysDescriptors.

/**
 * Returns a map of imported arrays names
 *
 * @param namespaceDefinitionElement element to start looking from
 * @return result map
 */
@NotNull
public static List<PerlExportDescriptor> getImportedArraysDescriptors(@NotNull PerlNamespaceDefinitionElement namespaceDefinitionElement) {
    PerlImportsCollector collector = new PerlArrayImportsCollector();
    PerlUtil.processImportedEntities(namespaceDefinitionElement, collector);
    return collector.getResult();
}
Also used : PerlArrayImportsCollector(com.perl5.lang.perl.util.processors.PerlArrayImportsCollector) PerlImportsCollector(com.perl5.lang.perl.util.processors.PerlImportsCollector) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with PerlNamespaceDefinitionElement

use of com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement in project Perl5-IDEA by Camelcade.

the class PerlHashUtil method getImportedHashesDescriptors.

/**
 * Returns a map of imported hashes names
 *
 * @param namespaceDefinitionElement element to start looking from
 * @return result map
 */
@NotNull
public static List<PerlExportDescriptor> getImportedHashesDescriptors(@NotNull PerlNamespaceDefinitionElement namespaceDefinitionElement) {
    PerlImportsCollector collector = new PerlHashImportsCollector();
    PerlUtil.processImportedEntities(namespaceDefinitionElement, collector);
    return collector.getResult();
}
Also used : PerlHashImportsCollector(com.perl5.lang.perl.util.processors.PerlHashImportsCollector) PerlImportsCollector(com.perl5.lang.perl.util.processors.PerlImportsCollector) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PerlNamespaceDefinitionElement (com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement)17 PsiElement (com.intellij.psi.PsiElement)12 NotNull (org.jetbrains.annotations.NotNull)10 Project (com.intellij.openapi.project.Project)8 ArrayList (java.util.ArrayList)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 PsiFile (com.intellij.psi.PsiFile)6 PerlExportDescriptor (com.perl5.lang.perl.extensions.packageprocessor.PerlExportDescriptor)6 ResolveResult (com.intellij.psi.ResolveResult)4 PerlImportsCollector (com.perl5.lang.perl.util.processors.PerlImportsCollector)4 PsiElementResolveResult (com.intellij.psi.PsiElementResolveResult)3 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)3 MasonSettings (com.perl5.lang.mason2.idea.configuration.MasonSettings)2 PerlSubDefinitionElement (com.perl5.lang.perl.psi.PerlSubDefinitionElement)2 PerlUseStatement (com.perl5.lang.perl.psi.PerlUseStatement)2 PerlFileImpl (com.perl5.lang.perl.psi.impl.PerlFileImpl)2 PerlNamespaceDefinitionStub (com.perl5.lang.perl.psi.stubs.namespaces.PerlNamespaceDefinitionStub)2 THashSet (gnu.trove.THashSet)2 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1