use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class StandardHeaderParser method parse.
@Override
public void parse(@NotNull PsiBuilder builder) {
PsiBuilder.Marker marker = builder.mark();
while (!builder.eof() && !ManifestParser.HEADER_END_TOKENS.contains(builder.getTokenType())) {
IElementType lastToken = builder.getTokenType();
builder.advanceLexer();
if (lastToken == ManifestTokenType.NEWLINE && builder.getTokenType() != ManifestTokenType.SIGNIFICANT_SPACE) {
break;
}
}
marker.done(ManifestElementType.HEADER_VALUE_PART);
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class ManifestParser method parseHeader.
private void parseHeader(PsiBuilder builder) {
PsiBuilder.Marker header = builder.mark();
String headerName = builder.getTokenText();
assert headerName != null : "[" + builder.getOriginalText() + "]@" + builder.getCurrentOffset();
builder.advanceLexer();
if (builder.getTokenType() == ManifestTokenType.COLON) {
builder.advanceLexer();
if (!expect(builder, ManifestTokenType.SIGNIFICANT_SPACE)) {
builder.error(ManifestBundle.message("manifest.whitespace.expected"));
}
HeaderParser headerParser = notNull(myRepository.getHeaderParser(headerName), StandardHeaderParser.INSTANCE);
headerParser.parse(builder);
} else {
PsiBuilder.Marker marker = builder.mark();
consumeHeaderValue(builder);
marker.error(ManifestBundle.message("manifest.colon.expected"));
}
header.done(ManifestElementType.HEADER);
}
use of com.intellij.lang.PsiBuilder in project intellij-plugins by JetBrains.
the class MarkdownLazyElementType method doParseContents.
@Override
protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi) {
final Project project = psi.getProject();
final Lexer lexer = new MarkdownLexerAdapter();
final CharSequence chars = chameleon.getChars();
final org.intellij.markdown.ast.ASTNode node = new MarkdownParser(MarkdownParserManager.FLAVOUR).parseInline(MarkdownElementType.markdownType(chameleon.getElementType()), chars, 0, chars.length());
final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, lexer, getLanguage(), chars);
assert builder.getCurrentOffset() == 0;
new PsiBuilderFillingVisitor(builder).visitNode(node);
assert builder.eof();
return builder.getTreeBuilt().getFirstChildNode();
}
use of com.intellij.lang.PsiBuilder in project intellij-plugins by JetBrains.
the class OsgiHeaderParser method parseClause.
private static boolean parseClause(PsiBuilder builder) {
PsiBuilder.Marker clause = builder.mark();
boolean result = true;
while (!builder.eof()) {
if (!parseSubClause(builder, false)) {
result = false;
break;
}
IElementType tokenType = builder.getTokenType();
if (CLAUSE_END_TOKENS.contains(tokenType)) {
break;
} else if (tokenType == ManifestTokenType.SEMICOLON) {
builder.advanceLexer();
}
}
clause.done(OsgiManifestElementType.CLAUSE);
return result;
}
use of com.intellij.lang.PsiBuilder in project intellij-plugins by JetBrains.
the class DartGeneratedParserUtilBase method lazyParseableBlockImpl.
public static boolean lazyParseableBlockImpl(PsiBuilder builder, int level) {
if (builder.getTokenType() != LBRACE)
return false;
final PsiBuilder.Marker marker = builder.mark();
builder.advanceLexer();
int braceCount = 1;
while (true) {
final IElementType tokenType = builder.getTokenType();
if (tokenType == null) {
break;
}
if (tokenType == LBRACE) {
braceCount++;
} else if (tokenType == RBRACE) {
braceCount--;
}
builder.advanceLexer();
if (braceCount == 0) {
break;
}
}
marker.collapse(LAZY_PARSEABLE_BLOCK);
return true;
}
Aggregations