Java Code Examples for com.intellij.lang.PsiBuilder#remapCurrentToken()

The following examples show how to use com.intellij.lang.PsiBuilder#remapCurrentToken() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RmlParser.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
private void parseLt(@NotNull PsiBuilder builder, @NotNull ParserState state) {
    // Can be a symbol or a JSX tag
    IElementType nextTokenType = builder.rawLookup(1);
    if (nextTokenType == m_types.LIDENT || nextTokenType == m_types.UIDENT
            || nextTokenType == m_types.OPTION) { // Note that option is a ReasonML keyword but also a JSX keyword !
        // Surely a tag
        builder.remapCurrentToken(m_types.TAG_LT);
        state.add(mark(builder, jsxTag, m_types.C_TAG).complete())
                .add(markScope(builder, jsxStartTag, jsxStartTag, m_types.C_TAG_START, m_types.TAG_LT).complete());

        state.advance();

        builder.remapCurrentToken(m_types.TAG_NAME);
        state.wrapWith(nextTokenType == m_types.UIDENT ? m_types.C_UPPER_SYMBOL : m_types.C_LOWER_SYMBOL);
    }
}
 
Example 2
Source File: RmlParser.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
private void parseLtSlash(@NotNull PsiBuilder builder, @NotNull ParserState state) {
    IElementType nextTokenType = builder.rawLookup(1);
    if (nextTokenType == m_types.LIDENT || nextTokenType == m_types.UIDENT) {
        // A closing tag
        if (state.isCurrentContext(jsxTagBody)) {
            state.popEnd();
        }

        builder.remapCurrentToken(m_types.TAG_LT);
        state.add(mark(builder, jsxTagClose, m_types.C_TAG_CLOSE).complete());

        state.advance();

        builder.remapCurrentToken(m_types.TAG_NAME);
        state.wrapWith(nextTokenType == m_types.UIDENT ? m_types.C_UPPER_SYMBOL : m_types.C_LOWER_SYMBOL);
    }
}
 
Example 3
Source File: RmlParser.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
private void parseSome(@NotNull PsiBuilder builder, @NotNull ParserState state) {
    if (state.isCurrentResolution(patternMatch)) {
        // Defining a pattern match
        // switch (c) { | |>Some<| .. }
        builder.remapCurrentToken(m_types.VARIANT_NAME);
        state.wrapWith(m_types.C_VARIANT).updateCurrentResolution(patternMatchVariant);
    }
}
 
Example 4
Source File: RmlParser.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
private void parseNone(@NotNull PsiBuilder builder, @NotNull ParserState state) {
    if (state.isCurrentResolution(patternMatch)) {
        // Defining a pattern match
        // switch (c) { | |>Some<| .. }
        builder.remapCurrentToken(m_types.VARIANT_NAME);
        state.wrapWith(m_types.C_VARIANT).updateCurrentResolution(patternMatchVariant);
    }
}
 
Example 5
Source File: ParserUtil.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
public static boolean smartRemapAndAdvance(PsiBuilder builder, String expectedTokenText, IElementType expectedTokenType, IElementType newTokenType) {
    IElementType current = builder.getTokenType();
    if (current == newTokenType) {
        // already remapped, probably due to reverting an earlier parse result
        builder.advanceLexer();
    } else if (expectedTokenText.equals(builder.getTokenText()) && current == expectedTokenType) {
        builder.remapCurrentToken(newTokenType);
        builder.advanceLexer();
    } else {
        builder.error("unexpected token");
        return false;
    }

    return true;
}
 
Example 6
Source File: OclParser.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
private void parseRaise(@NotNull PsiBuilder builder, @NotNull ParserState state) {
    if (state.isCurrentResolution(external)) {
        builder.remapCurrentToken(m_types.LIDENT);
        state.wrapWith(m_types.C_LOWER_SYMBOL).updateCurrentResolution(externalNamed).complete();
    }
}
 
Example 7
Source File: ParserUtil.java    From BashSupport with Apache License 2.0 4 votes vote down vote up
public static void remapMarkAdvance(PsiBuilder builder, IElementType newTokenType, IElementType markAs) {
    builder.remapCurrentToken(newTokenType);

    markTokenAndAdvance(builder, markAs);
}