55
55
56
56
interface
57
57
58
+ { $IFDEF SYN_COMPILER_12_UP}
59
+ { $DEFINE USE_TABLE_DICTIONARY}
60
+ { $ENDIF}
61
+
58
62
uses
59
63
{ $IFDEF SYN_CLX}
60
64
Types,
@@ -71,6 +75,9 @@ interface
71
75
SynHighlighterHashEntries,
72
76
SynUnicode,
73
77
{ $ENDIF}
78
+ { $IFDEF USE_TABLE_DICTIONARY}
79
+ Generics.Collections,
80
+ { $ENDIF}
74
81
SysUtils,
75
82
Classes;
76
83
@@ -93,6 +100,9 @@ TSynSQLSyn = class(TSynCustomHighlighter)
93
100
fKeywords: TSynHashEntryList;
94
101
fProcNames: TUnicodeStrings;
95
102
fTableNames: TUnicodeStrings;
103
+ { $IFDEF USE_TABLE_DICTIONARY}
104
+ fTableDict: TDictionary<string, Boolean>;
105
+ { $ENDIF}
96
106
fFunctionNames: TUniCodeStrings;
97
107
fDialect: TSQLDialect;
98
108
fCommentAttri: TSynHighlighterAttributes;
@@ -1238,7 +1248,12 @@ function TSynSQLSyn.IdentKind(MayBe: PWideChar): TtkTokenKind;
1238
1248
end ;
1239
1249
Entry := Entry.Next;
1240
1250
end ;
1241
- Result := tkIdentifier;
1251
+ { $IFDEF USE_TABLE_DICTIONARY}
1252
+ if fTableDict.ContainsKey(SynWideLowerCase(Copy(StrPas(fToIdent), 1 , fStringLen))) then
1253
+ Result := tkTableName
1254
+ else
1255
+ { $ENDIF}
1256
+ Result := tkIdentifier;
1242
1257
end ;
1243
1258
1244
1259
constructor TSynSQLSyn.Create(AOwner: TComponent);
@@ -1254,6 +1269,9 @@ constructor TSynSQLSyn.Create(AOwner: TComponent);
1254
1269
1255
1270
fTableNames := TUnicodeStringList.Create;
1256
1271
TUnicodeStringList(fTableNames).OnChange := TableNamesChanged;
1272
+ { $IFDEF USE_TABLE_DICTIONARY}
1273
+ fTableDict := TDictionary<string, Boolean>.Create;
1274
+ { $ENDIF}
1257
1275
1258
1276
fFunctionNames := TunicodeStringList.Create;
1259
1277
TUnicodeStringList(fFunctionNames).OnChange := FunctionNamesChanged;
@@ -1317,6 +1335,9 @@ destructor TSynSQLSyn.Destroy;
1317
1335
fKeywords.Free;
1318
1336
fProcNames.Free;
1319
1337
fTableNames.Free;
1338
+ { $IFDEF USE_TABLE_DICTIONARY}
1339
+ fTableDict.Free;
1340
+ { $ENDIF}
1320
1341
fFunctionNames.Free;
1321
1342
inherited Destroy;
1322
1343
end ;
@@ -1895,7 +1916,12 @@ procedure TSynSQLSyn.PutTableNamesInKeywordList;
1895
1916
Entry := Entry.Next;
1896
1917
end ;
1897
1918
if not Assigned(Entry) then
1919
+ { $IFDEF USE_TABLE_DICTIONARY}
1920
+ if not fTableDict.ContainsKey(SynWideLowerCase(fTableNames[i])) then
1921
+ fTableDict.Add(SynWideLowerCase(fTableNames[i]), True);
1922
+ { $ELSE}
1898
1923
DoAddKeyword(fTableNames[i], Ord(tkTableName));
1924
+ { $ENDIF}
1899
1925
end ;
1900
1926
end ;
1901
1927
@@ -1946,6 +1972,9 @@ procedure TSynSQLSyn.InitializeKeywordLists;
1946
1972
{ $ELSE}
1947
1973
fKeywords.Clear;
1948
1974
{ $ENDIF}
1975
+ { $IFDEF USE_TABLE_DICTIONARY}
1976
+ fTableDict.Clear;
1977
+ { $ENDIF}
1949
1978
1950
1979
for I := 0 to Ord(High(TtkTokenKind)) - 1 do
1951
1980
EnumerateKeywords(I, GetKeywords(I), IsIdentChar, DoAddKeyword);
0 commit comments