use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class ManifestParser method parseSection.
private void parseSection(PsiBuilder builder) {
PsiBuilder.Marker section = builder.mark();
while (!builder.eof()) {
IElementType tokenType = builder.getTokenType();
if (tokenType == ManifestTokenType.HEADER_NAME) {
parseHeader(builder);
} else if (tokenType == ManifestTokenType.SECTION_END) {
builder.advanceLexer();
break;
} else {
PsiBuilder.Marker marker = builder.mark();
consumeHeaderValue(builder);
marker.error(ManifestBundle.message("manifest.header.expected"));
}
}
section.done(ManifestElementType.SECTION);
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class XPath2Parser method parseItemOrEmptySequenceType.
@Nullable
private IElementType parseItemOrEmptySequenceType(PsiBuilder builder) {
final IElementType tokenType = builder.getTokenType();
if (tokenType == XPath2TokenTypes.ITEM || tokenType == XPath2TokenTypes.EMPTY_SEQUENCE) {
final PsiBuilder.Marker mark = builder.mark();
builder.advanceLexer();
parseArgumentList(builder);
mark.done(XPath2ElementTypes.ITEM_OR_EMPTY_SEQUENCE);
return tokenType;
}
return null;
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class XPathParser method parseFunction.
protected boolean parseFunction(PsiBuilder builder) {
IElementType tokenType = builder.getTokenType();
if (tokenType == XPathTokenTypes.FUNCTION_NAME || tokenType == XPathTokenTypes.EXT_PREFIX) {
final PsiBuilder.Marker func = builder.mark();
builder.advanceLexer();
if (builder.getTokenType() == XPathTokenTypes.COL) {
builder.advanceLexer();
checkMatches(builder, XPathTokenTypes.FUNCTION_NAME, "function name expected");
}
parseArgumentList(builder);
func.done(XPathElementTypes.FUNCTION_CALL);
return true;
}
return false;
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class XPathParser method makeToken.
protected static void makeToken(PsiBuilder builder) {
final IElementType tokenType = builder.getTokenType();
final PsiBuilder.Marker marker = builder.mark();
builder.advanceLexer();
marker.done(tokenType);
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class GroovyParser method parseDeclaration.
/**
* parses imports (marks them as not allowed), type definitions, methods, variables or fields (if isInClass), initializers (if isInClass), constructors
* with corresponding typeDefinitionName
* <p/>
* If non of preceding elements was found rolls back and return false
*/
public boolean parseDeclaration(@NotNull PsiBuilder builder, boolean isInClass, boolean isInAnnotation, @Nullable String typeDefinitionName) {
PsiBuilder.Marker declMarker = builder.mark();
boolean modifiersParsed = Modifiers.parse(builder, this);
if (GroovyTokenTypes.kIMPORT == builder.getTokenType()) {
final PsiBuilder.Marker impMarker = declMarker.precede();
ImportStatement.parseAfterModifiers(builder);
declMarker.done(GroovyElementTypes.IMPORT_STATEMENT);
impMarker.error(GroovyBundle.message("import.not.allowed"));
return true;
}
if (isTypeDefinitionStart(builder)) {
final IElementType tdType = TypeDefinition.parseAfterModifiers(builder, this);
if (tdType != GroovyElementTypes.WRONGWAY) {
declMarker.done(tdType);
} else {
builder.error(GroovyBundle.message("identifier.expected"));
declMarker.drop();
}
return true;
}
if (isInClass && parseInitializer(builder)) {
declMarker.done(GroovyElementTypes.CLASS_INITIALIZER);
return true;
}
final IElementType declType = Declaration.parseAfterModifiers(builder, isInClass, isInAnnotation, typeDefinitionName, this, modifiersParsed);
if (declType != GroovyElementTypes.WRONGWAY) {
if (declType != null) {
declMarker.done(declType);
} else {
declMarker.drop();
}
return true;
}
if (modifiersParsed) {
declMarker.drop();
builder.error(GroovyBundle.message("identifier.expected"));
return true;
}
declMarker.rollbackTo();
return false;
}
Aggregations