@hydranium/protocol 1.0.0-next.6 → 1.0.0-next.61
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 +35 -1
- package/lib/client/data-connection.d.ts +76 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +73 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +9 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +14 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +16 -21
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +56 -74
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +67 -101
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +5 -2
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +5 -2
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +8 -2
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +10 -4
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +116 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +155 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/data/data-protocol-methods.d.ts +2 -2
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +6 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +21 -1
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +70 -3
- package/lib/data/events.d.ts.map +1 -1
- package/lib/errors.d.ts +25 -6
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +32 -12
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/messages/index.d.ts +28 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +52 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +141 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +138 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +2 -2
- package/lib/model-server.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.d.ts +29 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +22 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +7 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +6 -1
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/testing/catalogue-audit.d.ts +80 -0
- package/lib/testing/catalogue-audit.d.ts.map +1 -0
- package/lib/testing/catalogue-audit.js +94 -0
- package/lib/testing/catalogue-audit.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +11 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +14 -5
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js +4 -1
- package/lib/testing/index.js.map +1 -1
- package/lib/transfer-diagnostic.d.ts +33 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +23 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/package.json +11 -2
- package/src/client/data-connection.ts +114 -0
- package/src/client/data-events.ts +24 -1
- package/src/client/data-port.ts +16 -22
- package/src/client/data-session.ts +86 -124
- package/src/client/index.ts +5 -2
- package/src/client/message-relay.ts +28 -6
- package/src/client/rpc-connection.ts +205 -0
- package/src/data/data-protocol-methods.ts +6 -3
- package/src/data/data-server-protocol.ts +29 -1
- package/src/data/events.ts +74 -3
- package/src/errors.ts +38 -14
- package/src/index.ts +4 -0
- package/src/messages/index.ts +35 -0
- package/src/messages/primitives.ts +215 -0
- package/src/model-server.ts +2 -2
- package/src/rpc/bind-rpc-methods.ts +49 -4
- package/src/rpc/create-rpc-proxy.ts +14 -1
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +33 -17
- package/src/testing/index.ts +4 -1
- package/src/transfer-diagnostic.ts +40 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
|
|
10
|
+
import { collectMessages } from '../messages/primitives';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Audit a translation catalogue against the codes that actually exist.
|
|
14
|
+
*
|
|
15
|
+
* **The one failure mode a catalogue has, and the only one nothing else
|
|
16
|
+
* catches.** A key naming no declared code falls back to the English — which is
|
|
17
|
+
* byte-identical to a deliberate omission, so a typo is invisible at runtime and
|
|
18
|
+
* indistinguishable from the partial-catalogue behaviour every adopter relies
|
|
19
|
+
* on. Nothing on the render path can tell them apart, `theia nls-extract`
|
|
20
|
+
* reports what the SOURCE declares rather than whether a catalogue matches it,
|
|
21
|
+
* and the framework's own gates see only the framework's own files.
|
|
22
|
+
*
|
|
23
|
+
* Shipped as test support rather than as a runtime check on purpose: an
|
|
24
|
+
* orphaned key is an authoring mistake, and failing a server boot over one would
|
|
25
|
+
* take a running product down for a cosmetic defect.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Flatten a nested catalogue into the `/`-joined keys a message code is spelled
|
|
30
|
+
* with, dropping `_`-prefixed keys as notes to a human reader.
|
|
31
|
+
*
|
|
32
|
+
* Nesting is a HOST convention, not the framework's: Theia flattens a nested
|
|
33
|
+
* catalogue by joining keys with `/`, which is the separator a code already
|
|
34
|
+
* uses, so an adopter on that host writes the file nested and one handed
|
|
35
|
+
* straight to a `DefaultMessageRenderer` writes it flat. Both end up here.
|
|
36
|
+
*
|
|
37
|
+
* `_`-prefixed keys are dropped by PREFIX rather than by matching one literal
|
|
38
|
+
* name, so a second note added to a file cannot silently become a catalogue
|
|
39
|
+
* entry. A code is three `/`-separated segments, so no real entry can begin
|
|
40
|
+
* with `_`.
|
|
41
|
+
*/
|
|
42
|
+
export function flattenCatalogue(catalogue: Record<string, unknown>, prefix = ''): Record<string, string> {
|
|
43
|
+
const flat: Record<string, string> = {};
|
|
44
|
+
for (const [key, value] of Object.entries(catalogue)) {
|
|
45
|
+
if (key.startsWith('_')) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const joined = prefix ? `${prefix}/${key}` : key;
|
|
49
|
+
if (typeof value === 'string') {
|
|
50
|
+
flat[joined] = value;
|
|
51
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
52
|
+
Object.assign(flat, flattenCatalogue(value as Record<string, unknown>, joined));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return flat;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Options for {@link findUndeclaredCodes}. */
|
|
59
|
+
export interface CatalogueAuditOptions {
|
|
60
|
+
/**
|
|
61
|
+
* Key prefixes to skip, for entries whose codes are NOT declared through a
|
|
62
|
+
* `defineMessage` barrel.
|
|
63
|
+
*
|
|
64
|
+
* The real case is a host's own mechanism: Theia's `nls.localize` takes its
|
|
65
|
+
* key as an inline literal at the call site, so those keys exist only in
|
|
66
|
+
* source text and no barrel can enumerate them. Keep this as narrow as the
|
|
67
|
+
* host layer actually is — exempting a namespace is exempting every typo in
|
|
68
|
+
* it, which is what this function exists to find.
|
|
69
|
+
*/
|
|
70
|
+
readonly exemptPrefixes?: readonly string[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Every catalogue key that names no code any of `barrels` declares.
|
|
75
|
+
*
|
|
76
|
+
* Barrels are taken as opaque objects and read with {@link collectMessages},
|
|
77
|
+
* which is what lets a caller pass a `import * as messages` namespace directly:
|
|
78
|
+
* a barrel's value type is a union of its declarations AND its functions, and
|
|
79
|
+
* filtering that union will not narrow to a `MessageDefinition`.
|
|
80
|
+
*
|
|
81
|
+
* Returns the offending keys rather than a boolean, so a failing assertion names
|
|
82
|
+
* WHICH key is wrong — a count says only that something is.
|
|
83
|
+
*/
|
|
84
|
+
export function findUndeclaredCodes(
|
|
85
|
+
catalogueKeys: readonly string[],
|
|
86
|
+
barrels: readonly object[],
|
|
87
|
+
options: CatalogueAuditOptions = {}
|
|
88
|
+
): string[] {
|
|
89
|
+
const declared = new Set(barrels.flatMap(barrel => collectMessages(barrel).map(message => message.code)));
|
|
90
|
+
const exempt = options.exemptPrefixes ?? [];
|
|
91
|
+
return catalogueKeys.filter(key => !exempt.some(prefix => key.startsWith(prefix)) && !declared.has(key));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Keys present in more than one catalogue — the shape a split catalogue rots
|
|
96
|
+
* into.
|
|
97
|
+
*
|
|
98
|
+
* Exactly one side renders a given message, so two catalogues holding one code
|
|
99
|
+
* are two authorities over one sentence and they diverge on the first reword.
|
|
100
|
+
* Nothing at runtime notices: both sides render, and whichever ran last wins on
|
|
101
|
+
* its own surface.
|
|
102
|
+
*
|
|
103
|
+
* Takes the key sets rather than a boolean answer for the same reason as
|
|
104
|
+
* {@link findUndeclaredCodes}, and reports NOTHING when a set is empty — an
|
|
105
|
+
* empty catalogue shares no key with anything, so a caller must assert
|
|
106
|
+
* non-emptiness separately or a failed read passes this vacuously.
|
|
107
|
+
*/
|
|
108
|
+
export function findSharedCodes(first: readonly string[], second: readonly string[]): string[] {
|
|
109
|
+
const other = new Set(second);
|
|
110
|
+
return first.filter(key => other.has(key));
|
|
111
|
+
}
|
|
@@ -34,7 +34,14 @@
|
|
|
34
34
|
import { Emitter, type MessageConnection } from 'vscode-jsonrpc';
|
|
35
35
|
import type { DataPort } from '../client/data-port';
|
|
36
36
|
import type { DataClientProtocol } from '../data/data-server-protocol';
|
|
37
|
-
import type {
|
|
37
|
+
import type {
|
|
38
|
+
ProjectsChangedEvent,
|
|
39
|
+
TransferDocumentDeletedEvent,
|
|
40
|
+
TransferDocumentSavedEvent,
|
|
41
|
+
TransferDocumentsBuiltEvent,
|
|
42
|
+
TransferDocumentUpdatedEvent
|
|
43
|
+
} from '../data/events';
|
|
44
|
+
import type { ResolvedMessage } from '../messages/primitives';
|
|
38
45
|
import type { Project } from '../project';
|
|
39
46
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
40
47
|
import type { TransferElement } from '../transfer-element';
|
|
@@ -51,13 +58,6 @@ export interface FakeDataPortOptions {
|
|
|
51
58
|
* which the consumer surfaces through {@link FakeDataPort.reported}.
|
|
52
59
|
*/
|
|
53
60
|
connect(): MessageConnection | Promise<MessageConnection>;
|
|
54
|
-
/**
|
|
55
|
-
* Stable client identity. Defaults to `'fake-data-port'`, which avoids the
|
|
56
|
-
* three sentinels the framework reserves (`'language-client'`, `'unknown'`,
|
|
57
|
-
* `'revert-on-close'`); override it when a test needs two distinguishable
|
|
58
|
-
* clients on one server.
|
|
59
|
-
*/
|
|
60
|
-
clientId?: string;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/** A {@link DataPort} that records what passed through it. */
|
|
@@ -73,10 +73,11 @@ export interface FakeDataPort extends DataPort {
|
|
|
73
73
|
/**
|
|
74
74
|
* Every {@link DataPort.reportError} call, in order. Read from outside: this
|
|
75
75
|
* is the only place a transport failure surfaces, so a test for the failure
|
|
76
|
-
* path asserts
|
|
77
|
-
*
|
|
76
|
+
* path asserts here rather than on a rejection the consumer may legitimately
|
|
77
|
+
* swallow. Prefer asserting on `message.code`, which is stable, over
|
|
78
|
+
* `message.text`, which is the English default and may be reworded.
|
|
78
79
|
*/
|
|
79
|
-
readonly reported: readonly { readonly error: unknown; readonly
|
|
80
|
+
readonly reported: readonly { readonly error: unknown; readonly message: ResolvedMessage }[];
|
|
80
81
|
/**
|
|
81
82
|
* Fire {@link DataPort.onDispose} — the host tearing the transport down, a
|
|
82
83
|
* language-server restart being the case that forces the event to exist.
|
|
@@ -96,10 +97,9 @@ export interface FakeDataPort extends DataPort {
|
|
|
96
97
|
*/
|
|
97
98
|
export function makeFakeDataPort(options: FakeDataPortOptions): FakeDataPort {
|
|
98
99
|
const connections: MessageConnection[] = [];
|
|
99
|
-
const reported: { error: unknown;
|
|
100
|
+
const reported: { error: unknown; message: ResolvedMessage }[] = [];
|
|
100
101
|
const disposeEmitter = new Emitter<void>();
|
|
101
102
|
return {
|
|
102
|
-
clientId: options.clientId ?? 'fake-data-port',
|
|
103
103
|
connections,
|
|
104
104
|
reported,
|
|
105
105
|
onDispose: disposeEmitter.event,
|
|
@@ -108,8 +108,8 @@ export function makeFakeDataPort(options: FakeDataPortOptions): FakeDataPort {
|
|
|
108
108
|
connections.push(connection);
|
|
109
109
|
return connection;
|
|
110
110
|
},
|
|
111
|
-
reportError(error: unknown,
|
|
112
|
-
reported.push({ error,
|
|
111
|
+
reportError(error: unknown, message: ResolvedMessage): void {
|
|
112
|
+
reported.push({ error, message });
|
|
113
113
|
},
|
|
114
114
|
fireDispose(): void {
|
|
115
115
|
disposeEmitter.fire(undefined);
|
|
@@ -132,6 +132,10 @@ export interface CapturingDataClient<
|
|
|
132
132
|
readonly updates: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>[];
|
|
133
133
|
/** Every `onDocumentSaved` event, in arrival order. */
|
|
134
134
|
readonly saves: TransferDocumentSavedEvent<TTransfer, TDiagnostic>[];
|
|
135
|
+
/** Every `onDocumentDeleted` event, in arrival order. */
|
|
136
|
+
readonly deletions: TransferDocumentDeletedEvent[];
|
|
137
|
+
/** Every `onDocumentsBuilt` event, in arrival order. */
|
|
138
|
+
readonly builds: TransferDocumentsBuiltEvent[];
|
|
135
139
|
/** Every `onProjectsChanged` event, in arrival order. */
|
|
136
140
|
readonly projectsChanges: ProjectsChangedEvent<TProject>[];
|
|
137
141
|
}
|
|
@@ -139,7 +143,7 @@ export interface CapturingDataClient<
|
|
|
139
143
|
/**
|
|
140
144
|
* A {@link DataClientProtocol} that records every notification it receives.
|
|
141
145
|
*
|
|
142
|
-
* Recording
|
|
146
|
+
* Recording EVERY channel even when a suite reads one is deliberate: an
|
|
143
147
|
* event delivered on the wrong channel is a real defect of the data head, and a
|
|
144
148
|
* double that drops the other two turns it into silence on the one being
|
|
145
149
|
* watched.
|
|
@@ -156,6 +160,8 @@ export function makeCapturingDataClient<
|
|
|
156
160
|
>(overrides: Partial<DataClientProtocol<TTransfer, TDiagnostic, TProject>> = {}): CapturingDataClient<TTransfer, TDiagnostic, TProject> {
|
|
157
161
|
const updates: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>[] = [];
|
|
158
162
|
const saves: TransferDocumentSavedEvent<TTransfer, TDiagnostic>[] = [];
|
|
163
|
+
const deletions: TransferDocumentDeletedEvent[] = [];
|
|
164
|
+
const builds: TransferDocumentsBuiltEvent[] = [];
|
|
159
165
|
const projectsChanges: ProjectsChangedEvent<TProject>[] = [];
|
|
160
166
|
const client: DataClientProtocol<TTransfer, TDiagnostic, TProject> = {
|
|
161
167
|
onDocumentUpdated:
|
|
@@ -168,11 +174,21 @@ export function makeCapturingDataClient<
|
|
|
168
174
|
(event => {
|
|
169
175
|
saves.push(event);
|
|
170
176
|
}),
|
|
177
|
+
onDocumentDeleted:
|
|
178
|
+
overrides.onDocumentDeleted ??
|
|
179
|
+
(event => {
|
|
180
|
+
deletions.push(event);
|
|
181
|
+
}),
|
|
182
|
+
onDocumentsBuilt:
|
|
183
|
+
overrides.onDocumentsBuilt ??
|
|
184
|
+
(event => {
|
|
185
|
+
builds.push(event);
|
|
186
|
+
}),
|
|
171
187
|
onProjectsChanged:
|
|
172
188
|
overrides.onProjectsChanged ??
|
|
173
189
|
(event => {
|
|
174
190
|
projectsChanges.push(event);
|
|
175
191
|
})
|
|
176
192
|
};
|
|
177
|
-
return { client, updates, saves, projectsChanges };
|
|
193
|
+
return { client, updates, saves, deletions, builds, projectsChanges };
|
|
178
194
|
}
|
package/src/testing/index.ts
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
// Subpath barrel for `@hydranium/protocol/testing` — the BROWSER-NEUTRAL shared
|
|
11
11
|
// primitives: `makeFakeClock` (deterministic `Clock` double on one virtual time
|
|
12
12
|
// axis), `waitFor` / `tick`, the client-side data-head doubles
|
|
13
|
-
// (`makeFakeDataPort` / `makeCapturingDataClient`),
|
|
13
|
+
// (`makeFakeDataPort` / `makeCapturingDataClient`), the translation-catalogue
|
|
14
|
+
// audit (`flattenCatalogue` / `findUndeclaredCodes` / `findSharedCodes`), and
|
|
15
|
+
// the `Harness` marker
|
|
14
16
|
// interface every framework harness extends. Kept out of the main barrel so production bundles don't pull
|
|
15
17
|
// the test scaffolding in by default; adopters opt in by importing from
|
|
16
18
|
// `@hydranium/protocol/testing`.
|
|
@@ -20,6 +22,7 @@
|
|
|
20
22
|
// type, so they cannot be made portable and live at `./testing/node` instead.
|
|
21
23
|
// The same rule the package surface uses — the portable name is the short one.
|
|
22
24
|
|
|
25
|
+
export * from './catalogue-audit';
|
|
23
26
|
export * from './data-doubles';
|
|
24
27
|
export * from './fake-clock';
|
|
25
28
|
export * from './harness';
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
+
import { type MessageParams, type ResolvedMessage } from './messages/primitives';
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Generic, transport-friendly diagnostic shape used by the model-server protocol.
|
|
12
14
|
*
|
|
@@ -56,6 +58,21 @@ export interface TransferDiagnostic {
|
|
|
56
58
|
* is not usable as a rule identity on its own.
|
|
57
59
|
*/
|
|
58
60
|
code?: number | string;
|
|
61
|
+
/**
|
|
62
|
+
* Substitutions for the placeholders in the message this {@link code} names,
|
|
63
|
+
* present only for a diagnostic raised from a framework message declaration.
|
|
64
|
+
*
|
|
65
|
+
* Without them a translated template renders with its `{name}` tokens left
|
|
66
|
+
* standing, because substitution leaves an unmatched token in place rather
|
|
67
|
+
* than raising — so a surface that translates from {@link code} alone is
|
|
68
|
+
* correct for a parameterless sentence and visibly wrong for a parameterised
|
|
69
|
+
* one. This is the field that makes the second case work; the LSP carrier has
|
|
70
|
+
* always moved the params, and no carrier below it did.
|
|
71
|
+
*
|
|
72
|
+
* Prefer {@link TransferDiagnostic.resolved} over reading this: it decides
|
|
73
|
+
* whether an identity is present at all, which a lone `params` cannot.
|
|
74
|
+
*/
|
|
75
|
+
params?: MessageParams;
|
|
59
76
|
}
|
|
60
77
|
|
|
61
78
|
export namespace TransferDiagnostic {
|
|
@@ -74,6 +91,29 @@ export namespace TransferDiagnostic {
|
|
|
74
91
|
return diagnostic.type === 'parsing-error';
|
|
75
92
|
}
|
|
76
93
|
|
|
94
|
+
/**
|
|
95
|
+
* The diagnostic as a renderable message, for a surface that translates.
|
|
96
|
+
* `undefined` when it carries no framework identity — a syntactic error, an
|
|
97
|
+
* adopter's own check, a linker failure — which is the case a caller must
|
|
98
|
+
* distinguish rather than render.
|
|
99
|
+
*
|
|
100
|
+
* Hand the result to `renderFrameworkMessage` with whatever catalogue the
|
|
101
|
+
* host has loaded. The `text` is the server's English, so a code the
|
|
102
|
+
* catalogue does not carry still yields a complete sentence.
|
|
103
|
+
*
|
|
104
|
+
* `code` alone does not establish an identity: it also holds Langium's
|
|
105
|
+
* internal code and an adopter's own, and either would be looked up against a
|
|
106
|
+
* catalogue that cannot have it. Requiring `params` is what discriminates,
|
|
107
|
+
* and it is why a parameterless framework message still populates the field
|
|
108
|
+
* with an empty object rather than omitting it.
|
|
109
|
+
*/
|
|
110
|
+
export function resolved(diagnostic: TransferDiagnostic): ResolvedMessage | undefined {
|
|
111
|
+
if (typeof diagnostic.code !== 'string' || diagnostic.params === undefined) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
return { code: diagnostic.code, params: diagnostic.params, text: diagnostic.message };
|
|
115
|
+
}
|
|
116
|
+
|
|
77
117
|
export function getPath(diagnostic: TransferDiagnostic): string {
|
|
78
118
|
return diagnostic.property ? `${diagnostic.element}${ELEMENT_PROPERTY_SEPARATOR}${diagnostic.property}` : diagnostic.element;
|
|
79
119
|
}
|