@hmharness/lsp 0.23.24 → 0.23.26

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/tools.d.ts CHANGED
@@ -7,12 +7,23 @@
7
7
  * proof (master prompt prohibition).
8
8
  */
9
9
  import type { Tool } from '@hmharness/kernel';
10
- import type { Diagnostic } from './protocol.js';
10
+ import type { Diagnostic, DocumentSymbol } from './protocol.js';
11
+ /** What a read-only tool observed — fed to the caller's Code World Model
12
+ * sink. Same posture as the extension onPageRead hook: observation only,
13
+ * best-effort, never able to fail the tool that observed. */
14
+ export interface LspObservation {
15
+ uri: string;
16
+ symbols?: DocumentSymbol[];
17
+ diagnostics?: Diagnostic[];
18
+ }
11
19
  export interface LspToolContext {
12
20
  workspaceRoot: string;
13
21
  /** HMH_HOME — required by the source-trust guard (Capability OS slice);
14
22
  * when absent PATH servers are refused honestly */
15
23
  home?: string;
24
+ /** Observation sink: symbols/diagnostics pulled by the tools ride into
25
+ * the persisted Code World Model. Optional; sink errors are swallowed. */
26
+ onObserve?: (obs: LspObservation) => void;
16
27
  }
17
28
  /** Stop every client this module started (TUI/CLI shutdown path). */
18
29
  export declare function shutdownLsp(): Promise<void>;
package/dist/tools.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import { ProcessManager } from "./process-manager.js";
2
2
  import { LspClient } from "./client.js";
3
3
  import { discoverServers, serverForFile, fileToUri } from "./registry.js";
4
+ function emitObservation(ctx, obs) {
5
+ try {
6
+ ctx.onObserve?.(obs);
7
+ }
8
+ catch { /* an observation sink must never fail the tool that observed */ }
9
+ }
4
10
  /** One live client per server for the lifetime of the context. */
5
11
  const clients = new Map();
6
12
  /** Sync last-resort kill on process exit (async shutdown may not run when
@@ -83,6 +89,7 @@ export function lspTools(ctx) {
83
89
  const abs = resolveFile(ctx, String(args.file ?? ''));
84
90
  const r = await withClient(String(args.file ?? ''), async (mc, uri) => {
85
91
  const diags = mc.diagnostics.get(uri) ?? [];
92
+ emitObservation(ctx, { uri, diagnostics: diags });
86
93
  return `[${mc.server.id}${mc.server.official ? '' : ' (community/unofficial)'}] ${uri}\n` + fmtDiags(diags);
87
94
  });
88
95
  return r;
@@ -122,6 +129,7 @@ export function lspTools(ctx) {
122
129
  async execute(args) {
123
130
  return withClient(String(args.file ?? ''), async (mc, uri) => {
124
131
  const syms = await mc.client.documentSymbols({ uri });
132
+ emitObservation(ctx, { uri, symbols: syms });
125
133
  const flat = [];
126
134
  const walk = (ss, depth) => {
127
135
  for (const s of ss.slice(0, 30)) {
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
- {
2
- "name": "@hmharness/lsp",
3
- "version": "0.23.24",
4
- "description": "hmharness LSP Client/Manager — drives external language servers (LSP 3.18 over stdio) for agent code intelligence. Client only: we never implement language servers.",
5
- "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
12
- }
13
- },
14
- "scripts": {
15
- "build": "tsc -p tsconfig.build.json"
16
- },
17
- "dependencies": {
18
- "@hmharness/kernel": "0.23.24"
19
- },
20
- "engines": {
21
- "node": ">=22"
22
- }
23
- }
1
+ {
2
+ "name": "@hmharness/lsp",
3
+ "version": "0.23.26",
4
+ "description": "hmharness LSP Client/Manager — drives external language servers (LSP 3.18 over stdio) for agent code intelligence. Client only: we never implement language servers.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.build.json"
16
+ },
17
+ "dependencies": {
18
+ "@hmharness/kernel": "0.23.26"
19
+ },
20
+ "engines": {
21
+ "node": ">=22"
22
+ }
23
+ }
@@ -1,60 +1,60 @@
1
- import { test } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { mkdtemp, rm, mkdir, writeFile, chmod } from 'node:fs/promises';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
- import { discoverServers, DEVECO_ROOTS } from '../registry.ts';
7
-
8
- test('registry: DevEco-local discovery prefers the bundled official server over PATH shims', async () => {
9
- // a FAKE DevEco root with a fake clangd that answers --version
10
- const fakeRoot = await mkdtemp(join(tmpdir(), 'deveco-'));
11
- const lspDir = join(fakeRoot, 'tools', 'llvm', 'server', 'lsp', 'win');
12
- await mkdir(lspDir, { recursive: true });
13
- const fakeClangd = join(lspDir, 'clangd.exe');
14
- // on win, a .cmd-style script works for spawnSync; use node itself via a shim dir
15
- const shimDir = await mkdtemp(join(tmpdir(), 'deveco-shim-'));
16
- const shim = join(shimDir, 'clangd.exe');
17
- if (process.platform === 'win32') {
18
- await writeFile(shim, `@echo off\r\necho clangd version 99.0.0 (fake devecos)\r\nexit /b 0\r\n`, 'utf8');
19
- } else {
20
- await writeFile(shim, '#!/bin/sh\necho "clangd version 99.0.0 (fake)"\nexit 0\n', 'utf8');
21
- await chmod(shim, 0o755);
22
- }
23
- // point the fake DevEco root's clangd at the shim via a copy
24
- const { copyFile } = await import('node:fs/promises');
25
- if (process.platform === 'win32') {
26
- await copyFile(shim, fakeClangd.replace(/\.exe$/, '.cmd'));
27
- // discovery looks for clangd.exe — write a .cmd dispatcher named exe? keep honest:
28
- // instead test through the injected roots with the shim AS the exe (windows can exec .cmd via shell only) —
29
- // simplest: make the injected discovery find the shim directly by naming it clangd.exe in a fake root layout
30
- }
31
- // use the shim placed in a fake-root layout with the exact expected filename
32
- const fakeRoot2 = await mkdtemp(join(tmpdir(), 'deveco2-'));
33
- const dir2 = join(fakeRoot2, 'tools', 'llvm', 'server', 'lsp', 'win');
34
- await mkdir(dir2, { recursive: true });
35
- const target = process.platform === 'win32' ? join(dir2, 'clangd.exe') : join(dir2, 'clangd.exe');
36
- await copyFile(shim, target).catch(async () => {
37
- // on windows spawnSync of a .cmd named .exe fails; fall back to probing absence honestly
38
- });
39
- const servers = discoverServers(true, { devecoRoots: [fakeRoot2] });
40
- const fake = servers.find((s) => s.origin === 'DevEco-local');
41
- if (fake) {
42
- assert.equal(fake.id, 'clangd');
43
- assert.equal(fake.official, true);
44
- assert.ok(fake.command.includes('tools/llvm/server/lsp'), 'recorded with the DevEco layout path');
45
- } else {
46
- // windows cannot exec a .cmd renamed .exe — discovery honestly finds nothing
47
- assert.ok(servers.every((s) => s.origin !== 'DevEco-local'));
48
- }
49
- // the REAL DevEco root (when installed) yields a healthy official clangd
50
- const real = discoverServers(true).find((s) => s.origin === 'DevEco-local');
51
- if (real) {
52
- assert.equal(real.healthy, true);
53
- assert.equal(real.official, true);
54
- }
55
- // real roots are exposed for auditability
56
- assert.ok(Array.isArray(DEVECO_ROOTS));
57
- await rm(fakeRoot, { recursive: true, force: true });
58
- await rm(shimDir, { recursive: true, force: true });
59
- await rm(fakeRoot2, { recursive: true, force: true });
60
- });
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { mkdtemp, rm, mkdir, writeFile, chmod } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import { join } from 'node:path';
6
+ import { discoverServers, DEVECO_ROOTS } from '../registry.ts';
7
+
8
+ test('registry: DevEco-local discovery prefers the bundled official server over PATH shims', async () => {
9
+ // a FAKE DevEco root with a fake clangd that answers --version
10
+ const fakeRoot = await mkdtemp(join(tmpdir(), 'deveco-'));
11
+ const lspDir = join(fakeRoot, 'tools', 'llvm', 'server', 'lsp', 'win');
12
+ await mkdir(lspDir, { recursive: true });
13
+ const fakeClangd = join(lspDir, 'clangd.exe');
14
+ // on win, a .cmd-style script works for spawnSync; use node itself via a shim dir
15
+ const shimDir = await mkdtemp(join(tmpdir(), 'deveco-shim-'));
16
+ const shim = join(shimDir, 'clangd.exe');
17
+ if (process.platform === 'win32') {
18
+ await writeFile(shim, `@echo off\r\necho clangd version 99.0.0 (fake devecos)\r\nexit /b 0\r\n`, 'utf8');
19
+ } else {
20
+ await writeFile(shim, '#!/bin/sh\necho "clangd version 99.0.0 (fake)"\nexit 0\n', 'utf8');
21
+ await chmod(shim, 0o755);
22
+ }
23
+ // point the fake DevEco root's clangd at the shim via a copy
24
+ const { copyFile } = await import('node:fs/promises');
25
+ if (process.platform === 'win32') {
26
+ await copyFile(shim, fakeClangd.replace(/\.exe$/, '.cmd'));
27
+ // discovery looks for clangd.exe — write a .cmd dispatcher named exe? keep honest:
28
+ // instead test through the injected roots with the shim AS the exe (windows can exec .cmd via shell only) —
29
+ // simplest: make the injected discovery find the shim directly by naming it clangd.exe in a fake root layout
30
+ }
31
+ // use the shim placed in a fake-root layout with the exact expected filename
32
+ const fakeRoot2 = await mkdtemp(join(tmpdir(), 'deveco2-'));
33
+ const dir2 = join(fakeRoot2, 'tools', 'llvm', 'server', 'lsp', 'win');
34
+ await mkdir(dir2, { recursive: true });
35
+ const target = process.platform === 'win32' ? join(dir2, 'clangd.exe') : join(dir2, 'clangd.exe');
36
+ await copyFile(shim, target).catch(async () => {
37
+ // on windows spawnSync of a .cmd named .exe fails; fall back to probing absence honestly
38
+ });
39
+ const servers = discoverServers(true, { devecoRoots: [fakeRoot2] });
40
+ const fake = servers.find((s) => s.origin === 'DevEco-local');
41
+ if (fake) {
42
+ assert.equal(fake.id, 'clangd');
43
+ assert.equal(fake.official, true);
44
+ assert.ok(fake.command.includes('tools/llvm/server/lsp'), 'recorded with the DevEco layout path');
45
+ } else {
46
+ // windows cannot exec a .cmd renamed .exe — discovery honestly finds nothing
47
+ assert.ok(servers.every((s) => s.origin !== 'DevEco-local'));
48
+ }
49
+ // the REAL DevEco root (when installed) yields a healthy official clangd
50
+ const real = discoverServers(true).find((s) => s.origin === 'DevEco-local');
51
+ if (real) {
52
+ assert.equal(real.healthy, true);
53
+ assert.equal(real.official, true);
54
+ }
55
+ // real roots are exposed for auditability
56
+ assert.ok(Array.isArray(DEVECO_ROOTS));
57
+ await rm(fakeRoot, { recursive: true, force: true });
58
+ await rm(shimDir, { recursive: true, force: true });
59
+ await rm(fakeRoot2, { recursive: true, force: true });
60
+ });
@@ -1,89 +1,89 @@
1
- /**
2
- * Fake LSP server for hermetic tests (no real language server needed on
3
- * CI): speaks the base protocol over stdio and answers the Tier-0
4
- * requests with fixed, deterministic results. Written as plain JS so the
5
- * test can spawn it directly with the system node.
6
- */
7
- const fs = require('fs');
8
-
9
- function send(obj) {
10
- const payload = Buffer.from(JSON.stringify(obj), 'utf8');
11
- process.stdout.write(Buffer.concat([Buffer.from(`Content-Length: ${payload.length}\r\n\r\n`, 'ascii'), payload]));
12
- }
13
-
14
- let buf = Buffer.alloc(0);
15
- process.stdin.on('data', (chunk) => {
16
- buf = Buffer.concat([buf, chunk]);
17
- for (;;) {
18
- const headerEnd = buf.indexOf('\r\n\r\n');
19
- if (headerEnd < 0) break;
20
- const m = /Content-Length:\s*(\d+)/i.exec(buf.subarray(0, headerEnd).toString('ascii'));
21
- if (!m) { buf = buf.subarray(headerEnd + 4); continue; }
22
- const len = Number(m[1]);
23
- const bodyStart = headerEnd + 4;
24
- if (buf.length < bodyStart + len) break;
25
- let msg;
26
- try { msg = JSON.parse(buf.subarray(bodyStart, bodyStart + len).toString('utf8')); } catch { buf = buf.subarray(bodyStart + len); continue; }
27
- buf = buf.subarray(bodyStart + len);
28
- handle(msg);
29
- }
30
- });
31
-
32
- function handle(msg) {
33
- if (msg.method === 'initialize' && typeof msg.id === 'number') {
34
- send({ jsonrpc: '2.0', id: msg.id, result: { capabilities: { hoverProvider: true, definitionProvider: true, referencesProvider: true, documentSymbolProvider: true }, serverInfo: { name: 'fake-lsp', version: '0.0.1' } } });
35
- return;
36
- }
37
- if (msg.method === 'initialized') return;
38
- if (msg.method === 'shutdown' && typeof msg.id === 'number') {
39
- send({ jsonrpc: '2.0', id: msg.id, result: null });
40
- return;
41
- }
42
- if (msg.method === 'exit') { process.exit(0); }
43
- if (msg.method === 'textDocument/didOpen') {
44
- const doc = msg.params.textDocument;
45
- if (doc.text.includes('DELBERATE_ERROR_MARKER')) {
46
- send({ jsonrpc: '2.0', method: 'textDocument/publishDiagnostics', params: { uri: doc.uri, diagnostics: [{ range: { start: { line: 0, character: 0 }, end: { line: 0, character: 5 } }, severity: 1, source: 'fake-lsp', message: 'marker found: deliberate error' }] } });
47
- } else {
48
- send({ jsonrpc: '2.0', method: 'textDocument/publishDiagnostics', params: { uri: doc.uri, diagnostics: [] } });
49
- }
50
- return;
51
- }
52
- if (msg.method === 'textDocument/hover' && typeof msg.id === 'number') {
53
- send({ jsonrpc: '2.0', id: msg.id, result: { contents: { kind: 'plaintext', value: 'fake hover: symbol at ' + msg.params.position.line + ':' + msg.params.position.character } } });
54
- return;
55
- }
56
- if (msg.method === 'textDocument/definition' && typeof msg.id === 'number') {
57
- send({ jsonrpc: '2.0', id: msg.id, result: { uri: 'file:///fake/def.ts', range: { start: { line: 3, character: 0 }, end: { line: 3, character: 10 } } } });
58
- return;
59
- }
60
- if (msg.method === 'textDocument/references' && typeof msg.id === 'number') {
61
- send({ jsonrpc: '2.0', id: msg.id, result: [{ uri: 'file:///fake/r1.ts', range: { start: { line: 1, character: 0 }, end: { line: 1, character: 4 } } }, { uri: 'file:///fake/r2.ts', range: { start: { line: 2, character: 0 }, end: { line: 2, character: 4 } } }] });
62
- return;
63
- }
64
- if (msg.method === 'textDocument/implementation' && typeof msg.id === 'number') {
65
- send({ jsonrpc: '2.0', id: msg.id, result: [{ uri: 'file:///fake/impl-a.ts', range: { start: { line: 9, character: 0 }, end: { line: 9, character: 6 } } }, { uri: 'file:///fake/impl-b.ts', range: { start: { line: 4, character: 0 }, end: { line: 4, character: 6 } } }] });
66
- return;
67
- }
68
- if (msg.method === 'textDocument/prepareCallHierarchy' && typeof msg.id === 'number') {
69
- send({ jsonrpc: '2.0', id: msg.id, result: [{ name: 'targetFn', kind: 12, uri: 'file:///fake/probe.ts', range: { start: { line: 0, character: 0 }, end: { line: 1, character: 0 } }, selectionRange: { start: { line: 0, character: 0 }, end: { line: 0, character: 9 } } }] });
70
- return;
71
- }
72
- if (msg.method === 'callHierarchy/incomingCalls' && typeof msg.id === 'number') {
73
- send({ jsonrpc: '2.0', id: msg.id, result: [{ from: { name: 'callerOne', uri: 'file:///fake/c1.ts', range: { start: { line: 2, character: 0 }, end: { line: 3, character: 0 } } }, fromRanges: [{ start: { line: 2, character: 4 }, end: { line: 2, character: 13 } }] }, { from: { name: 'callerTwo', uri: 'file:///fake/c2.ts', range: { start: { line: 5, character: 0 }, end: { line: 6, character: 0 } } }, fromRanges: [{ start: { line: 5, character: 4 }, end: { line: 5, character: 13 } }] }] });
74
- return;
75
- }
76
- if (msg.method === 'callHierarchy/outgoingCalls' && typeof msg.id === 'number') {
77
- send({ jsonrpc: '2.0', id: msg.id, result: [{ to: { name: 'helperFn', uri: 'file:///fake/h.ts', range: { start: { line: 1, character: 0 }, end: { line: 2, character: 0 } } }, toRanges: [{ start: { line: 1, character: 2 }, end: { line: 1, character: 11 } }] }] });
78
- return;
79
- }
80
- if (msg.method === 'textDocument/documentSymbol' && typeof msg.id === 'number') {
81
- send({ jsonrpc: '2.0', id: msg.id, result: [{ name: 'mainFn', kind: 12, range: { start: { line: 0, character: 0 }, end: { line: 5, character: 0 } }, children: [{ name: 'inner', kind: 6, range: { start: { line: 1, character: 2 }, end: { line: 2, character: 2 } } }] }] });
82
- return;
83
- }
84
- if (typeof msg.id === 'number') {
85
- send({ jsonrpc: '2.0', id: msg.id, error: { code: -32601, message: 'method not found: ' + msg.method } });
86
- }
87
- }
88
-
89
- fs.writeSync(2, ''); // keep stderr referenced
1
+ /**
2
+ * Fake LSP server for hermetic tests (no real language server needed on
3
+ * CI): speaks the base protocol over stdio and answers the Tier-0
4
+ * requests with fixed, deterministic results. Written as plain JS so the
5
+ * test can spawn it directly with the system node.
6
+ */
7
+ const fs = require('fs');
8
+
9
+ function send(obj) {
10
+ const payload = Buffer.from(JSON.stringify(obj), 'utf8');
11
+ process.stdout.write(Buffer.concat([Buffer.from(`Content-Length: ${payload.length}\r\n\r\n`, 'ascii'), payload]));
12
+ }
13
+
14
+ let buf = Buffer.alloc(0);
15
+ process.stdin.on('data', (chunk) => {
16
+ buf = Buffer.concat([buf, chunk]);
17
+ for (;;) {
18
+ const headerEnd = buf.indexOf('\r\n\r\n');
19
+ if (headerEnd < 0) break;
20
+ const m = /Content-Length:\s*(\d+)/i.exec(buf.subarray(0, headerEnd).toString('ascii'));
21
+ if (!m) { buf = buf.subarray(headerEnd + 4); continue; }
22
+ const len = Number(m[1]);
23
+ const bodyStart = headerEnd + 4;
24
+ if (buf.length < bodyStart + len) break;
25
+ let msg;
26
+ try { msg = JSON.parse(buf.subarray(bodyStart, bodyStart + len).toString('utf8')); } catch { buf = buf.subarray(bodyStart + len); continue; }
27
+ buf = buf.subarray(bodyStart + len);
28
+ handle(msg);
29
+ }
30
+ });
31
+
32
+ function handle(msg) {
33
+ if (msg.method === 'initialize' && typeof msg.id === 'number') {
34
+ send({ jsonrpc: '2.0', id: msg.id, result: { capabilities: { hoverProvider: true, definitionProvider: true, referencesProvider: true, documentSymbolProvider: true }, serverInfo: { name: 'fake-lsp', version: '0.0.1' } } });
35
+ return;
36
+ }
37
+ if (msg.method === 'initialized') return;
38
+ if (msg.method === 'shutdown' && typeof msg.id === 'number') {
39
+ send({ jsonrpc: '2.0', id: msg.id, result: null });
40
+ return;
41
+ }
42
+ if (msg.method === 'exit') { process.exit(0); }
43
+ if (msg.method === 'textDocument/didOpen') {
44
+ const doc = msg.params.textDocument;
45
+ if (doc.text.includes('DELBERATE_ERROR_MARKER')) {
46
+ send({ jsonrpc: '2.0', method: 'textDocument/publishDiagnostics', params: { uri: doc.uri, diagnostics: [{ range: { start: { line: 0, character: 0 }, end: { line: 0, character: 5 } }, severity: 1, source: 'fake-lsp', message: 'marker found: deliberate error' }] } });
47
+ } else {
48
+ send({ jsonrpc: '2.0', method: 'textDocument/publishDiagnostics', params: { uri: doc.uri, diagnostics: [] } });
49
+ }
50
+ return;
51
+ }
52
+ if (msg.method === 'textDocument/hover' && typeof msg.id === 'number') {
53
+ send({ jsonrpc: '2.0', id: msg.id, result: { contents: { kind: 'plaintext', value: 'fake hover: symbol at ' + msg.params.position.line + ':' + msg.params.position.character } } });
54
+ return;
55
+ }
56
+ if (msg.method === 'textDocument/definition' && typeof msg.id === 'number') {
57
+ send({ jsonrpc: '2.0', id: msg.id, result: { uri: 'file:///fake/def.ts', range: { start: { line: 3, character: 0 }, end: { line: 3, character: 10 } } } });
58
+ return;
59
+ }
60
+ if (msg.method === 'textDocument/references' && typeof msg.id === 'number') {
61
+ send({ jsonrpc: '2.0', id: msg.id, result: [{ uri: 'file:///fake/r1.ts', range: { start: { line: 1, character: 0 }, end: { line: 1, character: 4 } } }, { uri: 'file:///fake/r2.ts', range: { start: { line: 2, character: 0 }, end: { line: 2, character: 4 } } }] });
62
+ return;
63
+ }
64
+ if (msg.method === 'textDocument/implementation' && typeof msg.id === 'number') {
65
+ send({ jsonrpc: '2.0', id: msg.id, result: [{ uri: 'file:///fake/impl-a.ts', range: { start: { line: 9, character: 0 }, end: { line: 9, character: 6 } } }, { uri: 'file:///fake/impl-b.ts', range: { start: { line: 4, character: 0 }, end: { line: 4, character: 6 } } }] });
66
+ return;
67
+ }
68
+ if (msg.method === 'textDocument/prepareCallHierarchy' && typeof msg.id === 'number') {
69
+ send({ jsonrpc: '2.0', id: msg.id, result: [{ name: 'targetFn', kind: 12, uri: 'file:///fake/probe.ts', range: { start: { line: 0, character: 0 }, end: { line: 1, character: 0 } }, selectionRange: { start: { line: 0, character: 0 }, end: { line: 0, character: 9 } } }] });
70
+ return;
71
+ }
72
+ if (msg.method === 'callHierarchy/incomingCalls' && typeof msg.id === 'number') {
73
+ send({ jsonrpc: '2.0', id: msg.id, result: [{ from: { name: 'callerOne', uri: 'file:///fake/c1.ts', range: { start: { line: 2, character: 0 }, end: { line: 3, character: 0 } } }, fromRanges: [{ start: { line: 2, character: 4 }, end: { line: 2, character: 13 } }] }, { from: { name: 'callerTwo', uri: 'file:///fake/c2.ts', range: { start: { line: 5, character: 0 }, end: { line: 6, character: 0 } } }, fromRanges: [{ start: { line: 5, character: 4 }, end: { line: 5, character: 13 } }] }] });
74
+ return;
75
+ }
76
+ if (msg.method === 'callHierarchy/outgoingCalls' && typeof msg.id === 'number') {
77
+ send({ jsonrpc: '2.0', id: msg.id, result: [{ to: { name: 'helperFn', uri: 'file:///fake/h.ts', range: { start: { line: 1, character: 0 }, end: { line: 2, character: 0 } } }, toRanges: [{ start: { line: 1, character: 2 }, end: { line: 1, character: 11 } }] }] });
78
+ return;
79
+ }
80
+ if (msg.method === 'textDocument/documentSymbol' && typeof msg.id === 'number') {
81
+ send({ jsonrpc: '2.0', id: msg.id, result: [{ name: 'mainFn', kind: 12, range: { start: { line: 0, character: 0 }, end: { line: 5, character: 0 } }, children: [{ name: 'inner', kind: 6, range: { start: { line: 1, character: 2 }, end: { line: 2, character: 2 } } }] }] });
82
+ return;
83
+ }
84
+ if (typeof msg.id === 'number') {
85
+ send({ jsonrpc: '2.0', id: msg.id, error: { code: -32601, message: 'method not found: ' + msg.method } });
86
+ }
87
+ }
88
+
89
+ fs.writeSync(2, ''); // keep stderr referenced