001: /*
002: * AnsiSQLTokenMarker.java
003: *
004: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005: *
006: * Copyright 2002-2007, Thomas Kellerer
007: * No part of this code maybe reused without the permission of the author
008: *
009: * To contact the author please send an email to: support@sql-workbench.net
010: *
011: */
012: package workbench.gui.editor;
013:
014: import java.util.Collection;
015: import workbench.sql.syntax.SqlKeywordHelper;
016: import workbench.sql.wbcommands.WbCall;
017: import workbench.sql.wbcommands.WbConfirm;
018: import workbench.sql.wbcommands.WbCopy;
019: import workbench.sql.wbcommands.WbDefinePk;
020: import workbench.sql.wbcommands.WbDefineVar;
021: import workbench.sql.wbcommands.WbDisableOraOutput;
022: import workbench.sql.wbcommands.WbEnableOraOutput;
023: import workbench.sql.wbcommands.WbEndBatch;
024: import workbench.sql.wbcommands.WbExport;
025: import workbench.sql.wbcommands.WbFeedback;
026: import workbench.sql.wbcommands.WbImport;
027: import workbench.sql.wbcommands.WbInclude;
028: import workbench.sql.wbcommands.WbListPkDef;
029: import workbench.sql.wbcommands.WbListVars;
030: import workbench.sql.wbcommands.WbLoadPkMapping;
031: import workbench.sql.wbcommands.WbRemoveVar;
032: import workbench.sql.wbcommands.WbSavePkMapping;
033: import workbench.sql.wbcommands.WbSchemaDiff;
034: import workbench.sql.wbcommands.WbSchemaReport;
035: import workbench.sql.wbcommands.WbSelectBlob;
036: import workbench.sql.wbcommands.WbStartBatch;
037: import workbench.sql.wbcommands.WbXslt;
038:
039: /**
040: * @author support@sql-workbench.net
041: */
042: public class AnsiSQLTokenMarker extends SQLTokenMarker {
043: public AnsiSQLTokenMarker() {
044: super ();
045: initKeywordMap();
046: }
047:
048: public void setSqlKeyWords(Collection<String> keywords) {
049: this .addKeywordList(keywords, Token.KEYWORD1);
050: }
051:
052: public void setSqlFunctions(Collection<String> functions) {
053: this .addKeywordList(functions, Token.KEYWORD3);
054: }
055:
056: private void addKeywordList(Collection<String> words, byte anId) {
057: if (words == null)
058: return;
059:
060: for (String keyword : words) {
061: if (!keywords.containsKey(keyword)) {
062: keywords.add(keyword.toUpperCase().trim(), anId);
063: }
064: }
065: }
066:
067: public void setIsMySQL(boolean flag) {
068: this .isMySql = flag;
069: }
070:
071: public void initKeywordMap() {
072: keywords = new KeywordMap(true, 80);
073: addKeywords();
074: addDataTypes();
075: addSystemFunctions();
076: addOperators();
077: }
078:
079: private void addKeywords() {
080: SqlKeywordHelper helper = new SqlKeywordHelper();
081: addKeywordList(helper.getKeywords(), Token.KEYWORD1);
082:
083: // Workbench specific keywords
084: keywords.add("DESC", Token.KEYWORD2);
085: keywords.add("DESCRIBE", Token.KEYWORD2);
086: keywords.add("WBLIST", Token.KEYWORD2);
087: keywords.add("WBLISTPROCS", Token.KEYWORD2);
088: keywords.add("WBLISTDB", Token.KEYWORD2);
089: keywords.add("WBLISTCAT", Token.KEYWORD2);
090: keywords.add(WbConfirm.VERB, Token.KEYWORD2);
091: keywords.add(WbEnableOraOutput.VERB, Token.KEYWORD2);
092: keywords.add(WbDisableOraOutput.VERB, Token.KEYWORD2);
093: keywords.add(WbExport.VERB, Token.KEYWORD2);
094: keywords.add(WbImport.VERB, Token.KEYWORD2);
095: keywords.add(WbFeedback.VERB, Token.KEYWORD2);
096: keywords.add(WbInclude.VERB, Token.KEYWORD2);
097: keywords.add(WbCopy.VERB, Token.KEYWORD2);
098: keywords.add(WbDefineVar.VERB_DEFINE_SHORT, Token.KEYWORD2);
099: keywords.add(WbDefineVar.VERB_DEFINE_LONG, Token.KEYWORD2);
100: keywords.add(WbListVars.VERB, Token.KEYWORD2);
101: keywords.add(WbRemoveVar.VERB, Token.KEYWORD2);
102: keywords.add(WbStartBatch.VERB, Token.KEYWORD2);
103: keywords.add(WbEndBatch.VERB, Token.KEYWORD2);
104: keywords.add(WbFeedback.VERB, Token.KEYWORD2);
105: keywords.add(WbSchemaReport.VERB, Token.KEYWORD2);
106: keywords.add(WbSchemaDiff.VERB, Token.KEYWORD2);
107: keywords.add(WbXslt.VERB, Token.KEYWORD2);
108: keywords.add(WbSelectBlob.VERB, Token.KEYWORD2);
109: keywords.add(WbDefinePk.VERB, Token.KEYWORD2);
110: keywords.add(WbListPkDef.VERB, Token.KEYWORD2);
111: keywords.add(WbSavePkMapping.VERB, Token.KEYWORD2);
112: keywords.add(WbLoadPkMapping.VERB, Token.KEYWORD2);
113: keywords.add(WbCall.VERB, Token.KEYWORD2);
114: }
115:
116: private void addDataTypes() {
117: SqlKeywordHelper helper = new SqlKeywordHelper();
118: addKeywordList(helper.getDataTypes(), Token.KEYWORD1);
119: }
120:
121: private void addSystemFunctions() {
122: SqlKeywordHelper helper = new SqlKeywordHelper();
123: addKeywordList(helper.getSystemFunctions(), Token.KEYWORD3);
124: }
125:
126: private void addOperators() {
127: SqlKeywordHelper helper = new SqlKeywordHelper();
128: addKeywordList(helper.getOperators(), Token.KEYWORD1);
129: }
130: }
|