本文整理汇总了Java中com.intellij.psi.PsiReference.getVariants方法的典型用法代码示例。如果您正苦于以下问题:Java PsiReference.getVariants方法的具体用法?Java PsiReference.getVariants怎么用?Java PsiReference.getVariants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiReference
的用法示例。
在下文中一共展示了PsiReference.getVariants方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReferenceCanResolveVariants
import com.intellij.psi.PsiReference; //导入方法依赖的package包/类
public void testReferenceCanResolveVariants() {
PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"\"LLL:EXT:foo/sample.xlf:sys_<caret>language.language_isocode.ab\";");
PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
PsiReference[] references = elementAtCaret.getReferences();
for (PsiReference reference : references) {
if (reference instanceof TranslationReference) {
Object[] variants = reference.getVariants();
for (Object variant : variants) {
if (variant instanceof LookupElement) {
String lookupString = ((LookupElement) variant).getLookupString();
assertEquals("LLL:EXT:foo/sample.xlf:sys_language.language_isocode.ab", lookupString);
return;
}
}
}
}
fail("No TranslationReference found");
}
示例2: testReferenceCanResolveVariants
import com.intellij.psi.PsiReference; //导入方法依赖的package包/类
public void testReferenceCanResolveVariants() {
PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
"class ActionController {" +
"public function action() {" +
" $this->forward('<caret>baz');" +
"}" +
"}"
);
PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
PsiReference[] references = elementAtCaret.getReferences();
for (PsiReference reference : references) {
if (reference instanceof ControllerActionReference) {
Object[] variants = reference.getVariants();
for (Object variant : variants) {
if (variant instanceof LookupElement) {
String lookupString = ((LookupElement) variant).getLookupString();
assertEquals("foo", lookupString);
return;
}
}
}
}
fail("No ControllerActionReference found");
}