mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-57432 report 'create new instance of built-in types'
This commit is contained in:
@@ -341,3 +341,4 @@ cyclic.inheritance.involving.0=Cyclic inheritance involving ''{0}''
|
||||
there.is.no.default.constructor.available.in.class.0=There is no default constructor available in class ''{0}''
|
||||
groovy.library.is.not.configured.for.module=Groovy SDK is not configured for module ''{0}''
|
||||
configure.groovy.library=Configure Groovy SDK...
|
||||
create.instance.of.built-in.type=Instantiation of built-in type
|
||||
|
||||
@@ -490,7 +490,16 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
|
||||
@Override
|
||||
public void visitNewExpression(GrNewExpression newExpression) {
|
||||
final GrTypeElement typeElement = newExpression.getTypeElement();
|
||||
|
||||
if (typeElement instanceof GrBuiltInTypeElement) {
|
||||
if (newExpression.getArrayCount() == 0) {
|
||||
myHolder.createErrorAnnotation(typeElement, GroovyBundle.message("create.instance.of.built-in.type"));
|
||||
}
|
||||
}
|
||||
|
||||
if (newExpression.getArrayCount() > 0) return;
|
||||
|
||||
GrCodeReferenceElement refElement = newExpression.getReferenceElement();
|
||||
if (refElement == null) return;
|
||||
final PsiElement element = refElement.resolve();
|
||||
|
||||
+4
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
@@ -31,6 +32,9 @@ public interface GrNewExpression extends GrCallExpression, GrConstructorCall {
|
||||
@Nullable
|
||||
GrCodeReferenceElement getReferenceElement();
|
||||
|
||||
@Nullable
|
||||
GrTypeElement getTypeElement();
|
||||
|
||||
int getArrayCount();
|
||||
|
||||
@Nullable
|
||||
|
||||
+6
@@ -34,6 +34,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExp
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrBuiltInTypeElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
@@ -203,4 +204,9 @@ public class GrNewExpressionImpl extends GrCallExpressionImpl implements GrNewEx
|
||||
|
||||
return result.toArray(new GroovyResolveResult[result.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrTypeElement getTypeElement() {
|
||||
return findChildByClass(GrTypeElement.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,4 +281,6 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testNumberDuplicatesInMaps() throws Exception {doTest();}
|
||||
|
||||
public void testMapNotAcceptedAsStringParameter() {doTest();}
|
||||
|
||||
public void testBuiltInTypeInstantiation() {doTest();}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
def x = new <error descr="Instantiation of built-in type">int</error>()
|
||||
Reference in New Issue
Block a user