Search in sources :

Example 1 with StructuredCommentException

use of net.sourceforge.sqlexplorer.parsers.scp.StructuredCommentException in project tdq-studio-se by Talend.

the class BasicQueryParser method parse.

/* (non-JavaDoc)
	 * @see net.sourceforge.sqlexplorer.parsers.QueryParser#parse()
	 */
public void parse() throws ParserException {
    if (sql == null)
        return;
    Preferences prefs = SQLExplorerPlugin.getDefault().getPluginPreferences();
    if (prefs.getBoolean(IConstants.ENABLE_STRUCTURED_COMMENTS)) {
        StringBuffer buffer = new StringBuffer(sql.toString());
        Tokenizer tokenizer = new Tokenizer(buffer);
        StructuredCommentParser structuredComments = new StructuredCommentParser(this, buffer);
        // Otherwise just use a standard tokenizer
        try {
            Token token;
            while ((token = tokenizer.nextToken()) != null) {
                if (token.getTokenType() == Tokenizer.TokenType.EOL_COMMENT || token.getTokenType() == Tokenizer.TokenType.ML_COMMENT) {
                    structuredComments.addComment(token);
                }
            }
        } catch (StructuredCommentException e) {
        }
        // Do the structured comments and then reset the tokenizer
        structuredComments.process();
        tokenizer.reset();
        tokenizer = null;
        sql = buffer;
    }
    _sQuerys = prepareSQL(sql.toString());
    _sNextQuery = doParse();
    sql = null;
}
Also used : StructuredCommentParser(net.sourceforge.sqlexplorer.parsers.scp.StructuredCommentParser) StructuredCommentException(net.sourceforge.sqlexplorer.parsers.scp.StructuredCommentException) Token(net.sourceforge.sqlexplorer.parsers.Tokenizer.Token) Preferences(org.eclipse.core.runtime.Preferences) StringTokenizer(java.util.StringTokenizer)

Aggregations

StringTokenizer (java.util.StringTokenizer)1 Token (net.sourceforge.sqlexplorer.parsers.Tokenizer.Token)1 StructuredCommentException (net.sourceforge.sqlexplorer.parsers.scp.StructuredCommentException)1 StructuredCommentParser (net.sourceforge.sqlexplorer.parsers.scp.StructuredCommentParser)1 Preferences (org.eclipse.core.runtime.Preferences)1