Search in sources :

Example 21 with PerlFileImpl

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

the class PerlPackageCompletionUtil method fillWithPackageNameSuggestions.

public static void fillWithPackageNameSuggestions(@NotNull PsiElement element, @NotNull final CompletionResultSet result) {
    PsiFile file = element.getContainingFile().getOriginalFile();
    VirtualFile virtualFile = file.getViewProvider().getVirtualFile();
    if (virtualFile.getFileType() == PerlFileTypePackage.INSTANCE) {
        result.addElement(LookupElementBuilder.create(virtualFile.getNameWithoutExtension()));
        if (file instanceof PerlFileImpl) {
            String packageName = ((PerlFileImpl) file).getFilePackageName();
            if (packageName != null) {
                result.addElement(LookupElementBuilder.create(packageName));
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PerlFileImpl(com.perl5.lang.perl.psi.impl.PerlFileImpl) PsiFile(com.intellij.psi.PsiFile)

Example 22 with PerlFileImpl

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

the class PerlNamespaceElementImpl method getNamespaceFiles.

@Override
public List<PerlFileImpl> getNamespaceFiles() {
    List<PerlFileImpl> namespaceFiles = new ArrayList<>();
    PsiReference[] references = getReferences();
    for (PsiReference reference : references) {
        if (reference instanceof PerlNamespaceFileReference) {
            ResolveResult[] results = ((PerlNamespaceFileReference) reference).multiResolve(false);
            for (ResolveResult result : results) {
                PsiElement targetElement = result.getElement();
                assert targetElement != null;
                if (targetElement instanceof PerlFileImpl) {
                    namespaceFiles.add((PerlFileImpl) targetElement);
                }
            }
        }
    }
    return namespaceFiles;
}
Also used : PerlNamespaceFileReference(com.perl5.lang.perl.psi.references.PerlNamespaceFileReference) ArrayList(java.util.ArrayList) PsiReference(com.intellij.psi.PsiReference) ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PerlFileImpl (com.perl5.lang.perl.psi.impl.PerlFileImpl)21 PsiElement (com.intellij.psi.PsiElement)8 PsiFile (com.intellij.psi.PsiFile)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ArrayList (java.util.ArrayList)3 Project (com.intellij.openapi.project.Project)2 TextRange (com.intellij.openapi.util.TextRange)2 PerlNamespaceDefinitionElement (com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement)2 PerlVariableDeclarationElement (com.perl5.lang.perl.psi.PerlVariableDeclarationElement)2 PsiPerlStatement (com.perl5.lang.perl.psi.PsiPerlStatement)2 PsiPerlStatementImpl (com.perl5.lang.perl.psi.impl.PsiPerlStatementImpl)2 LocalQuickFixOnPsiElement (com.intellij.codeInspection.LocalQuickFixOnPsiElement)1 Document (com.intellij.openapi.editor.Document)1 PsiReference (com.intellij.psi.PsiReference)1 ResolveResult (com.intellij.psi.ResolveResult)1 ResolveState (com.intellij.psi.ResolveState)1 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1 IElementType (com.intellij.psi.tree.IElementType)1 XSourcePosition (com.intellij.xdebugger.XSourcePosition)1 PerlCastExpression (com.perl5.lang.perl.psi.PerlCastExpression)1