From a9b22f0d911f8a7a986ae92c9cb55a70cbd37c41 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 13 Jan 2012 20:33:54 +0100 Subject: [PATCH] no empty lines between doc comment and method after /** in groovy --- plugins/groovy/src/META-INF/plugin.xml | 1 + .../GroovyWhiteSpaceFormattingStrategy.java | 31 +++++++++++++++++++ .../testdata/groovy/enterAction/gdoc10.test | 1 - .../testdata/groovy/enterAction/gdoc11.test | 1 - .../testdata/groovy/enterAction/gdoc7.test | 1 - 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyWhiteSpaceFormattingStrategy.java diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index 46e08520d393..1ac8f56b3ff7 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -184,6 +184,7 @@ + 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 index 000000000000..c934be3b19cb --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyWhiteSpaceFormattingStrategy.java @@ -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; + } +} diff --git a/plugins/groovy/testdata/groovy/enterAction/gdoc10.test b/plugins/groovy/testdata/groovy/enterAction/gdoc10.test index 986cecf24998..cfb24f1af88c 100644 --- a/plugins/groovy/testdata/groovy/enterAction/gdoc10.test +++ b/plugins/groovy/testdata/groovy/enterAction/gdoc10.test @@ -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 diff --git a/plugins/groovy/testdata/groovy/enterAction/gdoc11.test b/plugins/groovy/testdata/groovy/enterAction/gdoc11.test index 62b69b69fc7d..018419abb4ce 100644 --- a/plugins/groovy/testdata/groovy/enterAction/gdoc11.test +++ b/plugins/groovy/testdata/groovy/enterAction/gdoc11.test @@ -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 diff --git a/plugins/groovy/testdata/groovy/enterAction/gdoc7.test b/plugins/groovy/testdata/groovy/enterAction/gdoc7.test index 706ea170ded5..2461959ba752 100644 --- a/plugins/groovy/testdata/groovy/enterAction/gdoc7.test +++ b/plugins/groovy/testdata/groovy/enterAction/gdoc7.test @@ -7,7 +7,6 @@ def foo() { * * @return */ - def foo() { 2 } \ No newline at end of file