Search in sources :

Example 21 with PerlNamespaceDefinitionElement

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

the class PerlMooseInnerReference method collectNamespaceMethodsAugmentations.

protected void collectNamespaceMethodsAugmentations(@NotNull PerlNamespaceDefinitionElement namespaceDefinition, @NotNull String subName, Set<PerlNamespaceDefinitionElement> recursionSet, List<ResolveResult> result) {
    recursionSet.add(namespaceDefinition);
    for (PerlNamespaceDefinitionElement childNamespace : namespaceDefinition.getChildNamespaceDefinitions()) {
        if (!recursionSet.contains(childNamespace)) {
            boolean noSubclasses = false;
            for (PsiElement augmentStatement : getAugmentStatements(childNamespace)) {
                if (subName.equals(((PerlMooseAugmentStatement) augmentStatement).getSubName())) {
                    result.add(new PsiElementResolveResult(augmentStatement));
                    noSubclasses = true;
                }
            }
            if (!noSubclasses) {
                collectNamespaceMethodsAugmentations(childNamespace, subName, recursionSet, result);
            }
        }
    }
}
Also used : PerlNamespaceDefinitionElement(com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) PsiElement(com.intellij.psi.PsiElement)

Example 22 with PerlNamespaceDefinitionElement

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

the class packageProcessorsTest method testModernPerl.

public void testModernPerl() {
    initWithFileSmart("ModernPerl");
    PerlNamespaceDefinitionElement namespaceDefinition = getElementAtCaret(PerlNamespaceDefinitionElement.class);
    assertNotNull(namespaceDefinition);
    assertEquals(PerlMroType.C3, namespaceDefinition.getMroType());
    PerlUseStatement useStatement = getElementAtCaret(PerlUseStatement.class);
    assertNotNull(useStatement);
    PerlPackageProcessor packageProcessor = useStatement.getPackageProcessor();
    assertNotNull(packageProcessor);
    assertInstanceOf(packageProcessor, PerlStrictProvider.class);
    assertInstanceOf(packageProcessor, PerlMroProvider.class);
    assertInstanceOf(packageProcessor, PerlWarningsProvider.class);
    assertInstanceOf(packageProcessor, PerlPackageLoader.class);
}
Also used : PerlNamespaceDefinitionElement(com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement) PerlUseStatement(com.perl5.lang.perl.psi.PerlUseStatement)

Example 23 with PerlNamespaceDefinitionElement

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

the class PerlPackageUtil method processNotOverridedMethods.

public static void processNotOverridedMethods(final PerlNamespaceDefinitionElement namespaceDefinition, Processor<PerlSubElement> processor) {
    if (namespaceDefinition != null) {
        PsiFile containingFile = namespaceDefinition.getContainingFile();
        String packageName = namespaceDefinition.getPackageName();
        if (packageName == null) {
            return;
        }
        Set<String> namesSet = new THashSet<>();
        // collecting overrided
        for (PerlSubDefinitionElement subDefinitionBase : PsiTreeUtil.findChildrenOfType(containingFile, PerlSubDefinitionElement.class)) {
            if (subDefinitionBase.isValid() && StringUtil.equals(packageName, subDefinitionBase.getPackageName())) {
                namesSet.add(subDefinitionBase.getSubName());
            }
        }
        processParentClassesSubs(namespaceDefinition, namesSet, new THashSet<>(), processor);
    }
}
Also used : PsiFile(com.intellij.psi.PsiFile) PerlSubDefinitionElement(com.perl5.lang.perl.psi.PerlSubDefinitionElement) THashSet(gnu.trove.THashSet)

Example 24 with PerlNamespaceDefinitionElement

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

the class PerlScalarUtil method getImportedScalarsDescritptors.

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

Example 25 with PerlNamespaceDefinitionElement

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

the class PerlSubUtil method getImportedSubsDescriptors.

/**
 * Returns a list of imported descriptors
 *
 * @param namespaceDefinitionElement element to start looking from
 * @return result map
 */
@NotNull
public static List<PerlExportDescriptor> getImportedSubsDescriptors(@NotNull PerlNamespaceDefinitionElement namespaceDefinitionElement) {
    PerlImportsCollector collector = new PerlSubImportsCollector();
    PerlUtil.processImportedEntities(namespaceDefinitionElement, collector);
    return collector.getResult();
}
Also used : PerlSubImportsCollector(com.perl5.lang.perl.util.processors.PerlSubImportsCollector) 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