groovy 1.8 and older allow private and protected top level classes

This commit is contained in:
Max Medvedev
2012-10-11 19:06:54 +03:00
parent 4fcb21bd70
commit 79354743ae
3 changed files with 7 additions and 5 deletions
@@ -1584,7 +1584,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
final PsiElement[] modifiers = list.getModifiers();
Set<String> set = new THashSet<String>(modifiers.length);
for (PsiElement modifier : modifiers) {
String name = modifier.getText();
@GrModifier.GrModifierConstant String name = modifier.getText();
if (set.contains(name)) {
final Annotation annotation = holder.createErrorAnnotation(list, GroovyBundle.message("duplicate.modifier", name));
annotation.registerFix(new GrModifierFix(member, list, name, false, false));
@@ -1620,7 +1620,9 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
holder.createErrorAnnotation(publicModifier, GroovyBundle.message("public.modifier.is.not.allowed.in.interfaces"))
.registerFix(new GrModifierFix(member, modifierList, PUBLIC, false, false));
}
else if (member instanceof PsiClass && member.getContainingClass() == null) {
else if (member instanceof PsiClass &&
member.getContainingClass() == null &&
GroovyConfigUtils.getInstance().isVersionAtLeast(member, GroovyConfigUtils.GROOVY2_0)) {
checkModifierIsNotAllowed(modifierList, PRIVATE, GroovyBundle.message("top.level.class.maynot.have.private.modifier"), holder);
checkModifierIsNotAllowed(modifierList, PROTECTED, GroovyBundle.message("top.level.class.maynot.have.protected.modifier"), holder);
}
@@ -105,7 +105,7 @@ public class GroovyCompiler extends GroovyCompilerBase {
}
if (!LibrariesUtil.hasGroovySdk(module)) {
if (!GroovyConfigUtils.getInstance().tryToSetUpGroovyFacetOntheFly(module)) {
if (!GroovyConfigUtils.getInstance().tryToSetUpGroovyFacetOnTheFly(module)) {
Messages.showErrorDialog(myProject, GroovyBundle.message("cannot.compile.groovy.files.no.facet", module.getName()),
GroovyBundle.message("cannot.compile"));
ModulesConfigurator.showDialog(module.getProject(), module.getName(), ClasspathEditor.NAME);
@@ -53,7 +53,7 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils {
public static final String NO_VERSION = "<no version>";
public static final String GROOVY1_7 = "1.7";
public static final String GROOVY1_8 = "1.8";
public static final String GROOVY1_9 = "1.9";
public static final String GROOVY2_0 = "2.0";
private GroovyConfigUtils() {
}
@@ -140,7 +140,7 @@ public abstract class GroovyConfigUtils extends AbstractConfigUtils {
return false;
}
public boolean tryToSetUpGroovyFacetOntheFly(final Module module) {
public boolean tryToSetUpGroovyFacetOnTheFly(final Module module) {
final Project project = module.getProject();
final Library[] libraries = getAllSDKLibraries(project);
if (libraries.length > 0) {