本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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};
}
示例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());
}
示例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());
}