@@ -116,9 +116,11 @@ object CodeRules {
116
116
" string|bool|double|float|bytes" ,
117
117
" int32|uint32|sint32|int64|unit64|sint64" ,
118
118
" map" ),
119
- " required|repeated|optional|option|oneof|default|reserved" ,
120
- " package|import" ,
121
- " rpc|returns" )
119
+ keywords = arrayOf(
120
+ " required|repeated|optional|option|oneof|default|reserved" ,
121
+ " package|import" ,
122
+ " rpc|returns" )
123
+ )
122
124
123
125
val pythonRules = createGenericCodeRules<R , S >(
124
126
codeStyleProviders,
@@ -133,12 +135,12 @@ object CodeRules {
133
135
.toMatchGroupRule(stylesProvider = codeStyleProviders.genericsStyleProvider)),
134
136
definitions = arrayOf(" class" , " def" , " lambda" ),
135
137
builtIns = arrayOf(" True|False|None" ),
136
- " from|import|global|nonlocal" ,
137
- " async|await|class|self|cls|def|lambda" ,
138
- " for|while|if|else|elif|break|continue|return" ,
139
- " try|except|finally|raise|pass|yeild" ,
140
- " in|as|is|del" ,
141
- " and|or|not|assert" ,
138
+ keywords = arrayOf( " from|import|global|nonlocal" ,
139
+ " async|await|class|self|cls|def|lambda" ,
140
+ " for|while|if|else|elif|break|continue|return" ,
141
+ " try|except|finally|raise|pass|yeild" ,
142
+ " in|as|is|del" ,
143
+ " and|or|not|assert" )
142
144
)
143
145
144
146
val rustRules = createGenericCodeRules<R , S >(
@@ -157,11 +159,11 @@ object CodeRules {
157
159
" Arc|Rc|Box|Pin|Future" ,
158
160
" true|false|bool|usize|i64|u64|u32|i32|str|String"
159
161
),
160
- " let|mut|static|const|unsafe" ,
161
- " crate|mod|extern|pub|pub(super)|use" ,
162
- " struct|enum|trait|type|where|impl|dyn|async|await|move|self|fn" ,
163
- " for|while|loop|if|else|match|break|continue|return|try" ,
164
- " in|as|ref" ,
162
+ keywords = arrayOf( " let|mut|static|const|unsafe" ,
163
+ " crate|mod|extern|pub|pub(super)|use" ,
164
+ " struct|enum|trait|type|where|impl|dyn|async|await|move|self|fn" ,
165
+ " for|while|loop|if|else|match|break|continue|return|try" ,
166
+ " in|as|ref" )
165
167
)
166
168
167
169
val xmlRules = listOf<Rule <R , Node <R >, S >> (
@@ -203,6 +205,16 @@ object CodeRules {
203
205
builtIns = JavaScript .BUILT_INS ,
204
206
keywords = JavaScript .KEYWORDS )
205
207
208
+ val typescriptRules = createGenericCodeRules<R , S >(
209
+ codeStyleProviders,
210
+ additionalRules = TypeScript .createCodeRules(codeStyleProviders),
211
+ definitions = arrayOf(" class" , " interface" , " enum" ,
212
+ " namespace" , " module" , " type" ),
213
+ builtIns = TypeScript .BUILT_INS ,
214
+ keywords = TypeScript .KEYWORDS ,
215
+ types = TypeScript .TYPES
216
+ )
217
+
206
218
return mapOf (
207
219
" kt" to kotlinRules,
208
220
" kotlin" to kotlinRules,
@@ -228,6 +240,9 @@ object CodeRules {
228
240
229
241
" js" to javascriptRules,
230
242
" javascript" to javascriptRules,
243
+
244
+ " ts" to typescriptRules,
245
+ " typescript" to typescriptRules
231
246
)
232
247
}
233
248
@@ -237,13 +252,17 @@ object CodeRules {
237
252
private fun <R , S > createGenericCodeRules (
238
253
codeStyleProviders : CodeStyleProviders <R >,
239
254
additionalRules : List <Rule <R , Node <R >, S >>,
240
- definitions : Array <String >, builtIns : Array <String >, vararg keywords : String
255
+ definitions : Array <String >,
256
+ builtIns : Array <String >,
257
+ keywords : Array <String >,
258
+ types : Array <String > = arrayOf(" ")
241
259
): List <Rule <R , Node <R >, S>> =
242
260
additionalRules +
243
261
listOf (
244
262
createDefinitionRule(codeStyleProviders, * definitions),
245
263
createWordPattern(* builtIns).toMatchGroupRule(stylesProvider = codeStyleProviders.genericsStyleProvider),
246
264
createWordPattern(* keywords).toMatchGroupRule(stylesProvider = codeStyleProviders.keywordStyleProvider),
265
+ createWordPattern(* types).toMatchGroupRule(stylesProvider = codeStyleProviders.typesStyleProvider),
247
266
PATTERN_NUMBERS .toMatchGroupRule(stylesProvider = codeStyleProviders.literalStyleProvider),
248
267
PATTERN_LEADING_WS_CONSUMER .toMatchGroupRule(),
249
268
PATTERN_TEXT .toMatchGroupRule(),
0 commit comments