final Node parsePackageContent()

in FlexPMD/flex-pmd-java/as3-parser/src/main/java/de/bokelberg/flex/parser/AS3Parser.java [264:331]


   final Node parsePackageContent() throws TokenException
   {
      final Node result = Node.create( NodeKind.CONTENT,
                                       tok.getLine(),
                                       tok.getColumn() );
      final List< Token > modifiers = new ArrayList< Token >();
      final List< Node > meta = new ArrayList< Node >();

      while ( !tokIs( Operators.RIGHT_CURLY_BRACKET )
            && !tokIs( KeyWords.EOF ) )
      {
         if ( tokIs( KeyWords.IMPORT ) )
         {
            result.addChild( parseImport() );
         }
         else if ( tokIs( KeyWords.USE ) )
         {
            result.addChild( parseUse() );
         }
         else if ( tokIs( Operators.LEFT_SQUARE_BRACKET ) )
         {
            meta.add( parseMetaData() );
         }
         else if ( tokIs( KeyWords.CLASS ) )
         {
            result.addChild( parseClass( meta,
                                         modifiers ) );

            modifiers.clear();
            meta.clear();
         }
         else if ( tokIs( KeyWords.INTERFACE ) )
         {
            result.addChild( parseInterface( meta,
                                             modifiers ) );
            modifiers.clear();
            meta.clear();
         }
         else if ( tokIs( KeyWords.FUNCTION ) )
         {
            parseClassFunctions( result,
                                 modifiers,
                                 meta );
         }
         else if ( tok.getText().startsWith( ASDOC_COMMENT ) )
         {
            currentAsDoc = Node.create( NodeKind.AS_DOC,
                                        tok.getLine(),
                                        tok.getColumn(),
                                        tok.getText() );
            nextToken();
         }
         else if ( tok.getText().startsWith( MULTIPLE_LINES_COMMENT ) )
         {
            currentMultiLineComment = Node.create( NodeKind.MULTI_LINE_COMMENT,
                                                   tok.getLine(),
                                                   tok.getColumn(),
                                                   tok.getText() );
            nextToken();
         }
         else
         {
            modifiers.add( tok );
            nextTokenIgnoringDocumentation();
         }
      }
      return result;
   }