This commit is contained in:
Maxim Medvedev
2011-04-18 15:31:30 +04:00
parent 60632b102f
commit 3df5de3a01
2 changed files with 15 additions and 16 deletions
@@ -98,13 +98,13 @@ public abstract class GroovyPsiElementFactory {
return createReferenceElementFromText(refName, null);
}
public abstract GrCodeReferenceElement createReferenceElementFromText(String refName, PsiElement context);
public abstract GrCodeReferenceElement createReferenceElementFromText(String refName, @Nullable PsiElement context);
public GrExpression createExpressionFromText(String exprText) {
return createExpressionFromText(exprText, null);
}
public abstract GrExpression createExpressionFromText(String exprText, PsiElement context);
public abstract GrExpression createExpressionFromText(String exprText, @Nullable PsiElement context);
public abstract GrVariableDeclaration createFieldDeclaration(String[] modifiers, String identifier, GrExpression initializer, PsiType type);
public abstract GrVariableDeclaration createFieldDeclarationFromText(String text);
@@ -126,13 +126,13 @@ public abstract class GroovyPsiElementFactory {
public abstract GrClosableBlock createClosureFromText(String s) throws IncorrectOperationException;
public GrParameter createParameter(String name, @Nullable String typeText, GroovyPsiElement context) throws IncorrectOperationException {
public GrParameter createParameter(String name, @Nullable String typeText, @Nullable GroovyPsiElement context) throws IncorrectOperationException {
return createParameter(name, typeText, null, context);
}
public abstract GrParameter createParameter(String name,
@Nullable String typeText,
String initializer,
@Nullable String initializer,
GroovyPsiElement context) throws IncorrectOperationException;
public abstract GrCodeReferenceElement createTypeOrPackageReference(String qName);
@@ -146,7 +146,7 @@ public abstract class GroovyPsiElementFactory {
return createTypeElement(typeText, null);
}
public abstract GrTypeElement createTypeElement(String typeText, PsiElement context);
public abstract GrTypeElement createTypeElement(String typeText, @Nullable PsiElement context);
public abstract GrParenthesizedExpression createParenthesizedExpr(GrExpression newExpr);
@@ -162,7 +162,7 @@ public abstract class GroovyPsiElementFactory {
public abstract PsiElement createDotToken(String newDot);
public abstract GrMethod createMethodFromText(String methodText, PsiElement context);
public abstract GrMethod createMethodFromText(String methodText, @Nullable PsiElement context);
public GrMethod createMethodFromText(String methodText) {
return createMethodFromText(methodText, null);
@@ -170,7 +170,7 @@ public abstract class GroovyPsiElementFactory {
public abstract GrAnnotation createAnnotationFromText(String annoText);
public abstract GroovyFile createGroovyFile(String text, boolean isPhisical, PsiElement context);
public abstract GroovyFile createGroovyFile(String text, boolean isPhysical, PsiElement context);
public abstract GrMethod createMethodFromText(String modifier, String name, String type, String[] paramTypes, PsiElement context);
@@ -178,7 +178,7 @@ public abstract class GroovyPsiElementFactory {
String[] paramTypes,
String[] paramNames,
String body,
PsiElement context);
@Nullable PsiElement context);
public GrMethod createConstructorFromText(@NotNull String constructorName, String[] paramTypes, String[] paramNames, String body) {
return createConstructorFromText(constructorName, paramTypes, paramNames, body, null);
@@ -147,7 +147,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
public GrExpression createExpressionFromText(String text, PsiElement context) {
GroovyFileImpl file = (GroovyFileImpl)createGroovyFile(text, false, context);
assert file.getTopStatements()[0] instanceof GrExpression;
return (GrExpression) ((GroovyFileBase) file).getTopStatements()[0];
return (GrExpression) file.getTopStatements()[0];
}
public GrVariableDeclaration createVariableDeclaration(@Nullable String[] modifiers,
@@ -182,6 +182,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
!GroovyConfigUtils.getInstance().isVersionAtLeast(initializer, GroovyConfigUtils.GROOVY1_8)) {
initializer = createMethodCallByAppCall((GrApplicationStatement)initializer);
}
assert initializer != null;
text.append(" = ").append(initializer.getText());
}
@@ -399,7 +400,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
return ((GrLabeledStatement)definition).getLabel();
}
public GrMethod createMethodFromText(@NotNull String methodText, PsiElement context) {
public GrMethod createMethodFromText(@NotNull String methodText, @Nullable PsiElement context) {
GroovyFileImpl file = createDummyFile(methodText);
if (context != null) {
file.setContext(context);
@@ -424,7 +425,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
return createGroovyFile(idText, false, null);
}
public GroovyFile createGroovyFile(String idText, boolean isPhysical, PsiElement context) {
public GroovyFile createGroovyFile(String idText, boolean isPhysical, @Nullable PsiElement context) {
GroovyFileImpl file = createDummyFile(idText, isPhysical);
file.setContext(context);
return file;
@@ -519,12 +520,12 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
}
private static String generateMethodText(String modifier,
private static String generateMethodText(@Nullable String modifier,
String name,
String type,
@Nullable String type,
String[] paramTypes,
String[] paramNames,
String body,
@Nullable String body,
boolean isConstructor) {
StringBuilder builder = new StringBuilder();
@@ -590,8 +591,6 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
}
public GrDocComment createDocCommentFromText(String text) {
StringBuilder builder = new StringBuilder();
builder.append(text);
return (GrDocComment)createGroovyFile(text).getFirstChild();
}