Skip to content

Show SQL cursors in outline view #216

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 11 additions & 1 deletion extension/server/src/providers/documentSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,17 @@ export default async function documentSymbolProvider(handler: DocumentSymbolPara
SymbolKind.Constant,
Range.create(def.position.line, 0, def.position.line, 0),
Range.create(def.position.line, 0, def.position.line, 0)
))
)),

...scope.cursors
.filter(cursor => cursor.position && cursor.position.path === currentPath)
.map(def => DocumentSymbol.create(
def.name,
def.keywords.join(` `).trim(),
SymbolKind.Interface,
Range.create(def.position.line, 0, def.position.line, 0),
Range.create(def.position.line, 0, def.position.line, 0)
))
);

scope.files
Expand Down
12 changes: 10 additions & 2 deletions language/models/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export default class Cache {

/** @type {import("../parserTypes").IncludeStatement[]} */
this.includes = cache.includes || [];

/** @type {Declaration[]} */
this.cursors = cache.cursors || [];

}

/**
Expand All @@ -61,6 +65,7 @@ export default class Cache {
files: [...this.files, ...second.files],
structs: [...this.structs, ...second.structs],
constants: [...this.constants, ...second.constants],
cursors: [...this.cursors, ...second.cursors],
sqlReferences: [...this.sqlReferences, ...second.sqlReferences],
indicators: [...this.indicators, ...second.indicators]
});
Expand All @@ -83,6 +88,7 @@ export default class Cache {
...this.subroutines.map(def => def.name),
...this.variables.map(def => def.name),
...this.structs.map(def => def.name),
...this.cursors.map(def => def.name),
].filter(name => name);
}

Expand All @@ -97,7 +103,8 @@ export default class Cache {
this.structs.filter(d => d.position.path === fsPath).pop(),
this.variables.filter(d => d.position.path === fsPath).pop(),
this.constants.filter(d => d.position.path === fsPath).pop(),
this.files.filter(d => d.position.path === fsPath).pop()
this.files.filter(d => d.position.path === fsPath).pop(),
this.cursors.filter(d => d.position.path === fsPath).pop()
].filter(d => d !== undefined);

const lines = lasts.map(d => d.range && d.range.end ? d.range.end : d.position.line).sort((a, b) => b - a);
Expand All @@ -124,6 +131,7 @@ export default class Cache {
...this.subroutines.filter(def => def.name.toUpperCase() === name),
...this.variables.filter(def => def.name.toUpperCase() === name),
...this.indicators.filter(def => def.name.toUpperCase() === name),
...this.cursors.filter(def => def.name.toUpperCase() === name),
];

if (allStructs.length > 0 && possibles.length === 0) {
Expand All @@ -140,7 +148,7 @@ export default class Cache {
}

clearReferences() {
[...this.parameters, ...this.constants, ...this.files, ...this.procedures, ...this.subroutines, ...this.variables, ...this.structs].forEach(def => {
[...this.parameters, ...this.constants, ...this.files, ...this.procedures, ...this.subroutines, ...this.variables, ...this.structs, ...this.cursors].forEach(def => {
def.references = [];
});

Expand Down
2 changes: 1 addition & 1 deletion language/models/declaration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Cache from "./cache";
export default class Declaration {
/**
*
* @param {"procedure"|"subroutine"|"file"|"struct"|"subitem"|"variable"|"constant"} type
* @param {"procedure"|"subroutine"|"file"|"struct"|"subitem"|"variable"|"constant"|"cursor"} type
*/
constructor(type) {
this.type = type;
Expand Down
Loading