Search in sources :

Example 11 with PerlNamespaceElement

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

the class PerlImportedSubsCompletionProvider method addCompletions.

public void addCompletions(@NotNull final CompletionParameters parameters, ProcessingContext context, @NotNull final CompletionResultSet resultSet) {
    PsiElement position = parameters.getPosition();
    PsiPerlMethod method = (PsiPerlMethod) position.getParent();
    if (method.isObjectMethod()) {
        return;
    }
    Project project = method.getProject();
    if (!method.hasExplicitNamespace()) {
        PerlNamespaceDefinitionElement namespaceContainer = PerlPackageUtil.getNamespaceContainerForElement(position);
        if (namespaceContainer != null) {
            fillWithNamespaceImports(namespaceContainer, resultSet);
        }
    } else {
        // not an object method, but has explicit namespace
        PerlNamespaceElement namespaceElement = method.getNamespaceElement();
        if (namespaceElement != null) {
            String targetPackageName = namespaceElement.getCanonicalName();
            if (targetPackageName != null) {
                for (PerlNamespaceDefinitionElement namespaceDefinition : PerlPackageUtil.getNamespaceDefinitions(project, targetPackageName)) {
                    fillWithNamespaceImports(namespaceDefinition, resultSet);
                }
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) PerlNamespaceDefinitionElement(com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement) PsiPerlMethod(com.perl5.lang.perl.psi.PsiPerlMethod) PerlNamespaceElement(com.perl5.lang.perl.psi.PerlNamespaceElement) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PerlNamespaceElement (com.perl5.lang.perl.psi.PerlNamespaceElement)7 PsiElement (com.intellij.psi.PsiElement)5 NotNull (org.jetbrains.annotations.NotNull)5 PerlSubNameElement (com.perl5.lang.perl.psi.PerlSubNameElement)4 PsiFile (com.intellij.psi.PsiFile)3 PsiReference (com.intellij.psi.PsiReference)3 PerlVisitor (com.perl5.lang.perl.psi.PerlVisitor)3 PsiPerlMethod (com.perl5.lang.perl.psi.PsiPerlMethod)3 Project (com.intellij.openapi.project.Project)2 IElementType (com.intellij.psi.tree.IElementType)2 PerlMethod (com.perl5.lang.perl.psi.PerlMethod)2 PerlUseStatementStub (com.perl5.lang.perl.psi.stubs.imports.PerlUseStatementStub)2 Nullable (org.jetbrains.annotations.Nullable)2 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)1 PsiElementResolveResult (com.intellij.psi.PsiElementResolveResult)1 ResolveResult (com.intellij.psi.ResolveResult)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 PerlExportDescriptor (com.perl5.lang.perl.extensions.packageprocessor.PerlExportDescriptor)1 PerlFancyMethodQuickFix (com.perl5.lang.perl.idea.quickfixes.PerlFancyMethodQuickFix)1 PerlNamespaceDefinitionElement (com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement)1