本文整理汇总了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)));
}
示例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;
}
});
}
示例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)));
}
示例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)));
}
示例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();
}