Search in sources :

Example 11 with PerlExportDescriptor

use of com.perl5.lang.perl.extensions.packageprocessor.PerlExportDescriptor 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 12 with PerlExportDescriptor

use of com.perl5.lang.perl.extensions.packageprocessor.PerlExportDescriptor 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 13 with PerlExportDescriptor

use of com.perl5.lang.perl.extensions.packageprocessor.PerlExportDescriptor 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

PerlExportDescriptor (com.perl5.lang.perl.extensions.packageprocessor.PerlExportDescriptor)9 NotNull (org.jetbrains.annotations.NotNull)9 PsiElement (com.intellij.psi.PsiElement)5 PerlImportsCollector (com.perl5.lang.perl.util.processors.PerlImportsCollector)4 Project (com.intellij.openapi.project.Project)3 PsiFile (com.intellij.psi.PsiFile)2 ResolveResult (com.intellij.psi.ResolveResult)2 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)2 ArrayList (java.util.ArrayList)2 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1 SortableTreeElement (com.intellij.ide.util.treeView.smartTree.SortableTreeElement)1 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)1 Language (com.intellij.lang.Language)1 ItemPresentation (com.intellij.navigation.ItemPresentation)1 FileViewProvider (com.intellij.psi.FileViewProvider)1 PsiElementResolveResult (com.intellij.psi.PsiElementResolveResult)1 PsiNamedElement (com.intellij.psi.PsiNamedElement)1 PerlLanguage (com.perl5.lang.perl.PerlLanguage)1 PerlItemPresentationBase (com.perl5.lang.perl.idea.presentations.PerlItemPresentationBase)1