本文整理汇总了Java中consulo.codeInsight.TargetElementUtil.getTargetCandidates方法的典型用法代码示例。如果您正苦于以下问题:Java TargetElementUtil.getTargetCandidates方法的具体用法?Java TargetElementUtil.getTargetCandidates怎么用?Java TargetElementUtil.getTargetCandidates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类consulo.codeInsight.TargetElementUtil
的用法示例。
在下文中一共展示了TargetElementUtil.getTargetCandidates方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExpression
import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Nullable
protected PsiExpression getExpression(PsiElement element) {
if (myMethodCall == null || !myMethodCall.isValid()) {
return myExpression == null || !myExpression.isValid() ? null : myExpression;
}
final PsiElement method = myMethodCall.resolveMethod();
if (method != null) {
final PsiMethod psiMethod = (PsiMethod)method;
return checkMethod(element, psiMethod);
} else if (myMethodCall instanceof PsiMethodCallExpression){
final Collection<PsiElement> psiElements = TargetElementUtil.getTargetCandidates(((PsiMethodCallExpression) myMethodCall).getMethodExpression());
for (PsiElement psiElement : psiElements) {
if (psiElement instanceof PsiMethod) {
final PsiExpression expression = checkMethod(element, (PsiMethod)psiElement);
if (expression != null) return expression;
}
}
}
return null;
}
示例2: doTest
import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
protected Collection<PsiElement> doTest(int expectedSize) {
PsiFile file = myFixture.getFile();
assertNotNull(file);
PsiReference reference = file.findReferenceAt(myFixture.getCaretOffset());
assertNotNull("no reference", reference);
final Collection<PsiElement> elements = TargetElementUtil.getTargetCandidates(reference);
assertNotNull(elements);
assertEquals(expectedSize, elements.size());
return elements;
}
示例3: getPsiElementsIn
import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Nullable
private static PsiElement[] getPsiElementsIn(final Editor editor, final PsiFile psiFile) {
try {
final PsiReference reference = TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset());
if (reference == null) {
return null;
}
final Collection<PsiElement> candidates = TargetElementUtil.getTargetCandidates(reference);
return ContainerUtil.toArray(candidates, new PsiElement[candidates.size()]);
}
catch (IndexNotReadyException e) {
return null;
}
}
示例4: doTest
import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
protected void doTest(PsiFile[] files, int expectedSize) {
final PsiFile myFile = files[0];
final Collection<PsiElement> elements = TargetElementUtil.getTargetCandidates(myFile.findReferenceAt(myFixture.getCaretOffset()));
assertNotNull(elements);
assertEquals(expectedSize, elements.size());
}
示例5: suggestCandidates
import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
private static Collection<PsiElement> suggestCandidates(final PsiReference reference) {
if (reference == null) {
return Collections.emptyList();
}
return TargetElementUtil.getTargetCandidates(reference);
}