Search in sources :

Example 1 with SingleLineRule

use of org.eclipse.jface.text.rules.SingleLineRule in project tdi-studio-se by Talend.

the class SQLCodeScanner method createRules.

/*
     * @see AbstractJavaScanner#createRules()
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
protected synchronized List createRules() {
    List rules = new ArrayList();
    // Add rule for character constants.
    Token token = getToken(IConstants.SQL_STRING);
    //$NON-NLS-2$ //$NON-NLS-1$
    rules.add(new SingleLineRule("'", "'", token, '\\'));
    // Add generic whitespace rule.
    rules.add(new WhitespaceRule(new org.talend.sqlbuilder.sqleditor.SQLWhitespaceDetector()));
    // Add word rule for keywords, types, and constants.
    token = getToken(IConstants.SQL_DEFAULT);
    // WordRule wordRule= new WordRule(new
    // org.gnu.amaz.SQLEditor.util.SQLWordDetector(), token);
    // UnsignedWordRule wordRule= new UnsignedWordRule(new
    // net.sourceforge.jfacedbc.sqleditor.SQLWordDetector(), token);
    UnsignedWordRule wordRule = new UnsignedWordRule(new SQLWordDetector(), token, getToken(IConstants.SQL_TABLE), getToken(IConstants.SQL_COLUMS), dictionary);
    token = getToken(IConstants.SQL_KEYWORD);
    for (int i = 0; i < fgKeywords.length; i++) {
        wordRule.addWord(fgKeywords[i], token);
    }
    for (int i = 0; i < sqlFunctions.length; i++) {
        wordRule.addWord(sqlFunctions[i], token);
    }
    token = getToken(IConstants.SQL_TABLE);
    if (dictionary != null) {
        Iterator it = dictionary.getTableNames();
        while (it.hasNext()) {
            wordRule.addWord(it.next().toString(), token);
        }
        it = dictionary.getCatalogSchemaNames();
        while (it.hasNext()) {
            wordRule.addWord(it.next().toString(), token);
        }
    }
    rules.add(wordRule);
    setDefaultReturnToken(getToken(IConstants.SQL_DEFAULT));
    return rules;
}
Also used : SingleLineRule(org.eclipse.jface.text.rules.SingleLineRule) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IToken(org.eclipse.jface.text.rules.IToken) Token(org.eclipse.jface.text.rules.Token) WhitespaceRule(org.eclipse.jface.text.rules.WhitespaceRule)

Aggregations

ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IToken (org.eclipse.jface.text.rules.IToken)1 SingleLineRule (org.eclipse.jface.text.rules.SingleLineRule)1 Token (org.eclipse.jface.text.rules.Token)1 WhitespaceRule (org.eclipse.jface.text.rules.WhitespaceRule)1