本文整理汇总了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);
}
}
示例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;
}
});
}