本文整理汇总了Java中com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.findAllTargetElements方法的典型用法代码示例。如果您正苦于以下问题:Java GotoDeclarationAction.findAllTargetElements方法的具体用法?Java GotoDeclarationAction.findAllTargetElements怎么用?Java GotoDeclarationAction.findAllTargetElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.navigation.actions.GotoDeclarationAction
的用法示例。
在下文中一共展示了GotoDeclarationAction.findAllTargetElements方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doJavaFileNavigationTest
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
private void doJavaFileNavigationTest(String srcPath, String destPath, int expectedTargets, boolean expectedEnabled,
boolean testGotoDeclaration, Class<? extends PsiElement> targetElementClass) throws IOException {
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + srcPath, destPath);
myFixture.configureFromExistingVirtualFile(file);
// test Ctrl+B
if (testGotoDeclaration) {
PsiElement[] targets = GotoDeclarationAction.findAllTargetElements(getProject(), myFixture.getEditor(), myFixture.getCaretOffset());
assertNotNull(targets);
assertEquals(expectedTargets, targets.length);
for (PsiElement target : targets) {
assertInstanceOf(LazyValueResourceElementWrapper.computeLazyElement(target), targetElementClass);
}
}
}
示例2: testNavigationInPlatformXml1
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
public void testNavigationInPlatformXml1() throws Exception {
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(
getTestSdkPath() + "/platforms/" + getPlatformDir() + "/data/res/values/resources.xml");
myFixture.configureFromExistingVirtualFile(file);
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(16, 43));
PsiElement[] targets =
GotoDeclarationAction.findAllTargetElements(myFixture.getProject(), myFixture.getEditor(), myFixture.getCaretOffset());
assertNotNull(targets);
assertEquals(1, targets.length);
final PsiElement targetElement = LazyValueResourceElementWrapper.computeLazyElement(targets[0]);
assertInstanceOf(targetElement, XmlAttributeValue.class);
final XmlAttributeValue targetAttrValue = (XmlAttributeValue)targetElement;
assertEquals("Theme", targetAttrValue.getValue());
assertEquals("name", ((XmlAttribute)targetAttrValue.getParent()).getName());
assertEquals("style", ((XmlTag)targetAttrValue.getParent().getParent()).getName());
assertEquals(file, targetElement.getContainingFile().getVirtualFile());
}
示例3: testNavigationInPlatformXml2
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
public void testNavigationInPlatformXml2() throws Exception {
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(
getTestSdkPath() + "/platforms/" + getPlatformDir() + "/data/res/values/resources.xml");
myFixture.configureFromExistingVirtualFile(file);
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(19, 17));
PsiElement[] targets =
GotoDeclarationAction.findAllTargetElements(myFixture.getProject(), myFixture.getEditor(), myFixture.getCaretOffset());
assertNotNull(targets);
assertEquals(1, targets.length);
final PsiElement targetElement = LazyValueResourceElementWrapper.computeLazyElement(targets[0]);
assertInstanceOf(targetElement, XmlAttributeValue.class);
final XmlAttributeValue targetAttrValue = (XmlAttributeValue)targetElement;
assertEquals("Theme", targetAttrValue.getValue());
assertEquals("name", ((XmlAttribute)targetAttrValue.getParent()).getName());
assertEquals("style", ((XmlTag)targetAttrValue.getParent().getParent()).getName());
assertEquals(file, targetElement.getContainingFile().getVirtualFile());
}
示例4: testNavigationInPlatformXml3
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
public void testNavigationInPlatformXml3() throws Exception {
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(
getTestSdkPath() + "/platforms/" + getPlatformDir() + "/data/res/values/resources.xml");
myFixture.configureFromExistingVirtualFile(file);
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(5, 44));
PsiElement[] targets =
GotoDeclarationAction.findAllTargetElements(myFixture.getProject(), myFixture.getEditor(), myFixture.getCaretOffset());
assertNotNull(targets);
assertEquals(1, targets.length);
final PsiElement targetElement = LazyValueResourceElementWrapper.computeLazyElement(targets[0]);
assertInstanceOf(targetElement, XmlAttributeValue.class);
final XmlAttributeValue targetAttrValue = (XmlAttributeValue)targetElement;
assertEquals("my_white", targetAttrValue.getValue());
assertEquals("name", ((XmlAttribute)targetAttrValue.getParent()).getName());
assertEquals("color", ((XmlTag)targetAttrValue.getParent().getParent()).getName());
assertEquals(file, targetElement.getContainingFile().getVirtualFile());
}
示例5: doTestNavigationToResource
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
private void doTestNavigationToResource(LogicalPosition position, int expectedCount, Class<?> aClass) {
myFixture.allowTreeAccessForAllFiles();
final String sdkSourcesPath = configureMockSdk();
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(sdkSourcesPath + "/android/app/Activity.java");
myFixture.configureFromExistingVirtualFile(file);
myFixture.getEditor().getCaretModel().moveToLogicalPosition(position);
PsiElement[] elements = GotoDeclarationAction.findAllTargetElements(
myFixture.getProject(), myFixture.getEditor(),
myFixture.getEditor().getCaretModel().getOffset());
assertEquals(expectedCount, elements.length);
for (PsiElement element : elements) {
assertInstanceOf(LazyValueResourceElementWrapper.computeLazyElement(element), aClass);
}
}
示例6: testMultipleConstructors
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
public void testMultipleConstructors() throws Exception {
String name = getTestName(false);
configureByFile("/codeInsight/gotoDeclaration/" + name + ".java");
final int offset = getEditor().getCaretModel().getOffset();
final PsiElement[] elements =
GotoDeclarationAction.findAllTargetElements(getProject(), getEditor(), offset);
assertEquals(Arrays.asList(elements).toString(), 0, elements.length);
final TargetElementUtil elementUtilBase = TargetElementUtil.getInstance();
final PsiReference reference = getFile().findReferenceAt(offset);
assertNotNull(reference);
final Collection<PsiElement> candidates = elementUtilBase.getTargetCandidates(reference);
assertEquals(candidates.toString(), 2, candidates.size());
}
示例7: testDeclareStyleableNameNavigation1
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
public void testDeclareStyleableNameNavigation1() throws Exception {
copyFileToProject("LabelView.java", "src/p1/p2/LabelView.java");
final VirtualFile file = copyFileToProject("attrs4.xml");
myFixture.configureFromExistingVirtualFile(file);
PsiElement[] targets =
GotoDeclarationAction.findAllTargetElements(myFixture.getProject(), myFixture.getEditor(), myFixture.getCaretOffset());
assertNotNull(targets);
assertEquals(1, targets.length);
PsiElement targetElement = targets[0];
assertInstanceOf(targetElement, PsiClass.class);
assertEquals("android.widget.TextView", ((PsiClass)targetElement).getQualifiedName());
}
示例8: testDeclareStyleableNameNavigation2
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
public void testDeclareStyleableNameNavigation2() throws Exception {
copyFileToProject("LabelView.java", "src/p1/p2/LabelView.java");
final VirtualFile file = copyFileToProject("attrs5.xml");
myFixture.configureFromExistingVirtualFile(file);
PsiElement[] targets =
GotoDeclarationAction.findAllTargetElements(myFixture.getProject(), myFixture.getEditor(), myFixture.getCaretOffset());
assertNotNull(targets);
assertEquals(1, targets.length);
PsiElement targetElement = targets[0];
assertInstanceOf(targetElement, PsiClass.class);
assertEquals("p1.p2.LabelView", ((PsiClass)targetElement).getQualifiedName());
}
示例9: testJavaNavigation
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
public void testJavaNavigation() throws Exception {
createInitialStructure();
myFixture.copyFileToProject("R.java", "app/src/p1/p2/R.java");
VirtualFile file = myFixture.copyFileToProject(BASE_PATH + getTestName(false) + ".java", "/app/src/p1/p2/Java.java");
myFixture.configureFromExistingVirtualFile(file);
PsiElement[] targets =
GotoDeclarationAction.findAllTargetElements(myFixture.getProject(), myFixture.getEditor(), myFixture.getCaretOffset());
assertNotNull(targets);
assertEquals(1, targets.length);
PsiElement targetElement = targets[0];
assertInstanceOf(targetElement, PsiFile.class);
assertEquals("main.xml", ((PsiFile)targetElement).getName());
}
示例10: getDeclarationsFrom
import com.intellij.codeInsight.navigation.actions.GotoDeclarationAction; //导入方法依赖的package包/类
@Nullable
private PsiElement[] getDeclarationsFrom(VirtualFile file) {
myFixture.configureFromExistingVirtualFile(file);
// AndroidGotoDeclarationHandler only handles .java files. We also want to check .xml files, so
// we use GotoDeclarationAction instead of creating AndroidGotoDeclarationHandler and invoking getGotoDeclarationTargets
// on it directly.
return GotoDeclarationAction.findAllTargetElements(myFixture.getProject(), myFixture.getEditor(), myFixture.getCaretOffset());
}