use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class JavaFileElementType method parseContents.
@Override
public ASTNode parseContents(final ASTNode chameleon) {
final PsiBuilder builder = JavaParserUtil.createBuilder(chameleon);
doParse(builder);
return builder.getTreeBuilt().getFirstChildNode();
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class JavaFileElementType method parseContentsLight.
@Override
public FlyweightCapableTreeStructure<LighterASTNode> parseContentsLight(final ASTNode chameleon) {
final PsiBuilder builder = JavaParserUtil.createBuilder(chameleon);
doParse(builder);
return builder.getLightTree();
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class GroovyDocParser method parse.
@Override
@NotNull
public ASTNode parse(@NotNull IElementType root, @NotNull PsiBuilder builder) {
PsiBuilder.Marker rootMarker = builder.mark();
new GroovyDocParsing().parse(builder);
rootMarker.done(root);
return builder.getTreeBuilt();
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class SwitchStatement method parseCaseLabel.
/**
* Parses one or more sequential 'case' or 'default' labels
*/
public static boolean parseCaseLabel(PsiBuilder builder, GroovyParser parser) {
IElementType elem = builder.getTokenType();
if (elem != GroovyTokenTypes.kCASE && elem != GroovyTokenTypes.kDEFAULT) {
return false;
}
PsiBuilder.Marker label = builder.mark();
builder.advanceLexer();
if (GroovyTokenTypes.kCASE.equals(elem) && !AssignmentExpression.parse(builder, parser)) {
builder.error(GroovyBundle.message("expression.expected"));
}
ParserUtils.getToken(builder, GroovyTokenTypes.mCOLON, GroovyBundle.message("colon.expected"));
label.done(GroovyElementTypes.CASE_LABEL);
PsiBuilder.Marker beforeNls = builder.mark();
ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
if (parseCaseLabel(builder, parser)) {
beforeNls.drop();
} else {
beforeNls.rollbackTo();
}
return true;
}
use of com.intellij.lang.PsiBuilder in project intellij-community by JetBrains.
the class Declaration method tryParseWithGenerics.
private static IElementType tryParseWithGenerics(@NotNull PsiBuilder builder, boolean isInClass, boolean isInAnnotation, @Nullable String typeDefinitionName, @NotNull GroovyParser parser, boolean modifiersParsed, boolean expressionPossible, boolean acceptTypeParameters) {
if (acceptTypeParameters) {
TypeParameters.parse(builder);
} else {
final PsiBuilder.Marker error = builder.mark();
TypeParameters.parse(builder);
error.error(GroovyBundle.message("type.parameters.are.unexpected"));
}
//point to begin of type or variable
PsiBuilder.Marker checkMarker = builder.mark();
switch(TypeSpec.parse(builder, false, expressionPossible)) {
case PATH_REF:
case REF_WITH_TYPE_PARAMS:
checkMarker.drop();
break;
case FAIL:
checkMarker.rollbackTo();
break;
case IDENTIFIER:
// declaration name element can be parsed as type element
IElementType result = VariableDefinitions.parseDefinitions(builder, isInClass, isInAnnotation, typeDefinitionName, modifiersParsed, false, parser);
if (result == GroovyElementTypes.WRONGWAY) {
checkMarker.rollbackTo();
} else {
checkMarker.drop();
return result;
}
}
return VariableDefinitions.parseDefinitions(builder, isInClass, isInAnnotation, typeDefinitionName, modifiersParsed, false, parser);
}
Aggregations