Skip to content

Commit

Permalink
Merge pull request #328 from KxSystems/ee-ls
Browse files Browse the repository at this point in the history
[LS] Outline view enhancements
  • Loading branch information
ecmel authored May 27, 2024
2 parents 889bc8b + 3fcdb0c commit 610e7c2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 392 deletions.
12 changes: 6 additions & 6 deletions server/src/parser/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ export function relative(token: Token, source: Token | undefined) {

export function lambda(token?: Token) {
return (
token &&
(token.tokenType === LCurly ||
token.tokenType === TestBegin ||
token.tokenType === TestBlock ||
token.tokenType === TestLambdaBlock)
token && (token.tokenType === LCurly || token.tokenType === TestLambdaBlock)
);
}

Expand All @@ -116,7 +112,11 @@ export function testblock(token?: Token) {
}

export function amended(token: Token) {
return token.assignment && token.assignment[0]?.tokenType === DoubleColon;
return (
inLambda(token) &&
token.assignment &&
token.assignment[0]?.tokenType === DoubleColon
);
}

export function local(token: Token, tokens: Token[]) {
Expand Down
27 changes: 15 additions & 12 deletions server/src/qLangServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
inParam,
namespace,
relative,
testblock,
} from "./parser";
import { lint } from "./linter";

Expand Down Expand Up @@ -143,7 +144,9 @@ export default class QLangServer {
}
return tokens
.filter(
(token) => assignable(token) && assigned(token) && !inLambda(token),
(token) =>
!inLambda(token) &&
((assignable(token) && assigned(token)) || lambda(token)),
)
.map((token) => createSymbol(token, tokens));
}
Expand Down Expand Up @@ -204,10 +207,8 @@ export default class QLangServer {
labelDetails: {
detail: ` .${namespace(token)}`,
},
kind: CompletionItemKind.Variable,
insertText: relative(token, source),
kind: lambda(assigned(token))
? CompletionItemKind.Function
: CompletionItemKind.Variable,
};
});
}
Expand Down Expand Up @@ -245,12 +246,15 @@ function positionToToken(tokens: Token[], position: Position) {
function createSymbol(token: Token, tokens: Token[]): DocumentSymbol {
const range = rangeFromToken(token);
return DocumentSymbol.create(
(inLambda(token) && !amended(token)
? token.image
: identifier(token)
).trim(),
lambda(token)
? testblock(token)
? token.image.trim()
: " "
: inLambda(token) && !amended(token)
? token.image
: identifier(token),
(amended(token) && "Amend") || undefined,
lambda(assigned(token))
lambda(token)
? SymbolKind.Object
: inParam(token)
? SymbolKind.Array
Expand All @@ -260,9 +264,8 @@ function createSymbol(token: Token, tokens: Token[]): DocumentSymbol {
tokens
.filter(
(child) =>
assigned(child) &&
assignable(child) &&
inLambda(child) === assigned(token),
inLambda(child) === token &&
((assigned(child) && assignable(child)) || lambda(child)),
)
.map((child) => createSymbol(child, tokens)),
);
Expand Down
Loading

0 comments on commit 610e7c2

Please sign in to comment.