Java Code Examples for com.intellij.lang.PsiBuilder#Marker
The following examples show how to use
com.intellij.lang.PsiBuilder#Marker .
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: GLSLParsing.java From glsl4idea with GNU Lesser General Public License v3.0 | 6 votes |
private boolean parseConditionalExpression() { // conditional_expression: logical_or_expression // | logical_or_expression QUESTION expression COLON assignment_expression PsiBuilder.Marker mark = b.mark(); if (!parseOperatorExpression()) { mark.drop(); return false; } if (tryMatch(QUESTION)) { parseExpression(); match(COLON, "Missing ':' in ternary operator ?:."); parseAssignmentExpression(); mark.done(CONDITIONAL_EXPRESSION); } else { mark.drop(); } return true; }
Example 2
Source File: LatteParserUtil.java From intellij-latte with MIT License | 6 votes |
public static boolean checkEmptyMacro(PsiBuilder builder, int level) { PsiBuilder.Marker marker = builder.mark(); boolean result = false; while (true) { IElementType token = builder.getTokenType(); if (token == null) { break; } else if (token == LatteTypes.T_MACRO_TAG_CLOSE) { break; } else if (token == LatteTypes.T_MACRO_TAG_CLOSE_EMPTY) { result = true; break; } builder.advanceLexer(); } marker.rollbackTo(); return result; }
Example 3
Source File: GLSLParsing.java From glsl4idea with GNU Lesser General Public License v3.0 | 6 votes |
private void parseQualifierList(boolean validPlacement) { final PsiBuilder.Marker mark = b.mark(); if (!validPlacement && !parseQualifier()) { mark.drop(); return; } //noinspection StatementWithEmptyBody while (parseQualifier()) { } if (validPlacement) { mark.done(QUALIFIER_LIST); } else { mark.error("Qualifier not allowed here."); } }
Example 4
Source File: ShaderLabOrRole.java From consulo-unity3d with Apache License 2.0 | 6 votes |
@Override public PsiBuilder.Marker parseAndDone(ShaderLabParserBuilder builder, @Nonnull PsiBuilder.Marker mark) { for(ShaderLabRole role : myRoles) { if(role instanceof ShaderLabValueRole && ((ShaderLabValueRole) role).isMyValue(builder)) { return role.parseAndDone(builder, mark); } } doneWithErrorSafe(builder, "Wrong value"); mark.done(ShaderLabElements.SIMPLE_VALUE); return mark; }
Example 5
Source File: ExpressionParsing.java From consulo-csharp with Apache License 2.0 | 6 votes |
private static PsiBuilder.Marker parseExpressionWithExpressionInLParRPar(CSharpBuilderWrapper builder, PsiBuilder.Marker mark, IElementType to, ModifierSet set) { PsiBuilder.Marker newMarker = mark == null ? builder.mark() : mark.precede(); builder.advanceLexer(); if(expect(builder, LPAR, "'(' expected")) { if(parse(builder, set) == null) { builder.error("Expression expected"); } expect(builder, RPAR, "')' expected"); } newMarker.done(to); return newMarker; }
Example 6
Source File: StatementParsing.java From intellij with Apache License 2.0 | 6 votes |
private void parseLoadStatement() { PsiBuilder.Marker marker = builder.mark(); expect(TokenKind.IDENTIFIER); expect(TokenKind.LPAREN); parseStringLiteral(false); // Not implementing [IDENTIFIER EQUALS] option -- not a documented feature, // so wait for users to complain boolean hasSymbols = false; while (!matches(TokenKind.RPAREN) && !matchesAnyOf(STATEMENT_TERMINATOR_SET)) { expect(TokenKind.COMMA); if (matches(TokenKind.RPAREN) || matchesAnyOf(STATEMENT_TERMINATOR_SET)) { break; } hasSymbols |= parseLoadedSymbol(); } if (!hasSymbols) { builder.error("'load' statements must include at least one loaded function"); } marker.done(BuildElementTypes.LOAD_STATEMENT); }
Example 7
Source File: GLSLParsing.java From glsl4idea with GNU Lesser General Public License v3.0 | 6 votes |
private boolean parseTypeSpecifierNoArray(boolean onlyBuiltIn) { // type_specifier_noarray: all_built_in_types // | struct_specifier // | type_name // todo: implement | INVARIANT IDENTIFIER (vertex only) // note: This also accepts IDENTIFIERS final PsiBuilder.Marker mark = b.mark(); if (!onlyBuiltIn && b.getTokenType() == STRUCT) { parseStructSpecifier(); mark.done(TYPE_SPECIFIER_STRUCT); } else if (TYPE_SPECIFIER_NONARRAY_TOKENS.contains(b.getTokenType())) { b.advanceLexer(); mark.done(TYPE_SPECIFIER_PRIMITIVE); } else if (!onlyBuiltIn && b.getTokenType() == IDENTIFIER) { parseIdentifier(); mark.done(TYPE_SPECIFIER_STRUCT_REFERENCE); } else { mark.error("Expected a type specifier."); return false; } return true; }
Example 8
Source File: RTJSParser.java From react-templates-plugin with MIT License | 6 votes |
public boolean parseInExpression() { final PsiBuilder.Marker expr = builder.mark(); if (isIdentifierToken(builder.getTokenType())) { parseExplicitIdentifier(); } else { final PsiBuilder.Marker keyValue = builder.mark(); parseKeyValue(); if (JSTokenTypes.IN_KEYWORD.equals(builder.getTokenType())) { keyValue.done(JSElementTypes.PARENTHESIZED_EXPRESSION); } else { expr.rollbackTo(); return false; } } builder.advanceLexer(); parseExpression(); // if (builder.getTokenType() == RTTokenTypes.TRACK_BY_KEYWORD) { // builder.advanceLexer(); // parseExpression(); // } expr.done(RTElementTypes.REPEAT_EXPRESSION); return true; }
Example 9
Source File: MethodParsing.java From consulo-csharp with Apache License 2.0 | 5 votes |
public static void parseMethodStartAtType(@Nonnull CSharpBuilderWrapper builder, @Nonnull PsiBuilder.Marker marker, @Nonnull ModifierSet set) { TypeInfo typeInfo = parseType(builder, STUB_SUPPORT); if(typeInfo != null) { parseMethodStartAfterType(builder, marker, typeInfo, Target.METHOD, set); } else { builder.error("Name expected"); done(marker, METHOD_DECLARATION); } }
Example 10
Source File: GLSLParsing.java From glsl4idea with GNU Lesser General Public License v3.0 | 5 votes |
private void parseLayoutQualifierElement() { // layout_qualifier_id: IDENTIFIER [ EQUAL constant_expression ] // | SHARED final PsiBuilder.Marker mark = b.mark(); if (tryMatch(IDENTIFIER)) { if (tryMatch(EQUAL)) { if (!parseConstantExpression()) b.error("Expected constant expression"); } } else if (!tryMatch(SHARED_KEYWORD)) { mark.error("Expected 'shared' or an identifier"); return; } mark.done(LAYOUT_QUALIFIER_ID); }
Example 11
Source File: ExpressionParsing.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nullable private static PsiBuilder.Marker parseMaybeNullableType(CSharpBuilderWrapper builder, ModifierSet set, int flags) { TypeInfo typeInfo = parseType(builder, NONE); if(typeInfo == null) { return null; } // if we have nullable type - need find colon, or return original marker if(typeInfo.isNullable) { if(builder.getTokenType() == QUEST) { return typeInfo.marker; } // o is int? "true" : "false" PsiBuilder.Marker marker = parseConditional(builder, set, flags); if(marker != null) { IElementType tokenType = builder.getTokenType(); marker.rollbackTo(); if(tokenType == COLON) { typeInfo.marker.rollbackTo(); TypeInfo anotherTypeInfo = parseType(builder, WITHOUT_NULLABLE); assert anotherTypeInfo != null; return anotherTypeInfo.marker; } } return typeInfo.marker; } else { return typeInfo.marker; } }
Example 12
Source File: ShaderLabParser.java From consulo-unity3d with Apache License 2.0 | 5 votes |
public static boolean parseReference(PsiBuilder builder) { if(builder.getTokenType() == ShaderLabTokens.IDENTIFIER) { PsiBuilder.Marker mark = builder.mark(); builder.advanceLexer(); mark.done(ShaderLabElements.REFERENCE); return true; } return false; }
Example 13
Source File: ShaderLabCommaPairRole.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Override public PsiBuilder.Marker parseAndDone(ShaderLabParserBuilder builder, @Nonnull PsiBuilder.Marker mark) { PsiBuilder.Marker firstMarker = builder.mark(); if(myFirstRole.parseAndDone(builder, firstMarker) != null) { if(builder.getTokenType() == ShaderLabTokens.COMMA) { builder.advanceLexer(); PsiBuilder.Marker secondMark = builder.mark(); if(mySecondRole.parseAndDone(builder, secondMark) == null) { secondMark.error("Expected second value"); } } else { builder.error("Expected comma"); } } else { firstMarker.error("Expected value"); } mark.done(ShaderLabElements.PAIR_VALUE); return mark; }
Example 14
Source File: ExpressionParsing.java From intellij with Apache License 2.0 | 5 votes |
private PsiBuilder.Marker parseSelectorSuffix(PsiBuilder.Marker marker) { if (!atToken(TokenKind.IDENTIFIER)) { builder.error("expected identifier after dot"); syncPast(EXPR_TERMINATOR_SET); return marker; } parseTargetOrReferenceIdentifier(); if (atToken(TokenKind.LPAREN)) { parseFuncallSuffix(); marker.done(BuildElementTypes.FUNCALL_EXPRESSION); } else { marker.done(BuildElementTypes.DOT_EXPRESSION); } return marker.precede(); }
Example 15
Source File: ExpressionParsing.java From consulo-csharp with Apache License 2.0 | 5 votes |
private static PsiBuilder.Marker parseAwaitExpression(@Nonnull CSharpBuilderWrapper builder, ModifierSet set) { PsiBuilder.Marker marker = builder.mark(); builder.advanceLexer(); if(parse(builder, set) == null) { builder.error("Expression expected"); } marker.done(AWAIT_EXPRESSION); return marker; }
Example 16
Source File: ForLoopParsingFunction.java From BashSupport with Apache License 2.0 | 4 votes |
/** * Helper function to parse an arithmetic for loop. * * @param builder The builder to use. * @return True if the arithmetic for loop has succesfully been parsed. */ boolean parseArithmeticForLoop(BashPsiBuilder builder) { /* arith_for_command: FOR ARITH_FOR_EXPRS list_terminator newline_list DO compound_list DONE | FOR ARITH_FOR_EXPRS list_terminator newline_list '{' compound_list '}' | FOR ARITH_FOR_EXPRS DO compound_list DONE | FOR ARITH_FOR_EXPRS '{' compound_list '}' ; */ PsiBuilder.Marker marker = builder.mark(); builder.advanceLexer();//after the "for" keyword //parse arithmetic expressions, it's a block like (( a; b; c )) with a,b,c //being arithmetic expressions if (builder.getTokenType() != EXPR_ARITH) { ParserUtil.error(marker, "parser.unexpected.token"); return false; } builder.advanceLexer();//after the "((" token if (!parseArithmeticExpression(builder, SEMI)) { ParserUtil.error(marker, "parser.unexpected.token"); return false; } if (!parseArithmeticExpression(builder, SEMI)) { ParserUtil.error(marker, "parser.unexpected.token"); return false; } if (!parseArithmeticExpression(builder, _EXPR_ARITH)) { ParserUtil.error(marker, "parser.unexpected.token"); return false; } if (Parsing.list.isListTerminator(builder.getTokenType())) { builder.advanceLexer(); builder.readOptionalNewlines(); } if (!LoopParserUtil.parseLoopBody(builder, true, false)) { marker.drop(); return false; } marker.done(ShellCommandParsing.FOR_COMMAND); return true; }
Example 17
Source File: ANTLRParseTreeToPSIConverter.java From antlr4-intellij-adaptor with BSD 2-Clause "Simplified" License | 4 votes |
protected final Deque<PsiBuilder.Marker> getMarkers() { return markers; }
Example 18
Source File: CSharpDocParsing.java From consulo-csharp with Apache License 2.0 | 4 votes |
private void parseAttributeValue(@Nullable CSharpDocAttributeInfo attributeInfo) { final PsiBuilder.Marker attValue = mark(); if(token() == CSharpDocTokenType.XML_ATTRIBUTE_VALUE_START_DELIMITER) { advance(); if(token() == CSharpDocTokenType.XML_BAD_CHARACTER) { final PsiBuilder.Marker error = mark(); advance(); error.error("Unexpected token"); } else if(token() == CSharpDocTokenType.XML_ATTRIBUTE_VALUE_TOKEN) { if(attributeInfo == null) { advance(); } else { switch(attributeInfo.getValueType()) { case REFERENCE: myBuilder.remapCurrentToken(CSharpDocElements.TYPE); break; case PARAMETER: myBuilder.remapCurrentToken(CSharpDocElements.PARAMETER_EXPRESSION); break; case TYPE_PARAMETER: myBuilder.remapCurrentToken(CSharpDocElements.GENERIC_PARAMETER_EXPRESSION); break; } advance(); } } if(token() == CSharpDocTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) { advance(); } else { error("Attribute value is not closed"); } } else { error("Attribute value expected"); } attValue.done(CSharpDocElements.ATTRIBUTE_VALUE); }
Example 19
Source File: BashSmartMarker.java From BashSupport with Apache License 2.0 | 4 votes |
public PsiBuilder.Marker precede() { return delegate.precede(); }
Example 20
Source File: SelectParsingFunction.java From BashSupport with Apache License 2.0 | 4 votes |
public boolean parse(BashPsiBuilder builder) { /* select_command: SELECT WORD newline_list DO list DONE | SELECT WORD newline_list '{' list '}' | SELECT WORD ';' newline_list DO list DONE | SELECT WORD ';' newline_list '{' list '}' | SELECT WORD newline_list IN word_list list_terminator newline_list DO list DONE | SELECT WORD newline_list IN word_list list_terminator newline_list '{' list '}' ; */ final PsiBuilder.Marker selectCommand = builder.mark(); builder.advanceLexer(); //after the select if (ParserUtil.isIdentifier(builder.getTokenType())) { ParserUtil.markTokenAndAdvance(builder, VAR_DEF_ELEMENT); } else { ParserUtil.error(selectCommand, "parser.unexpected.token"); return false; } builder.readOptionalNewlines(); if ((builder.getTokenType() == WORD || builder.getTokenType() == IN_KEYWORD_REMAPPED) && "in".equals(builder.getTokenText())) { builder.remapCurrentToken(IN_KEYWORD_REMAPPED); builder.advanceLexer();//after the IN if (ParserUtil.isEmptyListFollowedBy(builder, DO_KEYWORD)) { ParserUtil.error(builder, "parser.unexpected.token"); ParserUtil.readEmptyListFollowedBy(builder, DO_KEYWORD); } else { OptionalParseResult result = Parsing.word.parseWordListIfValid(builder, true, false); //include the terminator if (result.isValid() && !result.isParsedSuccessfully()) { selectCommand.drop(); return false; } } } builder.readOptionalNewlines(); //now parse the body if (!LoopParserUtil.parseLoopBody(builder, false, false)) { selectCommand.drop(); return false; } selectCommand.done(SELECT_COMMAND); return true; }