@intersystems-community/ascot 0.1.0 → 0.1.1
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 +90 -0
- package/lib/ascot.core.wasm +0 -0
- package/package.json +11 -2
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @intersystems-community/ascot
|
|
2
|
+
|
|
3
|
+
[ascot](https://github.com/intersystems-community/ascot) is a type checker and code
|
|
4
|
+
intelligence engine for InterSystems ObjectScript. This package is its WebAssembly build
|
|
5
|
+
for Node and other JavaScript hosts, with a small TypeScript wrapper. It is the engine
|
|
6
|
+
behind the InterSystems Language Server's ascot features; it does not include the `ascot`
|
|
7
|
+
command-line tool.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @intersystems-community/ascot
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createWorkspace, type Imported } from "@intersystems-community/ascot";
|
|
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
|
+
}
|
|
26
|
+
|
|
27
|
+
const ws = await createWorkspace(new NoIris());
|
|
28
|
+
|
|
29
|
+
// `open` is both open and edit: it stores the raw text (the kind comes from the uri's
|
|
30
|
+
// extension: .cls, .mac, .int, .inc) and returns the uris whose cached analysis is now
|
|
31
|
+
// stale, this one and anything that includes or references it.
|
|
32
|
+
await ws.open("file:///T.cls", `Class T Extends %RegisteredObject
|
|
33
|
+
{
|
|
34
|
+
ClassMethod M() As %Status
|
|
35
|
+
{
|
|
36
|
+
Set x = 1
|
|
37
|
+
Write x
|
|
38
|
+
Quit
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`);
|
|
42
|
+
|
|
43
|
+
await ws.diagnostics("file:///T.cls");
|
|
44
|
+
// [{ severity: "error", message: "Expected return value of type '%Status' but got nothing",
|
|
45
|
+
// range: { start: { line: 6, character: 5 }, ... }, relatedInformation: [...] }]
|
|
46
|
+
|
|
47
|
+
await ws.hover("file:///T.cls", { line: 5, character: 7 }); // the `x` being written
|
|
48
|
+
// "```objectscript\n%DataType = 1\n```"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Load every file of a project into one `Workspace` so cross-file references resolve, and
|
|
52
|
+
call `open` again on each edit. `close(uri)` removes a document; a closed editor tab is
|
|
53
|
+
usually not a removal, so keep the on-disk text open instead.
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
`createWorkspace(imported)` returns a `Workspace` whose methods mirror the engine's
|
|
58
|
+
exports, all returning promises. Positions and ranges are zero-based line/character pairs,
|
|
59
|
+
as in the Language Server Protocol.
|
|
60
|
+
|
|
61
|
+
| Method | Returns |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| `open(uri, text)` | uris whose analysis is now stale |
|
|
64
|
+
| `close(uri)` | uris whose analysis is now stale |
|
|
65
|
+
| `diagnostics(uri)` | `Diagnostic[]` |
|
|
66
|
+
| `inlayHint(uri, range)` | `InlayHint[]` |
|
|
67
|
+
| `definition(uri, position)` | `Location \| undefined` |
|
|
68
|
+
| `references(uri, position, includeDeclaration)` | `Location[]` |
|
|
69
|
+
| `hover(uri, position)` | markdown `string \| undefined` |
|
|
70
|
+
| `documentSymbol(uri)` | the class or routine and its members or labels |
|
|
71
|
+
| `workspaceSymbol(query)` | classes and members across the workspace by prefix |
|
|
72
|
+
| `queryCls(query)` | `[uri, ClassInfo][]` for classes by prefix |
|
|
73
|
+
| `queryMem(cls, query)` | `[uri, MemberInfo][]` for a class's members by prefix |
|
|
74
|
+
|
|
75
|
+
All result types (`Diagnostic`, `Location`, `ClassInfo`, `MemberInfo`, ...) are exported
|
|
76
|
+
from the package.
|
|
77
|
+
|
|
78
|
+
Calls are serialized: one runs at a time, and the rest queue behind it. Every `Workspace`
|
|
79
|
+
created by this package shares one wasm instance and one `Imported` class, so construct
|
|
80
|
+
them all from the same implementation.
|
|
81
|
+
|
|
82
|
+
## Bundling
|
|
83
|
+
|
|
84
|
+
The core wasm modules are read from this package's `lib/` directory at runtime, relative
|
|
85
|
+
to the wrapper's own location. If you bundle the JavaScript, copy `lib/*.core*.wasm` to a
|
|
86
|
+
`lib/` directory next to your bundle's output directory.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT or Apache-2.0, at your option.
|
package/lib/ascot.core.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intersystems-community/ascot",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "ascot, a type checker and code intelligence engine for InterSystems ObjectScript, for Node and other JS consumers.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"intersystems",
|
|
8
|
+
"iris",
|
|
9
|
+
"objectscript",
|
|
10
|
+
"type-checker",
|
|
11
|
+
"static-analysis",
|
|
12
|
+
"language-server",
|
|
13
|
+
"wasm"
|
|
14
|
+
],
|
|
6
15
|
"repository": {
|
|
7
16
|
"type": "git",
|
|
8
17
|
"url": "https://github.com/intersystems-community/ascot.git",
|
|
@@ -16,7 +25,7 @@
|
|
|
16
25
|
"lib/*.core*.wasm"
|
|
17
26
|
],
|
|
18
27
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
28
|
+
"node": ">=24"
|
|
20
29
|
},
|
|
21
30
|
"scripts": {
|
|
22
31
|
"build": "bash scripts/build.sh"
|