use of com.intellij.codeInsight.generation.ClassMember in project intellij-community by JetBrains.
the class GroovyGeneratePropertyMissingHandler method chooseOriginalMembers.
@Nullable
@Override
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) {
final PsiMethod[] missings = aClass.findMethodsByName("propertyMissing", true);
PsiMethod getter = null;
PsiMethod setter = null;
for (PsiMethod missing : missings) {
final PsiParameter[] parameters = missing.getParameterList().getParameters();
if (parameters.length == 1) {
if (isNameParam(parameters[0])) {
getter = missing;
}
} else if (parameters.length == 2) {
if (isNameParam(parameters[0])) {
setter = missing;
}
}
}
if (setter != null && getter != null) {
String text = GroovyCodeInsightBundle.message("generate.property.missing.already.defined.warning");
if (Messages.showYesNoDialog(project, text, GroovyCodeInsightBundle.message("generate.property.missing.already.defined.title"), Messages.getQuestionIcon()) == Messages.YES) {
final PsiMethod finalGetter = getter;
final PsiMethod finalSetter = setter;
if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
try {
finalSetter.delete();
finalGetter.delete();
return Boolean.TRUE;
} catch (IncorrectOperationException e) {
LOG.error(e);
return Boolean.FALSE;
}
}
}).booleanValue()) {
return null;
}
} else {
return null;
}
}
return new ClassMember[1];
}
use of com.intellij.codeInsight.generation.ClassMember in project intellij-community by JetBrains.
the class GenerateConstructorTest method doTest.
private void doTest(boolean preSelect) {
String name = getTestName(false);
myFixture.configureByFile("before" + name + ".java");
new GenerateConstructorHandler() {
@Override
protected ClassMember[] chooseMembers(ClassMember[] members, boolean allowEmpty, boolean copyJavadoc, Project project, Editor editor) {
if (preSelect) {
List<ClassMember> preselection = GenerateConstructorHandler.preselect(members);
return preselection.toArray(new ClassMember[preselection.size()]);
} else {
return members;
}
}
}.invoke(getProject(), getEditor(), getFile());
myFixture.checkResultByFile("after" + name + ".java");
}
use of com.intellij.codeInsight.generation.ClassMember in project intellij-community by JetBrains.
the class GroovyGenerateMethodMissingHandler method chooseOriginalMembers.
@Nullable
@Override
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) {
final PsiMethod[] missings = aClass.findMethodsByName("methodMissing", true);
PsiMethod method = null;
for (PsiMethod missing : missings) {
final PsiParameter[] parameters = missing.getParameterList().getParameters();
if (parameters.length == 2) {
if (isNameParam(parameters[0])) {
method = missing;
}
}
}
if (method != null) {
String text = GroovyCodeInsightBundle.message("generate.method.missing.already.defined.warning");
if (Messages.showYesNoDialog(project, text, GroovyCodeInsightBundle.message("generate.method.missing.already.defined.title"), Messages.getQuestionIcon()) == Messages.YES) {
final PsiMethod finalMethod = method;
if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
try {
finalMethod.delete();
return Boolean.TRUE;
} catch (IncorrectOperationException e) {
LOG.error(e);
return Boolean.FALSE;
}
}
}).booleanValue()) {
return null;
}
} else {
return null;
}
}
return new ClassMember[1];
}
use of com.intellij.codeInsight.generation.ClassMember in project intellij-community by JetBrains.
the class GenerateGetterSetterTest method doTest.
protected void doTest() throws Exception {
configureByFile("/generateGetterSetter/before" + getTestName(false) + ".java");
new GenerateGetterAndSetterHandler() {
@Nullable
@Override
protected ClassMember[] chooseMembers(ClassMember[] members, boolean allowEmptySelection, boolean copyJavadocCheckbox, Project project, @Nullable Editor editor) {
return members;
}
}.invoke(getProject(), getEditor(), getFile());
UIUtil.dispatchAllInvocationEvents();
checkResultByFile("/generateGetterSetter/after" + getTestName(false) + ".java");
}
use of com.intellij.codeInsight.generation.ClassMember in project intellij-plugins by JetBrains.
the class RubyMotionOverrideTest method doTest.
private void doTest(@NotNull final String name, @NotNull final String result) throws Exception {
final Symbol controller = SymbolUtil.findSymbol(getProject(), Type.CLASS, "TestController", null);
assertNotNull(controller);
final List<ClassMember> list = RubyOverrideHandler.createOverrideMembers(controller, myFixture.getFile());
final StringBuilder namesInClass = new StringBuilder();
for (ClassMember classMember : list) {
MemberChooserObjectBase methodMember = (MemberChooserObjectBase) classMember;
if (name.equals(methodMember.getText())) {
final PsiElement element = OverriddenMethodGenerator.generate(classMember, LanguageLevel.RUBY19);
assertNotNull(element);
namesInClass.append(element.getText()).append("\n");
}
}
assertEquals(result, namesInClass.toString().trim());
}
Aggregations