Skip to content

Commit

Permalink
feat: highlight the identifier after the tag as well
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Oct 24, 2023
1 parent f95866f commit 963daeb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/language/lsp/safe-ds-semantic-token-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
isSdsPipeline,
isSdsPlaceholder,
isSdsReference,
isSdsResult,
isSdsSchema,
isSdsSegment,
isSdsTypeArgument,
Expand Down Expand Up @@ -207,6 +208,12 @@ export class SafeDsSemanticTokenProvider extends AbstractSemanticTokenProvider {
type: SemanticTokenTypes.variable,
modifier: [SemanticTokenModifiers.readonly, ...additionalModifiers],
};
} else if (isSdsResult(node)) {
return {
// For lack of a better option, we use the token type for parameters here
type: SemanticTokenTypes.parameter,
modifier: additionalModifiers,
};
} else if (isSdsSchema(node)) {
return {
type: SemanticTokenTypes.type,
Expand Down
26 changes: 24 additions & 2 deletions syntaxes/safe-ds.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,30 @@
"end": "\\*/",
"patterns": [
{
"name": "keyword.other.safe-ds",
"match": "(@param|@result|@since|@typeParam)\\b"
"match": "(@param|@result)\\s+([_a-zA-Z][_a-zA-Z0-9]*)?",
"captures": {
"1": {
"name": "keyword.other.safe-ds"
},
"2": {
"name": "variable.parameter.safe-ds"
}
}
},
{
"match": "(@since)\\b",
"name": "keyword.other.safe-ds"
},
{
"match": "(@typeParam)\\s+([_a-zA-Z][_a-zA-Z0-9]*)?",
"captures": {
"1": {
"name": "keyword.other.safe-ds"
},
"2": {
"name": "entity.name.type.parameter"
}
}
}
]
},
Expand Down
5 changes: 5 additions & 0 deletions tests/language/lsp/safe-ds-semantic-token-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ describe('SafeDsSemanticTokenProvider', async () => {
`,
expectedTokenTypes: [SemanticTokenTypes.variable],
},
{
testName: 'result declaration',
code: 'fun f() -> (<|r|>: String)',
expectedTokenTypes: [SemanticTokenTypes.parameter],
},
{
testName: 'schema declaration',
code: 'schema <|S|>() {}',
Expand Down

0 comments on commit 963daeb

Please sign in to comment.