diff --git a/data/fixtures/scopes/yaml/collectionItem.unenclosed.iteration.scope b/data/fixtures/scopes/yaml/collectionItem.unenclosed.iteration.scope new file mode 100644 index 0000000000..c523bc87d3 --- /dev/null +++ b/data/fixtures/scopes/yaml/collectionItem.unenclosed.iteration.scope @@ -0,0 +1,23 @@ +items: + - 1 + - 2 + - 3 +--- + +[#1 Range] = +[#1 Domain] = 0:0-3:5 + >------ +0| items: +1| - 1 +2| - 2 +3| - 3 + -----< + + +[#2 Range] = +[#2 Domain] = 1:2-3:5 + >--- +1| - 1 +2| - 2 +3| - 3 + -----< diff --git a/data/fixtures/scopes/yaml/collectionItem.unenclosed.scope b/data/fixtures/scopes/yaml/collectionItem.unenclosed.scope new file mode 100644 index 0000000000..9faa3a2cd7 --- /dev/null +++ b/data/fixtures/scopes/yaml/collectionItem.unenclosed.scope @@ -0,0 +1,92 @@ +items: + - 1 + - 2 + - 3 +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-3:5 + >------ +0| items: +1| - 1 +2| - 2 +3| - 3 + -----< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = 1:4-1:5 + >-< +1| - 1 + +[#2 Removal] = 1:2-2:2 + >--- +1| - 1 +2| - 2 + --< + +[#2 Trailing delimiter] = 1:5-2:2 + > +1| - 1 +2| - 2 + --< + +[#2 Domain] = 1:2-1:5 + >---< +1| - 1 + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = 2:4-2:5 + >-< +2| - 2 + +[#3 Removal] = 2:2-3:2 + >--- +2| - 2 +3| - 3 + --< + +[#3 Leading delimiter] = 1:5-2:2 + > +1| - 1 +2| - 2 + --< + +[#3 Trailing delimiter] = 2:5-3:2 + > +2| - 2 +3| - 3 + --< + +[#3 Domain] = 2:2-2:5 + >---< +2| - 2 + +[#3 Insertion delimiter] = "\n" + + +[#4 Content] = 3:4-3:5 + >-< +3| - 3 + +[#4 Removal] = 2:5-3:5 + > +2| - 2 +3| - 3 + -----< + +[#4 Leading delimiter] = 2:5-3:2 + > +2| - 2 +3| - 3 + --< + +[#4 Domain] = 3:2-3:5 + >---< +3| - 3 + +[#4 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/yaml/comment.line.scope b/data/fixtures/scopes/yaml/comment.line.scope index 32f730b7fa..42719cdbb8 100644 --- a/data/fixtures/scopes/yaml/comment.line.scope +++ b/data/fixtures/scopes/yaml/comment.line.scope @@ -1,10 +1,10 @@ -# aaa +# Hello world --- [Content] = [Removal] = -[Domain] = 0:0-0:5 - >-----< -0| # aaa +[Domain] = 0:0-0:13 + >-------------< +0| # Hello world [Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/yaml/key.mapPair.iteration.scope b/data/fixtures/scopes/yaml/key.mapPair.iteration.scope new file mode 100644 index 0000000000..c75d13702c --- /dev/null +++ b/data/fixtures/scopes/yaml/key.mapPair.iteration.scope @@ -0,0 +1,20 @@ +obj: + name: "foo" + value: 123 +--- + +[#1 Range] = +[#1 Domain] = 0:0-2:12 + >---- +0| obj: +1| name: "foo" +2| value: 123 + ------------< + + +[#2 Range] = +[#2 Domain] = 1:2-2:12 + >----------- +1| name: "foo" +2| value: 123 + ------------< diff --git a/data/fixtures/scopes/yaml/key.mapPair.scope b/data/fixtures/scopes/yaml/key.mapPair.scope new file mode 100644 index 0000000000..7951202cd2 --- /dev/null +++ b/data/fixtures/scopes/yaml/key.mapPair.scope @@ -0,0 +1,67 @@ +obj: + name: "foo" + value: 123 +--- + +[#1 Content] = 0:0-0:3 + >---< +0| obj: + +[#1 Removal] = 0:0-1:2 + >---- +0| obj: +1| name: "foo" + --< + +[#1 Trailing delimiter] = 0:3-1:2 + >- +0| obj: +1| name: "foo" + --< + +[#1 Domain] = 0:0-2:12 + >---- +0| obj: +1| name: "foo" +2| value: 123 + ------------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:2-1:6 + >----< +1| name: "foo" + +[#2 Removal] = 1:2-1:8 + >------< +1| name: "foo" + +[#2 Trailing delimiter] = 1:6-1:8 + >--< +1| name: "foo" + +[#2 Domain] = 1:2-1:13 + >-----------< +1| name: "foo" + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:2-2:7 + >-----< +2| value: 123 + +[#3 Removal] = 2:2-2:9 + >-------< +2| value: 123 + +[#3 Trailing delimiter] = 2:7-2:9 + >--< +2| value: 123 + +[#3 Domain] = 2:2-2:12 + >----------< +2| value: 123 + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/list.scope b/data/fixtures/scopes/yaml/list.scope new file mode 100644 index 0000000000..41c3a0df61 --- /dev/null +++ b/data/fixtures/scopes/yaml/list.scope @@ -0,0 +1,17 @@ +items: [1, 2, 3] +--- + +[Content] = +[Domain] = 0:7-0:16 + >---------< +0| items: [1, 2, 3] + +[Removal] = 0:6-0:16 + >----------< +0| items: [1, 2, 3] + +[Leading delimiter] = 0:6-0:7 + >-< +0| items: [1, 2, 3] + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/list2.scope b/data/fixtures/scopes/yaml/list2.scope new file mode 100644 index 0000000000..7fb258c465 --- /dev/null +++ b/data/fixtures/scopes/yaml/list2.scope @@ -0,0 +1,27 @@ +items: + - 1 + - 2 + - 3 +--- + +[Content] = +[Domain] = 1:2-3:5 + >--- +1| - 1 +2| - 2 +3| - 3 + -----< + +[Removal] = 0:6-3:5 + > +0| items: +1| - 1 +2| - 2 +3| - 3 + -----< + +[Leading delimiter] = 1:0-1:2 + >--< +1| - 1 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/map.scope b/data/fixtures/scopes/yaml/map.scope new file mode 100644 index 0000000000..ebfb5b37b0 --- /dev/null +++ b/data/fixtures/scopes/yaml/map.scope @@ -0,0 +1,36 @@ +obj: + name: "foo" + value: 123 +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:12 + >---- +0| obj: +1| name: "foo" +2| value: 123 + ------------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 1:2-2:12 + >----------- +1| name: "foo" +2| value: 123 + ------------< + +[#2 Removal] = 0:4-2:12 + > +0| obj: +1| name: "foo" +2| value: 123 + ------------< + +[#2 Leading delimiter] = 1:0-1:2 + >--< +1| name: "foo" + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/string.multiLine.scope b/data/fixtures/scopes/yaml/string.multiLine.scope new file mode 100644 index 0000000000..3e737fb7c6 --- /dev/null +++ b/data/fixtures/scopes/yaml/string.multiLine.scope @@ -0,0 +1,25 @@ +value: | + Hello + world +--- + +[Content] = +[Domain] = 0:7-2:7 + >- +0| value: | +1| Hello +2| world + -------< + +[Removal] = 0:6-2:7 + >-- +0| value: | +1| Hello +2| world + -------< + +[Leading delimiter] = 0:6-0:7 + >-< +0| value: | + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/string.singleLine.scope b/data/fixtures/scopes/yaml/string.singleLine.scope new file mode 100644 index 0000000000..acbfec0bb6 --- /dev/null +++ b/data/fixtures/scopes/yaml/string.singleLine.scope @@ -0,0 +1,17 @@ +value: "hello world" +--- + +[Content] = +[Domain] = 0:7-0:20 + >-------------< +0| value: "hello world" + +[Removal] = 0:6-0:20 + >--------------< +0| value: "hello world" + +[Leading delimiter] = 0:6-0:7 + >-< +0| value: "hello world" + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/string.singleLine2.scope b/data/fixtures/scopes/yaml/string.singleLine2.scope new file mode 100644 index 0000000000..0c9f84ad77 --- /dev/null +++ b/data/fixtures/scopes/yaml/string.singleLine2.scope @@ -0,0 +1,17 @@ +value: hello world +--- + +[Content] = +[Domain] = 0:7-0:18 + >-----------< +0| value: hello world + +[Removal] = 0:6-0:18 + >------------< +0| value: hello world + +[Leading delimiter] = 0:6-0:7 + >-< +0| value: hello world + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/textFragment.comment.line.scope b/data/fixtures/scopes/yaml/textFragment.comment.line.scope new file mode 100644 index 0000000000..2c362ef415 --- /dev/null +++ b/data/fixtures/scopes/yaml/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +# Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| # Hello world + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/textFragment.string.multiLine.scope b/data/fixtures/scopes/yaml/textFragment.string.multiLine.scope new file mode 100644 index 0000000000..3e737fb7c6 --- /dev/null +++ b/data/fixtures/scopes/yaml/textFragment.string.multiLine.scope @@ -0,0 +1,25 @@ +value: | + Hello + world +--- + +[Content] = +[Domain] = 0:7-2:7 + >- +0| value: | +1| Hello +2| world + -------< + +[Removal] = 0:6-2:7 + >-- +0| value: | +1| Hello +2| world + -------< + +[Leading delimiter] = 0:6-0:7 + >-< +0| value: | + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/textFragment.string.singleLine.scope b/data/fixtures/scopes/yaml/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..178104ab0f --- /dev/null +++ b/data/fixtures/scopes/yaml/textFragment.string.singleLine.scope @@ -0,0 +1,10 @@ +value: "hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:8-0:19 + >-----------< +0| value: "hello world" + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/textFragment.string.singleLine2.scope b/data/fixtures/scopes/yaml/textFragment.string.singleLine2.scope new file mode 100644 index 0000000000..0c9f84ad77 --- /dev/null +++ b/data/fixtures/scopes/yaml/textFragment.string.singleLine2.scope @@ -0,0 +1,17 @@ +value: hello world +--- + +[Content] = +[Domain] = 0:7-0:18 + >-----------< +0| value: hello world + +[Removal] = 0:6-0:18 + >------------< +0| value: hello world + +[Leading delimiter] = 0:6-0:7 + >-< +0| value: hello world + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/yaml/value.mapPair.iteration.scope b/data/fixtures/scopes/yaml/value.mapPair.iteration.scope new file mode 100644 index 0000000000..c75d13702c --- /dev/null +++ b/data/fixtures/scopes/yaml/value.mapPair.iteration.scope @@ -0,0 +1,20 @@ +obj: + name: "foo" + value: 123 +--- + +[#1 Range] = +[#1 Domain] = 0:0-2:12 + >---- +0| obj: +1| name: "foo" +2| value: 123 + ------------< + + +[#2 Range] = +[#2 Domain] = 1:2-2:12 + >----------- +1| name: "foo" +2| value: 123 + ------------< diff --git a/data/fixtures/scopes/yaml/value.mapPair.scope b/data/fixtures/scopes/yaml/value.mapPair.scope new file mode 100644 index 0000000000..7508ea7c6f --- /dev/null +++ b/data/fixtures/scopes/yaml/value.mapPair.scope @@ -0,0 +1,70 @@ +obj: + name: "foo" + value: 123 +--- + +[#1 Content] = 1:2-2:12 + >----------- +1| name: "foo" +2| value: 123 + ------------< + +[#1 Removal] = 0:3-2:12 + >- +0| obj: +1| name: "foo" +2| value: 123 + ------------< + +[#1 Leading delimiter] = 0:3-1:2 + >- +0| obj: +1| name: "foo" + --< + +[#1 Domain] = 0:0-2:12 + >---- +0| obj: +1| name: "foo" +2| value: 123 + ------------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:13 + >-----< +1| name: "foo" + +[#2 Removal] = 1:6-1:13 + >-------< +1| name: "foo" + +[#2 Leading delimiter] = 1:6-1:8 + >--< +1| name: "foo" + +[#2 Domain] = 1:2-1:13 + >-----------< +1| name: "foo" + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:9-2:12 + >---< +2| value: 123 + +[#3 Removal] = 2:7-2:12 + >-----< +2| value: 123 + +[#3 Leading delimiter] = 2:7-2:9 + >--< +2| value: 123 + +[#3 Domain] = 2:2-2:12 + >----------< +2| value: 123 + +[#3 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/yaml.ts b/packages/common/src/scopeSupportFacets/yaml.ts index f81868669a..d12ba86b94 100644 --- a/packages/common/src/scopeSupportFacets/yaml.ts +++ b/packages/common/src/scopeSupportFacets/yaml.ts @@ -5,6 +5,174 @@ import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const yamlScopeSupport: LanguageScopeSupportFacetMap = { - "comment.line": supported, disqualifyDelimiter: supported, + list: supported, + map: supported, + + "collectionItem.unenclosed": supported, + "collectionItem.unenclosed.iteration": supported, + + "key.mapPair": supported, + "key.mapPair.iteration": supported, + + "value.mapPair": supported, + "value.mapPair.iteration": supported, + + "comment.line": supported, + + "string.singleLine": supported, + "string.multiLine": supported, + + "textFragment.string.multiLine": supported, + "textFragment.string.singleLine": supported, + "textFragment.comment.line": supported, + + // Not applicable + + anonymousFunction: notApplicable, + "argument.actual": notApplicable, + "argument.actual.constructor": notApplicable, + "argument.actual.constructor.iteration": notApplicable, + "argument.actual.iteration": notApplicable, + "argument.actual.method": notApplicable, + "argument.actual.method.iteration": notApplicable, + "argument.formal": notApplicable, + "argument.formal.constructor": notApplicable, + "argument.formal.constructor.iteration": notApplicable, + "argument.formal.iteration": notApplicable, + "argument.formal.method": notApplicable, + "argument.formal.method.iteration": notApplicable, + attribute: notApplicable, + "branch.if": notApplicable, + "branch.if.iteration": notApplicable, + "branch.loop": notApplicable, + "branch.switchCase": notApplicable, + "branch.switchCase.iteration": notApplicable, + "branch.ternary": notApplicable, + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + class: notApplicable, + "class.iteration.block": notApplicable, + "class.iteration.document": notApplicable, + className: notApplicable, + "className.iteration.block": notApplicable, + "className.iteration.document": notApplicable, + command: notApplicable, + "comment.block": notApplicable, + "condition.doWhile": notApplicable, + "condition.for": notApplicable, + "condition.if": notApplicable, + "condition.switchCase": notApplicable, + "condition.switchCase.iteration": notApplicable, + "condition.ternary": notApplicable, + "condition.while": notApplicable, + element: notApplicable, + endTag: notApplicable, + environment: notApplicable, + fieldAccess: notApplicable, + functionCall: notApplicable, + "functionCall.constructor": notApplicable, + functionCallee: notApplicable, + "functionCallee.constructor": notApplicable, + functionName: notApplicable, + "functionName.constructor": notApplicable, + "functionName.iteration.block": notApplicable, + "functionName.iteration.document": notApplicable, + "functionName.method": notApplicable, + "functionName.method.iteration.class": notApplicable, + ifStatement: notApplicable, + "interior.cell": notApplicable, + "interior.class": notApplicable, + "interior.command": notApplicable, + "interior.element": notApplicable, + "interior.function": notApplicable, + "interior.if": notApplicable, + "interior.lambda": notApplicable, + "interior.loop": notApplicable, + "interior.resource": notApplicable, + "interior.switchCase": notApplicable, + "interior.ternary": notApplicable, + "interior.try": notApplicable, + "key.attribute": notApplicable, + "name.argument.actual": notApplicable, + "name.argument.actual.iteration": notApplicable, + "name.argument.formal": notApplicable, + "name.argument.formal.constructor": notApplicable, + "name.argument.formal.constructor.iteration": notApplicable, + "name.argument.formal.iteration": notApplicable, + "name.argument.formal.method": notApplicable, + "name.argument.formal.method.iteration": notApplicable, + "name.assignment": notApplicable, + "name.assignment.pattern": notApplicable, + "name.class": notApplicable, + "name.constructor": notApplicable, + "name.field": notApplicable, + "name.foreach": notApplicable, + "name.function": notApplicable, + "name.iteration.block": notApplicable, + "name.iteration.document": notApplicable, + "name.method": notApplicable, + "name.resource": notApplicable, + "name.resource.iteration": notApplicable, + "name.variable": notApplicable, + "name.variable.pattern": notApplicable, + namedFunction: notApplicable, + "namedFunction.constructor": notApplicable, + "namedFunction.iteration.block": notApplicable, + "namedFunction.iteration.document": notApplicable, + "namedFunction.method": notApplicable, + "namedFunction.method.iteration.class": notApplicable, + notebookCell: notApplicable, + pairDelimiter: notApplicable, + regularExpression: notApplicable, + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + startTag: notApplicable, + statement: notApplicable, + "statement.class": notApplicable, + "statement.iteration.block": notApplicable, + "statement.iteration.document": notApplicable, + switchStatementSubject: notApplicable, + tags: notApplicable, + "textFragment.comment.block": notApplicable, + "textFragment.element": notApplicable, + "type.alias": notApplicable, + "type.argument.formal": notApplicable, + "type.argument.formal.constructor": notApplicable, + "type.argument.formal.constructor.iteration": notApplicable, + "type.argument.formal.iteration": notApplicable, + "type.argument.formal.method": notApplicable, + "type.argument.formal.method.iteration": notApplicable, + "type.cast": notApplicable, + "type.class": notApplicable, + "type.enum": notApplicable, + "type.field": notApplicable, + "type.field.iteration": notApplicable, + "type.foreach": notApplicable, + "type.interface": notApplicable, + "type.return": notApplicable, + "type.typeArgument": notApplicable, + "type.typeArgument.iteration": notApplicable, + "type.variable": notApplicable, + "value.argument.actual": notApplicable, + "value.argument.actual.iteration": notApplicable, + "value.argument.formal": notApplicable, + "value.argument.formal.constructor": notApplicable, + "value.argument.formal.constructor.iteration": notApplicable, + "value.argument.formal.iteration": notApplicable, + "value.argument.formal.method": notApplicable, + "value.argument.formal.method.iteration": notApplicable, + "value.assignment": notApplicable, + "value.attribute": notApplicable, + "value.field": notApplicable, + "value.foreach": notApplicable, + "value.resource": notApplicable, + "value.resource.iteration": notApplicable, + "value.return": notApplicable, + "value.return.lambda": notApplicable, + "value.typeAlias": notApplicable, + "value.variable": notApplicable, + "value.variable.pattern": notApplicable, + "value.yield": notApplicable, }; diff --git a/queries/yaml.scm b/queries/yaml.scm index 4b950da845..ecccbfca1b 100644 --- a/queries/yaml.scm +++ b/queries/yaml.scm @@ -67,12 +67,23 @@ ;;!! foo: bar ;;! ^^^ -;;!! | block scalar -;;! ^^^^^^^^^^^^^ -[ - (string_scalar) - (block_scalar) -] @string @textFragment +;;!! foo: | block scalar +;;! ^^^^^^^^^^^^^ +value: (_ + [ + (plain_scalar + (string_scalar) + ) + (block_scalar) + ] @string @textFragment +) + +;;!! foo: "bar" +;;! ^^^^^ +value: (_ + (double_quote_scalar) @string @textFragment + (#child-range! @textFragment 0 -1 true true) +) ;;!! # comment ;;! ^^^^^^^^^