@telorun/ide-support 0.2.6 → 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/dist/diagnostics/find-positions.d.ts +19 -0
- package/dist/diagnostics/find-positions.d.ts.map +1 -0
- package/dist/diagnostics/find-positions.js +65 -0
- package/dist/diagnostics/index.d.ts +1 -0
- package/dist/diagnostics/index.d.ts.map +1 -1
- package/dist/diagnostics/index.js +1 -0
- package/dist/diagnostics/normalize.d.ts.map +1 -1
- package/dist/diagnostics/normalize.js +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/diagnostics/find-positions.ts +80 -0
- package/src/diagnostics/index.ts +1 -0
- package/src/diagnostics/normalize.ts +1 -0
- package/src/types.ts +5 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LoadedGraph, PositionIndex } from "@telorun/analyzer";
|
|
2
|
+
/** Diagnostic location lookup: which file owns the diagnostic's resource,
|
|
3
|
+
* and what positions does that file's parse expose. Encapsulates the
|
|
4
|
+
* routing both the editor and the vscode/CLI hosts previously wrote
|
|
5
|
+
* inline against per-manifest metadata fields.
|
|
6
|
+
*
|
|
7
|
+
* Resolution order:
|
|
8
|
+
* 1. `data.resource.{kind,name}` → search every LoadedFile in the graph
|
|
9
|
+
* for the doc with matching kind+name. Returns that file's source +
|
|
10
|
+
* its positions for the matching doc index.
|
|
11
|
+
* 2. `data.filePath` → match the owning LoadedFile by canonical source.
|
|
12
|
+
*
|
|
13
|
+
* Returns `undefined` if the diagnostic carries no usable identity. */
|
|
14
|
+
export declare function findPositions(graph: LoadedGraph, diagnosticData: unknown): {
|
|
15
|
+
file: string;
|
|
16
|
+
positionIndex?: PositionIndex;
|
|
17
|
+
sourceLine?: number;
|
|
18
|
+
} | undefined;
|
|
19
|
+
//# sourceMappingURL=find-positions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-positions.d.ts","sourceRoot":"","sources":["../../src/diagnostics/find-positions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEpE;;;;;;;;;;;wEAWwE;AACxE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,OAAO,GAErB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACpE,SAAS,CAiBZ"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** Diagnostic location lookup: which file owns the diagnostic's resource,
|
|
2
|
+
* and what positions does that file's parse expose. Encapsulates the
|
|
3
|
+
* routing both the editor and the vscode/CLI hosts previously wrote
|
|
4
|
+
* inline against per-manifest metadata fields.
|
|
5
|
+
*
|
|
6
|
+
* Resolution order:
|
|
7
|
+
* 1. `data.resource.{kind,name}` → search every LoadedFile in the graph
|
|
8
|
+
* for the doc with matching kind+name. Returns that file's source +
|
|
9
|
+
* its positions for the matching doc index.
|
|
10
|
+
* 2. `data.filePath` → match the owning LoadedFile by canonical source.
|
|
11
|
+
*
|
|
12
|
+
* Returns `undefined` if the diagnostic carries no usable identity. */
|
|
13
|
+
export function findPositions(graph, diagnosticData) {
|
|
14
|
+
const data = diagnosticData;
|
|
15
|
+
if (!data)
|
|
16
|
+
return undefined;
|
|
17
|
+
if (data.resource?.kind && data.resource.name) {
|
|
18
|
+
const result = findByResource(graph, data.resource.kind, data.resource.name);
|
|
19
|
+
if (result)
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
if (data.filePath) {
|
|
23
|
+
const result = findByFile(graph, data.filePath);
|
|
24
|
+
if (result)
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
function findByResource(graph, kind, name) {
|
|
30
|
+
for (const mod of graph.modules.values()) {
|
|
31
|
+
for (const file of [mod.owner, ...mod.partials]) {
|
|
32
|
+
for (let i = 0; i < file.manifests.length; i++) {
|
|
33
|
+
const m = file.manifests[i];
|
|
34
|
+
if (!m)
|
|
35
|
+
continue;
|
|
36
|
+
if (m.kind !== kind)
|
|
37
|
+
continue;
|
|
38
|
+
if (m.metadata?.name !== name)
|
|
39
|
+
continue;
|
|
40
|
+
const pos = file.positions[i];
|
|
41
|
+
return {
|
|
42
|
+
file: file.source,
|
|
43
|
+
positionIndex: pos?.positionIndex,
|
|
44
|
+
sourceLine: pos?.sourceLine,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
function findByFile(graph, filePath) {
|
|
52
|
+
for (const mod of graph.modules.values()) {
|
|
53
|
+
for (const file of [mod.owner, ...mod.partials]) {
|
|
54
|
+
if (file.source === filePath) {
|
|
55
|
+
const pos = file.positions[0];
|
|
56
|
+
return {
|
|
57
|
+
file: file.source,
|
|
58
|
+
positionIndex: pos?.positionIndex,
|
|
59
|
+
sourceLine: pos?.sourceLine,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/diagnostics/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI3E;;;;;;oEAMoE;AACpE,wBAAgB,mBAAmB,CACjC,CAAC,EAAE,kBAAkB,EACrB,GAAG,EAAE,iBAAiB,GACrB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/diagnostics/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI3E;;;;;;oEAMoE;AACpE,wBAAgB,mBAAmB,CACjC,CAAC,EAAE,kBAAkB,EACrB,GAAG,EAAE,iBAAiB,GACrB,oBAAoB,CAetB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export interface NormalizedDiagnostic {
|
|
|
22
22
|
kind: "replace-kind";
|
|
23
23
|
replacement: string;
|
|
24
24
|
}>;
|
|
25
|
+
/** Preserved verbatim from the source `AnalysisDiagnostic`. Carries
|
|
26
|
+
* resource/path stamps that downstream UIs (popovers, "at <path>" hints,
|
|
27
|
+
* CodeAction wiring) read after normalization. Opaque on purpose so this
|
|
28
|
+
* module doesn't pin a shape that the analyzer evolves over time. */
|
|
29
|
+
data?: unknown;
|
|
25
30
|
}
|
|
26
31
|
export interface DiagnosticContext {
|
|
27
32
|
registry: AnalysisRegistry;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGzE,YAAY,EACV,QAAQ,EACR,KAAK,EACL,kBAAkB,EAClB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpG,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,YAAY,GAAG,UAAU,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGzE,YAAY,EACV,QAAQ,EACR,KAAK,EACL,kBAAkB,EAClB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpG,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,YAAY,GAAG,UAAU,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE;;;0EAGsE;IACtE,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/ide-support",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Editor-host-agnostic IDE support (completions, diagnostic normalization) for Telo manifests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"telo",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"src/**"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@telorun/analyzer": "0.
|
|
39
|
+
"@telorun/analyzer": "0.9.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^20.0.0",
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { LoadedGraph, PositionIndex } from "@telorun/analyzer";
|
|
2
|
+
|
|
3
|
+
/** Diagnostic location lookup: which file owns the diagnostic's resource,
|
|
4
|
+
* and what positions does that file's parse expose. Encapsulates the
|
|
5
|
+
* routing both the editor and the vscode/CLI hosts previously wrote
|
|
6
|
+
* inline against per-manifest metadata fields.
|
|
7
|
+
*
|
|
8
|
+
* Resolution order:
|
|
9
|
+
* 1. `data.resource.{kind,name}` → search every LoadedFile in the graph
|
|
10
|
+
* for the doc with matching kind+name. Returns that file's source +
|
|
11
|
+
* its positions for the matching doc index.
|
|
12
|
+
* 2. `data.filePath` → match the owning LoadedFile by canonical source.
|
|
13
|
+
*
|
|
14
|
+
* Returns `undefined` if the diagnostic carries no usable identity. */
|
|
15
|
+
export function findPositions(
|
|
16
|
+
graph: LoadedGraph,
|
|
17
|
+
diagnosticData: unknown,
|
|
18
|
+
):
|
|
19
|
+
| { file: string; positionIndex?: PositionIndex; sourceLine?: number }
|
|
20
|
+
| undefined {
|
|
21
|
+
const data = diagnosticData as
|
|
22
|
+
| { resource?: { kind?: string; name?: string }; filePath?: string }
|
|
23
|
+
| undefined;
|
|
24
|
+
if (!data) return undefined;
|
|
25
|
+
|
|
26
|
+
if (data.resource?.kind && data.resource.name) {
|
|
27
|
+
const result = findByResource(graph, data.resource.kind, data.resource.name);
|
|
28
|
+
if (result) return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (data.filePath) {
|
|
32
|
+
const result = findByFile(graph, data.filePath);
|
|
33
|
+
if (result) return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function findByResource(
|
|
40
|
+
graph: LoadedGraph,
|
|
41
|
+
kind: string,
|
|
42
|
+
name: string,
|
|
43
|
+
): { file: string; positionIndex?: PositionIndex; sourceLine?: number } | undefined {
|
|
44
|
+
for (const mod of graph.modules.values()) {
|
|
45
|
+
for (const file of [mod.owner, ...mod.partials]) {
|
|
46
|
+
for (let i = 0; i < file.manifests.length; i++) {
|
|
47
|
+
const m = file.manifests[i];
|
|
48
|
+
if (!m) continue;
|
|
49
|
+
if (m.kind !== kind) continue;
|
|
50
|
+
if (m.metadata?.name !== name) continue;
|
|
51
|
+
const pos = file.positions[i];
|
|
52
|
+
return {
|
|
53
|
+
file: file.source,
|
|
54
|
+
positionIndex: pos?.positionIndex,
|
|
55
|
+
sourceLine: pos?.sourceLine,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function findByFile(
|
|
64
|
+
graph: LoadedGraph,
|
|
65
|
+
filePath: string,
|
|
66
|
+
): { file: string; positionIndex?: PositionIndex; sourceLine?: number } | undefined {
|
|
67
|
+
for (const mod of graph.modules.values()) {
|
|
68
|
+
for (const file of [mod.owner, ...mod.partials]) {
|
|
69
|
+
if (file.source === filePath) {
|
|
70
|
+
const pos = file.positions[0];
|
|
71
|
+
return {
|
|
72
|
+
file: file.source,
|
|
73
|
+
positionIndex: pos?.positionIndex,
|
|
74
|
+
sourceLine: pos?.sourceLine,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
package/src/diagnostics/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -32,6 +32,11 @@ export interface NormalizedDiagnostic {
|
|
|
32
32
|
source: string;
|
|
33
33
|
message: string;
|
|
34
34
|
suggestions?: Array<{ kind: "replace-kind"; replacement: string }>;
|
|
35
|
+
/** Preserved verbatim from the source `AnalysisDiagnostic`. Carries
|
|
36
|
+
* resource/path stamps that downstream UIs (popovers, "at <path>" hints,
|
|
37
|
+
* CodeAction wiring) read after normalization. Opaque on purpose so this
|
|
38
|
+
* module doesn't pin a shape that the analyzer evolves over time. */
|
|
39
|
+
data?: unknown;
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
export interface DiagnosticContext {
|