mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Factory method for named constructor creation; unused class dropped
This commit is contained in:
@@ -108,7 +108,17 @@ public interface PsiElementFactory extends PsiJavaParserFacade, JVMElementFactor
|
||||
*
|
||||
* @return the created constructor instance.
|
||||
*/
|
||||
@NotNull PsiMethod createConstructor();
|
||||
@NotNull
|
||||
PsiMethod createConstructor();
|
||||
|
||||
/**
|
||||
* Creates an empty constructor with a given name.
|
||||
*
|
||||
* @param name the name of the constructor to create.
|
||||
* @return the created constructor instance.
|
||||
*/
|
||||
@NotNull
|
||||
PsiMethod createConstructor(@NotNull @NonNls String name);
|
||||
|
||||
/**
|
||||
* Creates an empty class initializer block.
|
||||
|
||||
@@ -218,7 +218,13 @@ public class PsiElementFactoryImpl extends PsiJavaParserFacadeImpl implements Ps
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiMethod createConstructor() {
|
||||
final PsiJavaFile aFile = createDummyJavaFile("class _Dummy_ { public _Dummy_() {} }");
|
||||
return createConstructor("_Dummy_");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiMethod createConstructor(@NotNull @NonNls final String name) {
|
||||
final PsiJavaFile aFile = createDummyJavaFile(join("class ", name, " { public ", name, "() {} }"));
|
||||
final PsiMethod method = aFile.getClasses()[0].getMethods()[0];
|
||||
return (PsiMethod)CodeStyleManager.getInstance(myManager.getProject()).reformat(method);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user