View Javadoc
1   ///////////////////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code and other text files for adherence to a set of rules.
3   // Copyright (C) 2001-2024 the original author or authors.
4   //
5   // This library is free software; you can redistribute it and/or
6   // modify it under the terms of the GNU Lesser General Public
7   // License as published by the Free Software Foundation; either
8   // version 2.1 of the License, or (at your option) any later version.
9   //
10  // This library is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // Lesser General Public License for more details.
14  //
15  // You should have received a copy of the GNU Lesser General Public
16  // License along with this library; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  ///////////////////////////////////////////////////////////////////////////////////////////////
19  
20  package com.puppycrawl.tools.checkstyle.grammar;
21  
22  /**
23   * This interface is used to be notified by parser about comments
24   * in the parsed code.
25   *
26   * @noinspection ClassOnlyUsedInOnePackage
27   * @noinspectionreason ClassOnlyUsedInOnePackage - we restrict all parsing to a single package
28   */
29  public interface CommentListener {
30  
31      /**
32       * Report the location of a single-line comment that extends from the
33       * given point to the end of the line. The type of comment is identified
34       * by a String whose value depends on the language being parsed, but would
35       * typically be the delimiter for the comment.
36       *
37       * @param type an identifier for what type of comment it is.
38       * @param startLineNo the starting line number
39       * @param startColNo the starting column number
40       */
41      void reportSingleLineComment(String type,
42                                   int startLineNo, int startColNo);
43  
44      /**
45       * Report the location of a block comment that can span multiple lines.
46       * The type of comment is identified by a String whose value depends on
47       * the language being parsed, but would typically be the delimiter for the
48       * comment.
49       *
50       * @param type an identifier for what type of comment it is.
51       * @param startLineNo the starting line number
52       * @param startColNo the starting column number
53       * @param endLineNo the ending line number
54       * @param endColNo the ending column number
55       */
56      void reportBlockComment(String type,
57                              int startLineNo, int startColNo,
58                              int endLineNo, int endColNo);
59  
60  }