qsharp-lang 1.0.19-dev → 1.0.21-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/language-service/language-service.d.ts +5 -3
- package/dist/language-service/language-service.js +41 -1
- package/dist/language-service/worker-proxy.js +1 -0
- package/lib/node/qsc_wasm.cjs +33 -1
- package/lib/node/qsc_wasm.d.cts +11 -4
- package/lib/node/qsc_wasm_bg.wasm +0 -0
- package/lib/web/qsc_wasm.d.ts +12 -4
- package/lib/web/qsc_wasm.js +33 -1
- package/lib/web/qsc_wasm_bg.wasm +0 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ICompletionList, IHover,
|
|
1
|
+
import type { ICompletionList, IHover, ILocation, ISignatureHelp, IWorkspaceConfiguration, IWorkspaceEdit, ITextEdit } from "../../lib/node/qsc_wasm.cjs";
|
|
2
2
|
import { VSDiagnostic } from "../vsdiagnostic.js";
|
|
3
3
|
import { IServiceProxy } from "../worker-proxy.js";
|
|
4
4
|
type QscWasm = typeof import("../../lib/node/qsc_wasm.cjs");
|
|
@@ -16,7 +16,8 @@ export interface ILanguageService {
|
|
|
16
16
|
closeDocument(uri: string): Promise<void>;
|
|
17
17
|
getCompletions(documentUri: string, offset: number): Promise<ICompletionList>;
|
|
18
18
|
getHover(documentUri: string, offset: number): Promise<IHover | undefined>;
|
|
19
|
-
getDefinition(documentUri: string, offset: number): Promise<
|
|
19
|
+
getDefinition(documentUri: string, offset: number): Promise<ILocation | undefined>;
|
|
20
|
+
getReferences(documentUri: string, offset: number, includeDeclaration: boolean): Promise<ILocation[]>;
|
|
20
21
|
getSignatureHelp(documentUri: string, offset: number): Promise<ISignatureHelp | undefined>;
|
|
21
22
|
getRename(documentUri: string, offset: number, newName: string): Promise<IWorkspaceEdit | undefined>;
|
|
22
23
|
prepareRename(documentUri: string, offset: number): Promise<ITextEdit | undefined>;
|
|
@@ -40,7 +41,8 @@ export declare class QSharpLanguageService implements ILanguageService {
|
|
|
40
41
|
closeDocument(documentUri: string): Promise<void>;
|
|
41
42
|
getCompletions(documentUri: string, offset: number): Promise<ICompletionList>;
|
|
42
43
|
getHover(documentUri: string, offset: number): Promise<IHover | undefined>;
|
|
43
|
-
getDefinition(documentUri: string, offset: number): Promise<
|
|
44
|
+
getDefinition(documentUri: string, offset: number): Promise<ILocation | undefined>;
|
|
45
|
+
getReferences(documentUri: string, offset: number, includeDeclaration: boolean): Promise<ILocation[]>;
|
|
44
46
|
getSignatureHelp(documentUri: string, offset: number): Promise<ISignatureHelp | undefined>;
|
|
45
47
|
getRename(documentUri: string, offset: number, newName: string): Promise<IWorkspaceEdit | undefined>;
|
|
46
48
|
prepareRename(documentUri: string, offset: number): Promise<ITextEdit | undefined>;
|
|
@@ -73,10 +73,50 @@ export class QSharpLanguageService {
|
|
|
73
73
|
return undefined;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
const mappedSpan = mapUtf8UnitsToUtf16Units([result.span.start, result.span.end], code);
|
|
77
|
+
result.span.start = mappedSpan[result.span.start];
|
|
78
|
+
result.span.end = mappedSpan[result.span.end];
|
|
77
79
|
}
|
|
78
80
|
return result;
|
|
79
81
|
}
|
|
82
|
+
async getReferences(documentUri, offset, includeDeclaration) {
|
|
83
|
+
const sourceCode = this.code[documentUri];
|
|
84
|
+
if (sourceCode === undefined) {
|
|
85
|
+
log.error(`getReferences: expected ${documentUri} to be in the document map`);
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
const convertedOffset = mapUtf16UnitsToUtf8Units([offset], sourceCode)[offset];
|
|
89
|
+
const results = this.languageService.get_references(documentUri, convertedOffset, includeDeclaration);
|
|
90
|
+
if (results && results.length > 0) {
|
|
91
|
+
const references = [];
|
|
92
|
+
for (const result of results) {
|
|
93
|
+
let resultCode = this.code[result.source];
|
|
94
|
+
// Inspect the URL protocol (equivalent to the URI scheme + ":").
|
|
95
|
+
// If the scheme is our library scheme, we need to call the wasm to
|
|
96
|
+
// provide the library file's contents to do the utf8->utf16 mapping.
|
|
97
|
+
const url = new URL(result.source);
|
|
98
|
+
if (url.protocol === qsharpLibraryUriScheme + ":") {
|
|
99
|
+
resultCode = wasm.get_library_source_content(url.pathname);
|
|
100
|
+
if (resultCode === undefined) {
|
|
101
|
+
log.error(`getReferences: expected ${url} to be in the library`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (resultCode) {
|
|
105
|
+
const mappedSpan = mapUtf8UnitsToUtf16Units([result.span.start, result.span.end], resultCode);
|
|
106
|
+
result.span.start = mappedSpan[result.span.start];
|
|
107
|
+
result.span.end = mappedSpan[result.span.end];
|
|
108
|
+
references.push(result);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
log.error(`cannot do utf8->utf16 mapping for ${result.source} since contents are not available`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return references;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
80
120
|
async getSignatureHelp(documentUri, offset) {
|
|
81
121
|
const code = this.code[documentUri];
|
|
82
122
|
if (code === undefined) {
|
package/lib/node/qsc_wasm.cjs
CHANGED
|
@@ -215,6 +215,17 @@ function passArray32ToWasm0(arg, malloc) {
|
|
|
215
215
|
WASM_VECTOR_LEN = arg.length;
|
|
216
216
|
return ptr;
|
|
217
217
|
}
|
|
218
|
+
|
|
219
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
220
|
+
ptr = ptr >>> 0;
|
|
221
|
+
const mem = getUint32Memory0();
|
|
222
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
|
223
|
+
const result = [];
|
|
224
|
+
for (let i = 0; i < slice.length; i++) {
|
|
225
|
+
result.push(takeObject(slice[i]));
|
|
226
|
+
}
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
218
229
|
/**
|
|
219
230
|
* @param {any} callback
|
|
220
231
|
* @param {number} level
|
|
@@ -648,7 +659,7 @@ class LanguageService {
|
|
|
648
659
|
/**
|
|
649
660
|
* @param {string} uri
|
|
650
661
|
* @param {number} offset
|
|
651
|
-
* @returns {
|
|
662
|
+
* @returns {ILocation | undefined}
|
|
652
663
|
*/
|
|
653
664
|
get_definition(uri, offset) {
|
|
654
665
|
const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
@@ -659,6 +670,27 @@ class LanguageService {
|
|
|
659
670
|
/**
|
|
660
671
|
* @param {string} uri
|
|
661
672
|
* @param {number} offset
|
|
673
|
+
* @param {boolean} include_declaration
|
|
674
|
+
* @returns {(ILocation)[]}
|
|
675
|
+
*/
|
|
676
|
+
get_references(uri, offset, include_declaration) {
|
|
677
|
+
try {
|
|
678
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
679
|
+
const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
680
|
+
const len0 = WASM_VECTOR_LEN;
|
|
681
|
+
wasm.languageservice_get_references(retptr, this.__wbg_ptr, ptr0, len0, offset, include_declaration);
|
|
682
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
683
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
684
|
+
var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
685
|
+
wasm.__wbindgen_export_2(r0, r1 * 4);
|
|
686
|
+
return v2;
|
|
687
|
+
} finally {
|
|
688
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* @param {string} uri
|
|
693
|
+
* @param {number} offset
|
|
662
694
|
* @returns {IHover | undefined}
|
|
663
695
|
*/
|
|
664
696
|
get_hover(uri, offset) {
|
package/lib/node/qsc_wasm.d.cts
CHANGED
|
@@ -154,9 +154,9 @@ export interface IHover {
|
|
|
154
154
|
span: ISpan
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
export interface
|
|
157
|
+
export interface ILocation {
|
|
158
158
|
source: string;
|
|
159
|
-
|
|
159
|
+
span: ISpan;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
export interface ISignatureHelp {
|
|
@@ -272,9 +272,16 @@ export class LanguageService {
|
|
|
272
272
|
/**
|
|
273
273
|
* @param {string} uri
|
|
274
274
|
* @param {number} offset
|
|
275
|
-
* @returns {
|
|
275
|
+
* @returns {ILocation | undefined}
|
|
276
276
|
*/
|
|
277
|
-
get_definition(uri: string, offset: number):
|
|
277
|
+
get_definition(uri: string, offset: number): ILocation | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* @param {string} uri
|
|
280
|
+
* @param {number} offset
|
|
281
|
+
* @param {boolean} include_declaration
|
|
282
|
+
* @returns {(ILocation)[]}
|
|
283
|
+
*/
|
|
284
|
+
get_references(uri: string, offset: number, include_declaration: boolean): (ILocation)[];
|
|
278
285
|
/**
|
|
279
286
|
* @param {string} uri
|
|
280
287
|
* @param {number} offset
|
|
Binary file
|
package/lib/web/qsc_wasm.d.ts
CHANGED
|
@@ -154,9 +154,9 @@ export interface IHover {
|
|
|
154
154
|
span: ISpan
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
export interface
|
|
157
|
+
export interface ILocation {
|
|
158
158
|
source: string;
|
|
159
|
-
|
|
159
|
+
span: ISpan;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
export interface ISignatureHelp {
|
|
@@ -272,9 +272,16 @@ export class LanguageService {
|
|
|
272
272
|
/**
|
|
273
273
|
* @param {string} uri
|
|
274
274
|
* @param {number} offset
|
|
275
|
-
* @returns {
|
|
275
|
+
* @returns {ILocation | undefined}
|
|
276
276
|
*/
|
|
277
|
-
get_definition(uri: string, offset: number):
|
|
277
|
+
get_definition(uri: string, offset: number): ILocation | undefined;
|
|
278
|
+
/**
|
|
279
|
+
* @param {string} uri
|
|
280
|
+
* @param {number} offset
|
|
281
|
+
* @param {boolean} include_declaration
|
|
282
|
+
* @returns {(ILocation)[]}
|
|
283
|
+
*/
|
|
284
|
+
get_references(uri: string, offset: number, include_declaration: boolean): (ILocation)[];
|
|
278
285
|
/**
|
|
279
286
|
* @param {string} uri
|
|
280
287
|
* @param {number} offset
|
|
@@ -324,6 +331,7 @@ export interface InitOutput {
|
|
|
324
331
|
readonly languageservice_close_document: (a: number, b: number, c: number) => void;
|
|
325
332
|
readonly languageservice_get_completions: (a: number, b: number, c: number, d: number) => number;
|
|
326
333
|
readonly languageservice_get_definition: (a: number, b: number, c: number, d: number) => number;
|
|
334
|
+
readonly languageservice_get_references: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
327
335
|
readonly languageservice_get_hover: (a: number, b: number, c: number, d: number) => number;
|
|
328
336
|
readonly languageservice_get_signature_help: (a: number, b: number, c: number, d: number) => number;
|
|
329
337
|
readonly languageservice_get_rename: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
package/lib/web/qsc_wasm.js
CHANGED
|
@@ -212,6 +212,17 @@ function passArray32ToWasm0(arg, malloc) {
|
|
|
212
212
|
WASM_VECTOR_LEN = arg.length;
|
|
213
213
|
return ptr;
|
|
214
214
|
}
|
|
215
|
+
|
|
216
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
217
|
+
ptr = ptr >>> 0;
|
|
218
|
+
const mem = getUint32Memory0();
|
|
219
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
|
220
|
+
const result = [];
|
|
221
|
+
for (let i = 0; i < slice.length; i++) {
|
|
222
|
+
result.push(takeObject(slice[i]));
|
|
223
|
+
}
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
215
226
|
/**
|
|
216
227
|
* @param {any} callback
|
|
217
228
|
* @param {number} level
|
|
@@ -644,7 +655,7 @@ export class LanguageService {
|
|
|
644
655
|
/**
|
|
645
656
|
* @param {string} uri
|
|
646
657
|
* @param {number} offset
|
|
647
|
-
* @returns {
|
|
658
|
+
* @returns {ILocation | undefined}
|
|
648
659
|
*/
|
|
649
660
|
get_definition(uri, offset) {
|
|
650
661
|
const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
@@ -655,6 +666,27 @@ export class LanguageService {
|
|
|
655
666
|
/**
|
|
656
667
|
* @param {string} uri
|
|
657
668
|
* @param {number} offset
|
|
669
|
+
* @param {boolean} include_declaration
|
|
670
|
+
* @returns {(ILocation)[]}
|
|
671
|
+
*/
|
|
672
|
+
get_references(uri, offset, include_declaration) {
|
|
673
|
+
try {
|
|
674
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
675
|
+
const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
676
|
+
const len0 = WASM_VECTOR_LEN;
|
|
677
|
+
wasm.languageservice_get_references(retptr, this.__wbg_ptr, ptr0, len0, offset, include_declaration);
|
|
678
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
679
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
680
|
+
var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
681
|
+
wasm.__wbindgen_export_2(r0, r1 * 4);
|
|
682
|
+
return v2;
|
|
683
|
+
} finally {
|
|
684
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* @param {string} uri
|
|
689
|
+
* @param {number} offset
|
|
658
690
|
* @returns {IHover | undefined}
|
|
659
691
|
*/
|
|
660
692
|
get_hover(uri, offset) {
|
package/lib/web/qsc_wasm_bg.wasm
CHANGED
|
Binary file
|