diff --git a/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPrivateIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPrivateIntention/after.groovy.template
new file mode 100644
index 000000000000..33342d659cf8
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPrivateIntention/after.groovy.template
@@ -0,0 +1,3 @@
+class Foo {
+ private def foo() {}
+}
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPrivateIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPrivateIntention/before.groovy.template
new file mode 100644
index 000000000000..2c2182265497
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPrivateIntention/before.groovy.template
@@ -0,0 +1,3 @@
+class Foo {
+ protected def foo() {}
+}
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPrivateIntention/description.html b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPrivateIntention/description.html
new file mode 100644
index 000000000000..284047d582cb
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPrivateIntention/description.html
@@ -0,0 +1,5 @@
+
+
+Makes selected element private.
+
+
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrMakeMemberProtectedIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberProtectedIntention/after.groovy.template
new file mode 100644
index 000000000000..2c2182265497
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberProtectedIntention/after.groovy.template
@@ -0,0 +1,3 @@
+class Foo {
+ protected def foo() {}
+}
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrMakeMemberProtectedIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberProtectedIntention/before.groovy.template
new file mode 100644
index 000000000000..33342d659cf8
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberProtectedIntention/before.groovy.template
@@ -0,0 +1,3 @@
+class Foo {
+ private def foo() {}
+}
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrMakeMemberProtectedIntention/description.html b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberProtectedIntention/description.html
new file mode 100644
index 000000000000..248c593647f9
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberProtectedIntention/description.html
@@ -0,0 +1,5 @@
+
+
+Makes selected element protected.
+
+
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPublicIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPublicIntention/after.groovy.template
new file mode 100644
index 000000000000..8b99ac69bb72
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPublicIntention/after.groovy.template
@@ -0,0 +1,3 @@
+class Foo {
+ public def foo() {}
+}
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPublicIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPublicIntention/before.groovy.template
new file mode 100644
index 000000000000..2c2182265497
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPublicIntention/before.groovy.template
@@ -0,0 +1,3 @@
+class Foo {
+ protected def foo() {}
+}
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPublicIntention/description.html b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPublicIntention/description.html
new file mode 100644
index 000000000000..770359cf32c4
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrMakeMemberPublicIntention/description.html
@@ -0,0 +1,5 @@
+
+
+Makes selected element public.
+
+
\ No newline at end of file
diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml
index 6a32ea528219..eaf8bf564677 100644
--- a/plugins/groovy/src/META-INF/plugin.xml
+++ b/plugins/groovy/src/META-INF/plugin.xml
@@ -1246,6 +1246,21 @@
intention.category.groovy/intention.category.groovy.declaration
org.jetbrains.plugins.groovy.intentions.declaration.GrSetStrongTypeIntention
+
+ org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle
+ intention.category.groovy/intention.category.groovy.declaration
+ org.jetbrains.plugins.groovy.intentions.declaration.GrMakeMemberPublicIntention
+
+
+ org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle
+ intention.category.groovy/intention.category.groovy.declaration
+ org.jetbrains.plugins.groovy.intentions.declaration.GrMakeMemberProtectedIntention
+
+
+ org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle
+ intention.category.groovy/intention.category.groovy.declaration
+ org.jetbrains.plugins.groovy.intentions.declaration.GrMakeMemberPrivateIntention
+
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties
index 4ab2fb6f8b7a..f00af47662a9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties
@@ -329,3 +329,5 @@ abstract.method.cannot.be.final=Abstract method cannot be final
abstract.methods.must.not.have.body=Abstract methods must not have body
method.has.incorrect.modifier.volatile=Method has incorrect modifier 'volatile'
native.methods.cannot.have.body=Native methods cannot have body
+top.level.class.maynot.have.private.modifier=Top level class may not have 'private' modifier
+top.level.class.maynot.have.protected.modifier=Top level class may not have 'protected' modifier
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties
index 28bf6b50dead..aed4b2d2f5a2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties
@@ -183,4 +183,10 @@ remove.unnecessary.return.intention.family.name=Remove unnecessary 'return' keyw
gr.alias.import.intention.name=Alias import
gr.alias.import.intention.family.name=Alias import statically imported member
gr.copy.string.concatenation.content.intention.name=Copy string concatenation text to clipboard
-gr.copy.string.concatenation.content.intention.family.name=Copy string concatenation text to clipboard
\ No newline at end of file
+gr.copy.string.concatenation.content.intention.family.name=Copy string concatenation text to clipboard
+gr.make.member.private.intention.name=Make 'private'
+gr.make.member.private.intention.family.name=Make 'private'
+gr.make.member.public.intention.name=Make 'public'
+gr.make.member.public.intention.family.name=Make 'public'
+gr.make.member.protected.intention.name=Make 'protected'
+gr.make.member.protected.intention.family.name=Make 'protected'
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrChangeMemberVisibilityModifierBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrChangeMemberVisibilityModifierBase.java
new file mode 100644
index 000000000000..3599da7637ba
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrChangeMemberVisibilityModifierBase.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+package org.jetbrains.plugins.groovy.intentions.declaration;
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.intentions.base.Intention;
+import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
+import org.jetbrains.plugins.groovy.lang.psi.GrNamedElement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember;
+
+/**
+ * @author Max Medvedev
+ */
+public abstract class GrChangeMemberVisibilityModifierBase extends Intention {
+ private final String myModifier;
+
+ public GrChangeMemberVisibilityModifierBase(String modifier) {
+ myModifier = modifier;
+ }
+
+ @Override
+ protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
+ final PsiElement parent = element.getParent();
+ if (!(parent instanceof GrMember)) return;
+
+ ((GrMember)parent).getModifierList().setModifierProperty(myModifier, true);
+ }
+
+ @NotNull
+ @Override
+ protected PsiElementPredicate getElementPredicate() {
+ return new PsiElementPredicate() {
+ @Override
+ public boolean satisfiedBy(PsiElement element) {
+ final PsiElement parent = element.getParent();
+ return parent instanceof GrMember &&
+ parent instanceof GrNamedElement &&
+ (((GrNamedElement)parent).getNameIdentifierGroovy() == element || ((GrNamedElement)parent).getModifierList() == element) &&
+ !((GrMember)parent).getModifierList().hasExplicitModifier(myModifier);
+ }
+ };
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrMakeMemberPrivateIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrMakeMemberPrivateIntention.java
new file mode 100644
index 000000000000..d454dd173c06
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrMakeMemberPrivateIntention.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+package org.jetbrains.plugins.groovy.intentions.declaration;
+
+import com.intellij.psi.PsiModifier;
+
+/**
+ * @author Max Medvedev
+ */
+public class GrMakeMemberPrivateIntention extends GrChangeMemberVisibilityModifierBase {
+ public GrMakeMemberPrivateIntention() {
+ super(PsiModifier.PRIVATE);
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrMakeMemberProtectedIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrMakeMemberProtectedIntention.java
new file mode 100644
index 000000000000..28bba1af4a0a
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrMakeMemberProtectedIntention.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+package org.jetbrains.plugins.groovy.intentions.declaration;
+
+import com.intellij.psi.PsiModifier;
+
+/**
+ * @author Max Medvedev
+ */
+public class GrMakeMemberProtectedIntention extends GrChangeMemberVisibilityModifierBase {
+ public GrMakeMemberProtectedIntention() {
+ super(PsiModifier.PROTECTED);
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrMakeMemberPublicIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrMakeMemberPublicIntention.java
new file mode 100644
index 000000000000..812043e3ce84
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrMakeMemberPublicIntention.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2012 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.
+ */
+package org.jetbrains.plugins.groovy.intentions.declaration;
+
+import com.intellij.psi.PsiModifier;
+
+/**
+ * @author Max Medvedev
+ */
+public class GrMakeMemberPublicIntention extends GrChangeMemberVisibilityModifierBase {
+ public GrMakeMemberPublicIntention() {
+ super(PsiModifier.PUBLIC);
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java
index 18d447e1bb03..4096e422f1e0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java
@@ -45,8 +45,6 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.GrStubElementBase;
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrModifierListStub;
import org.jetbrains.plugins.groovy.lang.resolve.noncode.ConstructorAnnotationsProcessor;
-import static org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier.*;
-
/**
* @autor: Dmitry.Krasilschikov
* @date: 18.03.2007
@@ -172,12 +170,6 @@ public class GrModifierListImpl extends GrStubElementBase im
}
}
- //top level classes cannot have private and protected modifiers
- if (owner instanceof GrTypeDefinition && ((GrTypeDefinition)owner).getContainingClass() == null) {
- if (modifier.equals(PROTECTED) || modifier.equals(PRIVATE)) return false;
- if (modifier.equals(PACKAGE_LOCAL)) return modifierList.hasExplicitModifier(PRIVATE) || modifierList.hasExplicitModifier(PROTECTED);
- }
-
if (modifierList.hasExplicitModifier(modifier)) {
return true;
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy
index b8cc47606c8e..ccb85c353ea6 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy
@@ -600,13 +600,14 @@ class A {
void testPrivateTopLevelClassInJava() {
myFixture.addFileToProject('pack/Foo.groovy', 'package pack; private class Foo{}')
myFixture.configureByText('Abc.java', '''\
-import pack.Foo;
+import pack.Foo;
class Abc {
void foo() {
- System.out.print(new Foo());
+ System.out.print(new Foo());
}
-}''')
+}
+''')
myFixture.testHighlighting(false, false, false)
}