當前位置: 首頁>>代碼示例>>Java>>正文


Java ResolveResult.getElement方法代碼示例

本文整理匯總了Java中com.intellij.psi.ResolveResult.getElement方法的典型用法代碼示例。如果您正苦於以下問題:Java ResolveResult.getElement方法的具體用法?Java ResolveResult.getElement怎麽用?Java ResolveResult.getElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.ResolveResult的用法示例。


在下文中一共展示了ResolveResult.getElement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: multiResolve

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
  final ResolveResult[] results = super.multiResolve(incompleteCode);
  boolean shadowed = false;
  for (ResolveResult result : results) {
    final PsiElement element = result.getElement();
    if (element != null && (element.getContainingFile() != myElement.getContainingFile() ||
                            element instanceof PyFunction || element instanceof PyClass)) {
      shadowed = true;
      break;
    }
  }
  if (results.length > 0 && !shadowed) {
    return results;
  }
  // resolve to self if no other target found
  return new ResolveResult[] { new PsiElementResolveResult(myElement) };
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:PyTargetReference.java

示例2: testResolveIncludedRef2

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
public void testResolveIncludedRef2() throws Throwable {
  myTestFixture.copyFileToProject("include.rng");

  final PsiReference ref = myTestFixture.getReferenceAtCaretPositionWithAssertion("resolve-include-ref-2.rng");
  assertTrue("PolyVariantRef", ref instanceof PsiPolyVariantReference);

  final PsiElement element = ref.resolve();
  assertNull(element);

  final ResolveResult[] results = ((PsiPolyVariantReference)ref).multiResolve(false);
  assertEquals(2, results.length);

  for (ResolveResult result : results) {
    PsiElement e = result.getElement();
    assertTrue(e instanceof XmlTag);

    final int contentLength = ((XmlTag)e).getSubTags().length;
    if (e.getContainingFile() == ref.getElement().getContainingFile()) {
      assertEquals(1, contentLength);
    } else {
      assertEquals(0, contentLength);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:RngHighlightingTest.java

示例3: resolveXsltReference

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
@Nullable
private static PsiElement resolveXsltReference(PsiReference reference) {
    final PsiElement element = reference.resolve();
    if (element != null) {
        return element;
    }
    if (reference instanceof PsiPolyVariantReference) {
        final ResolveResult[] results = ((PsiPolyVariantReference)reference).multiResolve(false);
        for (ResolveResult result : results) {
            if (result.isValidResult() && result.getElement() instanceof XsltElement) {
                return result.getElement();
            }
        }
    }
    return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:XsltResolveTest.java

示例4: getMultiResolvedMethod

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
/**
 * 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) {

    // 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;
}
 
開發者ID:Haehnchen,項目名稱:idea-php-laravel-plugin,代碼行數:26,代碼來源:Symfony2InterfacesUtil.java

示例5: getWeightByTypeArguments

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
@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;
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:17,代碼來源:StaticVsInstanceComparator.java

示例6: isReferenceTo

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
@RequiredReadAction
private static boolean isReferenceTo(@NotNull ResolveResult resolveResult, PsiElement element)
{
	PsiElement psiElement = resolveResult.getElement();
	if(element instanceof DotNetNamespaceAsElement && psiElement instanceof DotNetNamespaceAsElement)
	{
		if(Comparing.equal(((DotNetNamespaceAsElement) psiElement).getPresentableQName(), ((DotNetNamespaceAsElement) element).getPresentableQName()))
		{
			return true;
		}
	}

	if(element.getManager().areElementsEquivalent(element, psiElement))
	{
		return true;
	}
	return false;
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:19,代碼來源:CSharpReferenceExpressionImplUtil.java

示例7: hasElementWithName

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
@Nullable
private static CSharpTypeDeclaration hasElementWithName(ResolveResult[] resolveResults, String ref)
{
	for(ResolveResult resolveResult : resolveResults)
	{
		if(!resolveResult.isValidResult())
		{
			continue;
		}
		PsiElement resolveResultElement = resolveResult.getElement();
		if(resolveResultElement instanceof CSharpTypeDeclaration && Comparing.equal(((CSharpTypeDeclaration) resolveResultElement).getName(),
				ref))
		{
			return (CSharpTypeDeclaration) resolveResultElement;
		}
	}
	return null;
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:19,代碼來源:CS1614.java

示例8: isNotAliasedInImportElement

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
private static boolean isNotAliasedInImportElement(@NotNull PsiReference reference) {
  if (reference instanceof PsiPolyVariantReference) {
    final ResolveResult[] results = ((PsiPolyVariantReference)reference).multiResolve(false);
    for (ResolveResult result : results) {
      final PsiElement resolved = result.getElement();
      if (resolved instanceof PyImportElement && ((PyImportElement)resolved).getAsName() != null) {
        return false;
      }
    }
  }
  return true;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:RenamePyFileProcessor.java

示例9: fillResolveResults

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
@Override
public void fillResolveResults(PsiElement psiElement, List<ResolveResult> results, String typeName) {
    subject.fillResolveResults(psiElement, results, typeName);

    for (ResolveResult resolveResult : results) {
        PsiElement element = resolveResult.getElement();

        if (element instanceof PhpClass && !implementationMatcher.match(element)) {
            results.remove(resolveResult);
        }
    }

}
 
開發者ID:dkvashninbay,項目名稱:magento2plugin,代碼行數:14,代碼來源:ImplementationContextDecorator.java

示例10: getMultiResolvedMethod

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:Haehnchen,項目名稱:idea-php-toolbox,代碼行數:32,代碼來源:Symfony2InterfacesUtil.java

示例11: getWeight

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
public int getWeight(ResolveResult resolveResult)
{
	PsiElement element = resolveResult.getElement();

	if(element instanceof DotNetVariable)
	{
		return 200000;
	}

	if(element instanceof CSharpElementGroup)
	{
		return 100000;
	}

	if(element instanceof CSharpTypeDefStatement)
	{
		return 50100;
	}

	if(element instanceof DotNetGenericParameterListOwner)
	{
		if(((DotNetGenericParameterListOwner) element).getGenericParametersCount() == myGenericCount)
		{
			return 50000;
		}
		return -((DotNetGenericParameterListOwner) element).getGenericParametersCount() * 100;
	}

	if(element instanceof DotNetNamespaceAsElement)
	{
		return 0;
	}

	return 10;
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:36,代碼來源:TypeLikeComparator.java

示例12: isNameEqual

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
private static boolean isNameEqual(ResolveResult o1, ResolveResult o2)
{
	PsiElement e1 = o1.getElement();
	PsiElement e2 = o2.getElement();
	if(e1 instanceof PsiNamedElement && e2 instanceof PsiNamedElement)
	{
		return Comparing.equal(((PsiNamedElement) e1).getName(), ((PsiNamedElement) e2).getName());
	}
	return false;
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:11,代碼來源:StaticVsInstanceComparator.java

示例13: process

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
@Override
public boolean process(ResolveResult resolveResult)
{
	PsiElement element = resolveResult.getElement();
	myElements.add(element);
	return true;
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:8,代碼來源:AsPsiElementProcessor.java

示例14: multiResolveImpl

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
@NotNull
@RequiredReadAction
public static ResolveResult[] multiResolveImpl(ResolveToKind kind, final CSharpCallArgumentListOwner callArgumentListOwner, final CSharpQualifiedNonReference element, boolean resolveFromParent)
{
	ResolveResult[] resolveResults = buildSelectorAndMultiResolve(kind, callArgumentListOwner, element, resolveFromParent);
	if(element instanceof CSharpReferenceExpression)
	{
		int typeArgumentListSize = getTypeArgumentListSize(element);
		if(typeArgumentListSize > 0)
		{
			DotNetTypeRef[] typeArgumentListRefs = ((CSharpReferenceExpression) element).getTypeArgumentListRefs();

			for(int i = 0; i < resolveResults.length; i++)
			{
				ResolveResult resolveResult = resolveResults[i];

				PsiElement resolveResultElement = resolveResult.getElement();
				if(resolveResultElement instanceof CSharpTypeDeclaration)
				{
					Map<DotNetGenericParameter, DotNetTypeRef> map = new HashMap<DotNetGenericParameter, DotNetTypeRef>();
					DotNetGenericParameter[] genericParameters = ((CSharpTypeDeclaration) resolveResultElement).getGenericParameters();
					for(int j = 0; j < typeArgumentListRefs.length; j++)
					{
						DotNetTypeRef typeArgumentListRef = typeArgumentListRefs[j];
						DotNetGenericParameter genericParameter = ArrayUtil2.safeGet(genericParameters, j);
						if(genericParameter == null)
						{
							continue;
						}
						map.put(genericParameter, typeArgumentListRef);
					}
					resolveResults[i] = CSharpResolveResultWithExtractor.withExtractor(resolveResult, CSharpGenericExtractor.create(map));
				}
			}
		}
	}
	return resolveResults;
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:39,代碼來源:CSharpReferenceExpressionImplUtil.java

示例15: toTypeRef

import com.intellij.psi.ResolveResult; //導入方法依賴的package包/類
@NotNull
@RequiredReadAction
public static DotNetTypeRef toTypeRef(@NotNull ResolveResult resolveResult)
{
	PsiElement element = resolveResult.getElement();
	DotNetGenericExtractor extractor = DotNetGenericExtractor.EMPTY;
	if(resolveResult instanceof CSharpResolveResultWithExtractor)
	{
		extractor = ((CSharpResolveResultWithExtractor) resolveResult).getExtractor();
	}
	return toTypeRef(element, extractor);
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:13,代碼來源:CSharpReferenceExpressionImplUtil.java


注:本文中的com.intellij.psi.ResolveResult.getElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。