Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

css scope migration #2339

Merged
merged 9 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions data/fixtures/scopes/css/name.iteration.block.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
a { color: red; }
---

[#1 Range] =
[#1 Domain] = 0:0-0:17
>-----------------<
0| a { color: red; }


[#2 Range] =
[#2 Domain] = 0:3-0:16
>-------------<
0| a { color: red; }
7 changes: 7 additions & 0 deletions data/fixtures/scopes/css/name.iteration.document.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* hello */
---

[Range] =
[Domain] = 0:0-0:11
>-----------<
0| /* hello */
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* hello */
---

[Range] =
[Domain] = 0:0-0:11
>-----------<
0| /* hello */
13 changes: 13 additions & 0 deletions data/fixtures/scopes/scss/functionName.iteration.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
a { color: red; }
---

[#1 Range] =
[#1 Domain] = 0:0-0:17
>-----------------<
0| a { color: red; }


[#2 Range] =
[#2 Domain] = 0:3-0:16
>-------------<
0| a { color: red; }
3 changes: 3 additions & 0 deletions data/fixtures/scopes/scss/index.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that this was missing inspired #2370, which also includes this file

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"imports": ["css"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* hello */
---

[Range] =
[Domain] = 0:0-0:11
>-----------<
0| /* hello */
13 changes: 13 additions & 0 deletions data/fixtures/scopes/scss/namedFunction.iteration.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
a { color: red; }
---

[#1 Range] =
[#1 Domain] = 0:0-0:17
>-----------------<
0| a { color: red; }


[#2 Range] =
[#2 Domain] = 0:3-0:16
>-------------<
0| a { color: red; }
2 changes: 2 additions & 0 deletions packages/common/src/scopeSupportFacets/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ export const cssScopeSupport: LanguageScopeSupportFacetMap = {
"comment.line": supported,
"comment.block": supported,
"string.singleLine": supported,
"name.iteration.block": supported,
"name.iteration.document": supported,
};
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ export const scopeSupportFacetInfos: Record<
description: "A named method declaration in a class",
scopeType: "namedFunction",
},
"namedFunction.method.iteration.class": {
description: "Iteration scope for named functions: class bodies",
scopeType: "namedFunction",
isIteration: true,
},
"namedFunction.iteration": {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pokey There's no indicator in the name or description what this iteration scope should be. Shouldn't this be namedFunction.iteration.block?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so the issue is that we don't necessarily want the iteration scope for functions to always include blocks. For example, that's not what we do in typescript. I added this as a catch-all so that I could include blocks for css. Might be worth discussing?

Copy link
Member Author

@AndreasArvidsson AndreasArvidsson May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can us go ahead and merge this because we can always update later?

Copy link
Member

@pokey pokey May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly mixed feelings about merging in facet ids that we will want to change, as I think it could be a bit painful to rename them, especially as they get used more

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. Should be punt on this then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Would be good to get this PR in, but I think it's going to be easier to get this one right, as we use this facet for this PR. I'd be inclined to discuss Sunday

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, let's get this thing in. I filed #2375; let's discuss Sunday

description: "Iteration scope for named functions",
scopeType: "namedFunction",
isIteration: true,
},
"namedFunction.iteration.document": {
description: "Iteration scope for named functions: the entire document",
scopeType: "namedFunction",
isIteration: true,
},
anonymousFunction: {
description:
"An anonymous function, eg a lambda function, an arrow function, etc",
Expand All @@ -133,6 +148,25 @@ export const scopeSupportFacetInfos: Record<
description: "The name of a function",
scopeType: "functionName",
},
"functionName.method": {
description: "The name of a method in a class",
scopeType: "functionName",
},
"functionName.method.iteration.class": {
description: "Iteration scope for function names: class bodies",
scopeType: "functionName",
isIteration: true,
},
"functionName.iteration": {
description: "Iteration scope for function names",
scopeType: "functionName",
isIteration: true,
},
"functionName.iteration.document": {
description: "Iteration scope for function names: the entire document",
scopeType: "functionName",
isIteration: true,
},

functionCall: {
description: "A function call",
Expand Down Expand Up @@ -299,6 +333,17 @@ export const scopeSupportFacetInfos: Record<
scopeType: "name",
isIteration: true,
},
"name.iteration.block": {
description:
"Iteration scope for names: statement blocks (body of functions/if classes/for loops/etc).",
scopeType: "name",
isIteration: true,
},
"name.iteration.document": {
description: "Iteration scope for names: the entire document",
scopeType: "name",
isIteration: true,
},
"key.attribute": {
description: "Key (LHS) of an attribute eg in an xml element",
scopeType: "collectionKey",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ const scopeSupportFacets = [
"className.iteration.block",
"namedFunction",
"namedFunction.method",
"namedFunction.method.iteration.class",
"namedFunction.iteration",
"namedFunction.iteration.document",
"anonymousFunction",
"functionName",
"functionName.method",
"functionName.method.iteration.class",
"functionName.iteration",
"functionName.iteration.document",

"functionCall",
"functionCall.constructor",
Expand Down Expand Up @@ -76,6 +83,8 @@ const scopeSupportFacets = [
"name.resource.iteration",
"name.argument.formal",
"name.argument.formal.iteration",
"name.iteration.block",
"name.iteration.document",

"key.attribute",
"key.mapPair",
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/scopeSupportFacets/scss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;

export const scssScopeSupport: LanguageScopeSupportFacetMap = {
...cssScopeSupport,

"namedFunction.iteration": supported,
"namedFunction.iteration.document": supported,
"functionName.iteration": supported,
"functionName.iteration.document": supported,
};
8 changes: 8 additions & 0 deletions queries/css.scm
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@
(attribute_selector
(attribute_name) @name
) @_.domain

(stylesheet) @name.iteration
(block
.
"{" @name.iteration.start.endOf
"}" @name.iteration.end.startOf
.
)
8 changes: 8 additions & 0 deletions queries/scss.scm
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@
(parameter
(variable_name) @name
) @_.domain

(stylesheet) @namedFunction.iteration @functionName.iteration
(block
.
"{" @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf
"}" @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf
.
)
Loading