当前位置: 首页>>代码示例>>Java>>正文


Java FormatterUtil.replaceWhiteSpace方法代码示例

本文整理汇总了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;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:15,代码来源:AppleScriptFormattingModelBuilder.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GroovyFormattingModelBuilder.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:GroovyFormattingModelBuilder.java

示例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;
 }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:XmlFormattingModel.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:42,代码来源:XmlFormattingModel.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:60,代码来源:PsiBasedFormatterModelWithShiftIndentInside.java


注:本文中的com.intellij.psi.formatter.FormatterUtil.replaceWhiteSpace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。