com.intellij.psi.ResolveResult Java Examples

The following examples show how to use com.intellij.psi.ResolveResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSharpIndexAccessExpressionImpl.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Nonnull
@Override
public ResolveResult[] resolve(@Nonnull CSharpIndexAccessExpressionImpl expression, boolean incompleteCode)
{
	DotNetExpression qualifier = expression.getQualifier();
	DotNetTypeRef typeRef = qualifier.toTypeRef(true);
	if(typeRef instanceof DotNetPointerTypeRef)
	{
		DotNetTypeRef innerTypeRef = ((DotNetPointerTypeRef) typeRef).getInnerTypeRef();

		CSharpLightIndexMethodDeclarationBuilder builder = new CSharpLightIndexMethodDeclarationBuilder(expression.getProject(), 0);
		builder.withReturnType(innerTypeRef);
		builder.addParameter(new CSharpLightParameterBuilder(expression.getProject()).withName("p").withTypeRef(new CSharpTypeRefByQName(expression, DotNetTypes.System.Int32)));
		return new ResolveResult[]{new CSharpResolveResult(builder)};
	}

	ResolveResult[] resolveResults = CSharpReferenceExpressionImplUtil.multiResolveImpl(CSharpReferenceExpression.ResolveToKind.ARRAY_METHOD, expression, expression, true);
	return incompleteCode ? resolveResults : CSharpResolveUtil.filterValidResults(resolveResults);
}
 
Example #2
Source File: MethodResolveResult.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static MethodResolveResult createResult(@Nonnull MethodResolvePriorityInfo calcResult, @Nullable PsiElement element, @Nullable ResolveResult resolveResult)
{
	PsiElement providerElement = element == null ? null : element.getUserData(FORCE_PROVIDER_ELEMENT);
	if(providerElement == null && resolveResult instanceof CSharpResolveResult)
	{
		providerElement = ((CSharpResolveResult) resolveResult).getProviderElement();
	}
	MethodResolveResult methodResolveResult = new MethodResolveResult(element, calcResult);
	methodResolveResult.setProvider(providerElement);
	if(resolveResult instanceof CSharpUndefinedResolveResult)
	{
		methodResolveResult.myUnknown = true;
	}
	return methodResolveResult;
}
 
Example #3
Source File: NodeTypeReference.java    From intellij-neos with GNU General Public License v3.0 6 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    String nodeTypeNameToFindReferenceFor = yamlElement.getKeyText();

    // files which contain the NodeType definition
    Collection<VirtualFile> files = FileBasedIndex.getInstance().getContainingFiles(NodeTypesYamlFileIndex.KEY, nodeTypeNameToFindReferenceFor, GlobalSearchScope.allScope(yamlElement.getProject()));

    return files
            .stream()
            // get the PSI for each file
            .map(file -> PsiManager.getInstance(yamlElement.getProject()).findFile(file))
            // ensure we only have YAML files
            .filter(psiFile -> psiFile instanceof YAMLFile)
            .map(psiFile -> (YAMLFile) psiFile)
            // get all YAML keys in these files
            .flatMap(yamlFile -> YAMLUtil.getTopLevelKeys(yamlFile).stream())
            // get the correct YAML key
            .filter(yamlKeyValue -> yamlKeyValue.getKeyText().equals(nodeTypeNameToFindReferenceFor))
            // remove "current" element if it exists
            .filter(yamlKeyValue -> yamlElement != yamlKeyValue)
            // build up the result object
            .map(yamlKeyValue -> new PsiElementResolveResult(yamlKeyValue, true))
            .toArray(PsiElementResolveResult[]::new);
}
 
Example #4
Source File: CompletionResolveScopeProcessor.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
public CompletionResolveScopeProcessor(@Nonnull CSharpResolveOptions options, @Nonnull Processor<ResolveResult> processor, @Nonnull ExecuteTarget[] targets)
{
	myProcessor = processor;
	myPlace = options.getElement();

	myScope = myPlace.getResolveScope();
	CSharpContextUtil.ContextType completionContextType = options.getCompletionContextType();
	if(completionContextType != null)
	{
		myContextType = completionContextType;
	}
	else
	{
		myContextType = myPlace instanceof CSharpReferenceExpression ? CSharpContextUtil.getParentContextTypeForReference((CSharpReferenceExpression) myPlace) : CSharpContextUtil.ContextType.ANY;
	}
	putUserData(ExecuteTargetUtil.EXECUTE_TARGETS, ExecuteTargetUtil.of(targets));
}
 
Example #5
Source File: BaseUnusedUsingVisitor.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
private void putState(@Nonnull ResolveResult firstValidResult, @Nullable PsiElement element)
{
	if(element == null)
	{
		return;

	}
	if(firstValidResult instanceof CSharpResolveResult)
	{
		PsiElement providerElement = ((CSharpResolveResult) firstValidResult).getProviderElement();
		if(providerElement instanceof CSharpUsingListChild)
		{
			CSharpUsingListChild child = (CSharpUsingListChild) providerElement;

			putElement(child, element);
		}
	}
}
 
Example #6
Source File: TranslationReferenceTest.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
public void testReferenceCanResolveDefinition() {
    PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
            "\"LLL:EXT:foo/sample.xlf:sys_<caret>language.language_isocode.ab\";");

    PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
    PsiReference[] references = elementAtCaret.getReferences();
    for (PsiReference reference : references) {
        if (reference instanceof TranslationReference) {
            ResolveResult[] resolveResults = ((TranslationReference) reference).multiResolve(false);
            for (ResolveResult resolveResult : resolveResults) {
                assertInstanceOf(resolveResult.getElement(), XmlAttributeValue.class);

                return;
            }
        }
    }

    fail("TranslationReference could not be resolved");
}
 
Example #7
Source File: TestReferenceUtil.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
public static List<PsiElement> resolveReference(PsiElement element) {
    PsiReference[] references = element.getReferences();
    Assert.assertEquals(1, references.length);
    PsiReference reference = references[0];
    if (reference instanceof PsiPolyVariantReference) {
        ResolveResult[] results = ((PsiPolyVariantReference) reference).multiResolve(false);
        return Arrays.stream(results)
            .map(ResolveResult::getElement)
            .filter(Objects::nonNull)
            .map(TestReferenceUtil::getPsiElement)
            .filter(Objects::nonNull)
            .collect(Collectors.toList());
    } else {
        return Stream.of(getPsiElement(reference.resolve()))
            .filter(Objects::nonNull)
            .collect(Collectors.toList());
    }
}
 
Example #8
Source File: XQueryPrefixReference.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    XQueryFile file = (XQueryFile) myElement.getContainingFile();
    List<ResolveResult> results = new ArrayList<ResolveResult>();
    Collection<ResolveResult> primaryReferences = getPrimaryReferences();
    results.addAll(primaryReferences);
    if (shouldAddOtherReferences(primaryReferences)) {
        results.addAll(getReferencesFromNamespaceDeclarations(file.getNamespaceDeclarations()));
        results.addAll(getReferencesFromModuleImports(file.getModuleImports()));
        results.addAll(getReferencesFromModuleName(file.getModuleNamespaceName()));
    }
    if (results.isEmpty() && file.isPredeclaredNamespacePrefix(myElement.getText())) {
        results.add(new PsiElementResolveResult(getElement()));
    }
    return results.toArray(new ResolveResult[results.size()]);
}
 
Example #9
Source File: StaticVsInstanceComparator.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
private int getWeightByTypeArguments(ResolveResult o1)
{
	PsiElement element = o1.getElement();
	if(element instanceof DotNetGenericParameterListOwner)
	{
		int genericParametersCount = ((DotNetGenericParameterListOwner) element).getGenericParametersCount();
		int weight = genericParametersCount * 10;
		if(genericParametersCount == myTypeArgumentsSize)
		{
			weight += 1000;
		}
		return weight;
	}
	return 0;
}
 
Example #10
Source File: QualifiedNamespaceKindProcessor.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
private void processDefaultCompletion(@Nonnull Processor<ResolveResult> processor, PsiElement element, PsiElement qualifier)
{
	DotNetNamespaceAsElement namespace;
	String qualifiedText = "";
	if(qualifier != null)
	{
		qualifiedText = StringUtil.strip(qualifier.getText(), CSharpReferenceExpression.DEFAULT_REF_FILTER);
	}

	namespace = DotNetPsiSearcher.getInstance(element.getProject()).findNamespace(qualifiedText, element.getResolveScope());

	if(namespace == null)
	{
		return;
	}

	processNamespaceChildren(processor, element, namespace);
}
 
Example #11
Source File: LookupElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * @return a PSI element associated with this lookup element. It's used for navigation, showing quick documentation and sorting by proximity to the current location.
 * The default implementation tries to extract PSI element from {@link #getObject()} result.
 */
@Nullable
public PsiElement getPsiElement() {
  Object o = getObject();
  if (o instanceof PsiElement) {
    return (PsiElement)o;
  }
  if (o instanceof ResolveResult) {
    return ((ResolveResult)o).getElement();
  }
  if (o instanceof PsiElementNavigationItem) {
    return ((PsiElementNavigationItem)o).getTargetElement();
  }
  if (o instanceof SmartPsiElementPointer) {
    return ((SmartPsiElementPointer)o).getElement();
  }
  return null;
}
 
Example #12
Source File: WeightUtil.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
public static void sortAndProcess(@Nonnull List<MethodResolveResult> list, @Nonnull Processor<ResolveResult> processor, @Nonnull PsiElement place)
{
	if(list.isEmpty())
	{
		return;
	}

	ContainerUtil.sort(list, ourComparator);

	for(MethodResolveResult methodResolveResult : list)
	{
		ProgressManager.checkCanceled();

		methodResolveResult.setAssignable(place);

		if(!processor.process(methodResolveResult))
		{
			return;
		}
	}
}
 
Example #13
Source File: CSharpResolveUtil.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nullable
public static ResolveResult findFirstValidResult(ResolveResult[] resolveResults)
{
	if(resolveResults.length == 0)
	{
		return null;
	}
	for(ResolveResult resolveResult : resolveResults)
	{
		if(resolveResult.isValidResult() && isAssignable(resolveResult))
		{
			return resolveResult;
		}
	}
	return null;
}
 
Example #14
Source File: Symfony2InterfacesUtil.java    From Thinkphp5-Plugin with MIT License 6 votes vote down vote up
/**
 * 根据方法引用获取方法
 * Single resolve doesnt work if we have non unique class names in project context,
 * so try a multiResolve and use first matched method
 */
@Nullable
public static Method getMultiResolvedMethod(PsiReference psiReference) {
    if (psiReference == null) return null;
    // class be unique in normal case, so try this first
    PsiElement resolvedReference = psiReference.resolve();
    if (resolvedReference instanceof Method) {
        return (Method) resolvedReference;
    }

    // try multiResolve if class exists twice in project
    if (psiReference instanceof PsiPolyVariantReference) {
        for (ResolveResult resolveResult : ((PsiPolyVariantReference) psiReference).multiResolve(false)) {
            PsiElement element = resolveResult.getElement();
            if (element instanceof Method) {
                return (Method) element;
            }
        }
    }

    return null;
}
 
Example #15
Source File: ConstraintPropertyReference.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {

    List<PsiElement> psiElements = new ArrayList<>();

    String content = ((StringLiteralExpression) getElement()).getContents();
    for(Field field: constraintPhpClass.getFields()) {
        String name = field.getName();
        if(!field.isConstant() && field.getModifier().isPublic() && content.equals(name)) {
            psiElements.add(field);
        }
    }

    return PsiElementResolveResult.createResults(psiElements);
}
 
Example #16
Source File: GenericFromParentKindProcessor.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Override
public void process(@Nonnull CSharpResolveOptions options,
		@Nonnull DotNetGenericExtractor defaultExtractor,
		@Nullable PsiElement forceQualifierElement,
		@Nonnull Processor<ResolveResult> processor)
{
	PsiElement element = options.getElement();

	DotNetGenericParameterListOwner genericParameterListOwner = CSharpReferenceExpressionImplUtil.findParentOrNextIfDoc(element,
			DotNetGenericParameterListOwner.class);
	if(genericParameterListOwner == null)
	{
		return;
	}

	SimpleNamedScopeProcessor scopeProcessor = new SimpleNamedScopeProcessor(processor, options.isCompletion(), ExecuteTarget.GENERIC_PARAMETER);
	ResolveState state = ResolveState.initial();
	state = state.put(CSharpResolveUtil.SELECTOR, options.getSelector());
	genericParameterListOwner.processDeclarations(scopeProcessor, state, null, element);
}
 
Example #17
Source File: StaticVsInstanceComparator.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredReadAction
public int compare(ResolveResult o1, ResolveResult o2)
{
	if(isNameEqual(o1, o2))
	{
		int i = getWeightByContext(o2) - getWeightByContext(o1);
		if(i == 0)
		{
			return getWeightByTypeArguments(o2) - getWeightByTypeArguments(o1);
		}
		return i;
	}
	return myComparator.compare(o1, o2);
}
 
Example #18
Source File: ExpressionOrTypeLikeKindProcessor.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Override
public void process(@Nonnull CSharpResolveOptions options,
		@Nonnull DotNetGenericExtractor defaultExtractor,
		@Nullable PsiElement forceQualifierElement,
		@Nonnull Processor<ResolveResult> processor)
{
	options.kind(CSharpReferenceExpression.ResolveToKind.ANY_MEMBER);
	new AnyMemberKindProcessor().process(options, defaultExtractor, forceQualifierElement, processor);

	options.kind(CSharpReferenceExpression.ResolveToKind.TYPE_LIKE);
	new TypeLikeKindProcessor().process(options, defaultExtractor, forceQualifierElement, processor);
}
 
Example #19
Source File: CSharpStubReferenceExpressionImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Nonnull
@Override
public ResolveResult[] tryResolveFromQualifier(@Nonnull PsiElement element)
{
	return CSharpReferenceExpressionImplUtil.tryResolveFromQualifier(this, element);
}
 
Example #20
Source File: CSharpIndexAccessExpressionImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public PsiElement resolveToCallable()
{
	ResolveResult[] resolveResults = multiResolve(false);
	if(resolveResults.length == 0)
	{
		return null;
	}
	return CSharpResolveUtil.findFirstValidElement(resolveResults);
}
 
Example #21
Source File: CSharpReferenceExpressionImplUtil.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
public static boolean isReferenceTo(PsiPolyVariantReference referenceExpression, PsiElement element)
{
	final ResolveResult firstValidResult = CSharpResolveUtil.findValidOrFirstMaybeResult(referenceExpression.multiResolve(false));
	if(firstValidResult == null)
	{
		return false;
	}
	return isReferenceTo(firstValidResult, element);
}
 
Example #22
Source File: CS1614.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Nullable
@Override
public HighlightInfoFactory checkImpl(@Nonnull CSharpLanguageVersion languageVersion, @Nonnull CSharpHighlightContext highlightContext, @Nonnull CSharpAttribute element)
{
	CSharpReferenceExpressionEx referenceExpression = (CSharpReferenceExpressionEx) element.getReferenceExpression();
	if(referenceExpression == null)
	{
		return null;
	}

	String referenceNameWithAt = referenceExpression.getReferenceNameWithAt();
	if(StringUtil.isEmpty(referenceNameWithAt) || referenceNameWithAt.charAt(0) == '@' || referenceNameWithAt.endsWith(AttributeByNameSelector
			.AttributeSuffix))
	{
		return null;
	}

	ResolveResult[] resolveResults = referenceExpression.multiResolveImpl(CSharpReferenceExpression.ResolveToKind.ATTRIBUTE, false);

	CSharpTypeDeclaration atType = null;
	CSharpTypeDeclaration suffixType = null;
	if((atType = hasElementWithName(resolveResults, referenceNameWithAt)) != null && (suffixType = hasElementWithName(resolveResults,
			referenceNameWithAt + AttributeByNameSelector.AttributeSuffix)) != null)
	{
		CompilerCheckBuilder compilerCheckBuilder = newBuilder(referenceExpression, referenceNameWithAt);
		compilerCheckBuilder.addQuickFix(new UseTypeWithAtFix(referenceExpression, atType));
		compilerCheckBuilder.addQuickFix(new UseTypeWithSuffixFix(referenceExpression, suffixType));
		return compilerCheckBuilder;
	}
	return super.checkImpl(languageVersion, highlightContext, element);
}
 
Example #23
Source File: TranslationReference.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    List<ResolveResult> results = new ArrayList<>();
    PsiElement[] psiElements = TranslationUtil.getTranslationPsiElements(this.element.getProject(), this.element.getContents(), this.domainName);

    for (PsiElement psiElement : psiElements) {
        results.add(new PsiElementResolveResult(psiElement));
    }

    return results.toArray(new ResolveResult[results.size()]);
}
 
Example #24
Source File: DoctrinePhpClassFieldReference.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean b) {
    List<PsiElement> psiElementList = this.phpClass.getFields().stream()
        .filter(field -> !field.isConstant() && content.equals(field.getName()))
        .collect(Collectors.toList());

    return PsiElementResolveResult.createResults(psiElementList);
}
 
Example #25
Source File: CSharpArrayInitializerCompositeValueImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public PsiElement resolveToCallable()
{
	ResolveResult[] resolveResults = multiResolve(false);
	if(resolveResults.length == 0)
	{
		return null;
	}
	return CSharpResolveUtil.findFirstValidElement(resolveResults);
}
 
Example #26
Source File: Symfony2InterfacesUtil.java    From idea-php-toolbox with MIT License 5 votes vote down vote up
/**
 * Single resolve doesnt work if we have non unique class names in project context,
 * so try a multiResolve
 */
@Nullable
public static Method[] getMultiResolvedMethod(PsiReference psiReference) {

    // class be unique in normal case, so try this first
    PsiElement resolvedReference = psiReference.resolve();
    if (resolvedReference instanceof Method) {
        return new Method[] { (Method) resolvedReference };
    }

    // try multiResolve if class exists twice in project
    if(psiReference instanceof PsiPolyVariantReference) {
        Collection<Method> methods = new HashSet<>();
        for(ResolveResult resolveResult : ((PsiPolyVariantReference) psiReference).multiResolve(false)) {
            PsiElement element = resolveResult.getElement();
            if(element instanceof Method) {
                methods.add((Method) element);
            }
        }

        if(methods.size() > 0) {
            return methods.toArray(new Method[methods.size()]);
        }

    }

    return null;
}
 
Example #27
Source File: CSharpResolveUtil.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
public static boolean isAssignable(ResolveResult resolveResult)
{
	if(resolveResult instanceof CSharpResolveResult)
	{
		return ((CSharpResolveResult) resolveResult).isAssignable();
	}
	return true;
}
 
Example #28
Source File: CSharpArrayInitializerCompositeValueImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@RequiredReadAction
public ResolveResult[] multiResolve(boolean incompleteCode)
{
	CSharpArrayInitializerOwner arrayInitializerOwner = PsiTreeUtil.getParentOfType(this, CSharpArrayInitializerOwner.class);
	if(arrayInitializerOwner instanceof CSharpNewExpressionImpl)
	{
		DotNetTypeRef typeRef = ((CSharpNewExpressionImpl) arrayInitializerOwner).toTypeRef(false);
		if(typeRef == DotNetTypeRef.ERROR_TYPE)
		{
			return ResolveResult.EMPTY_ARRAY;
		}

		DotNetTypeResolveResult typeResolveResult = typeRef.resolve();
		PsiElement resolvedElement = typeResolveResult.getElement();
		if(resolvedElement == null)
		{
			return ResolveResult.EMPTY_ARRAY;
		}

		CSharpResolveOptions options = new CSharpResolveOptions(CSharpReferenceExpression.ResolveToKind.METHOD,
				new MemberByNameSelector("Add"), this, this, false, true);

		CommonProcessors.CollectProcessor<ResolveResult> processor = new CommonProcessors.CollectProcessor<ResolveResult>();
		CSharpReferenceExpressionImplUtil.collectResults(options, typeResolveResult.getGenericExtractor(), resolvedElement, processor);
		return processor.toArray(ResolveResult.ARRAY_FACTORY);
	}
	return ResolveResult.EMPTY_ARRAY;
}
 
Example #29
Source File: GlobReference.java    From intellij with Apache License 2.0 5 votes vote down vote up
@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;
  }
}
 
Example #30
Source File: BlazeGoImportResolver.java    From intellij with Apache License 2.0 5 votes vote down vote up
static ResolveResult[] doResolve(BlazeGoPackage goPackage, int index) {
  return Stream.of(goPackage)
      .map(BlazeGoPackage::getImportReferences)
      .filter(Objects::nonNull)
      .filter(list -> index < list.length)
      .map(list -> list[index])
      .filter(Objects::nonNull)
      .map(GoPackageFileSystemItem::getInstance)
      .filter(Objects::nonNull)
      .map(PsiElementResolveResult::new)
      .toArray(ResolveResult[]::new);
}