use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class JavaSuperMethodTest method testDoNotGoToSiblingInheritanceIfInLibrary.
public void testDoNotGoToSiblingInheritanceIfInLibrary() throws Throwable {
configureByFile(getBasePath() + "OverridingLibrary.java");
PsiClass aThread = getJavaFacade().findClass("java.lang.Thread");
PsiMethod startMethod = aThread.findMethodsByName("start", false)[0];
PsiMethod sibling = FindSuperElementsHelper.getSiblingInheritedViaSubClass(startMethod);
assertNotNull(sibling);
Collection<PsiMethod> superMethods = SuperMethodWarningUtil.getSuperMethods(startMethod, aThread, Collections.emptyList());
assertEmpty(superMethods);
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class ContextConfigurationTest method testMethodInAbstractJUnit3TestCase.
public void testMethodInAbstractJUnit3TestCase() throws Exception {
String packageName = "abstractTests";
String shortName = "AbstractTestImpl1";
String qualifiedName = StringUtil.getQualifiedName(packageName, shortName);
PsiClass psiClass = findClass(getModule1(), qualifiedName);
PsiMethod testMethod = psiClass.findMethodsByName(METHOD_NAME, true)[0];
MapDataContext dataContext = new MapDataContext();
dataContext.put(CommonDataKeys.PROJECT, myProject);
if (LangDataKeys.MODULE.getData(dataContext) == null) {
dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(testMethod));
}
dataContext.put(Location.DATA_KEY, MethodLocation.elementInClass(testMethod, psiClass));
ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
RunnerAndConfigurationSettings settings = context.getConfiguration();
JUnitConfiguration configuration = (JUnitConfiguration) settings.getConfiguration();
checkClassName(qualifiedName, configuration);
checkMethodName(METHOD_NAME, configuration);
checkPackage(packageName, configuration);
checkGeneretedName(configuration, shortName + "." + METHOD_NAME);
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class ContextConfigurationTest method testJUnitMethodTest.
public void testJUnitMethodTest() {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiMethod testMethod = psiClass.findMethodsByName(METHOD_NAME, false)[0];
JUnitConfiguration configuration = createConfiguration(testMethod);
checkTestObject(JUnitConfiguration.TEST_METHOD, configuration);
checkClassName(CLASS_NAME, configuration);
checkMethodName(METHOD_NAME, configuration);
checkPackage(PACKAGE_NAME, configuration);
checkGeneretedName(configuration, SHORT_CLASS_NAME + "." + METHOD_NAME);
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class ContextConfigurationTest method testApplication.
public void testApplication() {
PsiClass psiClass = findClass(getModule1(), CLASS_NAME);
PsiMethod psiMethod = psiClass.findMethodsByName("main", false)[0];
ApplicationConfiguration configuration = createConfiguration(psiMethod);
assertEquals(CLASS_NAME, configuration.MAIN_CLASS_NAME);
assertEquals(configuration.suggestedName(), configuration.getName());
assertEquals(SHORT_CLASS_NAME, configuration.getName());
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class GotoImplementationHandlerTest method testMethodReferences.
public void testMethodReferences() {
PsiFile file = myFixture.addFileToProject("Foo.java", "interface I {void f();}\n" + "class A implements I { public void f(){}}\n" + "class B implements I { public void f(){}}\n" + "class C {\n" + " void foo(java.util.List<I> l) {l.stream().forEach(I::<caret>f);}" + "}");
myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
final PsiElement[] impls = getTargets(file);
assertEquals(2, impls.length);
// target are non-deterministic now
Arrays.sort(impls, (o1, o2) -> {
String name1 = ((PsiMethod) o1).getContainingClass().getName();
String name2 = ((PsiMethod) o2).getContainingClass().getName();
return StringUtil.compare(name1, name2, false);
});
final PsiElement method = impls[0];
assertTrue(method instanceof PsiMethod);
final PsiClass aClass = ((PsiMethod) method).getContainingClass();
assertNotNull(aClass);
assertEquals("A", aClass.getName());
}
Aggregations