Skip to content

Commit 2c988b6

Browse files
authored
feat: display macro name in outline (#1326)
1 parent b406018 commit 2c988b6

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

server/src/sas/LanguageServiceProvider.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class LanguageServiceProvider {
170170
end: { line: block.endFoldingLine, character: block.endFoldingCol },
171171
};
172172
const docSymbol: DocumentSymbol = {
173-
name: block.type === 1 ? this._getProcName(block.startLine) : block.name,
173+
name: this._getSymbolName(block),
174174
kind: SymbolKinds[block.type],
175175
range,
176176
selectionRange: range,
@@ -247,26 +247,31 @@ export class LanguageServiceProvider {
247247
return this.syntaxProvider.lexer.syntaxDb.setLibService(fn);
248248
}
249249

250-
private _getProcName(line: number) {
250+
private _getSymbolName(block: FoldingBlock) {
251+
const line = block.startLine;
251252
const tokens = this.syntaxProvider.getSyntax(line);
252-
for (let i = 0; i < tokens.length; i++) {
253+
for (let i = 2; i < tokens.length; i++) {
253254
const token = tokens[i];
254-
if (token.style === "proc-name") {
255+
if (token.start <= block.startCol) {
256+
continue;
257+
}
258+
if (token.style === "proc-name" || token.style === "text") {
255259
const end =
256260
i === tokens.length - 1
257261
? this.model.getColumnCount(line)
258262
: tokens[i + 1].start;
259-
return (
260-
"PROC " +
261-
this.model
262-
.getText({
263-
start: { line, column: token.start },
264-
end: { line, column: end },
265-
})
266-
.toUpperCase()
267-
);
263+
const tokenText = this.model.getText({
264+
start: { line, column: token.start },
265+
end: { line, column: end },
266+
});
267+
if (tokenText.trim() === "") {
268+
continue;
269+
}
270+
return `${block.name} ${
271+
token.style === "proc-name" ? tokenText.toUpperCase() : tokenText
272+
}`;
268273
}
269274
}
270-
return "";
275+
return block.name;
271276
}
272277
}

0 commit comments

Comments
 (0)