use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class RestParser method parseMarkup.
private static void parseMarkup(PsiBuilder builder) {
PsiBuilder.Marker marker = builder.mark();
IElementType type = builder.getTokenType();
if (type == RestTokenTypes.SUBSTITUTION) {
builder.advanceLexer();
marker.done(RestElementTypes.REFERENCE_TARGET);
builder.advanceLexer();
marker = builder.mark();
type = builder.getTokenType();
}
if (type == RestTokenTypes.DIRECTIVE) {
gotoNextWhiteSpaces(builder);
if (builder.getTokenType() != RestTokenTypes.WHITESPACE) {
builder.advanceLexer();
marker.done(RestElementTypes.DIRECTIVE_BLOCK);
return;
}
skipBlankLines(builder);
if (builder.getTokenType() != RestTokenTypes.WHITESPACE || "\n".equals(builder.getTokenText())) {
marker.done(RestElementTypes.DIRECTIVE_BLOCK);
return;
}
String white = builder.getTokenText();
parseDirective(builder, white, marker);
} else if (type == RestTokenTypes.FOOTNOTE || type == RestTokenTypes.CITATION || type == RestTokenTypes.HYPERLINK || type == RestTokenTypes.ANONYMOUS_HYPERLINK) {
builder.advanceLexer();
marker.done(RestElementTypes.REFERENCE_TARGET);
} else {
builder.advanceLexer();
marker.drop();
}
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class RestParser method parse.
@NotNull
public ASTNode parse(IElementType root, PsiBuilder builder) {
final PsiBuilder.Marker rootMarker = builder.mark();
while (!builder.eof()) {
IElementType type = builder.getTokenType();
if (type == RestTokenTypes.EXPLISIT_MARKUP_START) {
builder.advanceLexer();
parseMarkup(builder);
} else if (type == RestTokenTypes.REFERENCE_NAME || type == RestTokenTypes.SUBSTITUTION) {
PsiBuilder.Marker marker = builder.mark();
builder.advanceLexer();
marker.done(RestTokenTypes.REFERENCE_NAME);
} else if (type == RestTokenTypes.TITLE) {
PsiBuilder.Marker marker = builder.mark();
builder.advanceLexer();
marker.done(RestTokenTypes.TITLE);
} else if (type == RestTokenTypes.FIELD) {
parseFieldList(builder);
} else if (type == RestTokenTypes.INLINE_LINE) {
PsiBuilder.Marker marker = builder.mark();
builder.advanceLexer();
marker.done(RestElementTypes.INLINE_BLOCK);
} else if (type == RestTokenTypes.ANONYMOUS_HYPERLINK) {
PsiBuilder.Marker marker = builder.mark();
builder.advanceLexer();
marker.done(RestElementTypes.REFERENCE_TARGET);
} else if (type == RestTokenTypes.LINE) {
parseLineText(builder, type);
} else
builder.advanceLexer();
}
rootMarker.done(root);
return builder.getTreeBuilt();
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class XPath2Parser method parseSequenceType.
private boolean parseSequenceType(PsiBuilder builder) {
PsiBuilder.Marker mark = builder.mark();
final IElementType type = parseItemOrEmptySequenceType(builder);
if (type != null) {
if (type == XPath2TokenTypes.ITEM) {
if (XPath2TokenTypes.OCCURRENCE_OPS.contains(builder.getTokenType())) {
makeToken(builder);
}
}
mark.done(XPath2ElementTypes.SEQUENCE_TYPE);
return true;
} else if (parseNodeType(builder) || parseQName(builder)) {
if (builder.getTokenType() == XPathTokenTypes.MULT) {
builder.remapCurrentToken(XPathTokenTypes.STAR);
}
if (XPath2TokenTypes.OCCURRENCE_OPS.contains(builder.getTokenType())) {
makeToken(builder);
}
mark.done(XPath2ElementTypes.SEQUENCE_TYPE);
return true;
}
mark.drop();
return false;
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class XPathParser method parseAxisSpecifier.
/**
* [5] AxisSpecifier ::= AxisName '::' | AbbreviatedAxisSpecifier
* <p/>
* [13] AbbreviatedAxisSpecifier ::= '@'?
*/
private boolean parseAxisSpecifier(PsiBuilder builder) {
final PsiBuilder.Marker marker = builder.mark();
final IElementType tokenType = builder.getTokenType();
if (XPathTokenTypes.AXIS.contains(tokenType)) {
builder.advanceLexer();
checkMatches(builder, XPathTokenTypes.COLCOL, ":: expected");
} else {
if (tokenType == XPathTokenTypes.AT) {
builder.advanceLexer();
} else if (tokenType == XPathTokenTypes.DOT || tokenType == XPathTokenTypes.DOTDOT) {
marker.drop();
return false;
} else {
final PsiBuilder.Marker m = builder.mark();
final boolean b = parseNodeTest(builder);
m.rollbackTo();
if (!b) {
marker.drop();
return false;
}
}
}
marker.done(XPathElementTypes.AXIS_SPECIFIER);
return true;
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class StatementParsing method parseImportStatement.
protected void parseImportStatement(IElementType statementType, IElementType elementType) {
final PsiBuilder builder = myContext.getBuilder();
final PsiBuilder.Marker importStatement = builder.mark();
builder.advanceLexer();
parseImportElements(elementType, true, false, false);
checkEndOfStatement();
importStatement.done(statementType);
}
Aggregations