|
| 1 | +// SYNTAX TEST "Packages/C#/C#.sublime-syntax" |
| 2 | + |
| 3 | +namespace CustomExtensionMembers; |
| 4 | + |
| 5 | +public static class MyExtensions |
| 6 | +{ |
| 7 | + extension(string str) |
| 8 | +//^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.body.cs meta.block.cs |
| 9 | +// ^^^^^^^^^ keyword.declaration.trait.cs |
| 10 | +// ^ punctuation.section.parameters.begin.cs |
| 11 | +// ^^^^^^^^^^^ meta.method.parameters.cs |
| 12 | +// ^^^^^^ storage.type.cs |
| 13 | +// ^^^ variable.parameter.cs |
| 14 | +// ^ punctuation.section.parameters.end.cs |
| 15 | + { |
| 16 | +// ^ meta.block.cs punctuation.section.block.begin.cs |
| 17 | + public int WordCount() => |
| 18 | +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.body.cs meta.block.cs meta.method.body.cs meta.block.cs |
| 19 | +// ^^^^^^ storage.modifier.access.cs |
| 20 | +// ^^^ storage.type.cs |
| 21 | +// ^^^^^^^^^ meta.method.cs entity.name.function.cs |
| 22 | +// ^^ meta.method.parameters.cs |
| 23 | +// ^ punctuation.section.parameters.begin.cs |
| 24 | +// ^ punctuation.section.parameters.end.cs |
| 25 | +// ^^^ meta.method.cs |
| 26 | +// ^^ keyword.declaration.function.arrow.cs |
| 27 | + str.Split([' ', '.', '?'], StringSplitOptions.RemoveEmptyEntries).Length; |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | + |
| 32 | +public static class IntExtensions |
| 33 | +{ |
| 34 | + extension(int number) |
| 35 | + { |
| 36 | + public void Increment() |
| 37 | + => number++; |
| 38 | + } |
| 39 | + |
| 40 | + // Take note of the extra ref keyword here |
| 41 | + extension(ref int number) |
| 42 | +//^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.body.cs meta.block.cs |
| 43 | +// ^^^^^^^^^ keyword.declaration.trait.cs |
| 44 | +// ^^^^^^^^^^^^^^^^ meta.method.cs |
| 45 | +// ^ punctuation.section.parameters.begin.cs |
| 46 | +// ^^^^^^^^^^^^^^^ meta.method.parameters.cs |
| 47 | +// ^^^ storage.modifier.parameter.cs |
| 48 | +// ^^^ storage.type.cs |
| 49 | +// ^^^^^^ variable.parameter.cs |
| 50 | +// ^ punctuation.section.parameters.end.cs |
| 51 | + { |
| 52 | + public void RefIncrement() |
| 53 | + => number++; |
| 54 | +//^^^^^^^^^^^^^^^^^^^^^^ meta.class.body.cs meta.block.cs meta.method.body.cs meta.block.cs |
| 55 | +//^^^^^^^^^^^^^^^^^^^^^ meta.method.cs |
| 56 | +// ^^ keyword.declaration.function.arrow.cs |
| 57 | +// ^^^^^^ variable.other.cs |
| 58 | +// ^^ keyword.operator.cs |
| 59 | +// ^ punctuation.terminator.statement.cs |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +public static class EnumerableExtensions |
| 64 | +{ |
| 65 | + extension<T>(IEnumerable<T> target) |
| 66 | +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.body.cs meta.block.cs |
| 67 | +// ^^^^^^^^^ keyword.declaration.trait.cs |
| 68 | +// ^^^ meta.generic.cs |
| 69 | +// ^ punctuation.definition.generic.begin.cs |
| 70 | +// ^ support.type.cs |
| 71 | +// ^ punctuation.definition.generic.end.cs |
| 72 | +// ^^^^^^^^^^^^^^^^^^^^^^^ meta.method.cs |
| 73 | +// ^ punctuation.section.parameters.begin.cs |
| 74 | +// ^^^^^^^^^^^^^^^^^^^^^^ meta.method.parameters.cs |
| 75 | +// ^^^^^^^^^^^ support.type.cs |
| 76 | +// ^^^ meta.generic.cs |
| 77 | +// ^ punctuation.definition.generic.begin.cs |
| 78 | +// ^ support.type.cs |
| 79 | +// ^ punctuation.definition.generic.end.cs |
| 80 | +// ^^^^^^ variable.parameter.cs |
| 81 | +// ^ punctuation.section.parameters.end.cs |
| 82 | + { |
| 83 | +// ^^ meta.class.body.cs meta.block.cs |
| 84 | +// ^ meta.method.cs |
| 85 | +// ^ meta.method.body.cs meta.block.cs punctuation.section.block.begin.cs |
| 86 | + public bool IsEmpty() => !target.Any(); |
| 87 | +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.body.cs meta.block.cs meta.method.body.cs meta.block.cs |
| 88 | +// ^^^^^^ storage.modifier.access.cs |
| 89 | +// ^^^^ storage.type.cs |
| 90 | +// ^^^^^^^ meta.method.cs entity.name.function.cs |
| 91 | +// ^^ meta.method.parameters.cs |
| 92 | +// ^ punctuation.section.parameters.begin.cs |
| 93 | +// ^ punctuation.section.parameters.end.cs |
| 94 | +// ^^^^^^^^^^^^^^^^^ meta.method.cs |
| 95 | +// ^^ keyword.declaration.function.arrow.cs |
| 96 | +// ^ keyword.operator.cs |
| 97 | +// ^^^^^^ variable.other.cs |
| 98 | +// ^ punctuation.accessor.dot.cs |
| 99 | +// ^^^^^ meta.function-call.cs |
| 100 | +// ^^^ variable.function.cs |
| 101 | +// ^^ meta.group.cs |
| 102 | +// ^ punctuation.section.group.begin.cs |
| 103 | +// ^ punctuation.section.group.end.cs |
| 104 | +// ^ punctuation.terminator.statement.cs |
| 105 | + } |
| 106 | +// ^^ meta.class.body.cs meta.block.cs meta.method.body.cs meta.block.cs |
| 107 | +// ^ punctuation.section.block.end.cs |
| 108 | +} |
| 109 | +// <- meta.class.body.cs meta.block.cs punctuation.section.block.end.cs |
| 110 | + |
| 111 | +// <- - meta.block |
0 commit comments