當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。