Search in sources :

Example 91 with PsiBuilder

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);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder)

Example 92 with PsiBuilder

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;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder) Nullable(org.jetbrains.annotations.Nullable)

Example 93 with PsiBuilder

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;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder)

Example 94 with PsiBuilder

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);
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder)

Example 95 with PsiBuilder

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;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) PsiBuilder(com.intellij.lang.PsiBuilder)

Aggregations

PsiBuilder (com.intellij.lang.PsiBuilder)124 IElementType (com.intellij.psi.tree.IElementType)90 Nullable (org.jetbrains.annotations.Nullable)18 NotNull (org.jetbrains.annotations.NotNull)16 Project (com.intellij.openapi.project.Project)7 LighterASTNode (com.intellij.lang.LighterASTNode)6 GroovyElementType (org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType)5 Language (com.intellij.lang.Language)3 ASTNode (com.intellij.lang.ASTNode)2 PsiElement (com.intellij.psi.PsiElement)2 ILazyParseableElementType (com.intellij.psi.tree.ILazyParseableElementType)2 ParsingContext (com.jetbrains.python.parsing.ParsingContext)2 StatementParsing (com.jetbrains.python.parsing.StatementParsing)2 ParserDefinition (com.intellij.lang.ParserDefinition)1 PsiParser (com.intellij.lang.PsiParser)1 HtmlParsing (com.intellij.lang.html.HtmlParsing)1 Lexer (com.intellij.lexer.Lexer)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1