Search in sources :

Example 16 with PsiElementResolveResult

use of com.intellij.psi.PsiElementResolveResult 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 17 with PsiElementResolveResult

use of com.intellij.psi.PsiElementResolveResult in project intellij by bazelbuild.

the class GlobReference method resolveInner.

@Override
protected ResolveResult[] resolveInner(boolean incompleteCode, PsiFile containingFile) {
    File containingDirectory = ((BuildFile) containingFile).getFile().getParentFile();
    if (containingDirectory == null) {
        return ResolveResult.EMPTY_ARRAY;
    }
    List<String> includes = resolveListContents(element.getIncludes());
    List<String> excludes = resolveListContents(element.getExcludes());
    boolean directoriesExcluded = element.areDirectoriesExcluded();
    if (includes.isEmpty()) {
        return ResolveResult.EMPTY_ARRAY;
    }
    Project project = element.getProject();
    try {
        List<File> files = UnixGlob.forPath(containingDirectory).addPatterns(includes).addExcludes(excludes).setExcludeDirectories(directoriesExcluded).setDirectoryFilter(directoryFilter(project, containingDirectory.getPath())).glob();
        List<ResolveResult> results = Lists.newArrayListWithCapacity(files.size());
        for (File file : files) {
            PsiFileSystemItem psiFile = BuildReferenceManager.getInstance(project).resolveFile(file);
            if (psiFile != null) {
                results.add(new PsiElementResolveResult(psiFile));
            }
        }
        return results.toArray(ResolveResult.EMPTY_ARRAY);
    } catch (Exception e) {
        return ResolveResult.EMPTY_ARRAY;
    }
}
Also used : Project(com.intellij.openapi.project.Project) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) PsiFileSystemItem(com.intellij.psi.PsiFileSystemItem) File(java.io.File) BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) PsiFile(com.intellij.psi.PsiFile) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) ResolveResult(com.intellij.psi.ResolveResult) IncorrectOperationException(com.intellij.util.IncorrectOperationException)

Aggregations

PsiElementResolveResult (com.intellij.psi.PsiElementResolveResult)17 PsiElement (com.intellij.psi.PsiElement)13 ResolveResult (com.intellij.psi.ResolveResult)13 NotNull (org.jetbrains.annotations.NotNull)12 ArrayList (java.util.ArrayList)8 Project (com.intellij.openapi.project.Project)5 PsiFile (com.intellij.psi.PsiFile)5 PerlGlobVariable (com.perl5.lang.perl.psi.PerlGlobVariable)2 PerlNamespaceDefinitionElement (com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement)2 PerlSubDeclarationElement (com.perl5.lang.perl.psi.PerlSubDeclarationElement)2 PerlSubDefinitionElement (com.perl5.lang.perl.psi.PerlSubDefinitionElement)2 PerlSubElement (com.perl5.lang.perl.psi.PerlSubElement)2 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)1 PsiReference (com.intellij.psi.PsiReference)1 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)1 XmlFile (com.intellij.psi.xml.XmlFile)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1