Skip to content

Commit c60efb2

Browse files
committed
update hover impl
+ deprecated MarkupString subbed with MarkupContent (see microsoft/vscode-languageserver-node#1456) + version bumps
1 parent a02a299 commit c60efb2

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Michał Kapała",
66
"publisher": "michal-kapala",
77
"license": "MIT",
8-
"version": "1.0.1",
8+
"version": "1.0.2",
99
"icon": "./icons/jitterbit_icon.png",
1010
"repository": {
1111
"type": "git",

server/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "jitterbit-lsp-server",
3-
"description": "Community Jitterbit Script LSP Server",
4-
"version": "1.0.0",
5-
"author": "Asinit Ltd.",
3+
"description": "Jitterbit Script LSP Server",
4+
"version": "1.0.1",
5+
"author": "michal-kapala",
66
"license": "MIT",
77
"engines": {
88
"node": "*"

server/src/features/hover.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Api, CodeAnalysis, TypedGlobalIdentifier } from 'jitterbit-script';
2-
import { Hover, HoverParams, MarkedString } from 'vscode-languageserver';
2+
import { Hover, HoverParams, MarkupContent, MarkupKind } from 'vscode-languageserver';
33
import { idInRange, makeRange } from '../utils/position';
44

55
/**
@@ -25,38 +25,30 @@ export function getHover(params: HoverParams, analysis?: CodeAnalysis): Hover |
2525
? `(${varType}, ${Api.getSysVar(id.symbol)?.type}) ${id.symbol}: ${id.type}`
2626
: `(${varType}) ${id.symbol}: ${id.type}`;
2727

28-
const contents: MarkedString[] = [
29-
{
30-
language: "jitterbit",
31-
value: signature
32-
}
33-
];
34-
28+
let value = `\`\`\`jitterbit\n${signature}\n\`\`\`\n`;
3529
if(varType === "system") {
3630
const sysVar = Api.getSysVar(id.symbol);
37-
if(sysVar) {
38-
contents.push(sysVar.description);
39-
}
31+
if(sysVar)
32+
value += sysVar.description;
4033
}
34+
const contents = {kind: MarkupKind.Markdown, value};
4135
return {contents, range: makeRange(id.start, id.end)};
4236
}
4337
}
4438

4539
// functions
40+
const prefix = `\`\`\`jitterbit\n(function)`;
4641
for(const id of analysis.callees) {
4742
const range = makeRange(id.start, id.end);
4843
if(idInRange(params.position, range)) {
4944
const func = Api.getFunc(id.symbol);
5045
if(!func)
5146
continue;
52-
const contents: MarkedString[] = [];
53-
for(let idx = 0; idx < func.signatures.length; idx++) {
54-
contents.push({
55-
language: "jitterbit",
56-
value: `(function) ${func.toString(idx)}`
57-
});
58-
}
59-
contents.push(func.docs);
47+
let value = "";
48+
for(let idx = 0; idx < func.signatures.length; idx++)
49+
value += `${prefix} ${func.toString(idx)}\n\`\`\`\n`;
50+
value += func.docs;
51+
const contents: MarkupContent = {kind: MarkupKind.Markdown, value};
6052
return {contents, range: makeRange(id.start, id.end)};
6153
}
6254
}

0 commit comments

Comments
 (0)