use of org.eclipse.jface.text.rules.WhitespaceRule 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;
}
Aggregations