Search in sources :

Example 1 with FileReferenceOwner

use of com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceOwner in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoPsiImplUtil method resolve.

@Nullable
public static PsiDirectory resolve(@NotNull GoImportString importString) {
    PsiReference[] references = importString.getReferences();
    for (PsiReference reference : references) {
        if (reference instanceof FileReferenceOwner) {
            PsiFileReference lastFileReference = ((FileReferenceOwner) reference).getLastFileReference();
            PsiElement result = lastFileReference != null ? lastFileReference.resolve() : null;
            return result instanceof PsiDirectory ? (PsiDirectory) result : null;
        }
    }
    return null;
}
Also used : FileReferenceOwner(com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceOwner) PsiFileReference(com.intellij.psi.impl.source.resolve.reference.impl.providers.PsiFileReference) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FileReferenceOwner (com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceOwner)1 PsiFileReference (com.intellij.psi.impl.source.resolve.reference.impl.providers.PsiFileReference)1 Nullable (org.jetbrains.annotations.Nullable)1