@intersystems-community/ascot 0.1.2 → 0.3.0
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/README.md +42 -30
- package/dist/index.d.ts +16 -12
- package/dist/index.js +25 -20
- package/dist/index.js.map +1 -1
- package/generated/ascot.js +14454 -1374
- package/generated/interfaces/iris-ascot-common.d.ts +242 -5
- package/generated/interfaces/iris-ascot-exported.d.ts +2 -1
- package/generated/interfaces/iris-ascot-imported.d.ts +3 -2
- package/lib/ascot.core.wasm +0 -0
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -12,19 +12,10 @@ npm install @intersystems-community/ascot
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
import { createWorkspace
|
|
17
|
-
|
|
18
|
-
// What the engine asks you for when a name isn't defined in the workspace, typically
|
|
19
|
-
// answered from an IRIS instance over its REST API. Return `undefined` for "not found",
|
|
20
|
-
// or for everything if you have no instance: the workspace is then checked on its own.
|
|
21
|
-
class NoIris implements Imported {
|
|
22
|
-
async getCls(cls: string) { return undefined; } // a class's members and metadata
|
|
23
|
-
async getInc(name: string) { return undefined; } // the text of `name.inc`
|
|
24
|
-
async getIntOrMac(name: string) { return undefined; } // the text of routine `name`
|
|
25
|
-
}
|
|
15
|
+
````ts
|
|
16
|
+
import { createWorkspace } from "@intersystems-community/ascot";
|
|
26
17
|
|
|
27
|
-
const ws = await createWorkspace(
|
|
18
|
+
const ws = await createWorkspace();
|
|
28
19
|
|
|
29
20
|
// `open` is both open and edit: it stores the raw text (the kind comes from the uri's
|
|
30
21
|
// extension: .cls, .mac, .int, .inc) and returns the uris whose cached analysis is now
|
|
@@ -42,10 +33,32 @@ ClassMethod M() As %Status
|
|
|
42
33
|
|
|
43
34
|
await ws.diagnostics("file:///T.cls");
|
|
44
35
|
// [{ severity: "error", message: "Expected return value of type '%Status' but got nothing",
|
|
45
|
-
// range: { start: { line: 6, character: 5 }, ... }, relatedInformation: [...]
|
|
36
|
+
// range: { start: { line: 6, character: 5 }, ... }, relatedInformation: [...],
|
|
37
|
+
// code: "A6781", codeDescription: "https://docs.rs/ascot/.../enum.TypeErrorKind.html#variant.ReturnNothingForX" }]
|
|
46
38
|
|
|
47
39
|
await ws.hover("file:///T.cls", { line: 5, character: 7 }); // the `x` being written
|
|
48
40
|
// "```objectscript\n%DataType = 1\n```"
|
|
41
|
+
````
|
|
42
|
+
|
|
43
|
+
To provide declarations for documents that aren't in the workspace, extend `IrisConnection`,
|
|
44
|
+
override the lookups you can answer, and pass an instance:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { IrisConnection, type ClassInfo } from "@intersystems-community/ascot";
|
|
48
|
+
|
|
49
|
+
class MyIris extends IrisConnection {
|
|
50
|
+
override async getCls(cls: string): Promise<ClassInfo | undefined> {
|
|
51
|
+
return undefined; // look `cls` up, e.g. over IRIS's REST API
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const connected = await createWorkspace(new MyIris());
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`createWorkspace` takes an optional second argument, a `Style` applied to every document:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const strict = await createWorkspace(undefined, { command: { form: "long" }, function: { case: "pascal" }, commandDo: { form: "short" } });
|
|
49
62
|
```
|
|
50
63
|
|
|
51
64
|
Load every file of a project into one `Workspace` so cross-file references resolve, and
|
|
@@ -54,30 +67,29 @@ usually not a removal, so keep the on-disk text open instead.
|
|
|
54
67
|
|
|
55
68
|
## API
|
|
56
69
|
|
|
57
|
-
`createWorkspace(
|
|
70
|
+
`createWorkspace(iris?, style?)` returns a `Workspace` whose methods mirror the engine's
|
|
58
71
|
exports, all returning promises. Positions and ranges are zero-based line/character pairs,
|
|
59
72
|
as in the Language Server Protocol.
|
|
60
73
|
|
|
61
|
-
| Method
|
|
62
|
-
|
|
|
63
|
-
| `open(uri, text)`
|
|
64
|
-
| `close(uri)`
|
|
65
|
-
| `diagnostics(uri)`
|
|
66
|
-
| `inlayHint(uri, range)`
|
|
67
|
-
| `definition(uri, position)`
|
|
68
|
-
| `references(uri, position, includeDeclaration)` | `Location[]`
|
|
69
|
-
| `hover(uri, position)`
|
|
70
|
-
| `documentSymbol(uri)`
|
|
71
|
-
| `workspaceSymbol(query)`
|
|
72
|
-
| `queryCls(query)`
|
|
73
|
-
| `queryMem(cls, query)`
|
|
74
|
+
| Method | Returns |
|
|
75
|
+
| ----------------------------------------------- | ----------------------------------------------------- |
|
|
76
|
+
| `open(uri, text)` | uris whose analysis is now stale |
|
|
77
|
+
| `close(uri)` | uris whose analysis is now stale |
|
|
78
|
+
| `diagnostics(uri)` | `Diagnostic[]` |
|
|
79
|
+
| `inlayHint(uri, range)` | `InlayHint[]` |
|
|
80
|
+
| `definition(uri, position)` | `Location \| undefined` |
|
|
81
|
+
| `references(uri, position, includeDeclaration)` | `Location[]` |
|
|
82
|
+
| `hover(uri, position)` | markdown `string \| undefined` |
|
|
83
|
+
| `documentSymbol(uri)` | the class or routine and its members or labels |
|
|
84
|
+
| `workspaceSymbol(query)` | classes and members across the workspace by prefix |
|
|
85
|
+
| `queryCls(query)` | `[uri, ClassInfo][]` for classes by prefix |
|
|
86
|
+
| `queryMem(cls, query)` | `[uri, MemberInfo][]` for a class's members by prefix |
|
|
74
87
|
|
|
75
88
|
All result types (`Diagnostic`, `Location`, `ClassInfo`, `MemberInfo`, ...) are exported
|
|
76
89
|
from the package.
|
|
77
90
|
|
|
78
|
-
Calls are serialized: one runs at a time, and the rest queue behind it
|
|
79
|
-
created by this package
|
|
80
|
-
them all from the same implementation.
|
|
91
|
+
Calls are serialized: one runs at a time, and the rest queue behind it, across every
|
|
92
|
+
`Workspace` created by this package, since they share one wasm instance.
|
|
81
93
|
|
|
82
94
|
## Bundling
|
|
83
95
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Root } from "../generated/ascot.js" with { "resolution-mode": "import" };
|
|
2
|
-
import type { ClassInfo, RoutineSource } from "../generated/interfaces/iris-ascot-common.js" with { "resolution-mode": "import"
|
|
2
|
+
import type { ClassInfo, RoutineSource, Style } from "../generated/interfaces/iris-ascot-common.js" with { "resolution-mode": "import"
|
|
3
3
|
};
|
|
4
4
|
export type * from "../generated/interfaces/iris-ascot-common.js";
|
|
5
5
|
type RawWorkspace = InstanceType<Root["exported"]["Workspace"]>;
|
|
@@ -8,15 +8,19 @@ type RawWorkspace = InstanceType<Root["exported"]["Workspace"]>;
|
|
|
8
8
|
export type Workspace = {
|
|
9
9
|
[K in keyof RawWorkspace]: RawWorkspace[K] extends (...args: infer A) => infer R ? (...args: A) => Promise<Awaited<R>> : RawWorkspace[K];
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
getCls(
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export declare class IrisConnection {
|
|
12
|
+
/** A class's own members and metadata. */
|
|
13
|
+
getCls(_cls: string): Promise<ClassInfo | undefined>;
|
|
14
|
+
/** The text of `name.inc`. */
|
|
15
|
+
getInc(_name: string): Promise<RoutineSource | undefined>;
|
|
16
|
+
/** The text of `name.int` or `name.mac`: `{ tag: "none" }` if there is no such routine,
|
|
17
|
+
* `val: undefined` if its source isn't available. */
|
|
18
|
+
getIntOrMac(_name: string): Promise<{
|
|
19
|
+
tag: "none";
|
|
20
|
+
} | {
|
|
21
|
+
tag: "some";
|
|
22
|
+
val: RoutineSource | undefined;
|
|
23
|
+
}>;
|
|
16
24
|
}
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
* calls (e.g. from two documents' diagnostics resolving concurrently) can't trip ascot's
|
|
20
|
-
* internal `RefCell` borrows or jco's single-in-flight-call constraint.
|
|
21
|
-
*/
|
|
22
|
-
export declare function createWorkspace(imported: Imported): Promise<Workspace>;
|
|
25
|
+
/** A workspace whose calls run one at a time, resolving what it doesn't contain through `iris`. */
|
|
26
|
+
export declare function createWorkspace(iris?: IrisConnection, style?: Style): Promise<Workspace>;
|
package/dist/index.js
CHANGED
|
@@ -33,21 +33,31 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.IrisConnection = void 0;
|
|
36
37
|
exports.createWorkspace = createWorkspace;
|
|
37
38
|
const fs = __importStar(require("node:fs"));
|
|
38
39
|
const path = __importStar(require("node:path"));
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
async
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
class IrisConnection {
|
|
41
|
+
/** A class's own members and metadata. */
|
|
42
|
+
async getCls(_cls) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
/** The text of `name.inc`. */
|
|
46
|
+
async getInc(_name) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
/** The text of `name.int` or `name.mac`: `{ tag: "none" }` if there is no such routine,
|
|
50
|
+
* `val: undefined` if its source isn't available. */
|
|
51
|
+
async getIntOrMac(_name) {
|
|
52
|
+
return { tag: "some", val: undefined };
|
|
53
|
+
}
|
|
50
54
|
}
|
|
55
|
+
exports.IrisConnection = IrisConnection;
|
|
56
|
+
const wasm = import("../generated/ascot.js").then(({ instantiate }) => instantiate((name) => new WebAssembly.Module(fs.readFileSync(path.resolve(__dirname, "../lib", name))), {
|
|
57
|
+
"iris:ascot/common": {},
|
|
58
|
+
"iris:ascot/imported": { IrisConnection },
|
|
59
|
+
}));
|
|
60
|
+
wasm.catch(() => { }); // reported by createWorkspace instead
|
|
51
61
|
// jco's jspi glue allows only one in-flight suspended call per component instance --
|
|
52
62
|
// overlapping calls (e.g. diagnostics() and hover() both awaiting a REST round trip)
|
|
53
63
|
// trip its exclusive-lock check. Every `Workspace` this package creates shares the same
|
|
@@ -74,14 +84,9 @@ function serialize(instance) {
|
|
|
74
84
|
},
|
|
75
85
|
});
|
|
76
86
|
}
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*/
|
|
82
|
-
async function createWorkspace(imported) {
|
|
83
|
-
const IrisConnection = Object.getPrototypeOf(imported).constructor;
|
|
84
|
-
const root = await loadWasm(IrisConnection);
|
|
85
|
-
return serialize(new root.exported.Workspace(imported));
|
|
87
|
+
/** A workspace whose calls run one at a time, resolving what it doesn't contain through `iris`. */
|
|
88
|
+
async function createWorkspace(iris, style) {
|
|
89
|
+
const root = await wasm;
|
|
90
|
+
return serialize(new root.exported.Workspace(iris, style));
|
|
86
91
|
}
|
|
87
92
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,EAAE,oCAAgB;AAC9B,MAAY,IAAI,sCAAkB;AA4BlC;IACC,0CAA0C;IAC1C,KAAK,CAAC,MAAM,CAAC,IAAY;QACxB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,8BAA8B;IAC9B,KAAK,CAAC,MAAM,CAAC,KAAa;QACzB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD;yDACqD;IACrD,KAAK,CAAC,WAAW,CAChB,KAAa;QAEb,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;IACxC,CAAC;CACD;;AAED,MAAM,IAAI,GAAkB,MAAM,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CACpF,WAAW,CACV,CAAC,IAAY,EAAE,EAAE,C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