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


Java PsiJavaReference類代碼示例

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


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

示例1: computeHashCode

import com.intellij.psi.PsiJavaReference; //導入依賴的package包/類
@Override
public int computeHashCode(final PsiElement element) {
  if (element == null) return 0;
  String text = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      PsiElement elementToCompare = element;
      if (element instanceof PsiJavaReference) {
        PsiElement resolved = ((PsiJavaReference)element).resolve();
        if (resolved != null) {
          elementToCompare = resolved;
        }
      }
      return elementToCompare instanceof PsiNamedElement ? ((PsiNamedElement)elementToCompare).getName()
                                                         : AstBufferUtil.getTextSkippingWhitespaceComments(elementToCompare.getNode());
    }
  });
  return Comparing.hashcode(text);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:SliceLeafAnalyzer.java

示例2: findJavaReference

import com.intellij.psi.PsiJavaReference; //導入依賴的package包/類
@Nullable
private static PsiJavaReference findJavaReference(final PsiFile file, final int offset)
{
	PsiReference reference = file.findReferenceAt(offset);
	if(reference instanceof PsiMultiReference)
	{
		for(final PsiReference psiReference : ((PsiMultiReference) reference).getReferences())
		{
			if(psiReference instanceof PsiJavaReference)
			{
				return (PsiJavaReference) psiReference;
			}
		}
	}
	return reference instanceof PsiJavaReference ? (PsiJavaReference) reference : null;
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:17,代碼來源:JavadocCompletionConfidence.java

示例3: suggestQualifyingSuperCalls

import com.intellij.psi.PsiJavaReference; //導入依賴的package包/類
static Set<LookupElement> suggestQualifyingSuperCalls(PsiElement element,
		PsiJavaReference javaReference,
		ElementFilter elementFilter,
		JavaCompletionProcessor.Options options,
		Condition<String> nameCondition)
{
	Set<LookupElement> set = ContainerUtil.newLinkedHashSet();
	for(final String className : getContainingClassNames(element))
	{
		PsiReferenceExpression fakeSuper = JavaCompletionUtil.createReference(className + ".super.rulez", element);
		PsiElement leaf = ObjectUtils.assertNotNull(fakeSuper.getReferenceNameElement());

		JavaCompletionProcessor superProcessor = new JavaCompletionProcessor(leaf, elementFilter, options, nameCondition);
		fakeSuper.processVariants(superProcessor);

		for(CompletionElement completionElement : superProcessor.getResults())
		{
			for(LookupElement item : JavaCompletionUtil.createLookupElements(completionElement, javaReference))
			{
				set.add(withQualifiedSuper(className, item));
			}
		}
	}
	return set;
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:26,代碼來源:SuperCalls.java

示例4: getSymbolTypeDeclarations

import com.intellij.psi.PsiJavaReference; //導入依賴的package包/類
@RequiredReadAction
@Nullable
@Override
public PsiElement[] getSymbolTypeDeclarations(@NotNull PsiElement targetElement, Editor editor, int offset) {
  PsiType type;
  if (targetElement instanceof PsiVariable){
    type = ((PsiVariable)targetElement).getType();
  }
  else if (targetElement instanceof PsiMethod){
    type = ((PsiMethod)targetElement).getReturnType();
  }
  else{
    return null;
  }
  if (type == null) return null;
  if (editor != null) {
    final PsiReference reference = TargetElementUtil.findReference(editor, offset);
    if (reference instanceof PsiJavaReference) {
      final JavaResolveResult resolveResult = ((PsiJavaReference)reference).advancedResolve(true);
      type = resolveResult.getSubstitutor().substitute(type);
    }
  }
  PsiClass psiClass = PsiUtil.resolveClassInType(type);
  return psiClass == null ? null : new PsiElement[] {psiClass};
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:26,代碼來源:JavaTypeDeclarationProvider.java

示例5: testDuplicateStaticImport

import com.intellij.psi.PsiJavaReference; //導入依賴的package包/類
public void testDuplicateStaticImport() throws Exception {
  PsiReference ref = configure();
  final JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true);
  PsiElement target = result.getElement();
  assertNotNull(target);
  assertTrue(result.isValidResult());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:8,代碼來源:ResolveVariable15Test.java

示例6: testRhombExtending

import com.intellij.psi.PsiJavaReference; //導入依賴的package包/類
public void testRhombExtending() throws Exception {
  PsiReference ref = configure();
  final JavaResolveResult result = ((PsiJavaReference)ref).advancedResolve(true);
  PsiElement target = result.getElement();
  assertNotNull(target);
  assertTrue(result.isValidResult());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:8,代碼來源:ResolveVariable15Test.java


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