View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.plsql;
5   
6   import java.io.Reader;
7   import java.util.HashMap;
8   import java.util.Map;
9   
10  import net.sourceforge.pmd.lang.AbstractParser;
11  import net.sourceforge.pmd.lang.ParserOptions;
12  import net.sourceforge.pmd.lang.TokenManager;
13  import net.sourceforge.pmd.lang.ast.AbstractTokenManager;
14  import net.sourceforge.pmd.lang.ast.Node;
15  import net.sourceforge.pmd.lang.ast.ParseException;
16  import net.sourceforge.pmd.util.IOUtil;
17  
18  /**
19   * Adapter for the PLSQLParser.
20   */
21  public class PLSQLParser extends AbstractParser {
22      public PLSQLParser(ParserOptions parserOptions) {
23          super(parserOptions);
24      }
25  
26      @Override
27      public TokenManager createTokenManager(Reader source) {
28          return new PLSQLTokenManager(IOUtil.skipBOM(source));
29      }
30  
31      /**
32       * Subclass should override this method to modify the PLSQLParser as needed.
33       */
34      protected net.sourceforge.pmd.lang.plsql.ast.PLSQLParser createPLSQLParser(Reader source) throws ParseException {
35          Reader in = IOUtil.skipBOM(source);
36          // Wrapped PLSQL AST Parser
37          net.sourceforge.pmd.lang.plsql.ast.PLSQLParser parser = new net.sourceforge.pmd.lang.plsql.ast.PLSQLParser(in);
38          return parser;
39      }
40  
41      public boolean canParse() {
42          return true;
43      }
44  
45      public Node parse(String fileName, Reader source) throws ParseException {
46          AbstractTokenManager.setFileName(fileName);
47          return createPLSQLParser(source).Input();
48      }
49  
50      public Map<Integer, String> getSuppressMap() {
51          return new HashMap<>(); // FIXME
52      }
53  }