xref: /OpenGrok/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/sql/SQLAnalyzer.java (revision 5d9f3aa0ca3da3a714233f987fa732f62c0965f6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * See LICENSE.txt included in this distribution for the specific
9  * language governing permissions and limitations under the License.
10  *
11  * When distributing Covered Code, include this CDDL HEADER in each
12  * file and include the License file at LICENSE.txt.
13  * If applicable, add the following below this CDDL HEADER, with the
14  * fields enclosed by brackets "[]" replaced with your own identifying
15  * information: Portions Copyright [yyyy] [name of copyright owner]
16  *
17  * CDDL HEADER END
18  */
19 
20 /*
21  * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
22  * Portions Copyright (c) 2017, 2020, Chris Fraire <cfraire@me.com>.
23  */
24 package org.opengrok.indexer.analysis.sql;
25 
26 import java.io.Reader;
27 
28 import org.opengrok.indexer.analysis.AbstractAnalyzer;
29 import org.opengrok.indexer.analysis.AnalyzerFactory;
30 import org.opengrok.indexer.analysis.JFlexTokenizer;
31 import org.opengrok.indexer.analysis.JFlexXref;
32 import org.opengrok.indexer.analysis.plain.PlainAnalyzer;
33 
34 public class SQLAnalyzer extends PlainAnalyzer {
35 
SQLAnalyzer(AnalyzerFactory factory)36     public SQLAnalyzer(AnalyzerFactory factory) {
37         super(factory, () -> new JFlexTokenizer(new SQLSymbolTokenizer(
38                 AbstractAnalyzer.DUMMY_READER)));
39     }
40 
41     /**
42      * @return {@code "SQL"}
43      */
44     @Override
getCtagsLang()45     public String getCtagsLang() {
46         return "SQL";
47     }
48 
49     /**
50      * Gets a version number to be used to tag processed documents so that
51      * re-analysis can be re-done later if a stored version number is different
52      * from the current implementation.
53      * @return 20191216_00
54      */
55     @Override
getSpecializedVersionNo()56     protected int getSpecializedVersionNo() {
57         return 20191216_00; // Edit comment above too!
58     }
59 
60     /**
61      * Creates a wrapped {@link SQLXref} instance.
62      * @param reader the data to produce xref for
63      * @return a defined instance
64      */
65     @Override
newXref(Reader reader)66     protected JFlexXref newXref(Reader reader) {
67         return new JFlexXref(new SQLXref(reader));
68     }
69 }
70