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


Java MethodImplementationsSearch类代码示例

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


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

示例1: test

import com.intellij.codeInsight.navigation.MethodImplementationsSearch; //导入依赖的package包/类
public void test() throws Exception {
  ModuleManager moduleManager = ModuleManager.getInstance(getProject());
  Module[] modules = moduleManager.getModules();
  assertEquals(3, modules.length);

  Module module1 = moduleManager.findModuleByName("test1");
  Module module2 = moduleManager.findModuleByName("test2");
  Module module3 = moduleManager.findModuleByName("test3");
  final GlobalSearchScope moduleScope = GlobalSearchScope.moduleScope(module1);
  PsiClass test1 = myJavaFacade.findClass("com.test.TestI", moduleScope);
  PsiClass test2 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module2));
  PsiClass test3 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module3));
  HashSet<PsiElement> expectedImpls1 = new HashSet<PsiElement>(Arrays.asList(
    myJavaFacade.findClass("com.test.TestIImpl1", moduleScope),
    myJavaFacade.findClass("com.test.TestIImpl2", moduleScope)
  ));
  assertEquals(expectedImpls1, new HashSet<PsiElement>(getClassImplementations(test1)));

  PsiMethod psiMethod = test1.findMethodsByName("test", false)[0];
  Set<PsiElement> expectedMethodImpl1 = new HashSet<PsiElement>(Arrays.asList(
    myJavaFacade.findClass("com.test.TestIImpl1", moduleScope).findMethodsByName("test",false)[0],
    myJavaFacade.findClass("com.test.TestIImpl2", moduleScope).findMethodsByName("test",false)[0]
  ));
  CommonProcessors.CollectProcessor<PsiElement> processor = new CommonProcessors.CollectProcessor<PsiElement>();
  MethodImplementationsSearch.processImplementations(psiMethod, processor, moduleScope);
  assertEquals(expectedMethodImpl1, new HashSet<PsiElement>(processor.getResults()));

  HashSet<PsiElement> expectedImpls2 = new HashSet<PsiElement>(Arrays.asList(
    myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module2)),
    myJavaFacade.findClass("com.test.TestIImpl3", GlobalSearchScope.moduleScope(module2))
  ));
  assertEquals(expectedImpls2, new HashSet<PsiElement>(getClassImplementations(test2)));

  HashSet<PsiElement> expectedImpls3 = new HashSet<PsiElement>(Arrays.asList(
    myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module3))
  ));
  assertEquals(expectedImpls3, new HashSet<PsiElement>(getClassImplementations(test3)));

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:GotoImplementationTest.java

示例2: execute

import com.intellij.codeInsight.navigation.MethodImplementationsSearch; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final DefinitionsScopedSearch.SearchParameters queryParameters, @NotNull final Processor<PsiElement> consumer) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      final PsiElement source = queryParameters.getElement();
      if (!source.isValid()) return true;

      if (source instanceof GrAccessorMethod) {
        GrField property = ((GrAccessorMethod)source).getProperty();
        return consumer.process(property);
      }
      else {
        final SearchScope searchScope = queryParameters.getScope();
        if (source instanceof GrMethod) {
          GrReflectedMethod[] reflectedMethods = ((GrMethod)source).getReflectedMethods();
          for (GrReflectedMethod reflectedMethod : reflectedMethods) {
            if (!MethodImplementationsSearch.processImplementations(reflectedMethod, consumer, searchScope)) return false;
          }
        }

        else if (source instanceof GrField) {
          for (GrAccessorMethod method : GroovyPropertyUtils.getFieldAccessors((GrField)source)) {
            if (!MethodImplementationsSearch.processImplementations(method, consumer, searchScope)) return false;
          }
        }
      }
      return true;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:GroovyImplementationSearch.java

示例3: test

import com.intellij.codeInsight.navigation.MethodImplementationsSearch; //导入依赖的package包/类
public void test() throws Exception {

    ModuleManager moduleManager = ModuleManager.getInstance(getProject());
    Module[] modules = moduleManager.getModules();
    assertEquals(3, modules.length);

    Module module1 = moduleManager.findModuleByName("test1");
    Module module2 = moduleManager.findModuleByName("test2");
    Module module3 = moduleManager.findModuleByName("test3");
    PsiClass test1 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module1));
    PsiClass test2 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module2));
    PsiClass test3 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module3));
    HashSet<PsiClass> expectedImpls1 = new HashSet<PsiClass>(Arrays.asList(
      myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module1)),
      myJavaFacade.findClass("com.test.TestIImpl2", GlobalSearchScope.moduleScope(module1))
    ));
    assertEquals(expectedImpls1, new HashSet<PsiClass>(getClassImplementations(test1)));

    PsiMethod psiMethod = test1.findMethodsByName("test", false)[0];
    Set<PsiMethod> expectedMethodImpl1 = new HashSet<PsiMethod>(Arrays.asList(
      myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module1)).findMethodsByName("test",false)[0],
      myJavaFacade.findClass("com.test.TestIImpl2", GlobalSearchScope.moduleScope(module1)).findMethodsByName("test",false)[0]
    ));
    assertEquals(expectedMethodImpl1, new HashSet<PsiMethod>(Arrays.asList(MethodImplementationsSearch.getMethodImplementations(psiMethod))));

    HashSet<PsiClass> expectedImpls2 = new HashSet<PsiClass>(Arrays.asList(
      myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module2)),
      myJavaFacade.findClass("com.test.TestIImpl3", GlobalSearchScope.moduleScope(module2))
    ));
    assertEquals(expectedImpls2, new HashSet<PsiClass>(getClassImplementations(test2)));

    HashSet<PsiClass> expectedImpls3 = new HashSet<PsiClass>(Arrays.asList(
      myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module3))
    ));
    assertEquals(expectedImpls3, new HashSet<PsiClass>(getClassImplementations(test3)));

  }
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:GotoImplementationTest.java

示例4: test

import com.intellij.codeInsight.navigation.MethodImplementationsSearch; //导入依赖的package包/类
public void test() throws Exception
{

	ModuleManager moduleManager = ModuleManager.getInstance(getProject());
	Module[] modules = moduleManager.getModules();
	assertEquals(3, modules.length);

	Module module1 = moduleManager.findModuleByName("test1");
	Module module2 = moduleManager.findModuleByName("test2");
	Module module3 = moduleManager.findModuleByName("test3");
	PsiClass test1 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module1));
	PsiClass test2 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module2));
	PsiClass test3 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module3));
	HashSet<PsiClass> expectedImpls1 = new HashSet<PsiClass>(Arrays.asList(myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module1)), myJavaFacade.findClass("com" +
			".test" + ".TestIImpl2", GlobalSearchScope.moduleScope(module1))));
	assertEquals(expectedImpls1, new HashSet<PsiClass>(getClassImplementations(test1)));

	PsiMethod psiMethod = test1.findMethodsByName("test", false)[0];
	Set<PsiMethod> expectedMethodImpl1 = new HashSet<PsiMethod>(Arrays.asList(myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module1)).findMethodsByName("test",
			false)[0], myJavaFacade.findClass("com.test.TestIImpl2", GlobalSearchScope.moduleScope(module1)).findMethodsByName("test", false)[0]));
	assertEquals(expectedMethodImpl1, new HashSet<PsiMethod>(Arrays.asList(MethodImplementationsSearch.getMethodImplementations(psiMethod, psiMethod.getUseScope()))));

	HashSet<PsiClass> expectedImpls2 = new HashSet<PsiClass>(Arrays.asList(myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module2)), myJavaFacade.findClass("com" +
			".test" + ".TestIImpl3", GlobalSearchScope.moduleScope(module2))));
	assertEquals(expectedImpls2, new HashSet<PsiClass>(getClassImplementations(test2)));

	HashSet<PsiClass> expectedImpls3 = new HashSet<PsiClass>(Arrays.asList(myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module3))));
	assertEquals(expectedImpls3, new HashSet<PsiClass>(getClassImplementations(test3)));

}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:GotoImplementationTest.java

示例5: getMethodImplementations

import com.intellij.codeInsight.navigation.MethodImplementationsSearch; //导入依赖的package包/类
private static Collection<PsiElement> getMethodImplementations(final PsiMethod psiMethod) {
  CommonProcessors.CollectProcessor<PsiElement> processor = new CommonProcessors.CollectProcessor<PsiElement>();
  MethodImplementationsSearch.processImplementations( psiMethod, processor, psiMethod.getUseScope());

  return processor.getResults();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:ImplementationsViewTest.java


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