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


Java UsageInfo.getNavigationOffset方法代码示例

本文整理汇总了Java中com.intellij.usageView.UsageInfo.getNavigationOffset方法的典型用法代码示例。如果您正苦于以下问题:Java UsageInfo.getNavigationOffset方法的具体用法?Java UsageInfo.getNavigationOffset怎么用?Java UsageInfo.getNavigationOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.usageView.UsageInfo的用法示例。


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

示例1: testNonCodeClassUsages

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
public void testNonCodeClassUsages() throws Exception {
  final TempDirTestFixture tdf = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
  tdf.setUp();

  try {
    new WriteCommandAction(getProject()) {
      @Override
      protected void run(@NotNull Result result) throws Throwable {
        final ModifiableModuleModel moduleModel = ModuleManager.getInstance(getProject()).getModifiableModel();
        moduleModel.newModule("independent/independent.iml", StdModuleTypes.JAVA.getId());
        moduleModel.commit();

        tdf.createFile("plugin.xml", "<document>\n" +
                                     "  <action class=\"com.Foo\" />\n" +
                                     "  <action class=\"com.Foo.Bar\" />\n" +
                                     "  <action class=\"com.Foo$Bar\" />\n" +
                                     "</document>");

        PsiTestUtil.addContentRoot(ModuleManager.getInstance(getProject()).findModuleByName("independent"), tdf.getFile(""));
      }
    }.execute();

    GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
    PsiClass foo = myJavaFacade.findClass("com.Foo", scope);
    PsiClass bar = myJavaFacade.findClass("com.Foo.Bar", scope);

    final int[] count = {0};
    Processor<UsageInfo> processor = new Processor<UsageInfo>() {
      @Override
      public boolean process(UsageInfo usageInfo) {
        int navigationOffset = usageInfo.getNavigationOffset();
        assertTrue(navigationOffset > 0);
        String textAfter = usageInfo.getFile().getText().substring(navigationOffset);
        assertTrue(textAfter, textAfter.startsWith("Foo") || textAfter.startsWith("Bar") ||
                              textAfter.startsWith("com.Foo.Bar") // sorry, can't get references with dollar-dot mismatch to work now
        );
        count[0]++;
        return true;
      }
    };
    JavaFindUsagesHandler handler = new JavaFindUsagesHandler(bar, JavaFindUsagesHandlerFactory.getInstance(getProject()));

    count[0] = 0;
    handler.processUsagesInText(foo, processor, scope);
    assertEquals(3, count[0]);

    count[0] = 0;
    handler.processUsagesInText(bar, processor, scope);
    assertEquals(2, count[0]);
  }
  finally {
    tdf.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:55,代码来源:FindUsagesTest.java

示例2: compare

import com.intellij.usageView.UsageInfo; //导入方法依赖的package包/类
@Override
public int compare(UsageInfo o1, UsageInfo o2) {
  return o1.getNavigationOffset() - o2.getNavigationOffset();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:UsageInfo2UsageAdapter.java


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