diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.properties b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.properties index 5631fad02ee0..917b0955d957 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.properties +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.properties @@ -389,6 +389,7 @@ trait.method.cannot.be.protected=Trait methods are not allowed to be protected traits.are.not.supported.in.groovy.0=Traits are not supported in Groovy {0} non.static.classes.not.allowed=Non-static inner classes are not allowed in traits selfType.class.does.not.inherit=@SelfType: Class ''{0}'' does not inherit ''{1}'' +illegal.type.void=Illegal type: 'void' select.module.description=Which module to use classpath of? select.module.title=Select module... diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index a51485d76831..409fb33f5c93 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package org.jetbrains.plugins.groovy.annotator; @@ -955,6 +943,18 @@ public class GroovyAnnotator extends GroovyElementVisitor { } } + @Override + public void visitArrayTypeElement(@NotNull GrArrayTypeElement typeElement) { + GrTypeElement componentTypeElement = typeElement.getComponentTypeElement(); + PsiType componentType = componentTypeElement.getType(); + if (PsiType.VOID.equals(componentType)) { + myHolder.createErrorAnnotation(componentTypeElement, GroovyBundle.message("illegal.type.void")); + } + else { + super.visitArrayTypeElement(typeElement); + } + } + @Override public void visitModifierList(@NotNull GrModifierList modifierList) { final PsiElement parent = modifierList.getParent(); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy index 7075ce68ad14..043ae60e2ec6 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy @@ -1,17 +1,5 @@ /* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package org.jetbrains.plugins.groovy.lang.highlighting @@ -181,6 +169,13 @@ class A { void testBuiltInTypeInstantiation() { doTest() } + void 'test void array type'() { + testHighlighting '''\ +void[] foo() {} +void[] bar = foo() +''' + } + void testSOEInFieldDeclarations() { doTest() } void testWrongAnnotation() { doTest() }