use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class MakeMethodStaticTest method perform.
private static void perform(boolean addClassParameter, boolean delegate) {
PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
assertTrue(element instanceof PsiMethod);
PsiMethod method = (PsiMethod) element;
new MakeMethodStaticProcessor(getProject(), method, new Settings(true, addClassParameter ? "anObject" : null, null, delegate)).run();
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class MakeMethodStaticTest method performWithFields.
private static void performWithFields(boolean delegate) {
PsiElement element = TargetElementUtil.findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
assertTrue(element instanceof PsiMethod);
PsiMethod method = (PsiMethod) element;
final ArrayList<VariableData> parametersForFields = new ArrayList<>();
final boolean addClassParameter = MakeStaticUtil.buildVariableData(method, parametersForFields);
new MakeMethodStaticProcessor(getProject(), method, new Settings(true, addClassParameter ? "anObject" : null, parametersForFields.toArray(new VariableData[parametersForFields.size()]), delegate)).run();
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class SimpleAccessorReferenceSearcher method processQuery.
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<PsiReference> consumer) {
PsiElement refElement = queryParameters.getElementToSearch();
if (!(refElement instanceof PsiMethod))
return;
addPropertyAccessUsages((PsiMethod) refElement, queryParameters.getEffectiveSearchScope(), queryParameters.getOptimizer());
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class TestDataGuessByExistingFilesUtil method guessTestDataName.
static String guessTestDataName(PsiMethod method) {
String testName = getTestName(method);
if (testName == null)
return null;
PsiClass psiClass = method.getContainingClass();
if (psiClass == null)
return null;
int count = 5;
PsiMethod prev = PsiTreeUtil.getPrevSiblingOfType(method, PsiMethod.class);
while (prev != null && count-- > 0) {
String s = getFilePath(prev, testName);
if (s != null)
return s;
prev = PsiTreeUtil.getPrevSiblingOfType(prev, PsiMethod.class);
}
count = 5;
PsiMethod next = PsiTreeUtil.getNextSiblingOfType(method, PsiMethod.class);
while (next != null && count-- > 0) {
String s = getFilePath(next, testName);
if (s != null)
return s;
next = PsiTreeUtil.getNextSiblingOfType(next, PsiMethod.class);
}
return null;
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class TestDataReferenceCollectorTest method doTest.
private List<String> doTest() {
myFixture.configureByFile("referenceCollector/" + getTestName(false) + ".java");
final PsiClass[] classes = ((PsiJavaFile) myFixture.getFile()).getClasses();
for (PsiClass aClass : classes) {
if (aClass.getName().equals("ATest")) {
final PsiMethod theMethod = aClass.getMethods()[0];
return new TestDataReferenceCollector("", theMethod.getName().substring(4)).collectTestDataReferences(theMethod);
}
}
throw new RuntimeException("Couldn't find class ATest in test data file");
}
Aggregations