diff --git a/data/fixtures/scopes/scss/branch.if.iteration.scope b/data/fixtures/scopes/scss/branch.if.iteration.scope new file mode 100644 index 0000000000..254dfad660 --- /dev/null +++ b/data/fixtures/scopes/scss/branch.if.iteration.scope @@ -0,0 +1,14 @@ +* { + @if true { } + @else if false { } + @else { } +} +--- + +[Range] = +[Domain] = 1:2-3:11 + >------------ +1| @if true { } +2| @else if false { } +3| @else { } + -----------< diff --git a/data/fixtures/scopes/scss/branch.if.scope b/data/fixtures/scopes/scss/branch.if.scope new file mode 100644 index 0000000000..4f871466e7 --- /dev/null +++ b/data/fixtures/scopes/scss/branch.if.scope @@ -0,0 +1,59 @@ +* { + @if true { } + @else if false { } + @else { } +} +--- + +[#1 Content] = +[#1 Domain] = 1:2-1:14 + >------------< +1| @if true { } + +[#1 Removal] = 1:3-2:8 + >----------- +1| @if true { } +2| @else if false { } + --------< + +[#1 Leading delimiter] = 1:0-1:2 + >--< +1| @if true { } + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:2-2:20 + >------------------< +2| @else if false { } + +[#2 Removal] = 2:0-3:0 + >-------------------- +2| @else if false { } +3| @else { } + < + +[#2 Leading delimiter] = 2:0-2:2 + >--< +2| @else if false { } + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 3:2-3:11 + >---------< +3| @else { } + +[#3 Removal] = 3:0-4:0 + >----------- +3| @else { } +4| } + < + +[#3 Leading delimiter] = 3:0-3:2 + >--< +3| @else { } + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scss/condition.if.scope b/data/fixtures/scopes/scss/condition.if.scope index 03e516a73a..0260d9e89a 100644 --- a/data/fixtures/scopes/scss/condition.if.scope +++ b/data/fixtures/scopes/scss/condition.if.scope @@ -1,29 +1,54 @@ * { - @if $container-width < $base-width { } + @if true { } + @else if false { } @else { } } --- -[Content] = 1:6-1:36 - >------------------------------< -1| @if $container-width < $base-width { } +[#1 Content] = 1:6-1:10 + >----< +1| @if true { } -[Removal] = 1:6-1:37 - >-------------------------------< -1| @if $container-width < $base-width { } +[#1 Removal] = 1:6-1:11 + >-----< +1| @if true { } -[Leading delimiter] = 1:5-1:6 +[#1 Leading delimiter] = 1:5-1:6 >-< -1| @if $container-width < $base-width { } +1| @if true { } -[Trailing delimiter] = 1:36-1:37 - >-< -1| @if $container-width < $base-width { } +[#1 Trailing delimiter] = 1:10-1:11 + >-< +1| @if true { } -[Domain] = 1:2-2:11 - >-------------------------------------- -1| @if $container-width < $base-width { } -2| @else { } +[#1 Domain] = 1:2-3:11 + >------------ +1| @if true { } +2| @else if false { } +3| @else { } -----------< -[Insertion delimiter] = " " +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:11-2:16 + >-----< +2| @else if false { } + +[#2 Removal] = 2:11-2:17 + >------< +2| @else if false { } + +[#2 Leading delimiter] = 2:10-2:11 + >-< +2| @else if false { } + +[#2 Trailing delimiter] = 2:16-2:17 + >-< +2| @else if false { } + +[#2 Domain] = 2:2-2:20 + >------------------< +2| @else if false { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scss/ifStatement.scope b/data/fixtures/scopes/scss/ifStatement.scope index 3af7418e4e..871ca7512f 100644 --- a/data/fixtures/scopes/scss/ifStatement.scope +++ b/data/fixtures/scopes/scss/ifStatement.scope @@ -1,25 +1,28 @@ * { - @if $container-width < $base-width { } + @if true { } + @else if false { } @else { } } --- [Content] = -[Domain] = 1:2-2:11 - >-------------------------------------- -1| @if $container-width < $base-width { } -2| @else { } +[Domain] = 1:2-3:11 + >------------ +1| @if true { } +2| @else if false { } +3| @else { } -----------< -[Removal] = 1:0-3:0 - >---------------------------------------- -1| @if $container-width < $base-width { } -2| @else { } -3| } +[Removal] = 1:0-4:0 + >-------------- +1| @if true { } +2| @else if false { } +3| @else { } +4| } < [Leading delimiter] = 1:0-1:2 >--< -1| @if $container-width < $base-width { } +1| @if true { } [Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scss/interior.function.scope b/data/fixtures/scopes/scss/interior.function.scope new file mode 100644 index 0000000000..550f4806fc --- /dev/null +++ b/data/fixtures/scopes/scss/interior.function.scope @@ -0,0 +1,37 @@ +@function foo() { } +--- + +[#1 Content] = +[#1 Removal] = 0:17-0:18 + >-< +0| @function foo() { } + +[#1 Domain] = 0:0-0:19 + >-------------------< +0| @function foo() { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:14-0:14 + >< +0| @function foo() { } + +[#2 Domain] = 0:13-0:15 + >--< +0| @function foo() { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:17-0:18 + >-< +0| @function foo() { } + +[#3 Domain] = 0:16-0:19 + >---< +0| @function foo() { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scss/interior.if.scope b/data/fixtures/scopes/scss/interior.if.scope new file mode 100644 index 0000000000..b6f883a0e1 --- /dev/null +++ b/data/fixtures/scopes/scss/interior.if.scope @@ -0,0 +1,133 @@ +* { + @if true { } + @else if false { } + @else { } +} +--- + +[#1 Content] = 1:2-3:11 + >------------ +1| @if true { } +2| @else if false { } +3| @else { } + -----------< + +[#1 Removal] = 0:3-4:0 + > +0| * { +1| @if true { } +2| @else if false { } +3| @else { } +4| } + < + +[#1 Domain] = 0:0-4:1 + >--- +0| * { +1| @if true { } +2| @else if false { } +3| @else { } +4| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:2-3:11 + >------------ +1| @if true { } +2| @else if false { } +3| @else { } + -----------< + +[#2 Removal] = 0:3-4:0 + > +0| * { +1| @if true { } +2| @else if false { } +3| @else { } +4| } + < + +[#2 Domain] = 0:2-4:1 + >- +0| * { +1| @if true { } +2| @else if false { } +3| @else { } +4| } + -< + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:12-1:13 + >-< +1| @if true { } + +[#3 Domain] = 1:2-1:14 + >------------< +1| @if true { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:12-1:13 + >-< +1| @if true { } + +[#4 Domain] = 1:11-1:14 + >---< +1| @if true { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 2:18-2:19 + >-< +2| @else if false { } + +[#5 Domain] = 2:2-2:20 + >------------------< +2| @else if false { } + +[#5 Insertion delimiter] = " " + + +[#6 Content] = +[#6 Removal] = 2:18-2:19 + >-< +2| @else if false { } + +[#6 Domain] = 2:17-2:20 + >---< +2| @else if false { } + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 3:9-3:10 + >-< +3| @else { } + +[#7 Domain] = 3:2-3:11 + >---------< +3| @else { } + +[#7 Insertion delimiter] = " " + + +[#8 Content] = +[#8 Removal] = 3:9-3:10 + >-< +3| @else { } + +[#8 Domain] = 3:8-3:11 + >---< +3| @else { } + +[#8 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/scss.ts b/packages/common/src/scopeSupportFacets/scss.ts index d98fba0130..03b0bde1b2 100644 --- a/packages/common/src/scopeSupportFacets/scss.ts +++ b/packages/common/src/scopeSupportFacets/scss.ts @@ -2,15 +2,13 @@ import { cssScopeSupport } from "./css"; import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -const { supported, unsupported } = ScopeSupportFacetLevel; +const { supported } = ScopeSupportFacetLevel; export const scssScopeSupport: LanguageScopeSupportFacetMap = { ...cssScopeSupport, "comment.line": supported, - "condition.if": supported, - namedFunction: supported, "namedFunction.iteration.block": supported, "namedFunction.iteration.document": supported, @@ -27,15 +25,13 @@ export const scssScopeSupport: LanguageScopeSupportFacetMap = { "value.argument.formal.iteration": supported, "value.return": supported, - ifStatement: supported, - "textFragment.comment.line": supported, - // Unsupported - - "branch.if": unsupported, - "branch.if.iteration": unsupported, + ifStatement: supported, + "branch.if": supported, + "branch.if.iteration": supported, + "condition.if": supported, - "interior.function": unsupported, - "interior.if": unsupported, + "interior.if": supported, + "interior.function": supported, }; diff --git a/queries/scss.scm b/queries/scss.scm index 53d624ecc2..4c78bab537 100644 --- a/queries/scss.scm +++ b/queries/scss.scm @@ -30,15 +30,42 @@ (while_statement) ] @statement +(_ + (block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) +) @_.domain + (single_line_comment) @comment @textFragment -(if_statement) @ifStatement +;;!! @if true { } @else { } +;;! ^^^^^^^^^^^^^^^^^^^^^^^ +(if_statement) @ifStatement @branch.iteration +;;!! @if true { } +;;! ^^^^^^^^^^^^ +;;! ^^^^ (if_statement (if_clause (condition) @condition - ) -) @_.domain + ) @branch @branch.removal.start.startOf @branch.removal.end.endOf + (else_if_clause + "if" @branch.removal.end.startOf + (#character-range! @branch.removal.start.startOf 1) + )? +) @condition.domain + +;;!! @else false { } +;;! ^^^^^^^^^^^^^^^ +;;! ^^^^^ +(else_if_clause + (condition) @condition +) @branch @condition.domain + +;;!! @else { } +;;! ^^^^^^^^^ +(else_clause) @branch (mixin_statement (name) @functionName @name