本文整理汇总了Java中com.intellij.lang.PsiParser.parse方法的典型用法代码示例。如果您正苦于以下问题:Java PsiParser.parse方法的具体用法?Java PsiParser.parse怎么用?Java PsiParser.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.lang.PsiParser
的用法示例。
在下文中一共展示了PsiParser.parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAST
import com.intellij.lang.PsiParser; //导入方法依赖的package包/类
private ASTNode createAST(String text) {
ParserDefinition definition = new BuildParserDefinition();
PsiParser parser = definition.createParser(getProject());
Lexer lexer = definition.createLexer(getProject());
PsiBuilderImpl psiBuilder =
new PsiBuilderImpl(
getProject(), null, definition, lexer, new CharTableImpl(), text, null, null);
PsiBuilderAdapter adapter =
new PsiBuilderAdapter(psiBuilder) {
@Override
public void error(String messageText) {
super.error(messageText);
errors.add(messageText);
}
};
return parser.parse(definition.getFileNodeType(), adapter);
}
示例2: parseText
import com.intellij.lang.PsiParser; //导入方法依赖的package包/类
public static @NotNull <T extends PsiElement> T parseText(
@NotNull String text,
@NotNull IElementType rootElementType,
@NotNull Class<T> rootElementClass,
@NotNull ParserDefinition parserDefinition,
@Nullable ErrorProcessor errorProcessor) {
LanguageParserDefinitions.INSTANCE.addExplicitExtension(
parserDefinition.getFileNodeType().getLanguage(),
parserDefinition
);
PsiParser parser = parserDefinition.createParser(model.first);
Lexer lexer = parserDefinition.createLexer(model.first);
PsiBuilderImpl psiBuilder = new PsiBuilderImpl(
model.first,
null,
parserDefinition,
lexer,
new CharTableImpl(),
text,
null,
null
);
ASTNode astNode = parser.parse(rootElementType, psiBuilder);
T res = astNode.getPsi(rootElementClass);
collectErrors(res, errorProcessor);
return res;
}
示例3: doParse
import com.intellij.lang.PsiParser; //导入方法依赖的package包/类
@NotNull
private PsiBuilder doParse(@NotNull ASTNode chameleon, Project project, LanguageVersion languageVersion)
{
LanguageLevel languageLevel = LanguageLevel.HIGHEST;
PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new JspJavaLexer(languageLevel), JavaLanguage.INSTANCE, languageVersion, chameleon.getChars());
JavaParserUtil.setLanguageLevel(builder, languageLevel);
PsiParser parser = new JavaInJspParser();
parser.parse(this, builder, languageVersion);
return builder;
}