create constructor matching super: insert braces when no present (IDEA-77194)

This commit is contained in:
anna
2012-01-13 21:33:58 +01:00
parent 4fe09fbead
commit f63576f878
3 changed files with 20 additions and 0 deletions

View File

@@ -112,6 +112,10 @@ public class CreateConstructorMatchingSuperFix extends BaseIntentionAction {
@Override
public void run() {
try {
if (targetClass.getLBrace() == null) {
PsiClass psiClass = JavaPsiFacade.getInstance(targetClass.getProject()).getElementFactory().createClass("X");
targetClass.addRangeAfter(psiClass.getLBrace(), psiClass.getRBrace(), targetClass.getLastChild());
}
PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
CodeStyleManager reformatter = CodeStyleManager.getInstance(project);
PsiMethod derived = null;

View File

@@ -0,0 +1,10 @@
// "Create constructor matching super" "true"
public class Test<T> {
Test (T t) {}
}
class Derived extends Test<String> {
Derived(String s) {
super(s);
}
}

View File

@@ -0,0 +1,6 @@
// "Create constructor matching super" "true"
public class Test<T> {
Test (T t) {}
}
class <caret>Derived extends Test<String>