当前位置: 首页>>代码示例>>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;未经允许,请勿转载。