View Javadoc

    1   package net.sourceforge.pmd.parsers;
    2
    3   import net.sourceforge.pmd.ast.JavaCharStream;
    4   import net.sourceforge.pmd.ast.JavaParser;
    5   import net.sourceforge.pmd.ast.ParseException;
    6
    7   import java.io.Reader;
    8   import java.util.Map;
    9
    10  /**
    11   * Adapter for the JavaParser, using Java 1.7 grammar.
    12   *
    13   */
    14  public class Java17Parser implements Parser {
    15
    16      private JavaParser parser;
    17      private String marker;
    18
    19      public Object parse(Reader source) throws ParseException {
    20          parser = new JavaParser(new JavaCharStream(source));
    21          parser.setJDK15();
    22          parser.setExcludeMarker(marker);
    23          return parser.CompilationUnit();
    24      }
    25
    26      public Map<Integer, String> getExcludeMap() {
    27          return parser.getExcludeMap();
    28      }
    29
    30      public void setExcludeMarker(String marker) {
    31          this.marker = marker;
    32      }
    33
    34  }