mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Duplicate dropped
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user