Fix: IDEA-64771 (Grails domain classes should have intention "make nullable")

This commit is contained in:
Sergey Evdokimov
2011-02-01 19:48:05 +03:00
parent e8d32df941
commit 7836775f96
3 changed files with 25 additions and 0 deletions
@@ -40,6 +40,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplic
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParenthesizedExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
@@ -196,4 +197,6 @@ public abstract class GroovyPsiElementFactory {
public abstract GrExtendsClause createExtendsClause();
public abstract GrImplementsClause createImplementsClause();
public abstract GrLiteral createLiteralFromValue(@Nullable Object value);
}
@@ -44,6 +44,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArg
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.*;
@@ -654,4 +655,20 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
return clause;
}
@Override
public GrLiteral createLiteralFromValue(@Nullable Object value) {
if (value instanceof String) {
return (GrLiteral)createStringLiteral((String)value);
}
if (value == null) {
return (GrLiteral)createExpressionFromText("null");
}
if (value instanceof Boolean) {
return (GrLiteral)createExpressionFromText(value.toString());
}
throw new IncorrectOperationException("Can not create literal from type: " + value.getClass().getName());
}
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.impl.light.LightElement;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.tree.IElementType;
@@ -1057,4 +1058,8 @@ public class PsiUtil {
owner.getModifierList().setModifierProperty(modifier, true);
}
}
public static boolean isLeafElementOfType(@Nullable PsiElement element, IElementType type) {
return element instanceof LeafElement && ((LeafElement)element).getElementType() == type;
}
}