no empty lines between doc comment and method after /**<enter> in groovy
authorpeter <peter@jetbrains.com>
Fri, 13 Jan 2012 19:33:54 +0000 (20:33 +0100)
committerpeter <peter@jetbrains.com>
Fri, 13 Jan 2012 19:34:31 +0000 (20:34 +0100)
plugins/groovy/src/META-INF/plugin.xml
plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyWhiteSpaceFormattingStrategy.java [new file with mode: 0644]
plugins/groovy/testdata/groovy/enterAction/gdoc10.test
plugins/groovy/testdata/groovy/enterAction/gdoc11.test
plugins/groovy/testdata/groovy/enterAction/gdoc7.test

index 46e08520d393680c67417f1d6532545ed1b0a5d8..1ac8f56b3ff78151352e7a86e7f32ae7de01efde 100644 (file)
     <lang.commenter language="Groovy" implementationClass="org.jetbrains.plugins.groovy.highlighter.GroovyCommenter"/>
     <lang.foldingBuilder language="Groovy" implementationClass="org.jetbrains.plugins.groovy.lang.folding.GroovyFoldingBuilder"/>
     <lang.formatter language="Groovy" implementationClass="org.jetbrains.plugins.groovy.formatter.GroovyFormattingModelBuilder"/>
+    <lang.whiteSpaceFormattingStrategy language="Groovy" implementationClass="org.jetbrains.plugins.groovy.formatter.GroovyWhiteSpaceFormattingStrategy"/>
 
     <enterHandlerDelegate implementation="org.jetbrains.plugins.groovy.lang.editor.actions.GroovyEnterHandler"
                           order="before EnterBetweenBracesHandler"/>
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyWhiteSpaceFormattingStrategy.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyWhiteSpaceFormattingStrategy.java
new file mode 100644 (file)
index 0000000..c934be3
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.formatter;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.formatter.WhiteSpaceFormattingStrategyAdapter;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
+
+/**
+ * @author peter
+ */
+public class GroovyWhiteSpaceFormattingStrategy extends WhiteSpaceFormattingStrategyAdapter {
+  @Override
+  public boolean containsWhitespacesOnly(@NotNull ASTNode node) {
+    return node.getElementType() == GroovyTokenTypes.mNLS;
+  }
+}
index 986cecf249983733fa1b3b62afd727e56e759a1a..cfb24f1af88cb2ed17f2e2f9c0fdeee8b6633f96 100644 (file)
@@ -7,5 +7,4 @@ def foo(int x, int y){2}
  * @param y
  * @return
  */
-
 def foo(int x, int y){2}
\ No newline at end of file
index 62b69b69fc7d54de07a4cc2bdff2eae038a24272..018419abb4ced41cc979a3372ec1107f490b0559 100644 (file)
@@ -6,5 +6,4 @@ void foo(int x, int y){}
  * @param x
  * @param y
  */
-
 void foo(int x, int y){}
\ No newline at end of file
index 706ea170ded51d7130af180f9c16e9b99b25630c..2461959ba752d516891ad1ef16fe3c1398b3feb0 100644 (file)
@@ -7,7 +7,6 @@ def foo() {
  * <caret>
  * @return
  */
-
 def foo() {
   2
 }
\ No newline at end of file