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


Java GotoRelatedItem类代码示例

本文整理汇总了Java中com.intellij.navigation.GotoRelatedItem的典型用法代码示例。如果您正苦于以下问题:Java GotoRelatedItem类的具体用法?Java GotoRelatedItem怎么用?Java GotoRelatedItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GotoRelatedItem类属于com.intellij.navigation包,在下文中一共展示了GotoRelatedItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: match

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
@Override
public boolean match(@NotNull LineMarkerInfo markerInfo) {
    if(markerInfo.getLineMarkerTooltip() == null || !markerInfo.getLineMarkerTooltip().equals(toolTip)) {
        return false;
    }

    if(!(markerInfo instanceof RelatedItemLineMarkerInfo)) {
        return false;
    }

    for (Object o : ((RelatedItemLineMarkerInfo) markerInfo).createGotoRelatedItems()) {
        if(o instanceof GotoRelatedItem && this.pattern.accepts(((GotoRelatedItem) o).getElement())) {
            return true;
        }
    }

    return false;
}
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:19,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例2: testCamelGutterForVariableAndConstant

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
public void testCamelGutterForVariableAndConstant() {
    myFixture.configureByFiles("JavaCamelRouteLineMarkerProviderFromVariableTestData.java");
    List<GutterMark> gutters = myFixture.findAllGutters();
    assertNotNull(gutters);

    //remove first element since it is navigate to super implementation gutter icon
    gutters.remove(0);

    assertEquals("Should contain 2 Camel gutters", 2, gutters.size());

    assertGuttersHasCamelIcon(gutters);

    LineMarkerInfo.LineMarkerGutterIconRenderer firstGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0);
    assertTrue(firstGutter.getLineMarkerInfo().getElement() instanceof PsiIdentifier);
    assertEquals("The navigation start element doesn't match", "uriVar",
        firstGutter.getLineMarkerInfo().getElement().getText());

    List<GotoRelatedItem> firstGutterTargets = getGutterNavigationDestinationElements(firstGutter);
    assertEquals("Navigation should have two targets", 2, firstGutterTargets.size());
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:21,代码来源:JavaCamelRouteLineMarkerProviderTestIT.java

示例3: testCamelGutterForMethodCallFrom

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
public void testCamelGutterForMethodCallFrom() {
    myFixture.configureByFiles("JavaCamelRouteLineMarkerProviderFromMethodCallTestData.java");
    List<GutterMark> gutters = myFixture.findAllGutters();
    assertNotNull(gutters);

    //remove first element since it is navigate to super implementation gutter icon
    gutters.remove(0);
    // remove last element since it is from method returning route uri
    gutters.remove(gutters.size() - 1);

    assertEquals("Should contain 1 Camel gutters", 1, gutters.size());

    assertGuttersHasCamelIcon(gutters);

    LineMarkerInfo.LineMarkerGutterIconRenderer firstGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0);
    assertTrue(firstGutter.getLineMarkerInfo().getElement() instanceof PsiIdentifier);
    assertEquals("The navigation start element doesn't match", "calcEndpoint",
        firstGutter.getLineMarkerInfo().getElement().getText());

    List<GotoRelatedItem> firstGutterTargets = getGutterNavigationDestinationElements(firstGutter);
    assertEquals("Navigation should have two targets", 2, firstGutterTargets.size());
    assertEquals("The navigation variable target element doesn't match", "calcEndpoint",
        getGuttersWithMethodTarget(firstGutterTargets).get(0).getName());
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:25,代码来源:JavaCamelRouteLineMarkerProviderTestIT.java

示例4: testCamelGutterForToD

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
public void testCamelGutterForToD() {
    myFixture.configureByFiles("XmlCamelRouteLineMarkerProviderToDTestData.xml");
    List<GutterMark> gutters = myFixture.findAllGutters();
    assertNotNull(gutters);

    assertEquals("Should contain 1 Camel gutter", 1, gutters.size());

    assertSame("Gutter should have the Camel icon", ServiceManager.getService(CamelPreferenceService.class).getCamelIcon(), gutters.get(0).getIcon());
    assertEquals("Camel route", gutters.get(0).getTooltipText());

    LineMarkerInfo.LineMarkerGutterIconRenderer gutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0);

    assertTrue(gutter.getLineMarkerInfo().getElement() instanceof XmlToken);
    assertEquals("The navigation start element doesn't match", "file:inbox",
            PsiTreeUtil.getParentOfType(gutter.getLineMarkerInfo().getElement(), XmlTag.class).getAttribute("uri").getValue());

    List<GotoRelatedItem> gutterTargets = getGutterNavigationDestinationElements(gutter);
    assertEquals("Navigation should have one target", 1, gutterTargets.size());
    assertEquals("The navigation target route doesn't match", "file:inbox", gutterTargets.get(0).getElement().getText());
    assertEquals("The navigation target tag name doesn't match", "toD",
            getGuttersWithXMLTarget(gutterTargets).get(0).getLocalName());

}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:24,代码来源:XmlCamelRouteLineMarkerProviderTestIT.java

示例5: 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

示例6: createNumberAction

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
private static Action createNumberAction(final int mnemonic,
                                       final ListPopupImpl listPopup,
                                       final Map<PsiElement, GotoRelatedItem> itemsMap,
                                       final Processor<Object> processor) {
  return new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
      for (final Object item : listPopup.getListStep().getValues()) {
        if (getMnemonic(item, itemsMap) == mnemonic) {
          listPopup.setFinalRunnable(new Runnable() {
            @Override
            public void run() {
              processor.process(item);
            }
          });
          listPopup.closeOk(null);
        }
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:NavigationUtil.java

示例7: collectRelatedItems

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
@NotNull
public static List<GotoRelatedItem> collectRelatedItems(@NotNull PsiElement contextElement, @Nullable DataContext dataContext) {
  Set<GotoRelatedItem> items = ContainerUtil.newLinkedHashSet();
  for (GotoRelatedProvider provider : Extensions.getExtensions(GotoRelatedProvider.EP_NAME)) {
    items.addAll(provider.getItems(contextElement));
    if (dataContext != null) {
      items.addAll(provider.getItems(dataContext));
    }
  }
  GotoRelatedItem[] result = items.toArray(new GotoRelatedItem[items.size()]);
  Arrays.sort(result, new Comparator<GotoRelatedItem>() {
    @Override
    public int compare(GotoRelatedItem i1, GotoRelatedItem i2) {
      String o1 = i1.getGroup();
      String o2 = i2.getGroup();
      return StringUtil.isEmpty(o1) ? 1 : StringUtil.isEmpty(o2) ? -1 : o1.compareTo(o2);
    }
  });
  return Arrays.asList(result);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:NavigationUtil.java

示例8: getItems

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
@NotNull
@Override
public List<? extends GotoRelatedItem> getItems(@NotNull DataContext context) {
  final PsiFile file = CommonDataKeys.PSI_FILE.getData(context);
  if (file == null) return Collections.emptyList();

  Collection<PsiElement> result;
  final boolean isTest = TestFinderHelper.isTest(file);
  if (isTest) {
    result = TestFinderHelper.findClassesForTest(file);
  }
  else {
    result = TestFinderHelper.findTestsForClass(file);
  }

  if (!result.isEmpty()) {
    final List<GotoRelatedItem> items = new ArrayList<GotoRelatedItem>();
    for (PsiElement element : result) {
      items.add(new GotoRelatedItem(element, isTest ? "Tests" : "Testee classes"));
    }
    return items;
  }
  return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GotoTestRelatedProvider.java

示例9: 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

示例10: 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

示例11: getItems

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
@NotNull
@Override
public List<? extends GotoRelatedItem> getItems(@NotNull DataContext context) {
  final Editor editor = CommonDataKeys.EDITOR.getData(context);
  final Project project = CommonDataKeys.PROJECT.getData(context);
  final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
  if (editor == null || file == null || project == null) {
    return Collections.emptyList();
  }

  final List<Location> locations = TestLocationDataRule.collectRelativeLocations(project, file);
  if (locations.isEmpty()) {
    return Collections.emptyList();
  }
  
  return ContainerUtil.map(locations, new Function<Location, GotoRelatedItem>() {
    @Override
    public GotoRelatedItem fun(Location location) {
      return new GotoRelatedItem(location.getPsiElement());
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TestCaseAsRelatedFileProvider.java

示例12: getItems

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
@Override
public List<? extends GotoRelatedItem> getItems(PsiElement psiElement) {
  PsiFile psiFile = psiElement.getContainingFile();
  Project project = psiElement.getProject();
  if (!(psiFile instanceof OCFile) || !Blaze.isBlazeProject(project)) {
    return ImmutableList.of();
  }
  OCFile ocFile = (OCFile) psiFile;
  // Try to find the corresponding file quickly. If we can't even figure that out (e.g.,
  // if headers are stored in a different directory) then delegate to the original provider.
  OCFile correspondingFile = SwitchToHeaderOrSourceSearch.getCorrespondingFile(ocFile);
  if (correspondingFile == null) {
    Optional<List<? extends GotoRelatedItem>> fromDelegate =
        getItemsWithTimeout(() -> DELEGATE.getItems(psiElement));
    if (fromDelegate.isPresent()) {
      return fromDelegate.get();
    }
    logger.info("Timed out without a fallback.");
    return ImmutableList.of();
  }
  return ImmutableList.of(
      new GotoRelatedItem(
          correspondingFile, correspondingFile.isHeader() ? "Headers" : "Sources"));
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:25,代码来源:DelegatingSwitchToHeaderOrSourceProvider.java

示例13: getItemsWithTimeout

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
/**
 * Runs the getter under a progress indicator that cancels itself after a certain timeout (assumes
 * that the getter will check for cancellation cooperatively).
 *
 * @param getter computes the GotoRelatedItems.
 * @return a list of items computed, or Optional.empty if timed out.
 */
private Optional<List<? extends GotoRelatedItem>> getItemsWithTimeout(
    ThrowableComputable<List<? extends GotoRelatedItem>, RuntimeException> getter) {
  try {
    ProgressIndicator indicator = new ProgressIndicatorBase();
    ProgressIndicator wrappedIndicator =
        new WatchdogIndicator(indicator, TIMEOUT_MS, TimeUnit.MILLISECONDS);
    // We don't use "runProcessWithProgressSynchronously" because that pops up a ProgressWindow,
    // and that will cause the event IDs to bump up and no longer match the event ID stored in
    // DataContexts which may be used in one of the GotoRelatedProvider#getItems overloads.
    return Optional.of(
        ProgressManager.getInstance()
            .runProcess(() -> ReadAction.compute(getter), wrappedIndicator));
  } catch (ProcessCanceledException e) {
    return Optional.empty();
  }
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:24,代码来源:DelegatingSwitchToHeaderOrSourceProvider.java

示例14: getSingleLineMarker

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
public static RelatedItemLineMarkerInfo<PsiElement> getSingleLineMarker(SmartyFile smartyFile, Collection<LineMarkerInfo> lineMarkerInfos, GotoRelatedItem gotoRelatedItem) {

        // hell: find any possible small icon
        Icon icon = null;
        if(gotoRelatedItem instanceof RelatedPopupGotoLineMarker.PopupGotoRelatedItem) {
            icon = ((RelatedPopupGotoLineMarker.PopupGotoRelatedItem) gotoRelatedItem).getSmallIcon();
        }

        if(icon == null) {
            icon = OxidPluginIcons.OXID_LINEMARKER;
        }

        NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(icon).
                setTargets(gotoRelatedItem.getElement());

        String customName = gotoRelatedItem.getCustomName();
        if(customName != null) {
            builder.setTooltipText(customName);
        }

        return builder.createLineMarkerInfo(smartyFile);
    }
 
开发者ID:Haehnchen,项目名称:idea-php-oxid-plugin,代码行数:23,代码来源:SmartyTemplateLineMarkerProvider.java

示例15: getRelatedPopover

import com.intellij.navigation.GotoRelatedItem; //导入依赖的package包/类
@NotNull
private LineMarkerInfo getRelatedPopover(@NotNull String singleItemTitle, @NotNull String singleItemTooltipPrefix, @NotNull PsiElement lineMarkerTarget, @NotNull Collection<GotoRelatedItem> gotoRelatedItems, @NotNull Icon icon) {
    // single item has no popup
    String title = singleItemTitle;
    if(gotoRelatedItems.size() == 1) {
        String customName = gotoRelatedItems.iterator().next().getCustomName();
        if(customName != null) {
            title = String.format(singleItemTooltipPrefix, customName);
        }
    }

    return new LineMarkerInfo<>(
        lineMarkerTarget,
        lineMarkerTarget.getTextRange(),
        icon,
        6,
        new ConstantFunction<>(title),
        new RelatedPopupGotoLineMarker.NavigationHandler(gotoRelatedItems),
        GutterIconRenderer.Alignment.RIGHT
    );
}
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:22,代码来源:TemplateLineMarker.java


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