@exercism/codemirror-lang-cpp 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1007 @@
1
+ import { parser } from '@exercism/lezer-cpp';
2
+ import { syntaxTree, LRLanguage, indentNodeProp, flatIndent, delimitedIndent, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
3
+ import { snippetCompletion, completeFromList } from '@codemirror/autocomplete';
4
+ import { NodeWeakMap, IterMode } from '@lezer/common';
5
+
6
+ /**
7
+ Snippets for the constructs that C and C++ share.
8
+ */
9
+ const sharedSnippets = [
10
+ /*@__PURE__*/snippetCompletion("${type} ${name}(${params}) {\n\t${}\n}", {
11
+ label: "function",
12
+ detail: "definition",
13
+ type: "keyword"
14
+ }),
15
+ /*@__PURE__*/snippetCompletion("for (int ${i} = 0; ${i} < ${n}; ${i}++) {\n\t${}\n}", {
16
+ label: "for",
17
+ detail: "loop",
18
+ type: "keyword"
19
+ }),
20
+ /*@__PURE__*/snippetCompletion("int main() {\n\t${}\n\treturn 0;\n}", {
21
+ label: "main",
22
+ detail: "function",
23
+ type: "keyword"
24
+ }),
25
+ /*@__PURE__*/snippetCompletion("if (${condition}) {\n\t${}\n}", {
26
+ label: "if",
27
+ detail: "block",
28
+ type: "keyword"
29
+ }),
30
+ /*@__PURE__*/snippetCompletion("if (${condition}) {\n\t${}\n} else {\n\t${}\n}", {
31
+ label: "if",
32
+ detail: "/ else block",
33
+ type: "keyword"
34
+ }),
35
+ /*@__PURE__*/snippetCompletion("while (${condition}) {\n\t${}\n}", {
36
+ label: "while",
37
+ detail: "loop",
38
+ type: "keyword"
39
+ }),
40
+ /*@__PURE__*/snippetCompletion("do {\n\t${}\n} while (${condition});", {
41
+ label: "do",
42
+ detail: "loop",
43
+ type: "keyword"
44
+ }),
45
+ /*@__PURE__*/snippetCompletion("switch (${value}) {\ncase ${}:\n\t${}\n\tbreak;\ndefault:\n\tbreak;\n}", {
46
+ label: "switch",
47
+ detail: "statement",
48
+ type: "keyword"
49
+ }),
50
+ /*@__PURE__*/snippetCompletion("#include <${header}>", {
51
+ label: "#include",
52
+ detail: "system header",
53
+ type: "keyword"
54
+ }),
55
+ /*@__PURE__*/snippetCompletion("#include \"${header}\"", {
56
+ label: "#include",
57
+ detail: "local header",
58
+ type: "keyword"
59
+ }),
60
+ /*@__PURE__*/snippetCompletion("#define ${NAME} ${value}", {
61
+ label: "#define",
62
+ detail: "macro",
63
+ type: "keyword"
64
+ }),
65
+ /*@__PURE__*/snippetCompletion("#ifndef ${NAME}_H\n#define ${NAME}_H\n\n${}\n\n#endif", {
66
+ label: "#ifndef",
67
+ detail: "include guard",
68
+ type: "keyword"
69
+ })
70
+ ];
71
+ /**
72
+ A collection of C-related
73
+ [snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
74
+ */
75
+ const cSnippets = /*@__PURE__*/sharedSnippets.concat([
76
+ /*@__PURE__*/snippetCompletion("struct ${name} {\n\t${}\n};", {
77
+ label: "struct",
78
+ detail: "definition",
79
+ type: "keyword"
80
+ }),
81
+ /*@__PURE__*/snippetCompletion("typedef struct {\n\t${}\n} ${name};", {
82
+ label: "typedef",
83
+ detail: "struct",
84
+ type: "keyword"
85
+ }),
86
+ /*@__PURE__*/snippetCompletion("enum ${name} {\n\t${}\n};", {
87
+ label: "enum",
88
+ detail: "definition",
89
+ type: "keyword"
90
+ })
91
+ ]);
92
+ /**
93
+ A collection of C++-related
94
+ [snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
95
+ */
96
+ const cppSnippets = /*@__PURE__*/sharedSnippets.concat([
97
+ /*@__PURE__*/snippetCompletion("for (const auto &${item} : ${items}) {\n\t${}\n}", {
98
+ label: "for",
99
+ detail: "range loop",
100
+ type: "keyword"
101
+ }),
102
+ /*@__PURE__*/snippetCompletion("class ${Name} {\npublic:\n\t${Name}(${});\n\nprivate:\n\t${}\n};", {
103
+ label: "class",
104
+ detail: "definition",
105
+ type: "keyword"
106
+ }),
107
+ /*@__PURE__*/snippetCompletion("struct ${Name} {\n\t${}\n};", {
108
+ label: "struct",
109
+ detail: "definition",
110
+ type: "keyword"
111
+ }),
112
+ /*@__PURE__*/snippetCompletion("enum class ${Name} {\n\t${}\n};", {
113
+ label: "enum",
114
+ detail: "class",
115
+ type: "keyword"
116
+ }),
117
+ /*@__PURE__*/snippetCompletion("namespace ${name} {\n\n${}\n\n} // namespace ${name}", {
118
+ label: "namespace",
119
+ detail: "block",
120
+ type: "keyword"
121
+ }),
122
+ /*@__PURE__*/snippetCompletion("try {\n\t${}\n} catch (const ${std::exception} &${e}) {\n\t${}\n}", {
123
+ label: "try",
124
+ detail: "/ catch block",
125
+ type: "keyword"
126
+ }),
127
+ /*@__PURE__*/snippetCompletion("[${&}](${params}) {\n\t${}\n}", {
128
+ label: "lambda",
129
+ detail: "expression",
130
+ type: "keyword"
131
+ }),
132
+ /*@__PURE__*/snippetCompletion("template <typename ${T}>", {
133
+ label: "template",
134
+ detail: "declaration",
135
+ type: "keyword"
136
+ }),
137
+ /*@__PURE__*/snippetCompletion("#pragma once", {
138
+ label: "#pragma",
139
+ detail: "once",
140
+ type: "keyword"
141
+ })
142
+ ]);
143
+ /**
144
+ Snippets for Objective-C. They cover C's constructs and the
145
+ Objective-C class, method, loop and literal forms.
146
+ */
147
+ const objcSnippets = /*@__PURE__*/sharedSnippets.filter(s => !/^#(include|ifndef)/.test(s.label)).concat([
148
+ /*@__PURE__*/snippetCompletion("#import <${Foundation/Foundation.h}>", {
149
+ label: "#import",
150
+ detail: "system header",
151
+ type: "keyword"
152
+ }),
153
+ /*@__PURE__*/snippetCompletion("#import \"${header}\"", {
154
+ label: "#import",
155
+ detail: "local header",
156
+ type: "keyword"
157
+ }),
158
+ /*@__PURE__*/snippetCompletion("for (${id} ${item} in ${collection}) {\n\t${}\n}", {
159
+ label: "for",
160
+ detail: "in loop",
161
+ type: "keyword"
162
+ }),
163
+ /*@__PURE__*/snippetCompletion("- (${void})${name} {\n\t${}\n}", {
164
+ label: "method",
165
+ detail: "instance method",
166
+ type: "keyword"
167
+ }),
168
+ /*@__PURE__*/snippetCompletion("+ (${void})${name} {\n\t${}\n}", {
169
+ label: "method",
170
+ detail: "class method",
171
+ type: "keyword"
172
+ }),
173
+ /*@__PURE__*/snippetCompletion("- (instancetype)init {\n\tself = [super init];\n\tif (self) {\n\t\t${}\n\t}\n\treturn self;\n}", {
174
+ label: "init",
175
+ detail: "initializer",
176
+ type: "keyword"
177
+ }),
178
+ /*@__PURE__*/snippetCompletion("typedef NS_ENUM(NSInteger, ${Name}) {\n\t${}\n};", {
179
+ label: "NS_ENUM",
180
+ detail: "enum",
181
+ type: "keyword"
182
+ }),
183
+ /*@__PURE__*/snippetCompletion("^(${params}) {\n\t${}\n}", {
184
+ label: "block",
185
+ detail: "expression",
186
+ type: "keyword"
187
+ })
188
+ ]);
189
+ /**
190
+ Snippets for the Objective-C `@` directives. They are offered when
191
+ the word being typed starts with `@`.
192
+ */
193
+ const objcDirectiveSnippets = [
194
+ /*@__PURE__*/snippetCompletion("@interface ${Name} : ${NSObject}\n\n${}\n\n@end", {
195
+ label: "@interface",
196
+ detail: "declaration",
197
+ type: "keyword"
198
+ }),
199
+ /*@__PURE__*/snippetCompletion("@implementation ${Name}\n\n${}\n\n@end", {
200
+ label: "@implementation",
201
+ detail: "definition",
202
+ type: "keyword"
203
+ }),
204
+ /*@__PURE__*/snippetCompletion("@protocol ${Name} <NSObject>\n\n${}\n\n@end", {
205
+ label: "@protocol",
206
+ detail: "declaration",
207
+ type: "keyword"
208
+ }),
209
+ /*@__PURE__*/snippetCompletion("@property (nonatomic, ${strong}) ${NSString} *${name};", {
210
+ label: "@property",
211
+ detail: "declaration",
212
+ type: "keyword"
213
+ }),
214
+ /*@__PURE__*/snippetCompletion("@try {\n\t${}\n} @catch (NSException *${exception}) {\n\t${}\n}", {
215
+ label: "@try",
216
+ detail: "/ @catch block",
217
+ type: "keyword"
218
+ }),
219
+ /*@__PURE__*/snippetCompletion("@autoreleasepool {\n\t${}\n}", {
220
+ label: "@autoreleasepool",
221
+ detail: "block",
222
+ type: "keyword"
223
+ }),
224
+ /*@__PURE__*/snippetCompletion("@selector(${name})", {
225
+ label: "@selector",
226
+ detail: "expression",
227
+ type: "keyword"
228
+ }),
229
+ /*@__PURE__*/snippetCompletion("@[${}]", {
230
+ label: "@[",
231
+ detail: "array literal",
232
+ type: "keyword"
233
+ }),
234
+ /*@__PURE__*/snippetCompletion("@{${key}: ${value}}", {
235
+ label: "@{",
236
+ detail: "dictionary literal",
237
+ type: "keyword"
238
+ })
239
+ ];
240
+
241
+ function words(str, type) {
242
+ return str.split(/\s+/).filter(w => w).map(label => ({ label, type }));
243
+ }
244
+ // Keywords and the fundamental types of C99, plus the names from
245
+ // <stdbool.h> and <stddef.h> that read like keywords.
246
+ const cKeywordNames = `
247
+ auto break case const continue default do else enum extern for goto if inline
248
+ register restrict return sizeof static struct switch typedef union volatile while
249
+ _Bool _Complex _Static_assert _Noreturn _Alignas _Alignof _Atomic _Thread_local`;
250
+ const cTypeNames = `char double float int long short signed unsigned void bool`;
251
+ const cConstantNames = `true false NULL`;
252
+ const cppKeywordNames = `
253
+ auto break case const continue default do else enum extern for goto if inline
254
+ register return sizeof static struct switch typedef union volatile while alignas alignof and and_eq bitand bitor catch class compl concept consteval
255
+ constexpr constinit const_cast co_await co_return co_yield decltype delete
256
+ dynamic_cast explicit export friend mutable namespace new noexcept not not_eq
257
+ operator or or_eq private protected public reinterpret_cast requires
258
+ static_assert static_cast template this thread_local throw try typeid typename
259
+ using virtual xor xor_eq override final`;
260
+ const cppTypeNames = `bool char char8_t char16_t char32_t double float int long short
261
+ signed unsigned void wchar_t`;
262
+ const cppConstantNames = `true false nullptr`;
263
+ /**
264
+ Keywords, fundamental types and constants for C.
265
+ */
266
+ const cKeywords = [
267
+ .../*@__PURE__*/words(cKeywordNames, "keyword"),
268
+ .../*@__PURE__*/words(cTypeNames, "type"),
269
+ .../*@__PURE__*/words(cConstantNames, "constant")
270
+ ];
271
+ /**
272
+ Keywords, fundamental types and constants for C++.
273
+ */
274
+ const cppKeywords = [
275
+ .../*@__PURE__*/words(cppKeywordNames, "keyword"),
276
+ .../*@__PURE__*/words(cppTypeNames, "type"),
277
+ .../*@__PURE__*/words(cppConstantNames, "constant")
278
+ ];
279
+ // The C standard library, grouped by header.
280
+ const cLibraryFunctions = `
281
+ printf fprintf sprintf snprintf vprintf vfprintf vsprintf vsnprintf scanf fscanf
282
+ sscanf puts fputs putchar fputc putc getchar fgetc getc fgets ungetc fopen fclose
283
+ fread fwrite fflush fseek ftell rewind feof ferror perror remove rename
284
+ malloc calloc realloc free abs labs llabs div ldiv atoi atol atoll atof strtol
285
+ strtoll strtoul strtoull strtod strtof rand srand qsort bsearch exit abort atexit
286
+ getenv system
287
+ strlen strcpy strncpy strcat strncat strcmp strncmp strchr strrchr strstr strspn
288
+ strcspn strpbrk strtok strdup strndup strerror memcpy memmove memset memcmp memchr
289
+ isalnum isalpha isblank iscntrl isdigit isgraph islower isprint ispunct isspace
290
+ isupper isxdigit tolower toupper
291
+ sqrt pow fabs floor ceil round trunc fmod exp log log2 log10 sin cos tan asin
292
+ acos atan atan2 hypot fmin fmax lround llround cbrt
293
+ assert time clock difftime mktime localtime gmtime strftime
294
+ va_start va_arg va_end va_copy`;
295
+ const cLibraryTypes = `
296
+ size_t ptrdiff_t FILE int8_t int16_t int32_t int64_t uint8_t uint16_t uint32_t
297
+ uint64_t intptr_t uintptr_t intmax_t uintmax_t time_t clock_t va_list div_t`;
298
+ const cLibraryConstants = `
299
+ EOF stdin stdout stderr EXIT_SUCCESS EXIT_FAILURE RAND_MAX INT_MAX INT_MIN UINT_MAX
300
+ LONG_MAX LONG_MIN ULONG_MAX LLONG_MAX LLONG_MIN ULLONG_MAX CHAR_BIT CHAR_MAX
301
+ CHAR_MIN SIZE_MAX INT8_MAX INT16_MAX INT32_MAX INT64_MAX UINT8_MAX UINT16_MAX
302
+ UINT32_MAX UINT64_MAX INT32_MIN INT64_MIN M_PI errno`;
303
+ /**
304
+ Names from the C standard library.
305
+ */
306
+ const cLibrary = [
307
+ .../*@__PURE__*/words(cLibraryFunctions, "function"),
308
+ .../*@__PURE__*/words(cLibraryTypes, "type"),
309
+ .../*@__PURE__*/words(cLibraryConstants, "constant")
310
+ ];
311
+ // Members of namespace std that common exercises use most.
312
+ const stdTypes = `
313
+ string string_view wstring vector array deque list forward_list map multimap set
314
+ multiset unordered_map unordered_set unordered_multimap unordered_multiset stack
315
+ queue priority_queue pair tuple optional variant any function unique_ptr
316
+ shared_ptr weak_ptr size_t ptrdiff_t int8_t int16_t int32_t int64_t uint8_t
317
+ uint16_t uint32_t uint64_t istream ostream iostream stringstream istringstream
318
+ ostringstream ifstream ofstream exception runtime_error logic_error
319
+ invalid_argument out_of_range domain_error length_error range_error
320
+ overflow_error underflow_error bad_alloc initializer_list numeric_limits
321
+ iterator reverse_iterator back_insert_iterator bitset complex regex smatch
322
+ mt19937 random_device uniform_int_distribution uniform_real_distribution
323
+ mutex lock_guard thread`;
324
+ const stdFunctions = `
325
+ sort stable_sort partial_sort nth_element reverse rotate shuffle unique remove
326
+ remove_if replace replace_if fill fill_n copy copy_if copy_n move swap transform
327
+ for_each find find_if find_if_not count count_if all_of any_of none_of equal
328
+ mismatch search min max minmax min_element max_element minmax_element clamp
329
+ lower_bound upper_bound binary_search equal_range merge includes set_union
330
+ set_intersection set_difference next_permutation prev_permutation iota
331
+ accumulate reduce inner_product partial_sum adjacent_difference gcd lcm abs
332
+ pow sqrt floor ceil round trunc fmod log log2 log10 exp sin cos tan atan2 hypot
333
+ to_string to_chars from_chars stoi stol stoll stoul stoull stof stod getline
334
+ make_pair make_tuple make_unique make_shared make_optional tie get begin end
335
+ rbegin rend cbegin cend size empty distance next prev advance back_inserter
336
+ inserter isalpha isdigit isalnum isspace isupper islower ispunct toupper
337
+ tolower exchange forward as_const ref cref hash`;
338
+ const stdObjects = `cout cin cerr clog endl npos ios`;
339
+ const stdNamespaces = `chrono ranges views literals filesystem this_thread`;
340
+ /**
341
+ The fixed-width integer types and `size_t`, which C++ code often
342
+ uses without `std::`.
343
+ */
344
+ const cppGlobalTypes = /*@__PURE__*/words(cLibraryTypes, "type")
345
+ .filter(c => /_t$/.test(c.label));
346
+ /**
347
+ Names in namespace `std`, offered after `std::`, and on their own
348
+ when the file has `using namespace std;`.
349
+ */
350
+ const stdNames = [
351
+ .../*@__PURE__*/words(stdTypes, "class"),
352
+ .../*@__PURE__*/words(stdFunctions, "function"),
353
+ .../*@__PURE__*/words(stdObjects, "variable"),
354
+ .../*@__PURE__*/words(stdNamespaces, "namespace")
355
+ ];
356
+ const cHeaderNames = `
357
+ assert.h complex.h ctype.h errno.h fenv.h float.h inttypes.h iso646.h limits.h
358
+ locale.h math.h setjmp.h signal.h stdarg.h stdbool.h stddef.h stdint.h stdio.h
359
+ stdlib.h string.h tgmath.h time.h wchar.h wctype.h`;
360
+ const cppHeaderNames = `
361
+ algorithm any array atomic bitset cassert cctype cerrno cfloat charconv chrono
362
+ climits clocale cmath complex concepts condition_variable cstddef cstdint cstdio
363
+ cstdlib cstring ctime deque exception execution filesystem format forward_list
364
+ fstream functional future initializer_list iomanip ios iosfwd iostream istream
365
+ iterator limits list map memory mutex numeric optional ostream queue random
366
+ ranges ratio regex set span sstream stack stdexcept string string_view thread
367
+ tuple type_traits typeinfo unordered_map unordered_set utility valarray variant
368
+ vector`;
369
+ /**
370
+ Header names offered inside `#include <...>` in C.
371
+ */
372
+ const cHeaders = /*@__PURE__*/words(cHeaderNames, "namespace");
373
+ /**
374
+ Header names offered inside `#include <...>` in C++.
375
+ */
376
+ const cppHeaders = /*@__PURE__*/words(cppHeaderNames, "namespace");
377
+ // Objective-C adds these to C's keywords and types.
378
+ const objcKeywordNames = `self super in typeof nullable nonnull __block __weak __strong
379
+ __kindof __unsafe_unretained`;
380
+ const objcTypeNames = `id instancetype BOOL SEL Class IMP NSInteger NSUInteger CGFloat
381
+ NSRange NSComparisonResult NSTimeInterval unichar`;
382
+ const objcConstantNames = `nil Nil YES NO NSNotFound NSOrderedAscending NSOrderedSame
383
+ NSOrderedDescending`;
384
+ /**
385
+ Keywords, types and constants for Objective-C, including C's.
386
+ */
387
+ const objcKeywords = [
388
+ ...cKeywords,
389
+ .../*@__PURE__*/words(objcKeywordNames, "keyword"),
390
+ .../*@__PURE__*/words(objcTypeNames, "type"),
391
+ .../*@__PURE__*/words(objcConstantNames, "constant")
392
+ ];
393
+ // The Foundation classes and functions that Exercism solutions use most.
394
+ const foundationClasses = `
395
+ NSObject NSString NSMutableString NSArray NSMutableArray NSDictionary
396
+ NSMutableDictionary NSSet NSMutableSet NSCountedSet NSOrderedSet NSNumber NSValue
397
+ NSNull NSData NSDate NSDateComponents NSDateFormatter NSCalendar NSTimeZone
398
+ NSLocale NSCharacterSet NSMutableCharacterSet NSScanner NSRegularExpression
399
+ NSTextCheckingResult NSPredicate NSSortDescriptor NSIndexSet NSMutableIndexSet
400
+ NSError NSException NSEnumerator NSNumberFormatter NSDecimalNumber
401
+ NSAttributedString NSProcessInfo NSBundle NSFileManager NSURL NSUUID`;
402
+ const foundationFunctions = `
403
+ NSLog NSMakeRange NSMaxRange NSLocationInRange NSStringFromClass
404
+ NSStringFromSelector NSSelectorFromString NSClassFromString NSStringFromRange
405
+ NSEqualRanges NSUnionRange NSIntersectionRange`;
406
+ const foundationConstants = `
407
+ NSIntegerMax NSIntegerMin NSUIntegerMax NSCaseInsensitiveSearch NSLiteralSearch
408
+ NSBackwardsSearch NSAnchoredSearch NSNumericSearch NSUTF8StringEncoding
409
+ NSRegularExpressionCaseInsensitive NSCalendarUnitYear NSCalendarUnitMonth
410
+ NSCalendarUnitDay NSCalendarUnitWeekday NSCalendarUnitHour NSCalendarUnitMinute
411
+ NSCalendarUnitSecond NSCalendarIdentifierGregorian`;
412
+ /**
413
+ The common classes, functions and constants of Foundation.
414
+ */
415
+ const foundationNames = [
416
+ .../*@__PURE__*/words(foundationClasses, "class"),
417
+ .../*@__PURE__*/words(foundationFunctions, "function"),
418
+ .../*@__PURE__*/words(foundationConstants, "constant")
419
+ ];
420
+ // The Foundation methods that Exercism solutions send most. A selector
421
+ // with arguments keeps its colons, and completing it inserts the first
422
+ // part with its colon.
423
+ const foundationSelectorNames = `
424
+ alloc init new copy mutableCopy description class isKindOfClass: isMemberOfClass:
425
+ respondsToSelector: isEqual: hash
426
+ length characterAtIndex: substringFromIndex: substringToIndex: substringWithRange:
427
+ stringByAppendingString: stringByAppendingFormat: stringWithFormat: stringWithString:
428
+ initWithFormat: initWithString: stringByReplacingOccurrencesOfString:withString:
429
+ stringByTrimmingCharactersInSet: componentsSeparatedByString:
430
+ componentsSeparatedByCharactersInSet: componentsJoinedByString: rangeOfString:
431
+ rangeOfCharacterFromSet: hasPrefix: hasSuffix: containsString: isEqualToString:
432
+ compare: caseInsensitiveCompare: uppercaseString lowercaseString capitalizedString
433
+ intValue integerValue doubleValue floatValue boolValue longLongValue
434
+ unsignedIntegerValue stringValue appendString: appendFormat: insertString:atIndex:
435
+ deleteCharactersInRange: reverseObjectEnumerator
436
+ count objectAtIndex: firstObject lastObject containsObject: indexOfObject:
437
+ arrayWithObjects: arrayWithArray: arrayWithCapacity: array addObject:
438
+ addObjectsFromArray: insertObject:atIndex: removeObject: removeObjectAtIndex:
439
+ removeLastObject removeAllObjects replaceObjectAtIndex:withObject:
440
+ exchangeObjectAtIndex:withObjectAtIndex: sortedArrayUsingSelector:
441
+ sortedArrayUsingComparator: sortUsingComparator: sortUsingSelector:
442
+ filteredArrayUsingPredicate: enumerateObjectsUsingBlock: arrayByAddingObject:
443
+ subarrayWithRange: valueForKey: valueForKeyPath:
444
+ objectForKey: setObject:forKey: removeObjectForKey: allKeys allValues
445
+ dictionaryWithObjects:forKeys: dictionaryWithDictionary: dictionary
446
+ enumerateKeysAndObjectsUsingBlock: keysSortedByValueUsingSelector:
447
+ setWithArray: setWithObjects: set member: unionSet: intersectSet: minusSet:
448
+ countForObject: allObjects
449
+ numberWithInt: numberWithInteger: numberWithDouble: numberWithBool:
450
+ numberWithUnsignedInteger: numberWithLongLong:
451
+ characterIsMember: letterCharacterSet decimalDigitCharacterSet
452
+ whitespaceCharacterSet whitespaceAndNewlineCharacterSet punctuationCharacterSet
453
+ alphanumericCharacterSet uppercaseLetterCharacterSet lowercaseLetterCharacterSet
454
+ characterSetWithCharactersInString: invertedSet
455
+ regularExpressionWithPattern:options:error: matchesInString:options:range:
456
+ numberOfMatchesInString:options:range: firstMatchInString:options:range:
457
+ stringByReplacingMatchesInString:options:range:withTemplate:
458
+ predicateWithFormat: predicateWithBlock: currentCalendar components:fromDate:
459
+ dateFromComponents: dateByAddingTimeInterval: dateWithTimeInterval:sinceDate:
460
+ timeIntervalSinceDate: dateFromString: stringFromDate: setDateFormat:
461
+ raise:format: exceptionWithName:reason:userInfo:`;
462
+ /**
463
+ Common Foundation selectors, offered after the receiver of a message.
464
+ */
465
+ const foundationSelectors = /*@__PURE__*/words(foundationSelectorNames, "method");
466
+ // The `@` directives and literals.
467
+ const objcDirectiveNames = `
468
+ @interface @implementation @end @protocol @class @property @synthesize @dynamic
469
+ @optional @required @private @protected @public @package @import @selector
470
+ @encode @try @catch @finally @throw @autoreleasepool @synchronized @YES @NO`;
471
+ /**
472
+ The Objective-C `@` directives.
473
+ */
474
+ const objcDirectives = /*@__PURE__*/words(objcDirectiveNames, "keyword");
475
+ const objcHeaderNames = `Foundation/Foundation.h`;
476
+ /**
477
+ Header names offered inside `#import <...>` and `#include <...>` in
478
+ Objective-C.
479
+ */
480
+ const objcHeaders = [
481
+ .../*@__PURE__*/words(objcHeaderNames, "namespace"),
482
+ ...cHeaders
483
+ ];
484
+
485
+ const cache = /*@__PURE__*/new NodeWeakMap();
486
+ // Names declared directly inside one of these nodes are visible only
487
+ // inside it.
488
+ const ScopeNodes = /*@__PURE__*/new Set([
489
+ "Program", "CompoundStatement", "FunctionDefinition", "LambdaExpression",
490
+ "ForStatement", "ForRangeLoop", "IfStatement", "SwitchStatement", "WhileStatement",
491
+ "CatchClause", "FieldDeclarationList",
492
+ "MethodDefinition", "BlockExpression", "ForInStatement"
493
+ ]);
494
+ // Inside these, a name is visible only after its declaration. Names at
495
+ // the top of the file and in a class body are offered everywhere, since
496
+ // a function can be declared in a header or defined lower down.
497
+ const OrderedScopes = /*@__PURE__*/new Set([
498
+ "CompoundStatement", "FunctionDefinition", "LambdaExpression", "ForStatement",
499
+ "ForRangeLoop", "IfStatement", "SwitchStatement", "WhileStatement", "CatchClause",
500
+ "MethodDefinition", "BlockExpression", "ForInStatement"
501
+ ]);
502
+ // A namespace body is a CompoundStatement, but its names stay visible
503
+ // in the rest of the file, as they do in most Exercism solutions,
504
+ // which put everything in one namespace. The instance variables of an
505
+ // Objective-C class are visible in all of its methods, which may be in
506
+ // another part of the file.
507
+ function isScope(node) {
508
+ var _a;
509
+ if (!ScopeNodes.has(node.name))
510
+ return false;
511
+ let parent = (_a = node.node.parent) === null || _a === void 0 ? void 0 : _a.name;
512
+ if (node.name == "CompoundStatement" && parent == "NamespaceDefinition")
513
+ return false;
514
+ if (node.name == "FieldDeclarationList" && (parent == "ClassInterface" || parent == "ClassImplementation"))
515
+ return false;
516
+ return true;
517
+ }
518
+ const Declarators = /*@__PURE__*/new Set([
519
+ "PointerDeclarator", "ReferenceDeclarator", "ArrayDeclarator", "FunctionDeclarator",
520
+ "ParenthesizedDeclarator", "InitDeclarator", "StructuredBindingDeclarator"
521
+ ]);
522
+ const NameNodes = /*@__PURE__*/new Set(["Identifier", "FieldIdentifier", "TypeIdentifier"]);
523
+ const TypeSpecifiers = /*@__PURE__*/new Set(["StructSpecifier", "ClassSpecifier", "UnionSpecifier", "EnumSpecifier"]);
524
+ // Find the names declared by a declarator such as `*p`, `arr[3]` or
525
+ // `f(int x)`. Only the first named child of each declarator holds the
526
+ // name. The rest are sizes, parameters and initial values.
527
+ function declaratorNames(node, type, def) {
528
+ if (NameNodes.has(node.name)) {
529
+ def(node, type);
530
+ }
531
+ else if (node.name == "StructuredBindingDeclarator") {
532
+ for (let ch = node.firstChild; ch; ch = ch.nextSibling)
533
+ if (ch.name == "Identifier")
534
+ def(ch, type);
535
+ }
536
+ else if (Declarators.has(node.name)) {
537
+ let isFunction = node.name == "FunctionDeclarator";
538
+ for (let ch = node.firstChild; ch; ch = ch.nextSibling) {
539
+ if (NameNodes.has(ch.name) || Declarators.has(ch.name)) {
540
+ declaratorNames(ch, isFunction ? "function" : type, def);
541
+ break;
542
+ }
543
+ }
544
+ }
545
+ }
546
+ // Call `declaratorNames` on the direct children of a declaration that
547
+ // are declarators. The type comes first, so a TypeIdentifier is a name
548
+ // only after it, as in `typedef int number;`. A constructor declaration
549
+ // such as `C(int v);` has no type at all.
550
+ function declaredNames(type) {
551
+ return (node, def) => {
552
+ let sawType = false;
553
+ for (let ch = node.node.firstChild; ch; ch = ch.nextSibling) {
554
+ if (TypeSpecifiers.has(ch.name))
555
+ gatherCompletions[ch.name](ch, def);
556
+ let isName = NameNodes.has(ch.name) && (sawType || ch.name != "TypeIdentifier");
557
+ if (isName || Declarators.has(ch.name)) {
558
+ declaratorNames(ch, ch.name == "TypeIdentifier" ? "type" : type, def);
559
+ }
560
+ else if (!sawType && !ch.type.isError && /^[A-Z]/.test(ch.name) && ch.name != "Attribute") {
561
+ sawType = true;
562
+ }
563
+ }
564
+ // Parameter names inside a function declarator belong to the
565
+ // function, so the search stops here.
566
+ return true;
567
+ };
568
+ }
569
+ function typeName(type) {
570
+ return (node, def) => {
571
+ // In `NS_ENUM(NSInteger, Kind)`, the second type is the new one.
572
+ let name = node.node.getChild("NS_ENUM") ? node.node.getChildren("TypeIdentifier").pop()
573
+ : node.node.getChild("TypeIdentifier");
574
+ if (name)
575
+ def(name, type);
576
+ // Enumerators of a plain `enum` are visible next to the enum. Those
577
+ // of `enum class` are not.
578
+ if (node.name == "EnumSpecifier" && !node.node.getChild("class") && !node.node.getChild("struct")) {
579
+ let list = node.node.getChild("EnumeratorList");
580
+ if (list)
581
+ for (let e of list.getChildren("Enumerator")) {
582
+ let id = e.getChild("Identifier");
583
+ if (id)
584
+ def(id, "constant");
585
+ }
586
+ }
587
+ return true;
588
+ };
589
+ }
590
+ // In `for (auto &item : items)`, the first name or declarator is the
591
+ // loop variable and the second name is the range.
592
+ function rangeLoopNames(node, def) {
593
+ for (let ch = node.firstChild; ch; ch = ch.nextSibling)
594
+ if (Declarators.has(ch.name) || ch.name == "Identifier") {
595
+ declaratorNames(ch, "variable", def);
596
+ break;
597
+ }
598
+ }
599
+ const gatherCompletions = {
600
+ Declaration: /*@__PURE__*/declaredNames("variable"),
601
+ FieldDeclaration: /*@__PURE__*/declaredNames("property"),
602
+ ParameterDeclaration: /*@__PURE__*/declaredNames("variable"),
603
+ OptionalParameterDeclaration: /*@__PURE__*/declaredNames("variable"),
604
+ TypeDefinition: /*@__PURE__*/declaredNames("type"),
605
+ // The parser reads `int x{};` in a class body as a function with an
606
+ // empty body, so the name is a function only if it has parameters.
607
+ FunctionDefinition: /*@__PURE__*/declaredNames("variable"),
608
+ StructSpecifier: /*@__PURE__*/typeName("class"),
609
+ ClassSpecifier: /*@__PURE__*/typeName("class"),
610
+ UnionSpecifier: /*@__PURE__*/typeName("class"),
611
+ EnumSpecifier: /*@__PURE__*/typeName("enum"),
612
+ AliasDeclaration: (node, def) => {
613
+ let name = node.node.getChild("TypeIdentifier");
614
+ if (name)
615
+ def(name, "type");
616
+ return true;
617
+ },
618
+ TypeParameterDeclaration: (node, def) => {
619
+ let name = node.node.getChild("TypeIdentifier");
620
+ if (name)
621
+ def(name, "type");
622
+ return true;
623
+ },
624
+ // `using std::string;` makes `string` available on its own.
625
+ UsingDeclaration: (node, def) => {
626
+ let scoped = node.node.getChild("ScopedIdentifier");
627
+ let name = scoped === null || scoped === void 0 ? void 0 : scoped.getChild("Identifier");
628
+ if (name && !node.node.getChild("namespace"))
629
+ def(name, "type");
630
+ return true;
631
+ },
632
+ NamespaceDefinition: (node, def) => {
633
+ let name = node.node.getChild("Identifier");
634
+ if (name)
635
+ def(name, "namespace");
636
+ return false;
637
+ },
638
+ // Objective-C. A class name and its instance variables and properties
639
+ // are visible in the whole file. A method's parameters are visible in
640
+ // its body, but those of a method declaration are not visible at all.
641
+ ClassInterface: (node, def) => {
642
+ let name = node.node.getChild("TypeIdentifier");
643
+ if (name)
644
+ def(name, "class");
645
+ return false;
646
+ },
647
+ ClassImplementation: (node, def) => {
648
+ let name = node.node.getChild("TypeIdentifier");
649
+ if (name)
650
+ def(name, "class");
651
+ return false;
652
+ },
653
+ ProtocolDeclaration: (node, def) => {
654
+ for (let name of node.node.getChildren("TypeIdentifier"))
655
+ def(name, "interface");
656
+ return true;
657
+ },
658
+ ClassDeclaration: (node, def) => {
659
+ for (let name of node.node.getChildren("TypeIdentifier"))
660
+ def(name, "class");
661
+ return true;
662
+ },
663
+ // `@property NSString *name;` gives `name` and its instance variable `_name`.
664
+ PropertyDeclaration: (node, def) => {
665
+ declaredNames("property")(node, (name, type) => {
666
+ def(name, type);
667
+ def(name, "variable", "_");
668
+ });
669
+ return true;
670
+ },
671
+ MethodDeclaration: () => true,
672
+ KeywordDeclarator: (node, def) => {
673
+ let name = node.node.getChild("Identifier");
674
+ if (name)
675
+ def(name, "variable");
676
+ return true;
677
+ },
678
+ PreprocDirective: (node, def) => {
679
+ let first = node.node.firstChild;
680
+ if ((first === null || first === void 0 ? void 0 : first.name) == "#define") {
681
+ let name = node.node.getChild("Identifier");
682
+ if (name)
683
+ def(name, "constant");
684
+ }
685
+ return true;
686
+ },
687
+ __proto__: null
688
+ };
689
+ function getScope(doc, node) {
690
+ let cached = cache.get(node);
691
+ if (cached)
692
+ return cached;
693
+ let completions = [], top = true;
694
+ function def(node, type, prefix = "") {
695
+ let name = prefix + doc.sliceString(node.from, node.to);
696
+ completions.push({ option: { label: name, type }, at: node.from });
697
+ }
698
+ if (node.name == "ForRangeLoop" || node.name == "ForInStatement")
699
+ rangeLoopNames(node, def);
700
+ node.cursor(IterMode.IncludeAnonymous).iterate(node => {
701
+ if (top) {
702
+ top = false;
703
+ }
704
+ else if (node.name) {
705
+ let gather = gatherCompletions[node.name];
706
+ if (gather && gather(node, def) || isScope(node))
707
+ return false;
708
+ }
709
+ else if (node.to - node.from > 8192) {
710
+ // Allow caching for bigger internal nodes
711
+ for (let c of getScope(doc, node.node))
712
+ completions.push(c);
713
+ return false;
714
+ }
715
+ });
716
+ cache.set(node, completions);
717
+ return completions;
718
+ }
719
+ const Identifier = /^[\w$\xa1-￿][\w$\d\xa1-￿]*$/;
720
+ /**
721
+ Nodes inside which no completion is offered: strings, comments,
722
+ the names after `.` and `->`, and Objective-C selectors, which
723
+ have their own source.
724
+ */
725
+ const dontComplete = [
726
+ "String", "RawString", "CharLiteral", "SystemLibString",
727
+ "LineComment", "BlockComment", "FieldIdentifier", "StatementIdentifier",
728
+ "SelectorName", "CategoryName", ".", "->", "::"
729
+ ];
730
+ /**
731
+ Completion source that looks up the names declared in the file
732
+ (functions, types, variables, parameters, fields and macros), and
733
+ offers each one where it is in scope.
734
+ */
735
+ const localCompletionSource = context => {
736
+ if (afterAccessor(context))
737
+ return null;
738
+ let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
739
+ if (dontComplete.indexOf(inner.name) > -1)
740
+ return null;
741
+ let isWord = inner.name == "Identifier" || inner.name == "TypeIdentifier" ||
742
+ inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
743
+ if (!isWord && !context.explicit)
744
+ return null;
745
+ let options = [], seen = new Set();
746
+ for (let pos = inner; pos; pos = pos.parent) {
747
+ if (isScope(pos))
748
+ for (let { option, at } of getScope(context.state.doc, pos)) {
749
+ if (at >= context.pos && OrderedScopes.has(pos.name))
750
+ continue;
751
+ if (seen.has(option.label))
752
+ continue;
753
+ seen.add(option.label);
754
+ options.push(option);
755
+ }
756
+ }
757
+ return {
758
+ options,
759
+ from: isWord ? inner.from : context.pos,
760
+ validFor: Identifier
761
+ };
762
+ };
763
+ function includeBefore(context) {
764
+ let line = context.state.doc.lineAt(context.pos);
765
+ return /^\s*#\s*(?:include|import)\s*[<"]([\w./]*)$/.exec(line.text.slice(0, context.pos - line.from));
766
+ }
767
+ function inInclude(context) {
768
+ return includeBefore(context) != null;
769
+ }
770
+ // True when the word being typed follows `.`, `->` or `::`, or is a
771
+ // header name in `#include`. Member and namespace names are handled by
772
+ // their own sources, or not at all.
773
+ function afterAccessor(context) {
774
+ if (inInclude(context))
775
+ return true;
776
+ let word = context.matchBefore(/\w*/);
777
+ let before = context.state.sliceDoc(Math.max(0, (word ? word.from : context.pos) - 3), word ? word.from : context.pos);
778
+ return /(\.|->|::)\s*$/.test(before);
779
+ }
780
+ /**
781
+ Wrap a completion source so that it offers nothing inside strings
782
+ and comments, or after `.`, `->` or `::`.
783
+ */
784
+ function generalSource(source) {
785
+ return context => {
786
+ let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
787
+ for (let pos = inner; pos; pos = pos.parent)
788
+ if (dontComplete.indexOf(pos.name) > -1)
789
+ return null;
790
+ if (afterAccessor(context))
791
+ return null;
792
+ return source(context);
793
+ };
794
+ }
795
+ /**
796
+ Completion source for the names in namespace `std`. It offers them
797
+ after `std::`, and anywhere names are completed when the file says
798
+ `using namespace std;`.
799
+ */
800
+ function stdCompletionSource(names) {
801
+ return context => {
802
+ let line = context.state.doc.lineAt(context.pos);
803
+ let before = line.text.slice(0, context.pos - line.from);
804
+ let qualified = /\bstd\s*::\s*(\w*)$/.exec(before);
805
+ if (qualified) {
806
+ let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
807
+ for (let pos = inner; pos; pos = pos.parent)
808
+ if (dontComplete.indexOf(pos.name) > -1 && pos.name != "::")
809
+ return null;
810
+ return { from: context.pos - qualified[1].length, options: names, validFor: /^\w*$/ };
811
+ }
812
+ if (!/\busing\s+namespace\s+std\s*;/.test(context.state.sliceDoc()))
813
+ return null;
814
+ return generalSource(context => {
815
+ let word = context.matchBefore(/\w+/);
816
+ if (!word && !context.explicit)
817
+ return null;
818
+ return { from: word ? word.from : context.pos, options: names, validFor: /^\w*$/ };
819
+ })(context);
820
+ };
821
+ }
822
+ /**
823
+ Completion source for header names inside `#include <...>`.
824
+ */
825
+ function headerCompletionSource(headers) {
826
+ return (context) => {
827
+ let m = includeBefore(context);
828
+ if (!m || !/<[\w./]*$/.test(m[0]))
829
+ return null;
830
+ return { from: context.pos - m[1].length, options: headers, validFor: /^[\w./]*$/ };
831
+ };
832
+ }
833
+ // Method heads declare selectors, so they get no selector completion.
834
+ const MethodHeads = /*@__PURE__*/new Set(["MethodDeclaration", "MethodDefinition", "PropertyAttribute"]);
835
+ // The selector of a method declared in the file, such as `initWithA:b:`.
836
+ function selectorOf(doc, method) {
837
+ let parts = method.getChildren("KeywordDeclarator");
838
+ if (!parts.length) {
839
+ let name = method.getChild("SelectorName");
840
+ return name ? doc.sliceString(name.from, name.to) : null;
841
+ }
842
+ return parts.map(p => {
843
+ let name = p.getChild("SelectorName");
844
+ return (name ? doc.sliceString(name.from, name.to) : "") + ":";
845
+ }).join("");
846
+ }
847
+ function fileSelectors(doc, tree) {
848
+ let found = [];
849
+ tree.cursor().iterate(node => {
850
+ if (node.name == "MethodDeclaration" || node.name == "MethodDefinition") {
851
+ let label = selectorOf(doc, node.node);
852
+ if (label)
853
+ found.push({ label, type: "method" });
854
+ return false;
855
+ }
856
+ });
857
+ return found;
858
+ }
859
+ // Completing `setObject:forKey:` inserts `setObject:`, so that the
860
+ // first argument comes next.
861
+ function firstPart(option) {
862
+ let colon = option.label.indexOf(":");
863
+ return colon < 0 || colon == option.label.length - 1 ? option : Object.assign(Object.assign({}, option), { apply: option.label.slice(0, colon + 1) });
864
+ }
865
+ /**
866
+ Completion source for Objective-C selectors. Where a message names
867
+ its method, as in `[list add|`, it offers the given selectors and
868
+ the selectors of the methods declared in the file.
869
+ */
870
+ function selectorCompletionSource(selectors) {
871
+ return context => {
872
+ let tree = syntaxTree(context.state);
873
+ let inner = tree.resolveInner(context.pos, -1);
874
+ if (inner.name != "SelectorName")
875
+ return null;
876
+ for (let pos = inner.parent; pos; pos = pos.parent)
877
+ if (MethodHeads.has(pos.name) || pos.name == "SelectorExpression")
878
+ return null;
879
+ let seen = new Set(), options = [];
880
+ for (let option of fileSelectors(context.state.doc, tree.topNode).concat(selectors)) {
881
+ if (seen.has(option.label))
882
+ continue;
883
+ seen.add(option.label);
884
+ options.push(firstPart(option));
885
+ }
886
+ return { from: inner.from, options, validFor: /^\w*$/ };
887
+ };
888
+ }
889
+ /**
890
+ Completion source for the Objective-C `@` directives, offered when
891
+ the word being typed starts with `@`.
892
+ */
893
+ function directiveCompletionSource(options) {
894
+ return context => {
895
+ let word = context.matchBefore(/@\w*/);
896
+ if (!word)
897
+ return null;
898
+ let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
899
+ for (let pos = inner; pos; pos = pos.parent)
900
+ if (pos.name == "String" || pos.name == "LineComment" || pos.name == "BlockComment")
901
+ return null;
902
+ return { from: word.from, options, validFor: /^@\w*$/ };
903
+ };
904
+ }
905
+ /**
906
+ Wrap a completion source so that it offers nothing when the word
907
+ being typed starts with `@`, where only directives make sense.
908
+ */
909
+ function notAfterAt(source) {
910
+ return context => context.matchBefore(/@\w*/) ? null : source(context);
911
+ }
912
+
913
+ /**
914
+ A language provider based on Exercism's fork of the [Lezer C++
915
+ parser](https://code.haverbeke.berlin/lezer/cpp), extended with
916
+ highlighting and indentation information.
917
+ */
918
+ const cppLanguage = /*@__PURE__*/LRLanguage.define({
919
+ name: "cpp",
920
+ parser: /*@__PURE__*/parser.configure({
921
+ props: [
922
+ /*@__PURE__*/indentNodeProp.add({
923
+ IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }),
924
+ TryStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|catch)\b/ }),
925
+ LabeledStatement: flatIndent,
926
+ CaseStatement: context => context.baseIndent + context.unit,
927
+ BlockComment: () => null,
928
+ CompoundStatement: /*@__PURE__*/delimitedIndent({ closing: "}" }),
929
+ Statement: /*@__PURE__*/continuedIndent({ except: /^{/ }),
930
+ "MessageExpression ArrayLiteral": /*@__PURE__*/delimitedIndent({ closing: "]" }),
931
+ DictionaryLiteral: /*@__PURE__*/delimitedIndent({ closing: "}" })
932
+ }),
933
+ /*@__PURE__*/foldNodeProp.add({
934
+ "DeclarationList CompoundStatement EnumeratorList FieldDeclarationList InitializerList": foldInside,
935
+ "ArrayLiteral DictionaryLiteral": foldInside,
936
+ // An Objective-C class or protocol folds from the end of its
937
+ // first line to its `@end`.
938
+ "ClassInterface ClassImplementation ProtocolDeclaration"(tree, state) {
939
+ let end = tree.lastChild;
940
+ if (!end || end.name != "@end")
941
+ return null;
942
+ let from = state.doc.lineAt(tree.from).to;
943
+ return from < end.from ? { from, to: end.from } : null;
944
+ },
945
+ BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; }
946
+ })
947
+ ]
948
+ }),
949
+ languageData: {
950
+ commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
951
+ indentOnInput: /^\s*(?:case |default:|\{|\})$/,
952
+ closeBrackets: { stringPrefixes: ["L", "u", "U", "u8", "LR", "UR", "uR", "u8R", "R"] }
953
+ }
954
+ });
955
+ /**
956
+ Language support for C++. Includes
957
+ [snippet](https://codemirror.net/6/docs/ref/#lang-cpp.cppSnippets), keyword, standard library and
958
+ local name completion.
959
+ */
960
+ function cpp() {
961
+ return new LanguageSupport(cppLanguage, [
962
+ cppLanguage.data.of({
963
+ autocomplete: generalSource(completeFromList(cppSnippets.concat(cppKeywords, cppGlobalTypes)))
964
+ }),
965
+ cppLanguage.data.of({ autocomplete: stdCompletionSource(stdNames) }),
966
+ cppLanguage.data.of({ autocomplete: headerCompletionSource(cppHeaders) }),
967
+ cppLanguage.data.of({ autocomplete: localCompletionSource })
968
+ ]);
969
+ }
970
+ /**
971
+ Language support for C. It uses the C++ parser, which also parses
972
+ C, and completes C's keywords, standard library and
973
+ [snippets](https://codemirror.net/6/docs/ref/#lang-cpp.cSnippets) along with local names.
974
+ */
975
+ function c() {
976
+ return new LanguageSupport(cppLanguage, [
977
+ cppLanguage.data.of({
978
+ autocomplete: generalSource(completeFromList(cSnippets.concat(cKeywords, cLibrary)))
979
+ }),
980
+ cppLanguage.data.of({ autocomplete: headerCompletionSource(cHeaders) }),
981
+ cppLanguage.data.of({ autocomplete: localCompletionSource })
982
+ ]);
983
+ }
984
+ /**
985
+ A language provider for Objective-C, using the parser's `objc`
986
+ dialect.
987
+ */
988
+ const objcLanguage = /*@__PURE__*/cppLanguage.configure({ dialect: "objc" }, "objc");
989
+ /**
990
+ Language support for Objective-C. Includes C's keywords and
991
+ library, the Objective-C keywords, types and `@` directives, the
992
+ common Foundation classes, functions and methods,
993
+ [snippets](https://codemirror.net/6/docs/ref/#lang-cpp.objcSnippets), and local names.
994
+ */
995
+ function objc() {
996
+ return new LanguageSupport(objcLanguage, [
997
+ objcLanguage.data.of({
998
+ autocomplete: notAfterAt(generalSource(completeFromList(objcSnippets.concat(objcKeywords, cLibrary, foundationNames))))
999
+ }),
1000
+ objcLanguage.data.of({ autocomplete: directiveCompletionSource(objcDirectiveSnippets.concat(objcDirectives)) }),
1001
+ objcLanguage.data.of({ autocomplete: selectorCompletionSource(foundationSelectors) }),
1002
+ objcLanguage.data.of({ autocomplete: headerCompletionSource(objcHeaders) }),
1003
+ objcLanguage.data.of({ autocomplete: localCompletionSource })
1004
+ ]);
1005
+ }
1006
+
1007
+ export { c, cSnippets, cpp, cppLanguage, cppSnippets, localCompletionSource, objc, objcLanguage, objcSnippets, selectorCompletionSource };