当前位置: 首页>>代码示例>>Java>>正文


Java GroovyParser类代码示例

本文整理汇总了Java中org.jetbrains.plugins.groovy.lang.parser.GroovyParser的典型用法代码示例。如果您正苦于以下问题:Java GroovyParser类的具体用法?Java GroovyParser怎么用?Java GroovyParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GroovyParser类属于org.jetbrains.plugins.groovy.lang.parser包,在下文中一共展示了GroovyParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
public static void parse(PsiBuilder builder, GroovyParser parser) {

    PsiBuilder.Marker annArgs = builder.mark();
    if (!ParserUtils.getToken(builder, GroovyTokenTypes.mLPAREN)) {
      annArgs.done(GroovyElementTypes.ANNOTATION_ARGUMENTS);
      return;
    }

    if (builder.getTokenType() != GroovyTokenTypes.mRPAREN) {
      parsePairs(builder, parser);
    }

    ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
    ParserUtils.getToken(builder, GroovyTokenTypes.mRPAREN, GroovyBundle.message("rparen.expected"));
    annArgs.done(GroovyElementTypes.ANNOTATION_ARGUMENTS);
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AnnotationArguments.java

示例2: parseAnnotationMemberValueInitializer

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
public static boolean parseAnnotationMemberValueInitializer(PsiBuilder builder, GroovyParser parser) {
  if (builder.getTokenType() == GroovyTokenTypes.mAT) {
    return Annotation.parse(builder, parser);
  }
  else if (builder.getTokenType() == GroovyTokenTypes.mLBRACK) {
    PsiBuilder.Marker marker = builder.mark();
    ParserUtils.getToken(builder, GroovyTokenTypes.mLBRACK);
    while (parseAnnotationMemberValueInitializer(builder, parser)) {
      if (builder.eof() || builder.getTokenType() == GroovyTokenTypes.mRBRACK) break;
      ParserUtils.getToken(builder, GroovyTokenTypes.mCOMMA, GroovyBundle.message("comma.expected"));
    }

    ParserUtils.getToken(builder, GroovyTokenTypes.mRBRACK, GroovyBundle.message("rbrack.expected"));
    marker.done(GroovyElementTypes.ANNOTATION_ARRAY_INITIALIZER);
    return true;
  }

  //check
  return ConditionalExpression.parse(builder, parser) && !ParserUtils.getToken(builder, GroovyTokenTypes.mASSIGN);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AnnotationArguments.java

示例3: parsePairs

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
private static boolean parsePairs(PsiBuilder builder, GroovyParser parser) {
  PsiBuilder.Marker start = builder.mark();

  if (!parsePair(builder, parser)) {
    start.rollbackTo();
    return false;
  }

  while (ParserUtils.getToken(builder, GroovyTokenTypes.mCOMMA)) {
    ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);

    parsePair(builder, parser);
  }
  start.drop();

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AnnotationArguments.java

示例4: parseFile

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
public static void parseFile(PsiBuilder builder, GroovyParser parser) {

    ParserUtils.getToken(builder, GroovyTokenTypes.mSH_COMMENT);
    ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);

    if (!PackageDefinition.parse(builder, parser)) {
      parser.parseStatementWithImports(builder);
    }

    while (!builder.eof()) {
      if (!Separators.parse(builder)) {
        builder.error(GroovyBundle.message("separator.expected"));
      }
      if (builder.eof()) break;
      if (!parser.parseStatementWithImports(builder)) {
        ParserUtils.wrapError(builder, GroovyBundle.message("unexpected.symbol"));
      }
    }
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:CompilationUnit.java

示例5: parse

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
public static boolean parse(PsiBuilder builder, GroovyParser parser) {
  Marker pMarker = builder.mark();

  Modifiers.parse(builder, parser);

  if (!ParserUtils.getToken(builder, GroovyTokenTypes.kPACKAGE)) {
    pMarker.rollbackTo();
    return false;
  }

  if (ReferenceElement.parseForPackage(builder) == ReferenceElement.ReferenceElementResult.FAIL) {
    builder.error(GroovyBundle.message("identifier.expected"));
  }

  pMarker.done(GroovyElementTypes.PACKAGE_DEFINITION);
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PackageDefinition.java

示例6: tradForClauseParse

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
private static boolean tradForClauseParse(PsiBuilder builder, GroovyParser parser) {
  PsiBuilder.Marker marker = builder.mark();

  if (!ParameterDeclaration.parseTraditionalForParameter(builder, parser)) {
    marker.rollbackTo();
    marker = builder.mark();
    ExpressionStatement.argParse(builder, parser);
  }

  ParserUtils.getToken(builder, GroovyTokenTypes.mSEMI, GroovyBundle.message("semi.expected"));
  ExpressionStatement.argParse(builder, parser);
  ParserUtils.getToken(builder, GroovyTokenTypes.mSEMI, GroovyBundle.message("semi.expected"));
  ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
  if (!GroovyTokenTypes.mRPAREN.equals(builder.getTokenType())) {
    ExpressionStatement.argParse(builder, parser);
  }
  marker.done(GroovyElementTypes.FOR_TRADITIONAL_CLAUSE);
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ForStatement.java

示例7: parseCaseLabel

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SwitchStatement.java

示例8: parse

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
public static boolean parse(PsiBuilder builder, GroovyParser parser, boolean comExprAllowed) {
  Marker marker = builder.mark();
  final boolean isTuple = ParserUtils.lookAhead(builder, GroovyTokenTypes.mLPAREN, GroovyTokenTypes.mIDENT, GroovyTokenTypes.mCOMMA);
  if (parseSide(builder, parser, isTuple,comExprAllowed)) {
    if (ParserUtils.getToken(builder, TokenSets.ASSIGNMENTS)) {
      ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
      if (!parse(builder, parser, comExprAllowed)) {
        builder.error(GroovyBundle.message("expression.expected"));
      }
      marker.done(GroovyElementTypes.ASSIGNMENT_EXPRESSION);
    }
    else {
      if (isTuple) {
        builder.error(GroovyBundle.message("assign.expected"));
      }
      marker.drop();
    }
    return true;
  }
  else {
    marker.drop();
    return false;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AssignmentExpression.java

示例9: parseSide

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
private static boolean parseSide(PsiBuilder builder, GroovyParser parser, boolean tuple, boolean comExprAllowed) {
  if (tuple) {
    return TupleParse.parseTupleForAssignment(builder);
  }

  if (comExprAllowed) {
    Marker marker = builder.mark();
    final ExpressionStatement.Result result = ExpressionStatement.parse(builder, parser);
    switch (result) {
      case EXPR_STATEMENT:
        marker.drop();
        return true;
      case EXPRESSION:
        ConditionalExpression.parseAfterCondition(builder, parser, marker);
        return true;
      case WRONG_WAY:
        marker.rollbackTo();
    }
  }
  return ConditionalExpression.parse(builder, parser);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:AssignmentExpression.java

示例10: parseAfterModifiers

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
@Nullable
public static IElementType parseAfterModifiers(@NotNull PsiBuilder builder,
                                               boolean isInClass,
                                               boolean isInAnnotation,
                                               @Nullable String typeDefinitionName,
                                               @NotNull GroovyParser parser,
                                               boolean modifiersParsed) {
  boolean expressionPossible = !isInAnnotation && !isInClass;
  if (modifiersParsed && builder.getTokenType() == GroovyTokenTypes.mLT) {
    return parseDeclarationWithGenerics(builder, isInClass, isInAnnotation, typeDefinitionName, parser, modifiersParsed, expressionPossible);
  }
  else if (modifiersParsed) {
    return parseDeclarationWithoutGenerics(builder, isInClass, isInAnnotation, typeDefinitionName, parser, modifiersParsed, expressionPossible);
  }
  else if (typeDefinitionName != null && ParserUtils.lookAhead(builder, GroovyTokenTypes.mIDENT, GroovyTokenTypes.mLPAREN) && typeDefinitionName.equals(builder.getTokenText())) {
    //parse constructor
    return VariableDefinitions.parseDefinitions(builder, isInClass, isInAnnotation, typeDefinitionName, modifiersParsed, false, parser);
  }
  else {
    return parsePossibleCallExpression(builder, isInClass, isInAnnotation, typeDefinitionName, parser, expressionPossible);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:Declaration.java

示例11: CompoundStringExpression

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
private CompoundStringExpression(PsiBuilder builder,
                                GroovyParser parser,
                                boolean forRefExpr,
                                IElementType begin,
                                IElementType content,
                                IElementType end,
                                IElementType literal,
                                GroovyElementType compoundLiteral,
                                String message) {

  myBuilder = builder;
  myParser = parser;
  myForRefExpr = forRefExpr;
  myBegin = begin;
  myContent = content;
  myEnd = end;
  mySimpleLiteral = literal;
  myCompoundLiteral = compoundLiteral;
  myMessage = message;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CompoundStringExpression.java

示例12: parse

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
public static GroovyElementType parse(PsiBuilder builder, GroovyParser parser) {
  PsiBuilder.Marker marker = builder.mark();
  if (!ParserUtils.getToken(builder, GroovyTokenTypes.mLBRACK, GroovyBundle.message("lbrack.expected"))) {
    marker.drop();
    return GroovyElementTypes.WRONGWAY;
  }
  if (ParserUtils.getToken(builder, GroovyTokenTypes.mRBRACK)) {
    marker.done(GroovyElementTypes.LIST_OR_MAP);
    return GroovyElementTypes.LIST_OR_MAP;
  } else if (ParserUtils.getToken(builder, GroovyTokenTypes.mCOLON)) {
    ParserUtils.getToken(builder, GroovyTokenTypes.mRBRACK, GroovyBundle.message("rbrack.expected"));
  } else {
    ArgumentList.parseArgumentList(builder, GroovyTokenTypes.mRBRACK, parser);
    ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
    ParserUtils.getToken(builder, GroovyTokenTypes.mRBRACK, GroovyBundle.message("rbrack.expected"));
  }

  marker.done(GroovyElementTypes.LIST_OR_MAP);
  return GroovyElementTypes.LIST_OR_MAP;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ListOrMapConstructorExpression.java

示例13: subParse

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
private static void subParse(PsiBuilder builder, PsiBuilder.Marker marker, GroovyElementType shiftOrRange, GroovyParser parser) {
  ParserUtils.getToken(builder, RANGES);
  ParserUtils.getToken(builder, GroovyTokenTypes.mNLS);
  if (!BinaryExpression.ADDITIVE.parseBinary(builder, parser)) {
    builder.error(GroovyBundle.message("expression.expected"));
  }
  PsiBuilder.Marker newMarker = marker.precede();
  marker.done(shiftOrRange);
  GroovyElementType newShiftOrRange = isRangeOrShift(builder);
  if (RANGES.contains(builder.getTokenType()) ||
          getCompositeSign(builder)) {
    subParse(builder, newMarker, newShiftOrRange, parser);
  } else {
    newMarker.drop();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ShiftExpression.java

示例14: parse

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
public static boolean parse(PsiBuilder builder, GroovyParser parser, boolean runPostfixIfFail) {
  PsiBuilder.Marker marker = builder.mark();
  if (builder.getTokenType() == GroovyTokenTypes.mLPAREN) {
    final ReferenceElement.ReferenceElementResult result = parseTypeCast(builder);
    if (result != ReferenceElement.ReferenceElementResult.FAIL) {
      if (ConditionalExpression.parse(builder, parser) || result == ReferenceElement.ReferenceElementResult.REF_WITH_TYPE_PARAMS) {
        marker.done(GroovyElementTypes.CAST_EXPRESSION);
        return true;
      } else {
        marker.rollbackTo();
        return runPostfix(builder, parser, runPostfixIfFail);
      }
    } else {
      marker.drop();
      return runPostfix(builder, parser, runPostfixIfFail);
    }
  } else {
    marker.drop();
    return runPostfix(builder, parser, runPostfixIfFail);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:UnaryExpressionNotPlusMinus.java

示例15: parse

import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; //导入依赖的package包/类
public static boolean parse(PsiBuilder builder, GroovyParser parser) {

    PsiBuilder.Marker marker = builder.mark();
    if ((PREFIXES.contains(builder.getTokenType()))
        ? BinaryExpression.POWER.parseBinary(builder, parser)
        : PowerExpressionNotPlusMinus.parse(builder, parser)) {
      if (ParserUtils.getToken(builder, MULT_DIV)) {
        subParse(builder, parser, marker);
      }
      else {
        marker.drop();
      }
      return true;
    }
    else {
      marker.drop();
      return false;
    }
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MultiplicativeExpression.java


注:本文中的org.jetbrains.plugins.groovy.lang.parser.GroovyParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。