diff --git a/java/java-impl/src/com/intellij/psi/formatter/common/JavaBlockUtil.java b/java/java-impl/src/com/intellij/psi/formatter/common/JavaBlockUtil.java deleted file mode 100644 index 3e0f26b6f6a2..000000000000 --- a/java/java-impl/src/com/intellij/psi/formatter/common/JavaBlockUtil.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2000-2009 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. - */ - -/* - * @author max - */ -package com.intellij.psi.formatter.common; - -import com.intellij.lang.ASTNode; -import com.intellij.lang.LanguageParserDefinitions; -import com.intellij.lang.ParserDefinition; -import com.intellij.psi.PsiComment; -import com.intellij.psi.PsiElement; -import com.intellij.psi.TokenType; -import com.intellij.psi.impl.source.SourceTreeToPsiMap; -import com.intellij.psi.jsp.JspElementType; -import com.intellij.psi.templateLanguages.OuterLanguageElement; -import com.intellij.psi.tree.TokenSet; -import com.intellij.psi.xml.XmlElementType; - -public class JavaBlockUtil { - - private JavaBlockUtil() { - } - - public static boolean mayShiftIndentInside(final ASTNode leaf) { - return (isComment(leaf) && !checkJspTexts(leaf)) - || leaf.getElementType() == TokenType.WHITE_SPACE - || leaf.getElementType() == XmlElementType.XML_DATA_CHARACTERS - || leaf.getElementType() == JspElementType.JAVA_CODE - || leaf.getElementType() == JspElementType.JSP_SCRIPTLET - || leaf.getElementType() == XmlElementType.XML_ATTRIBUTE_VALUE_TOKEN; - } - - private static boolean checkJspTexts(final ASTNode leaf) { - ASTNode child = leaf.getFirstChildNode(); - while(child != null){ - if(child instanceof OuterLanguageElement) return true; - child = child.getTreeNext(); - } - return false; - } - - private static boolean isComment(final ASTNode node) { - final PsiElement psiElement = SourceTreeToPsiMap.treeElementToPsi(node); - if (psiElement instanceof PsiComment) return true; - final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(psiElement.getLanguage()); - if (parserDefinition == null) return false; - final TokenSet commentTokens = parserDefinition.getCommentTokens(); - return commentTokens.contains(node.getElementType()); - } -} \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java index dfd3dbe844bc..d2e7d5863c2b 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/AbstractJavaBlock.java @@ -27,10 +27,10 @@ import com.intellij.psi.*; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.formatter.FormatterUtil; import com.intellij.psi.formatter.common.AbstractBlock; -import com.intellij.psi.formatter.common.JavaBlockUtil; import com.intellij.psi.formatter.java.wrap.JavaWrapManager; import com.intellij.psi.formatter.java.wrap.ReservedWrapsProvider; import com.intellij.psi.impl.source.SourceTreeToPsiMap; +import com.intellij.psi.impl.source.codeStyle.ShiftIndentInsideHelper; import com.intellij.psi.impl.source.tree.*; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.impl.source.tree.java.ClassElement; @@ -1212,7 +1212,7 @@ public abstract class AbstractJavaBlock extends AbstractBlock implements JavaBlo } public boolean isLeaf() { - return JavaBlockUtil.mayShiftIndentInside(myNode); + return ShiftIndentInsideHelper.mayShiftIndentInside(myNode); } @Nullable diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/LeafBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/LeafBlock.java index 96365015cb6e..da88301f4d93 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/LeafBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/LeafBlock.java @@ -18,7 +18,7 @@ package com.intellij.psi.formatter.java; import com.intellij.formatting.*; import com.intellij.lang.ASTNode; import com.intellij.openapi.util.TextRange; -import com.intellij.psi.formatter.common.JavaBlockUtil; +import com.intellij.psi.impl.source.codeStyle.ShiftIndentInsideHelper; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -90,7 +90,7 @@ public class LeafBlock implements ASTBlock{ } public boolean isLeaf() { - return JavaBlockUtil.mayShiftIndentInside(myNode); + return ShiftIndentInsideHelper.mayShiftIndentInside(myNode); } public void setStartOffset(final int startOffset) {