use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class MethodInheritanceUtils method calculateSiblingMethods.
public static Set<PsiMethod> calculateSiblingMethods(PsiMethod method) {
final Set<PsiMethod> siblingMethods = new HashSet<>();
final Stack<PsiMethod> pendingMethods = new Stack<>();
pendingMethods.add(method);
while (!pendingMethods.isEmpty()) {
final PsiMethod methodToAnalyze = pendingMethods.pop();
siblingMethods.add(methodToAnalyze);
final Iterable<PsiMethod> overridingMethods = OverridingMethodsSearch.search(methodToAnalyze, false);
for (PsiMethod overridingMethod : overridingMethods) {
if (!siblingMethods.contains(overridingMethod) && !pendingMethods.contains(overridingMethod)) {
pendingMethods.add(overridingMethod);
}
}
final PsiMethod[] superMethods = methodToAnalyze.findSuperMethods();
for (PsiMethod superMethod : superMethods) {
if (!siblingMethods.contains(superMethod) && !pendingMethods.contains(superMethod)) {
pendingMethods.add(superMethod);
}
}
}
return siblingMethods;
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class MethodInheritanceUtils method findAvailableSubClassesForMethod.
public static PsiClass[] findAvailableSubClassesForMethod(PsiMethod method) {
final Iterable<PsiMethod> query = SearchUtils.findOverridingMethods(method);
final List<PsiClass> sourceClasses = new ArrayList<>();
for (PsiMethod superMethod : query) {
final PsiClass containingClass = superMethod.getContainingClass();
if (!(containingClass instanceof PsiCompiledElement)) {
sourceClasses.add(containingClass);
}
}
return sourceClasses.toArray(new PsiClass[sourceClasses.size()]);
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class ReturnDocTagInfo method isValidInContext.
@Override
public boolean isValidInContext(PsiElement element) {
if (!(element instanceof PsiMethod))
return false;
PsiMethod method = (PsiMethod) element;
final PsiType type = method.getReturnType();
if (type == null)
return false;
return !PsiType.VOID.equals(type);
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class ExtractMethodObjectTest method doTest.
private void doTest(final boolean createInnerClass) throws Exception {
final String testName = getTestName(false);
configureByFile("/refactoring/extractMethodObject/" + testName + ".java");
PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
assertTrue(element instanceof PsiMethod);
final PsiMethod method = (PsiMethod) element;
final ExtractMethodObjectProcessor processor = new ExtractMethodObjectProcessor(getProject(), getEditor(), method.getBody().getStatements(), "InnerClass");
final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
processor.setCreateInnerClass(createInnerClass);
extractProcessor.setShowErrorDialogs(false);
extractProcessor.prepare();
extractProcessor.testPrepare();
ExtractMethodObjectHandler.run(getProject(), getEditor(), processor, extractProcessor);
checkResultByFile("/refactoring/extractMethodObject/" + testName + ".java" + ".after");
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class AbstractApplicationConfigurationProducer method isConfigurationFromContext.
@Override
public boolean isConfigurationFromContext(T appConfiguration, ConfigurationContext context) {
final PsiElement location = context.getPsiLocation();
final PsiClass aClass = ApplicationConfigurationType.getMainClass(location);
if (aClass != null && Comparing.equal(JavaExecutionUtil.getRuntimeQualifiedName(aClass), appConfiguration.MAIN_CLASS_NAME)) {
final PsiMethod method = PsiTreeUtil.getParentOfType(location, PsiMethod.class, false);
if (method != null && TestFrameworks.getInstance().isTestMethod(method)) {
return false;
}
final Module configurationModule = appConfiguration.getConfigurationModule().getModule();
if (Comparing.equal(context.getModule(), configurationModule))
return true;
ApplicationConfiguration template = (ApplicationConfiguration) context.getRunManager().getConfigurationTemplate(getConfigurationFactory()).getConfiguration();
final Module predefinedModule = template.getConfigurationModule().getModule();
if (Comparing.equal(predefinedModule, configurationModule)) {
return true;
}
}
return false;
}
Aggregations