Skip to content

Commit

Permalink
feat: show placeholders in outline (#1286)
Browse files Browse the repository at this point in the history
### Summary of Changes

Placeholders that are defined directly inside the body of a pipeline or
segment are now included in the outline. It is also possible to search
for them using the command palette. For example, `@trainingSet` searches
for any symbol named `trainingSet`, which now includes placeholders.
  • Loading branch information
lars-reimann authored Dec 20, 2024
1 parent 3275900 commit 3880bfe
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
isSdsAttribute,
isSdsClass,
isSdsEnumVariant,
isSdsExpression,
isSdsFunction,
isSdsPipeline,
isSdsSegment,
Expand Down Expand Up @@ -52,6 +53,18 @@ export class SafeDsDocumentSymbolProvider extends DefaultDocumentSymbolProvider
} else {
return undefined;
}
} else if (isSdsPipeline(node)) {
if (node.body) {
return super.getChildSymbols(document, node.body);
} else {
return undefined;
}
} else if (isSdsSegment(node)) {
if (node.body) {
return super.getChildSymbols(document, node.body);
} else {
return undefined;
}
} else {
return super.getChildSymbols(document, node);
}
Expand All @@ -62,9 +75,8 @@ export class SafeDsDocumentSymbolProvider extends DefaultDocumentSymbolProvider
isSdsAnnotation(node) ||
isSdsAttribute(node) ||
isSdsEnumVariant(node) ||
isSdsFunction(node) ||
isSdsPipeline(node) ||
isSdsSegment(node)
isSdsExpression(node) ||
isSdsFunction(node)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ describe('SafeDsSemanticTokenProvider', async () => {
val a = 1;
(q: Int) {
val b = 1;
yield r = 1;
};
}
Expand All @@ -145,6 +146,12 @@ describe('SafeDsSemanticTokenProvider', async () => {
{
name: 'p',
kind: SymbolKind.Function,
children: [
{
name: 'a',
kind: SymbolKind.Variable,
},
],
},
],
},
Expand All @@ -155,6 +162,7 @@ describe('SafeDsSemanticTokenProvider', async () => {
val a = 1;
(p: Int) {
val b = 1;
yield r = 1;
};
}
Expand All @@ -164,6 +172,12 @@ describe('SafeDsSemanticTokenProvider', async () => {
name: 's',
kind: SymbolKind.Function,
detail: '(p: Int) -> (r: Int)',
children: [
{
name: 'a',
kind: SymbolKind.Variable,
},
],
},
],
},
Expand Down

0 comments on commit 3880bfe

Please sign in to comment.