本文整理汇总了Java中com.intellij.navigation.GotoRelatedItem.getElement方法的典型用法代码示例。如果您正苦于以下问题:Java GotoRelatedItem.getElement方法的具体用法?Java GotoRelatedItem.getElement怎么用?Java GotoRelatedItem.getElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.navigation.GotoRelatedItem
的用法示例。
在下文中一共展示了GotoRelatedItem.getElement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRelatedItemsPopup
import com.intellij.navigation.GotoRelatedItem; //导入方法依赖的package包/类
@NotNull
public static JBPopup getRelatedItemsPopup(final List<? extends GotoRelatedItem> items, String title) {
Object[] elements = new Object[items.size()];
//todo[nik] move presentation logic to GotoRelatedItem class
final Map<PsiElement, GotoRelatedItem> itemsMap = new HashMap<PsiElement, GotoRelatedItem>();
for (int i = 0; i < items.size(); i++) {
GotoRelatedItem item = items.get(i);
elements[i] = item.getElement() != null ? item.getElement() : item;
itemsMap.put(item.getElement(), item);
}
return getPsiElementPopup(elements, itemsMap, title, new Processor<Object>() {
@Override
public boolean process(Object element) {
if (element instanceof PsiElement) {
//noinspection SuspiciousMethodCalls
itemsMap.get(element).navigate();
}
else {
((GotoRelatedItem)element).navigate();
}
return true;
}
}
);
}
示例2: addItemsForMarkers
import com.intellij.navigation.GotoRelatedItem; //导入方法依赖的package包/类
private static void addItemsForMarkers(List<RelatedItemLineMarkerInfo> markers,
List<GotoRelatedItem> result) {
Set<PsiFile> addedFiles = new HashSet<PsiFile>();
for (RelatedItemLineMarkerInfo<?> marker : markers) {
Collection<? extends GotoRelatedItem> items = marker.createGotoRelatedItems();
for (GotoRelatedItem item : items) {
PsiElement element = item.getElement();
if (element instanceof PsiFile) {
PsiFile file = (PsiFile)element;
if (addedFiles.contains(file)) {
continue;
}
}
if (element != null) {
ContainerUtil.addIfNotNull(element.getContainingFile(), addedFiles);
}
result.add(item);
}
}
}
示例3: testActivityToAndManifest
import com.intellij.navigation.GotoRelatedItem; //导入方法依赖的package包/类
public void testActivityToAndManifest() throws Exception {
final VirtualFile manifestFile =
myFixture.copyFileToProject(BASE_PATH + "Manifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML);
final VirtualFile activityFile = myFixture.copyFileToProject(BASE_PATH + "Activity1.java", "src/p1/p2/MyActivity.java");
AndroidGotoRelatedProvider.ourAddDeclarationToManifest = true;
final List<GotoRelatedItem> items;
try {
items = doGotoRelatedFile(activityFile);
}
finally {
AndroidGotoRelatedProvider.ourAddDeclarationToManifest = false;
}
assertEquals(1, items.size());
final GotoRelatedItem item = items.get(0);
final PsiElement element = item.getElement();
assertInstanceOf(element, XmlAttributeValue.class);
assertEquals(manifestFile, element.getContainingFile().getVirtualFile());
}
示例4: createPopup
import com.intellij.navigation.GotoRelatedItem; //导入方法依赖的package包/类
public static JBPopup createPopup(final List<? extends GotoRelatedItem> items, final String title) {
Object[] elements = new Object[items.size()];
//todo[nik] move presentation logic to GotoRelatedItem class
final Map<PsiElement, GotoRelatedItem> itemsMap = new HashMap<PsiElement, GotoRelatedItem>();
for (int i = 0; i < items.size(); i++) {
GotoRelatedItem item = items.get(i);
elements[i] = item.getElement() != null ? item.getElement() : item;
itemsMap.put(item.getElement(), item);
}
return getPsiElementPopup(elements, itemsMap, title, new Processor<Object>() {
@Override
public boolean process(Object element) {
if (element instanceof PsiElement) {
//noinspection SuspiciousMethodCalls
itemsMap.get(element).navigate();
}
else {
((GotoRelatedItem)element).navigate();
}
return true;
}
}
);
}
示例5: getRelatedItemsPopup
import com.intellij.navigation.GotoRelatedItem; //导入方法依赖的package包/类
/**
* Returns navigation popup that shows list of related items from {@code items} list
*
* @param items
* @param title
* @param showContainingModules Whether the popup should show additional information that aligned at the right side of the dialog.<br>
* It's usually a module name or library name of corresponding navigation item.<br>
* {@code false} by default
* @return
*/
@Nonnull
public static JBPopup getRelatedItemsPopup(final List<? extends GotoRelatedItem> items, String title, boolean showContainingModules) {
Object[] elements = new Object[items.size()];
//todo[nik] move presentation logic to GotoRelatedItem class
final Map<PsiElement, GotoRelatedItem> itemsMap = new HashMap<>();
for (int i = 0; i < items.size(); i++) {
GotoRelatedItem item = items.get(i);
elements[i] = item.getElement() != null ? item.getElement() : item;
itemsMap.put(item.getElement(), item);
}
return getPsiElementPopup(elements, itemsMap, title, showContainingModules, element -> {
if (element instanceof PsiElement) {
//noinspection SuspiciousMethodCalls
itemsMap.get(element).navigate();
}
else {
((GotoRelatedItem)element).navigate();
}
return true;
});
}
示例6: findRelatedActivities
import com.intellij.navigation.GotoRelatedItem; //导入方法依赖的package包/类
@NotNull
private static Collection<PsiClass> findRelatedActivities(@NotNull XmlFile file,
@NotNull AndroidFacet facet,
@NotNull DomFileDescription<?> description) {
if (description instanceof LayoutDomFileDescription) {
final Computable<List<GotoRelatedItem>> computable = AndroidGotoRelatedProvider.getLazyItemsForXmlFile(file, facet);
if (computable == null) {
return Collections.emptyList();
}
final List<GotoRelatedItem> items = computable.compute();
if (items.isEmpty()) {
return Collections.emptyList();
}
final PsiClass activityClass = findActivityClass(facet.getModule());
if (activityClass == null) {
return Collections.emptyList();
}
final List<PsiClass> result = new ArrayList<PsiClass>();
for (GotoRelatedItem item : items) {
final PsiElement element = item.getElement();
if (element instanceof PsiClass) {
final PsiClass aClass = (PsiClass)element;
if (aClass.isInheritor(activityClass, true)) {
result.add(aClass);
}
}
}
return result;
}
else {
return findRelatedActivitiesForMenu(file, facet);
}
}
示例7: doCheckItems
import com.intellij.navigation.GotoRelatedItem; //导入方法依赖的package包/类
private static void doCheckItems(List<VirtualFile> expectedTargetFiles, List<GotoRelatedItem> items, Class<?> targetElementClass) {
final Set<VirtualFile> targetFiles = new HashSet<VirtualFile>();
for (GotoRelatedItem item : items) {
final PsiElement element = item.getElement();
assertInstanceOf(element, targetElementClass);
final VirtualFile targetFile = element.getContainingFile().getVirtualFile();
assertNotNull(targetFile);
targetFiles.add(targetFile);
}
assertEquals(new HashSet<VirtualFile>(expectedTargetFiles), targetFiles);
}