Java Code Examples for com.intellij.lang.PsiBuilder

The following examples show how to use com.intellij.lang.PsiBuilder. These examples are extracted from open source projects. 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 Project: glsl4idea   Source File: GLSLParsing.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Parse type specifier.
 * onlyBuildIn can be used to accept as types only tokens in TYPE_SPECIFIER_NONARRAY_TOKENS.
 * This can be used in for example parsing constructors.
 *
 * @param onlyBuiltIn if true, only build-in type specifiers are considered valid
 */
private boolean parseTypeSpecifier(boolean onlyBuiltIn) {
    // type_specifier_noarray
    // type_specifier_noarray "[" const_expr "]"

    final PsiBuilder.Marker mark = b.mark();

    if (!parseTypeSpecifierNoArray(onlyBuiltIn)) {
        mark.drop();
        return false;
    }

    if (b.getTokenType() == LEFT_BRACKET) {
        parseArrayDeclarator();
    }
    mark.done(TYPE_SPECIFIER);
    return true;
}
 
Example 2
Source Project: glsl4idea   Source File: GLSLParsing.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
private void parseParameterDeclaration() {
    // parameter_declaration: [parameter_qualifier] [type_qualifier] IDENTIFIER [array_declarator]
    final PsiBuilder.Marker mark = b.mark();

    parseQualifiedTypeSpecifier();

    if (b.getTokenType() == IDENTIFIER) {
        parseStructOrParameterDeclarator(PARAMETER_DECLARATOR);
    } else {
        // Fake a declarator.
        PsiBuilder.Marker mark2 = b.mark();
        mark2.done(PARAMETER_DECLARATOR);
    }

    mark.done(PARAMETER_DECLARATION);
}
 
Example 3
Source Project: react-templates-plugin   Source File: RTJSParser.java    License: MIT License 6 votes vote down vote up
@Override
protected boolean parseUnaryExpression() {
    final IElementType tokenType = builder.getTokenType();
    if (tokenType == JSTokenTypes.OR) {
        builder.advanceLexer();
        if (!parseFilter()) {
            builder.error("expected filter");
        }
        return true;
    }
    if (tokenType == RTTokenTypes.ONE_TIME_BINDING) {
        final PsiBuilder.Marker expr = builder.mark();
        builder.advanceLexer();
        if (!super.parseUnaryExpression()) {
            builder.error(JSBundle.message("javascript.parser.message.expected.expression"));
        }
        expr.done(JSElementTypes.PREFIX_EXPRESSION);
        return true;
    }
    return super.parseUnaryExpression();
}
 
Example 4
Source Project: intellij   Source File: ExpressionParsing.java    License: Apache License 2.0 6 votes vote down vote up
/** funcall_suffix ::= '(' arg_list? ')' arg_list ::= ((arg ',')* arg ','? )? */
private void parseFuncallSuffix() {
  PsiBuilder.Marker mark = builder.mark();
  expect(TokenKind.LPAREN, true);
  if (matches(TokenKind.RPAREN)) {
    mark.done(BuildElementTypes.ARGUMENT_LIST);
    return;
  }
  parseFuncallArgument();
  while (!atAnyOfTokens(FUNCALL_TERMINATOR_SET)) {
    expect(TokenKind.COMMA);
    if (atAnyOfTokens(FUNCALL_TERMINATOR_SET)) {
      break;
    }
    parseFuncallArgument();
  }
  expect(TokenKind.RPAREN, true);
  mark.done(BuildElementTypes.ARGUMENT_LIST);
}
 
Example 5
Source Project: consulo-csharp   Source File: ExpressionParsing.java    License: Apache License 2.0 6 votes vote down vote up
private static PsiBuilder.Marker parseExpressionWithTypeInLParRPar(CSharpBuilderWrapper builder, int flags, PsiBuilder.Marker mark, IElementType to)
{
	PsiBuilder.Marker newMarker = mark == null ? builder.mark() : mark.precede();
	builder.advanceLexer();

	if(expect(builder, LPAR, "'(' expected"))
	{
		if(parseType(builder, flags, TokenSet.EMPTY) == null)
		{
			builder.error("Type expected");
		}
		expect(builder, RPAR, "')' expected");
	}
	newMarker.done(to);
	return newMarker;
}
 
Example 6
Source Project: consulo-csharp   Source File: GenericParameterParsing.java    License: Apache License 2.0 5 votes vote down vote up
public static PsiBuilder.Marker parseGenericConstraintList(CSharpBuilderWrapper builder)
{
	PsiBuilder.Marker marker = builder.mark();

	boolean empty = true;
	while(!builder.eof())
	{
		builder.enableSoftKeyword(CSharpSoftTokens.WHERE_KEYWORD);
		IElementType elementType = builder.getTokenType();
		builder.disableSoftKeyword(CSharpSoftTokens.WHERE_KEYWORD);

		if(elementType == CSharpSoftTokens.WHERE_KEYWORD)
		{
			PsiBuilder.Marker genericConstraint = parseGenericConstraint(builder);
			if(genericConstraint == null)
			{
				break;
			}
			else
			{
				empty = false;
			}
		}
		else
		{
			break;
		}
	}

	if(empty)
	{
		marker.drop();
	}
	else
	{
		marker.done(GENERIC_CONSTRAINT_LIST);
	}
	return marker;
}
 
Example 7
Source Project: idea-php-dotenv-plugin   Source File: DotEnvParser.java    License: MIT License 5 votes vote down vote up
static boolean dotEnvFile(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "dotEnvFile")) return false;
  while (true) {
    int c = current_position_(b);
    if (!item_(b, l + 1)) break;
    if (!empty_element_parsed_guard_(b, "dotEnvFile", c)) break;
  }
  return true;
}
 
Example 8
Source Project: mule-intellij-plugins   Source File: MelParser.java    License: Apache License 2.0 5 votes vote down vote up
static boolean root(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "root")) return false;
  int c = current_position_(b);
  while (true) {
    if (!expressionSemicolon(b, l + 1)) break;
    if (!empty_element_parsed_guard_(b, "root", c)) break;
    c = current_position_(b);
  }
  return true;
}
 
Example 9
Source Project: Intellij-Plugin   Source File: SpecParser.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean tableBody_0(PsiBuilder b, int l) {
    if (!recursion_guard_(b, l, "tableBody_0")) return false;
    boolean r;
    Marker m = enter_section_(b);
    r = consumeToken(b, TABLE_BORDER);
    r = r && tableBody_0_1(b, l + 1);
    r = r && tableBody_0_2(b, l + 1);
    exit_section_(b, m, null, r);
    return r;
}
 
Example 10
Source Project: intellij-haskforce   Source File: HaskellParser.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean export_1_1_0_1(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "export_1_1_0_1")) return false;
  boolean r;
  Marker m = enter_section_(b);
  r = consumeToken(b, DOUBLEPERIOD);
  if (!r) r = cnames(b, l + 1);
  if (!r) r = qvars(b, l + 1);
  exit_section_(b, m, null, r);
  return r;
}
 
Example 11
Source Project: intellij-haskforce   Source File: HaskellParser.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean infixexp_1_0(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "infixexp_1_0")) return false;
  boolean r;
  Marker m = enter_section_(b);
  r = qop(b, l + 1);
  r = r && infixexp0(b, l + 1);
  exit_section_(b, m, null, r);
  return r;
}
 
Example 12
public static boolean ListType(PsiBuilder builder_, int level_) {
  if (!recursion_guard_(builder_, level_, "ListType")) return false;
  if (!nextTokenIs(builder_, LBRACKET)) return false;
  boolean result_, pinned_;
  Marker marker_ = enter_section_(builder_, level_, _NONE_, LIST_TYPE, null);
  result_ = consumeToken(builder_, LBRACKET);
  pinned_ = result_; // pin = 1
  result_ = result_ && report_error_(builder_, NamedType(builder_, level_ + 1));
  result_ = pinned_ && report_error_(builder_, consumeToken(builder_, RBRACKET)) && result_;
  result_ = pinned_ && ListType_3(builder_, level_ + 1) && result_;
  exit_section_(builder_, level_, marker_, result_, pinned_, null);
  return result_ || pinned_;
}
 
Example 13
Source Project: JetBrains-NASM-Language   Source File: NASMParser.java    License: MIT License 5 votes vote down vote up
public static boolean LabelIdentifier(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "LabelIdentifier")) return false;
  boolean r;
  Marker m = enter_section_(b, l, _NONE_, LABEL_IDENTIFIER, "<label identifier>");
  r = LabelIdentifier_0(b, l + 1);
  r = r && LabelIdentifier_1(b, l + 1);
  exit_section_(b, l, m, r, false, null);
  return r;
}
 
Example 14
Source Project: JetBrains-NASM-Language   Source File: NASMParser.java    License: MIT License 5 votes vote down vote up
private static boolean Conditional_0_4_0_1(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "Conditional_0_4_0_1")) return false;
  while (true) {
    int c = current_position_(b);
    if (!consumeToken(b, NL)) break;
    if (!empty_element_parsed_guard_(b, "Conditional_0_4_0_1", c)) break;
  }
  return true;
}
 
Example 15
Source Project: Intellij-Plugin   Source File: SpecParser.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean teardown_2_0(PsiBuilder b, int l) {
    if (!recursion_guard_(b, l, "teardown_2_0")) return false;
    boolean r;
    Marker m = enter_section_(b);
    r = step(b, l + 1);
    if (!r) r = comment(b, l + 1);
    if (!r) r = consumeToken(b, TEARDOWN_IDENTIFIER);
    exit_section_(b, m, null, r);
    return r;
}
 
Example 16
public static boolean MapLiteral(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "MapLiteral")) return false;
  if (!nextTokenIs(b, BRACKET_CURLYOPEN)) return false;
  boolean r;
  Marker m = enter_section_(b);
  r = consumeToken(b, BRACKET_CURLYOPEN);
  r = r && MapLiteral_1(b, l + 1);
  r = r && MapLiteral_2(b, l + 1);
  r = r && consumeToken(b, BRACKET_CURLYCLOSE);
  exit_section_(b, m, MAP_LITERAL, r);
  return r;
}
 
Example 17
Source Project: arma-intellij-plugin   Source File: HeaderParser.java    License: MIT License 5 votes vote down vote up
private static boolean token__0(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "token__0")) return false;
  boolean r;
  Marker m = enter_section_(b);
  r = consumeToken(b, NUMBER_LITERAL);
  if (!r) r = consumeToken(b, HEX_LITERAL);
  if (!r) r = consumeToken(b, STRING_LITERAL);
  exit_section_(b, m, null, r);
  return r;
}
 
Example 18
Source Project: intellij-haskforce   Source File: HaskellParser.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean constrs_2(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "constrs_2")) return false;
  while (true) {
    int c = current_position_(b);
    if (!constrs_2_0(b, l + 1)) break;
    if (!empty_element_parsed_guard_(b, "constrs_2", c)) break;
  }
  return true;
}
 
Example 19
Source Project: nix-idea   Source File: NixParser.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean attr_assign(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "attr_assign")) return false;
  if (!nextTokenIs(b, "<attr assign>", FNUTT_OPEN, ID)) return false;
  boolean r;
  Marker m = enter_section_(b, l, _NONE_, ATTR_ASSIGN, "<attr assign>");
  r = attr_path(b, l + 1);
  r = r && consumeToken(b, ASSIGN);
  r = r && expr(b, l + 1);
  exit_section_(b, l, m, r, false, null);
  return r;
}
 
Example 20
Source Project: intellij-haskforce   Source File: HaskellParser.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean modulePrefix_0(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "modulePrefix_0")) return false;
  boolean r;
  Marker m = enter_section_(b);
  r = conid(b, l + 1);
  r = r && consumeToken(b, PERIOD);
  exit_section_(b, m, null, r);
  return r;
}
 
Example 21
Source Project: JetBrains-NASM-Language   Source File: NASMParser.java    License: MIT License 5 votes vote down vote up
public static boolean DataElement(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "DataElement")) return false;
  if (!nextTokenIs(b, "<data element>", DATA_OP, ID)) return false;
  boolean r;
  Marker m = enter_section_(b, l, _NONE_, DATA_ELEMENT, "<data element>");
  r = DataElement_0(b, l + 1);
  r = r && consumeToken(b, DATA_OP);
  r = r && DataValue(b, l + 1);
  r = r && DataElement_3(b, l + 1);
  exit_section_(b, l, m, r, false, null);
  return r;
}
 
Example 22
Source Project: intellij-haskforce   Source File: HaskellParser.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean qcon(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "qcon")) return false;
  if (!nextTokenIs(b, "<qcon>", CONIDREGEXP, LPAREN)) return false;
  boolean r;
  Marker m = enter_section_(b, l, _NONE_, QCON, "<qcon>");
  r = qconid(b, l + 1);
  if (!r) r = qcon_1(b, l + 1);
  exit_section_(b, l, m, r, false, null);
  return r;
}
 
Example 23
Source Project: consulo-csharp   Source File: MethodParsing.java    License: Apache License 2.0 5 votes vote down vote up
public static void parseParameterList(CSharpBuilderWrapper builder, int flags, IElementType end, ModifierSet set)
{
	PsiBuilder.Marker mark = builder.mark();

	builder.advanceLexer();

	if(builder.getTokenType() != end)
	{
		while(!builder.eof())
		{
			parseParameter(builder, end, flags, set);

			if(builder.getTokenType() == COMMA)
			{
				builder.advanceLexer();
			}
			else if(builder.getTokenType() == end)
			{
				break;
			}
			else
			{
				PsiBuilder.Marker errorMarker = builder.mark();
				builder.advanceLexer();
				errorMarker.error("Expected comma");
			}
		}
	}

	expect(builder, end, "')' expected");
	mark.done(BitUtil.isSet(flags, STUB_SUPPORT) ? CSharpStubElements.PARAMETER_LIST : CSharpElements.PARAMETER_LIST);
}
 
Example 24
Source Project: intellij-haskforce   Source File: HaskellParser.java    License: Apache License 2.0 5 votes vote down vote up
static boolean typedeclclosedfamily(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "typedeclclosedfamily")) return false;
  if (!nextTokenIs(b, FAMILYTOKEN)) return false;
  boolean r, p;
  Marker m = enter_section_(b, l, _NONE_);
  r = consumeToken(b, FAMILYTOKEN);
  r = r && kindedvars(b, l + 1);
  r = r && consumeToken(b, WHERE);
  p = r; // pin = 3
  r = r && decls(b, l + 1);
  exit_section_(b, l, m, r, p, null);
  return r || p;
}
 
Example 25
private static boolean Pattern_1_0(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "Pattern_1_0")) return false;
  boolean r;
  Marker m = enter_section_(b);
  r = consumeToken(b, OP_COMMA);
  r = r && PatternPart(b, l + 1);
  exit_section_(b, m, null, r);
  return r;
}
 
Example 26
Source Project: JetBrains-NASM-Language   Source File: NASMParser.java    License: MIT License 5 votes vote down vote up
public static boolean Struc(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "Struc")) return false;
  if (!nextTokenIs(b, STRUC_TAG)) return false;
  boolean r;
  Marker m = enter_section_(b);
  r = consumeToken(b, STRUC_TAG);
  r = r && Identifier(b, l + 1);
  r = r && Struc_2(b, l + 1);
  r = r && Struc_3(b, l + 1);
  r = r && consumeToken(b, ENDSTRUC_TAG);
  exit_section_(b, m, STRUC, r);
  return r;
}
 
Example 27
Source Project: intellij-haskforce   Source File: HaskellParser.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean itdecl_1_0(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "itdecl_1_0")) return false;
  boolean r;
  Marker m = enter_section_(b);
  r = consumeToken(b, DATA);
  if (!r) r = consumeToken(b, NEWTYPE);
  exit_section_(b, m, null, r);
  return r;
}
 
Example 28
Source Project: JetBrains-NASM-Language   Source File: NASMParser.java    License: MIT License 5 votes vote down vote up
private static boolean DataValue_2_0_1(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "DataValue_2_0_1")) return false;
  boolean r;
  Marker m = enter_section_(b);
  r = DataValue_2_0_1_0(b, l + 1);
  r = r && DataValue_2_0_1_1(b, l + 1);
  exit_section_(b, m, null, r);
  return r;
}
 
Example 29
static boolean PipeUnionMember(PsiBuilder builder_, int level_) {
  if (!recursion_guard_(builder_, level_, "PipeUnionMember")) return false;
  if (!nextTokenIs(builder_, PIPE)) return false;
  boolean result_, pinned_;
  Marker marker_ = enter_section_(builder_, level_, _NONE_);
  result_ = consumeToken(builder_, PIPE);
  pinned_ = result_; // pin = 1
  result_ = result_ && UnionMember(builder_, level_ + 1);
  exit_section_(builder_, level_, marker_, result_, pinned_, null);
  return result_ || pinned_;
}
 
Example 30
Source Project: intellij-haskforce   Source File: HaskellParser.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean typee(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "typee")) return false;
  boolean r, p;
  Marker m = enter_section_(b, l, _NONE_, TYPEE, "<typee>");
  r = btype(b, l + 1);
  p = r; // pin = 1
  r = r && typee_1(b, l + 1);
  exit_section_(b, l, m, r, p, null);
  return r || p;
}