本文整理汇总了Java中com.intellij.lang.PsiParser类的典型用法代码示例。如果您正苦于以下问题:Java PsiParser类的具体用法?Java PsiParser怎么用?Java PsiParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiParser类属于com.intellij.lang包,在下文中一共展示了PsiParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createParser
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Override
public PsiParser createParser(Project project) {
return new PsiParser() {
@NotNull
@Override
public ASTNode parse(IElementType root, PsiBuilder builder) {
final PsiBuilder.Marker rootMarker = builder.mark();
final PsiBuilder.Marker propertiesList = builder.mark();
while (!builder.eof()) {
parseProvider(builder);
}
propertiesList.done(SPIElementTypes.PROVIDERS_LIST);
rootMarker.done(root);
return builder.getTreeBuilt();
}
};
}
示例2: 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);
}
示例3: createParser
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@NotNull
@Override
public PsiParser createParser(Project project) {
return new PsiParser() {
@NotNull
@Override
public ASTNode parse(IElementType root, PsiBuilder builder) {
return new DtdParsing(root, XmlEntityDecl.EntityContextType.GENERIC_XML, builder).parse();
}
};
}
示例4: createParser
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Override
public PsiParser createParser(Project project) {
return (root, builder) -> {
PsiBuilder.Marker rootMarker = builder.mark();
new ProjectViewPsiParser(builder).parseFile();
rootMarker.done(root);
return builder.getTreeBuilt();
};
}
示例5: 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;
}
示例6: createParser
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@NotNull
public PsiParser createParser(final Project project) {
if(project != null) {
project.putUserData(JSGRAPHQL_ACTIVATED, true);
}
return new JSGraphQLParser();
}
示例7: createParser
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@NotNull
public PsiParser createParser(final Project project) {
//return new MultiMarkdownParser();
return MultiMarkdownGlobalSettings.getInstance().lightParserFailedBuild.runBuild(new FailedBuildRunnable<PsiParser>() {
@Nullable @Override public PsiParser runCanFail() throws Throwable {
return new MultiMarkdownLightParser();
}
@Nullable @Override public PsiParser run() {
return new MultiMarkdownParser();
}
});
}
示例8: stateHackMess
import com.intellij.lang.PsiParser; //导入依赖的package包/类
/**
* Called when the parser gets confused from layout rules.
*
* Increases the debt of rbraces in the token remapper in
* HaskellParserWrapper. When the remapper is in debt it will swallow
* (=remap them to TokenType.WHITE_SPACE) synthetic rbraces until no debt
* remains.
*/
public static boolean stateHackMess(@NotNull PsiBuilder builder, int level) {
if (!(builder instanceof Builder)) return false;
PsiParser wrapper = ((Builder) builder).parser;
if (!(wrapper instanceof HaskellParserWrapper)) return false;
// IElementType tok = builder.getTokenType();
int offs = builder.getCurrentOffset();
int line = StringUtil.offsetToLineNumber(builder.getOriginalText(), offs);
int lineStart = StringUtil.lineColToOffset(builder.getOriginalText(), line, 1);
Pair<Integer, Integer> p = ((HaskellParserWrapper) wrapper).debtPoints.get(offs);
if (p != null && p.getSecond() == 0 && !((HaskellParserWrapper) wrapper).regressed) {
((HaskellParserWrapper) wrapper).maxRbraceDebt = ((HaskellParserWrapper) wrapper).debtPoints.get(offs).getFirst();
((HaskellParserWrapper) wrapper).rbraceDebt = ((HaskellParserWrapper) wrapper).rbraceDebt - ((HaskellParserWrapper) wrapper).maxRbraceDebt;
((HaskellParserWrapper) wrapper).debtPoints.put(offs, Pair.create(((HaskellParserWrapper) wrapper).maxRbraceDebt, ((HaskellParserWrapper) wrapper).maxRbraceDebt));
} else if (((HaskellParserWrapper) wrapper).maxRbraceDebt == -1) {
int numOpen = findBraces(((HaskellParserWrapper) wrapper).lexer.openBraces, offs, line, lineStart);
((HaskellParserWrapper) wrapper).maxRbraceDebt = numOpen;
}
// System.out.println("Confused at: " + offs + " line " + line + " on token " + tok
// + " regressed: " + ((HaskellParserWrapper) wrapper).regressed + " max: "
// + ((HaskellParserWrapper) wrapper).maxRbraceDebt);
boolean ret = ((HaskellParserWrapper) wrapper).increaseRbraceDebt(builder.getCurrentOffset());
if (((HaskellParserWrapper) wrapper).maxRbraceDebt == 0) ((HaskellParserWrapper) wrapper).maxRbraceDebt = -1;
return ret;
}
示例9: indented
import com.intellij.lang.PsiParser; //导入依赖的package包/类
public static boolean indented(@NotNull PsiBuilder builder, int level, Parser geq) {
if (!(builder instanceof Builder)) return false;
PsiParser wrapper = ((Builder) builder).parser;
if (!(wrapper instanceof HaskellParserWrapper)) return false;
if (builder.eof()) return false;
// IElementType currtok = builder.getTokenType();
Pair<Integer, IElementType> prevtok = previousElem(builder);
if (prevtok == null) return true;
int offs = builder.getCurrentOffset();
int line = StringUtil.offsetToLineNumber(builder.getOriginalText(), offs);
int prevline = StringUtil.offsetToLineNumber(builder.getOriginalText(), offs + prevtok.getFirst());
if (prevline == line) return true;
int thisLineStart = StringUtil.lineColToOffset(builder.getOriginalText(), line, 0);
int prevLineStart = StringUtil.lineColToOffset(builder.getOriginalText(), prevline, 0);
// CharSequence lineStuff = builder.getOriginalText().subSequence(thisLineStart, offs);
CharSequence prevLineStuff = builder.getOriginalText().subSequence(prevLineStart, thisLineStart - 1);
int indentation = indentationLevel(prevLineStuff);
int myindentation = offs - thisLineStart;
// String tokName = builder.getTokenText();
boolean geqVal = geq.parse(builder, level);
if (geqVal && myindentation >= indentation ||
!geqVal && myindentation > indentation) return true;
return false;
}
示例10: doParseContents
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Override
protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi)
{
final Project project = psi.getProject();
final Language languageForParser = getLanguageForParser(psi);
final LanguageVersion tempLanguageVersion = chameleon.getUserData(LanguageVersion.KEY);
final LanguageVersion languageVersion = tempLanguageVersion == null ? psi.getLanguageVersion() : tempLanguageVersion;
final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new _CSharpMacroLexer(), languageForParser, languageVersion, chameleon.getChars());
final PsiParser parser = LanguageParserDefinitions.INSTANCE.forLanguage(languageForParser).createParser(languageVersion);
return parser.parse(this, builder, languageVersion).getFirstChildNode();
}
示例11: doParseContents
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Override
@RequiredReadAction
protected ASTNode doParseContents(@NotNull final ASTNode chameleon, @NotNull final PsiElement psi)
{
final Project project = psi.getProject();
CSharpDocLanguage docLanguage = CSharpDocLanguage.INSTANCE;
final LanguageVersion languageVersion = LanguageVersionUtil.findDefaultVersion(docLanguage);
DeprecatedCSharpDocLexer docLexer = new DeprecatedCSharpDocLexer();
final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, docLexer, docLanguage, languageVersion, chameleon.getChars());
final PsiParser parser = LanguageParserDefinitions.INSTANCE.forLanguage(docLanguage).createParser(languageVersion);
return parser.parse(this, builder, languageVersion).getFirstChildNode();
}
示例12: 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;
}
示例13: createParser
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@NotNull
@Override
public PsiParser createParser()
{
if(myExpressionElementType == null)
{
myExpressionElementType = createExpressionElementType();
}
return new CfsParser(myExpressionElementType);
}
示例14: createParser
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Nonnull
@Override
public PsiParser createParser(@Nonnull LanguageVersion languageVersion) {
if(languageVersion instanceof LanguageVersionWithParsing) {
return ((LanguageVersionWithParsing)languageVersion).createParser();
}
throw new IllegalArgumentException("'createParser' need override for language version '" + languageVersion + "'");
}
示例15: createParser
import com.intellij.lang.PsiParser; //导入依赖的package包/类
@Override
public PsiParser createParser(Project project) {
return new TSParser();
}