本文整理汇总了Java中com.intellij.psi.formatter.FormatterUtil.replaceWhiteSpace方法的典型用法代码示例。如果您正苦于以下问题:Java FormatterUtil.replaceWhiteSpace方法的具体用法?Java FormatterUtil.replaceWhiteSpace怎么用?Java FormatterUtil.replaceWhiteSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.formatter.FormatterUtil
的用法示例。
在下文中一共展示了FormatterUtil.replaceWhiteSpace方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replaceWithPsiInLeaf
import com.intellij.psi.formatter.FormatterUtil; //导入方法依赖的package包/类
@Override
protected String replaceWithPsiInLeaf(TextRange textRange, String whiteSpace, ASTNode leafElement) {
if (!myCanModifyAllWhiteSpaces) {
if (AppleScriptPsiImplUtil.isWhiteSpaceOrNls(leafElement)) return null;
}
IElementType elementTypeToUse = TokenType.WHITE_SPACE;
ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
if (prevNode != null && AppleScriptPsiImplUtil.isWhiteSpaceOrNls(prevNode)) {
elementTypeToUse = prevNode.getElementType();
}
FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, elementTypeToUse, textRange);
return whiteSpace;
}
示例2: replaceWithPsiInLeaf
import com.intellij.psi.formatter.FormatterUtil; //导入方法依赖的package包/类
@Override
protected String replaceWithPsiInLeaf(TextRange textRange, String whiteSpace, ASTNode leafElement) {
if (!myCanModifyAllWhiteSpaces) {
if (PsiImplUtil.isWhiteSpaceOrNls(leafElement)) return null;
}
IElementType elementTypeToUse = TokenType.WHITE_SPACE;
ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
if (prevNode != null && PsiImplUtil.isWhiteSpaceOrNls(prevNode)) {
elementTypeToUse = prevNode.getElementType();
}
FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, elementTypeToUse, textRange);
return whiteSpace;
}
示例3: replaceWithPsiInLeaf
import com.intellij.psi.formatter.FormatterUtil; //导入方法依赖的package包/类
@Override
protected String replaceWithPsiInLeaf(TextRange textRange, String whiteSpace, ASTNode leafElement) {
if (!myCanModifyAllWhiteSpaces) {
if (TokenSets.WHITE_SPACES_SET.contains(leafElement.getElementType())) return null;
}
IElementType elementTypeToUse = TokenType.WHITE_SPACE;
ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
if (prevNode != null && TokenSets.WHITE_SPACES_SET.contains(prevNode.getElementType())) {
elementTypeToUse = prevNode.getElementType();
}
FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, elementTypeToUse, textRange);
return whiteSpace;
}
示例4: replaceWithPsiInLeaf
import com.intellij.psi.formatter.FormatterUtil; //导入方法依赖的package包/类
@Override
protected String replaceWithPsiInLeaf(final TextRange textRange, String whiteSpace, ASTNode leafElement) {
if (!myCanModifyAllWhiteSpaces) {
if (leafElement.getElementType() == TokenType.WHITE_SPACE) return null;
ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
if (prevNode != null) {
IElementType type = prevNode.getElementType();
if(type == TokenType.WHITE_SPACE) {
final String text = prevNode.getText();
@NonNls final String cdataStartMarker = "<![CDATA[";
final int cdataPos = text.indexOf(cdataStartMarker);
if (cdataPos != -1 && whiteSpace.indexOf(cdataStartMarker) == -1) {
whiteSpace = DocumentBasedFormattingModel.mergeWsWithCdataMarker(whiteSpace, text, cdataPos);
if (whiteSpace == null) return null;
}
prevNode = TreeUtil.prevLeaf(prevNode);
type = prevNode != null ? prevNode.getElementType():null;
}
@NonNls final String cdataEndMarker = "]]>";
if(type == XmlTokenType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1) {
final ASTNode at = findElementAt(prevNode.getStartOffset());
if (at != null && at.getPsi() instanceof PsiWhiteSpace) {
final String s = at.getText();
final int cdataEndPos = s.indexOf(cdataEndMarker);
whiteSpace = DocumentBasedFormattingModel.mergeWsWithCdataMarker(whiteSpace, s, cdataEndPos);
leafElement = at;
} else {
whiteSpace = null;
}
if (whiteSpace == null) return null;
}
}
}
FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, TokenType.WHITE_SPACE, textRange);
return whiteSpace;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:PsiBasedFormatterModelWithShiftIndentInside.java
示例5: replaceWithPsiInLeaf
import com.intellij.psi.formatter.FormatterUtil; //导入方法依赖的package包/类
@Override
protected String replaceWithPsiInLeaf(final TextRange textRange, String whiteSpace, ASTNode leafElement) {
if (!myCanModifyAllWhiteSpaces) {
if (leafElement.getElementType() == TokenType.WHITE_SPACE) return null;
LOG.assertTrue(leafElement.getPsi().isValid());
ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
if (prevNode != null) {
IElementType type = prevNode.getElementType();
if(type == TokenType.WHITE_SPACE) {
final String text = prevNode.getText();
final @NonNls String cdataStartMarker = "<![CDATA[";
final int cdataPos = text.indexOf(cdataStartMarker);
if (cdataPos != -1 && whiteSpace.indexOf(cdataStartMarker) == -1) {
whiteSpace = mergeWsWithCdataMarker(whiteSpace, text, cdataPos);
if (whiteSpace == null) return null;
}
prevNode = TreeUtil.prevLeaf(prevNode);
type = prevNode != null ? prevNode.getElementType():null;
}
final @NonNls String cdataEndMarker = "]]>";
if(type == XmlTokenType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1) {
final ASTNode at = findElementAt(prevNode.getStartOffset());
if (at != null && at.getPsi() instanceof PsiWhiteSpace) {
final String s = at.getText();
final int cdataEndPos = s.indexOf(cdataEndMarker);
whiteSpace = mergeWsWithCdataMarker(whiteSpace, s, cdataEndPos);
leafElement = at;
} else {
whiteSpace = null;
}
if (whiteSpace == null) return null;
}
}
}
FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, TokenType.WHITE_SPACE, textRange);
return whiteSpace;
}
示例6: replaceWithPsiInLeaf
import com.intellij.psi.formatter.FormatterUtil; //导入方法依赖的package包/类
@Override
protected String replaceWithPsiInLeaf(final TextRange textRange, String whiteSpace, ASTNode leafElement) {
if (!myCanModifyAllWhiteSpaces) {
if (leafElement.getElementType() == TokenType.WHITE_SPACE) return null;
ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
if (prevNode != null) {
IElementType type = prevNode.getElementType();
if(type == TokenType.WHITE_SPACE) {
final String text = prevNode.getText();
final @NonNls String cdataStartMarker = "<![CDATA[";
final int cdataPos = text.indexOf(cdataStartMarker);
if (cdataPos != -1 && whiteSpace.indexOf(cdataStartMarker) == -1) {
whiteSpace = DocumentBasedFormattingModel.mergeWsWithCdataMarker(whiteSpace, text, cdataPos);
if (whiteSpace == null) return null;
}
prevNode = TreeUtil.prevLeaf(prevNode);
type = prevNode != null ? prevNode.getElementType():null;
}
final @NonNls String cdataEndMarker = "]]>";
if(type == XmlElementType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1) {
final ASTNode at = findElementAt(prevNode.getStartOffset());
if (at != null && at.getPsi() instanceof PsiWhiteSpace) {
final String s = at.getText();
final int cdataEndPos = s.indexOf(cdataEndMarker);
whiteSpace = DocumentBasedFormattingModel.mergeWsWithCdataMarker(whiteSpace, s, cdataEndPos);
leafElement = at;
} else {
whiteSpace = null;
}
if (whiteSpace == null) return null;
}
}
}
FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, TokenType.WHITE_SPACE, textRange);
return whiteSpace;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:42,代码来源:PsiBasedFormatterModelWithShiftIndentInside.java
示例7: replaceWithPsiInLeaf
import com.intellij.psi.formatter.FormatterUtil; //导入方法依赖的package包/类
protected String replaceWithPsiInLeaf(final TextRange textRange, String whiteSpace, ASTNode leafElement) {
if (!myCanModifyAllWhiteSpaces) {
if (leafElement.getElementType() == TokenType.WHITE_SPACE) return null;
LOG.assertTrue(leafElement.getPsi().isValid());
ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
if (prevNode != null) {
IElementType type = prevNode.getElementType();
if(type == TokenType.WHITE_SPACE) {
final String text = prevNode.getText();
final @NonNls String cdataStartMarker = "<![CDATA[";
final int cdataPos = text.indexOf(cdataStartMarker);
if (cdataPos != -1 && whiteSpace.indexOf(cdataStartMarker) == -1) {
whiteSpace = mergeWsWithCdataMarker(whiteSpace, text, cdataPos);
if (whiteSpace == null) return null;
}
prevNode = TreeUtil.prevLeaf(prevNode);
type = prevNode != null ? prevNode.getElementType():null;
}
final @NonNls String cdataEndMarker = "]]>";
if(type == XmlElementType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1) {
final ASTNode at = findElementAt(prevNode.getStartOffset());
if (at != null && at.getPsi() instanceof PsiWhiteSpace) {
final String s = at.getText();
final int cdataEndPos = s.indexOf(cdataEndMarker);
whiteSpace = mergeWsWithCdataMarker(whiteSpace, s, cdataEndPos);
leafElement = at;
} else {
whiteSpace = null;
}
if (whiteSpace == null) return null;
}
}
}
FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, TokenType.WHITE_SPACE, textRange);
return whiteSpace;
}
示例8: replaceWithPsiInLeaf
import com.intellij.psi.formatter.FormatterUtil; //导入方法依赖的package包/类
@Override
protected String replaceWithPsiInLeaf(final TextRange textRange, String whiteSpace, ASTNode leafElement)
{
if(!myCanModifyAllWhiteSpaces)
{
if(leafElement.getElementType() == TokenType.WHITE_SPACE)
{
return null;
}
ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
if(prevNode != null)
{
IElementType type = prevNode.getElementType();
if(type == TokenType.WHITE_SPACE)
{
final String text = prevNode.getText();
@NonNls final String cdataStartMarker = "<![CDATA[";
final int cdataPos = text.indexOf(cdataStartMarker);
if(cdataPos != -1 && whiteSpace.indexOf(cdataStartMarker) == -1)
{
whiteSpace = DocumentBasedFormattingModel.mergeWsWithCdataMarker(whiteSpace, text, cdataPos);
if(whiteSpace == null)
{
return null;
}
}
prevNode = TreeUtil.prevLeaf(prevNode);
type = prevNode != null ? prevNode.getElementType() : null;
}
@NonNls final String cdataEndMarker = "]]>";
if(type == XmlTokenType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1)
{
final ASTNode at = findElementAt(prevNode.getStartOffset());
if(at != null && at.getPsi() instanceof PsiWhiteSpace)
{
final String s = at.getText();
final int cdataEndPos = s.indexOf(cdataEndMarker);
whiteSpace = DocumentBasedFormattingModel.mergeWsWithCdataMarker(whiteSpace, s, cdataEndPos);
leafElement = at;
}
else
{
whiteSpace = null;
}
if(whiteSpace == null)
{
return null;
}
}
}
}
FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, TokenType.WHITE_SPACE, textRange);
return whiteSpace;
}