Ejemplo n.º 1
0
 private IElementType parseMemberDeclarationRest(boolean isEnum) {
   IElementType keywordToken = tt();
   IElementType declType = null;
   if (keywordToken == CLASS_KEYWORD) {
     if (lookahead(1) == OBJECT_KEYWORD) {
       declType = parseClassObject();
     } else {
       declType = parseClass(isEnum);
     }
   } else if (keywordToken == TRAIT_KEYWORD) {
     declType = parseClass(isEnum);
   } else if (keywordToken == FUN_KEYWORD) {
     declType = parseFunction();
   } else if (keywordToken == VAL_KEYWORD || keywordToken == VAR_KEYWORD) {
     declType = parseProperty();
   } else if (keywordToken == TYPE_KEYWORD) {
     declType = parseTypeDef();
   } else if (keywordToken == OBJECT_KEYWORD) {
     parseObject(true, true);
     declType = OBJECT_DECLARATION;
   } else if (keywordToken == LBRACE) {
     parseBlock();
     declType = ANONYMOUS_INITIALIZER;
   }
   return declType;
 }
Ejemplo n.º 2
0
  /*
   * toplevelObject
   *   : namespace
   *   : class
   *   : extension
   *   : function
   *   : property
   *   : typedef
   *   : object
   *   ;
   */
  private void parseTopLevelObject() {
    PsiBuilder.Marker decl = mark();

    TokenDetector detector = new TokenDetector(ENUM_KEYWORD);
    parseModifierList(MODIFIER_LIST, detector, true);

    IElementType keywordToken = tt();
    IElementType declType = null;
    //        if (keywordToken == PACKAGE_KEYWORD) {
    //            declType = parseNamespaceBlock();
    //        }
    //        else
    if (keywordToken == CLASS_KEYWORD || keywordToken == TRAIT_KEYWORD) {
      declType = parseClass(detector.isDetected());
    } else if (keywordToken == FUN_KEYWORD) {
      declType = parseFunction();
    } else if (keywordToken == VAL_KEYWORD || keywordToken == VAR_KEYWORD) {
      declType = parseProperty();
    } else if (keywordToken == TYPE_KEYWORD) {
      declType = parseTypeDef();
    } else if (keywordToken == OBJECT_KEYWORD) {
      parseObject(true, true);
      declType = OBJECT_DECLARATION;
    }

    if (declType == null) {
      errorAndAdvance("Expecting package directive or top level declaration");
      decl.drop();
    } else {
      decl.done(declType);
    }
  }
Ejemplo n.º 3
0
  /*
   * classObject
   *   : modifiers "class" object
   *   ;
   */
  private JetNodeType parseClassObject() {
    assert _at(CLASS_KEYWORD) && lookahead(1) == OBJECT_KEYWORD;

    advance(); // CLASS_KEYWORD

    PsiBuilder.Marker objectDeclaration = mark();
    parseObject(false, true);
    objectDeclaration.done(OBJECT_DECLARATION);

    return CLASS_OBJECT;
  }