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


Java PsiUtilCore.getNotAnyLanguage方法代码示例

本文整理汇总了Java中com.intellij.psi.util.PsiUtilCore.getNotAnyLanguage方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtilCore.getNotAnyLanguage方法的具体用法?Java PsiUtilCore.getNotAnyLanguage怎么用?Java PsiUtilCore.getNotAnyLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.util.PsiUtilCore的用法示例。


在下文中一共展示了PsiUtilCore.getNotAnyLanguage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: markToReformatBeforeOrInsertWhitespace

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static void markToReformatBeforeOrInsertWhitespace(final ASTNode left, @NotNull final ASTNode right) {
  final Language leftLang = left != null ? PsiUtilCore.getNotAnyLanguage(left) : null;
  final Language rightLang = PsiUtilCore.getNotAnyLanguage(right);

  ASTNode generatedWhitespace = null;
  if (leftLang != null && leftLang.isKindOf(rightLang)) {
    generatedWhitespace = LanguageTokenSeparatorGenerators.INSTANCE.forLanguage(leftLang).generateWhitespaceBetweenTokens(left, right);
  }
  else if (rightLang.isKindOf(leftLang)) {
    generatedWhitespace = LanguageTokenSeparatorGenerators.INSTANCE.forLanguage(rightLang).generateWhitespaceBetweenTokens(left, right);
  }

  if (generatedWhitespace != null) {
    final TreeUtil.CommonParentState parentState = new TreeUtil.CommonParentState();
    TreeUtil.prevLeaf((TreeElement)right, parentState);
    parentState.nextLeafBranchStart.getTreeParent().addChild(generatedWhitespace, parentState.nextLeafBranchStart);
  }
  else {
    markToReformatBefore(right, true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CodeEditUtil.java

示例2: LanguageTokenSeparatorGenerators

import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private LanguageTokenSeparatorGenerators() {
  super("com.intellij.lang.tokenSeparatorGenerator", new TokenSeparatorGenerator() {
    @Override
    public ASTNode generateWhitespaceBetweenTokens(ASTNode left, ASTNode right) {
      Language l = PsiUtilCore.getNotAnyLanguage(left);
      Language rightLang = PsiUtilCore.getNotAnyLanguage(right);
      if (rightLang.isKindOf(l)) {
        l = rightLang; // get more precise lexer
      }
      final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
      if (parserDefinition != null) {
        PsiManager manager = right.getTreeParent().getPsi().getManager();
        ASTNode generatedWhitespace;
        //noinspection EnumSwitchStatementWhichMissesCases
        switch(parserDefinition.spaceExistanceTypeBetweenTokens(left, right)){
          case MUST:
            generatedWhitespace = Factory.createSingleLeafElement(TokenType.WHITE_SPACE, " ", 0, 1, null, manager);
            break;
          case MUST_LINE_BREAK:
            generatedWhitespace = Factory.createSingleLeafElement(TokenType.WHITE_SPACE, "\n", 0, 1, null, manager);
            break;
          default:
            generatedWhitespace = null;
        }
        return generatedWhitespace;
      }
      return null;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:LanguageTokenSeparatorGenerators.java


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