@gdscript-analyzer/core 0.2.1 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +26 -23
  2. package/index.d.ts +26 -23
  3. package/package.json +7 -7
package/README.md CHANGED
@@ -35,13 +35,14 @@ func _ready() -> void:
35
35
  print(half)
36
36
  `, null);
37
37
 
38
- // Diagnostics come back as a JSON string.
39
- console.log(JSON.parse(az.diagnostics(uri)));
38
+ // Diagnostics come back as a native JS array — no JSON.parse.
39
+ console.log(az.diagnostics(uri));
40
40
  // → [{ code: "INTEGER_DIVISION", severity: "warning", range: { start, end }, message: ... }]
41
41
  ```
42
42
 
43
- Every query that returns data returns a **JSON string** (parse it). Positions are
44
- **UTF-8 byte offsets** (see [Positions](#positions-byte-offsets) below).
43
+ Every query returns a **native JS value** (object / array / `null`) no
44
+ `JSON.parse`. Positions are **UTF-8 byte offsets** (see
45
+ [Positions](#positions-byte-offsets) below).
45
46
 
46
47
  ---
47
48
 
@@ -84,31 +85,33 @@ URI (re-sending would needlessly invalidate the resource-path registry). Use
84
85
  ## API
85
86
 
86
87
  All queries take a `uri`; offset-based queries take a UTF-8 **byte** `offset`.
87
- Array/object queries return a **JSON string**; the `… | null` ones return JS
88
- `null` when there's nothing at the offset.
88
+ Array/object queries return a **native JS value**; the `… | null` ones return JS
89
+ `null` when there's nothing at the offset. Navigation/edit results
90
+ (`gotoDefinition`, `findReferences`, `rename`) carry a `uri` per target, so you
91
+ need no `FileId`→URI mapping of your own.
89
92
 
90
93
  | Method | Returns | What |
91
94
  | --- | --- | --- |
92
- | `diagnostics(uri)` | JSON array | parse + type diagnostics |
93
- | `documentSymbols(uri)` | JSON array | the document outline |
94
- | `foldingRanges(uri)` | JSON array | foldable ranges |
95
- | `inlayHints(uri)` | JSON array | inferred-type / param inlay hints |
96
- | `completions(uri, offset)` | JSON array | completions at `offset` |
97
- | `hover(uri, offset)` | JSON string \| `null` | type + docs at `offset` |
98
- | `signatureHelp(uri, offset)` | JSON string \| `null` | active call signature |
99
- | `codeActions(uri, offset)` | JSON array | quick fixes at `offset` |
100
- | `gotoDefinition(uri, offset)` | JSON array | definition target(s) |
101
- | `findReferences(uri, offset)` | JSON array | all references |
102
- | `rename(uri, offset, newName)` | JSON string | `{"ok": SourceChange}` or `{"error": RenameError}` |
103
- | `workspaceSymbols(query)` | JSON array | project-wide symbol search |
104
- | `syntaxTree(uri)` | JSON string \| `null` | pretty-printed CST (debugging) |
95
+ | `diagnostics(uri)` | array | parse + type diagnostics |
96
+ | `documentSymbols(uri)` | array | the document outline |
97
+ | `foldingRanges(uri)` | array | foldable ranges |
98
+ | `inlayHints(uri)` | array | inferred-type / param inlay hints |
99
+ | `completions(uri, offset)` | array | completions at `offset` |
100
+ | `hover(uri, offset)` | object \| `null` | type + docs at `offset` |
101
+ | `signatureHelp(uri, offset)` | object \| `null` | active call signature |
102
+ | `codeActions(uri, offset)` | array | quick fixes at `offset` |
103
+ | `gotoDefinition(uri, offset)` | array | definition target(s) (each with a `uri`) |
104
+ | `findReferences(uri, offset)` | array | all references (each with a `uri`) |
105
+ | `rename(uri, offset, newName)` | object | `{ ok: SourceChange }` or `{ error: RenameError }` |
106
+ | `workspaceSymbols(query)` | array | project-wide symbol search |
107
+ | `syntaxTree(uri)` | string \| `null` | pretty-printed CST (debugging) |
105
108
 
106
109
  ```js
107
110
  const offset = 38; // a UTF-8 byte offset into the document
108
- JSON.parse(az.completions(uri, offset));
109
- const hover = az.hover(uri, offset); // string | null
110
- if (hover) console.log(JSON.parse(hover));
111
- JSON.parse(az.gotoDefinition(uri, offset));
111
+ az.completions(uri, offset); // array
112
+ const hover = az.hover(uri, offset); // object | null
113
+ if (hover) console.log(hover);
114
+ az.gotoDefinition(uri, offset); // array, each target has a `uri`
112
115
  ```
113
116
 
114
117
  ### Positions (byte offsets)
package/index.d.ts CHANGED
@@ -29,33 +29,36 @@ export declare class AnalysisHandle {
29
29
  * empty result (the array queries return `[]` and the `null`-returning queries `null` for both).
30
30
  */
31
31
  isOpen(uri: string): boolean
32
- /** Parse + type diagnostics for `uri`, as a JSON array string. */
33
- diagnostics(uri: string): string
34
- /** The document outline for `uri`, as a JSON array string. */
35
- documentSymbols(uri: string): string
36
- /** Foldable ranges for `uri`, as a JSON array string. */
37
- foldingRanges(uri: string): string
38
- /** Inlay hints for `uri`, as a JSON array string. */
39
- inlayHints(uri: string): string
40
- /** Completions at a byte `offset` in `uri`, as a JSON array string. */
41
- completions(uri: string, offset: number): string
32
+ /** Parse + type diagnostics for `uri`, as a JS array. */
33
+ diagnostics(uri: string): any
34
+ /** The document outline for `uri`, as a JS array. */
35
+ documentSymbols(uri: string): any
36
+ /** Foldable ranges for `uri`, as a JS array. */
37
+ foldingRanges(uri: string): any
38
+ /** Inlay hints for `uri`, as a JS array. */
39
+ inlayHints(uri: string): any
40
+ /** Completions at a byte `offset` in `uri`, as a JS array. */
41
+ completions(uri: string, offset: number): any
42
42
  /** Hover at a byte `offset` in `uri`; JS `null` when there is nothing typed there. */
43
- hover(uri: string, offset: number): string | null
43
+ hover(uri: string, offset: number): any | null
44
44
  /** Signature help at a byte `offset` in `uri`; JS `null` when not at a call site. */
45
- signatureHelp(uri: string, offset: number): string | null
46
- /** Code actions at a byte `offset` in `uri`, as a JSON array string. */
47
- codeActions(uri: string, offset: number): string
48
- /** Go-to-definition target(s) for the symbol at a byte `offset` in `uri`, as a JSON array string. */
49
- gotoDefinition(uri: string, offset: number): string
50
- /** Every reference to the symbol at a byte `offset` in `uri`, as a JSON array string. */
51
- findReferences(uri: string, offset: number): string
45
+ signatureHelp(uri: string, offset: number): any | null
46
+ /** Code actions at a byte `offset` in `uri`, as a JS array. */
47
+ codeActions(uri: string, offset: number): any
52
48
  /**
53
- * Rename the symbol at a byte `offset` in `uri` to `newName`. JSON object string:
54
- * `{"ok": <SourceChange>}` or `{"error": <RenameError>}`.
49
+ * Go-to-definition target(s) for the symbol at a byte `offset` in `uri`, as a JS array (each
50
+ * target carries a `uri`).
55
51
  */
56
- rename(uri: string, offset: number, newName: string): string
57
- /** Project-wide symbols matching `query`, as a JSON array string. */
58
- workspaceSymbols(query: string): string
52
+ gotoDefinition(uri: string, offset: number): any
53
+ /** Every reference to the symbol at a byte `offset` in `uri`, as a JS array (each carries a `uri`). */
54
+ findReferences(uri: string, offset: number): any
55
+ /**
56
+ * Rename the symbol at a byte `offset` in `uri` to `newName`. A JS object:
57
+ * `{ ok: <SourceChange> }` or `{ error: <RenameError> }` (edits carry a `uri`).
58
+ */
59
+ rename(uri: string, offset: number, newName: string): any
60
+ /** Project-wide symbols matching `query`, as a JS array. */
61
+ workspaceSymbols(query: string): any
59
62
  /** The pretty-printed syntax tree for `uri` (debugging); JS `null` for an unknown `uri`. */
60
63
  syntaxTree(uri: string): string | null
61
64
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "//": "npm packaging for the napi-rs addon built from crates/gdscript-ffi. Per-platform `@gdscript-analyzer/core-<triple>` packages are wired as optionalDependencies (generated by `napi create-npm-dirs`); the loader index.js picks the right one at runtime.",
3
3
  "name": "@gdscript-analyzer/core",
4
4
  "//version": "Authoritative version is synced from Cargo.toml by release-napi.yml at publish time; this value is a fallback for local/manual publishes.",
5
- "version": "0.2.1",
5
+ "version": "0.4.0",
6
6
  "description": "Headless GDScript (Godot 4.x) static analysis for Node — diagnostics, type-aware hover, completion, symbols, and navigation. The native binding of gdscript-analyzer (Roslyn for Godot).",
7
7
  "license": "(MIT OR Apache-2.0)",
8
8
  "author": "Yaniv Kalfa <yanivkalfa@gmail.com>",
@@ -63,11 +63,11 @@
63
63
  ]
64
64
  },
65
65
  "optionalDependencies": {
66
- "@gdscript-analyzer/core-darwin-x64": "0.2.1",
67
- "@gdscript-analyzer/core-darwin-arm64": "0.2.1",
68
- "@gdscript-analyzer/core-win32-x64-msvc": "0.2.1",
69
- "@gdscript-analyzer/core-win32-arm64-msvc": "0.2.1",
70
- "@gdscript-analyzer/core-linux-x64-gnu": "0.2.1",
71
- "@gdscript-analyzer/core-linux-arm64-gnu": "0.2.1"
66
+ "@gdscript-analyzer/core-darwin-x64": "0.4.0",
67
+ "@gdscript-analyzer/core-darwin-arm64": "0.4.0",
68
+ "@gdscript-analyzer/core-win32-x64-msvc": "0.4.0",
69
+ "@gdscript-analyzer/core-win32-arm64-msvc": "0.4.0",
70
+ "@gdscript-analyzer/core-linux-x64-gnu": "0.4.0",
71
+ "@gdscript-analyzer/core-linux-arm64-gnu": "0.4.0"
72
72
  }
73
73
  }