Skip to content

Commit

Permalink
feat: display macro name in outline (#1326)
Browse files Browse the repository at this point in the history
  • Loading branch information
scnwwu authored Dec 18, 2024
1 parent b406018 commit 2c988b6
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions server/src/sas/LanguageServiceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class LanguageServiceProvider {
end: { line: block.endFoldingLine, character: block.endFoldingCol },
};
const docSymbol: DocumentSymbol = {
name: block.type === 1 ? this._getProcName(block.startLine) : block.name,
name: this._getSymbolName(block),
kind: SymbolKinds[block.type],
range,
selectionRange: range,
Expand Down Expand Up @@ -247,26 +247,31 @@ export class LanguageServiceProvider {
return this.syntaxProvider.lexer.syntaxDb.setLibService(fn);
}

private _getProcName(line: number) {
private _getSymbolName(block: FoldingBlock) {
const line = block.startLine;
const tokens = this.syntaxProvider.getSyntax(line);
for (let i = 0; i < tokens.length; i++) {
for (let i = 2; i < tokens.length; i++) {
const token = tokens[i];
if (token.style === "proc-name") {
if (token.start <= block.startCol) {
continue;
}
if (token.style === "proc-name" || token.style === "text") {
const end =
i === tokens.length - 1
? this.model.getColumnCount(line)
: tokens[i + 1].start;
return (
"PROC " +
this.model
.getText({
start: { line, column: token.start },
end: { line, column: end },
})
.toUpperCase()
);
const tokenText = this.model.getText({
start: { line, column: token.start },
end: { line, column: end },
});
if (tokenText.trim() === "") {
continue;
}
return `${block.name} ${
token.style === "proc-name" ? tokenText.toUpperCase() : tokenText
}`;
}
}
return "";
return block.name;
}
}

0 comments on commit 2c988b6

Please sign in to comment.