当前位置: 首页>>代码示例>>Java>>正文


Java GotoRelatedItem.getElement方法代码示例

本文整理汇总了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;
    }
  }
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:NavigationUtil.java

示例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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:RelatedItemLineMarkerGotoAdapter.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidGotoRelatedTest.java

示例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;
    }
  }
  );
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:GotoRelatedFileAction.java

示例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;
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:33,代码来源:NavigationUtil.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:AndroidMissingOnClickHandlerInspection.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:AndroidGotoRelatedTest.java


注:本文中的com.intellij.navigation.GotoRelatedItem.getElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。