private static List<Token> getDeclaratorInlineComment(AstNode declarator) {
    List<Token> comments;

    // inline comments are attached to the next AST node (not sibling,
    // because the last attribute inline comment is attached to the next
    // node of the parent)
    AstNode next = declarator.getNextAstNode();

    // inline documentation may be on the next definition token
    // or next curly brace
    if (next != null) {
      // discard COMMA and SEMICOLON
      if (next.getToken().getType() == CxxPunctuator.COMMA
          || next.getToken().getType() == CxxPunctuator.SEMICOLON) {
        next = next.getNextAstNode();
      }

      comments = getInlineDocumentation(next.getToken(), declarator.getTokenLine());
    } else {
      // could happen on parse error ?
      comments = new ArrayList<>();
    }

    return comments;
  }
 @Override
 public void visitNode(AstNode astNode) {
   if (astNode
       .getNextAstNode()
       .is(
           EcmaScriptGrammar.CASE_CLAUSE,
           EcmaScriptGrammar.DEFAULT_CLAUSE,
           EcmaScriptGrammar.CASE_CLAUSES)) {
     AstNode statementList = astNode.getFirstChild(EcmaScriptGrammar.STATEMENT_LIST);
     if (statementList != null
         && statementList
             .getLastChild()
             .getFirstChild()
             .isNot(
                 EcmaScriptGrammar.BREAK_STATEMENT,
                 EcmaScriptGrammar.RETURN_STATEMENT,
                 EcmaScriptGrammar.THROW_STATEMENT)) {
       getContext()
           .createLineViolation(
               this,
               "Last statement in this switch-clause should be an unconditional break.",
               astNode);
     }
   }
 }
  private void visitEnumSpecifier(AstNode enumSpecifierNode) {
    AstNode enumIdNode = enumSpecifierNode.getFirstDescendant(GenericTokenType.IDENTIFIER);

    String enumId = (enumIdNode == null) ? UNNAMED_ENUM_ID : enumIdNode.getTokenValue();

    if (!isPublicApiMember(enumSpecifierNode)) {
      logDebug(enumId + " not in public API");
      return;
    }

    visitPublicApi(enumSpecifierNode, enumId, getBlockDocumentation(enumSpecifierNode));

    // deal with enumeration values
    AstNode enumeratorList = enumSpecifierNode.getFirstDescendant(CxxGrammarImpl.enumeratorList);

    if (enumeratorList != null) {
      for (AstNode definition : enumeratorList.getChildren(CxxGrammarImpl.enumeratorDefinition)) {

        // look for block documentation
        List<Token> comments = getBlockDocumentation(definition);

        // look for inlined doc
        if (comments.isEmpty()) {
          AstNode next = definition.getNextAstNode();

          // inline documentation may be on the next definition token
          // or next curly brace
          if (next != null) {
            // discard COMMA
            if (next.getToken().getType() == CxxPunctuator.COMMA) {
              next = next.getNextAstNode();
            }

            comments = getInlineDocumentation(next.getToken(), definition.getTokenLine());
          }
        }

        visitPublicApi(
            definition,
            definition.getFirstDescendant(GenericTokenType.IDENTIFIER).getTokenValue(),
            comments);
      }
    }
  }
 private static boolean isCallToDispatchEvent(AstNode primaryExpr) {
   return "dispatchEvent".equals(primaryExpr.getTokenValue())
       && primaryExpr.getNextAstNode().is(FlexGrammar.ARGUMENTS)
       && primaryExpr.getNextAstNode().getFirstChild(FlexGrammar.LIST_EXPRESSION) != null;
 }