carrick 0.3.57 → 0.3.59
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 +117 -26
- package/bin/carrick.mjs +13 -2
- package/dist/auth/credentials.d.ts +14 -0
- package/dist/auth/credentials.js +86 -0
- package/dist/auth/credentials.js.map +1 -0
- package/dist/auth/oauth.d.ts +11 -0
- package/dist/auth/oauth.js +119 -0
- package/dist/auth/oauth.js.map +1 -0
- package/dist/auth/read.d.ts +139 -0
- package/dist/auth/read.js +44 -0
- package/dist/auth/read.js.map +1 -0
- package/dist/auth/run.d.ts +12 -0
- package/dist/auth/run.js +68 -0
- package/dist/auth/run.js.map +1 -0
- package/dist/contract.d.ts +10 -0
- package/dist/contract.js +3 -0
- package/dist/contract.js.map +1 -1
- package/dist/definition.d.ts +33 -0
- package/dist/definition.js +107 -0
- package/dist/definition.js.map +1 -0
- package/dist/diagnostics.d.ts +72 -3
- package/dist/diagnostics.js +275 -55
- package/dist/diagnostics.js.map +1 -1
- package/dist/hook/refresh.d.ts +32 -0
- package/dist/hook/refresh.js +138 -0
- package/dist/hook/refresh.js.map +1 -0
- package/dist/hook/session-start.js +13 -0
- package/dist/hook/session-start.js.map +1 -1
- package/dist/init/connect.d.ts +17 -0
- package/dist/init/connect.js +120 -0
- package/dist/init/connect.js.map +1 -0
- package/dist/init/mcp.d.ts +50 -0
- package/dist/init/mcp.js +235 -0
- package/dist/init/mcp.js.map +1 -0
- package/dist/init/projects.d.ts +46 -0
- package/dist/init/projects.js +137 -0
- package/dist/init/projects.js.map +1 -0
- package/dist/init/repos.d.ts +113 -19
- package/dist/init/repos.js +60 -39
- package/dist/init/repos.js.map +1 -1
- package/dist/init/run.d.ts +16 -0
- package/dist/init/run.js +243 -61
- package/dist/init/run.js.map +1 -1
- package/dist/init/settings.d.ts +1 -1
- package/dist/init/settings.js +1 -1
- package/dist/init/settings.js.map +1 -1
- package/dist/lens.d.ts +41 -0
- package/dist/lens.js +116 -0
- package/dist/lens.js.map +1 -0
- package/dist/server.js +327 -24
- package/dist/server.js.map +1 -1
- package/dist/surfaces.d.ts +28 -0
- package/dist/surfaces.js +70 -0
- package/dist/surfaces.js.map +1 -0
- package/package.json +6 -6
- package/sidecar/dist/src/capture/deno-project.d.ts +41 -0
- package/sidecar/dist/src/capture/deno-project.js +513 -0
- package/sidecar/dist/src/capture/index.d.ts +1 -0
- package/sidecar/dist/src/capture/index.js +60 -19
- package/sidecar/dist/src/capture/self-check.d.ts +2 -0
- package/sidecar/dist/src/capture/self-check.js +3 -2
- package/sidecar/dist/src/project-loader.js +22 -1
- package/dist/init/identity.d.ts +0 -20
- package/dist/init/identity.js +0 -60
- package/dist/init/identity.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/auth/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC1J,MAAM,UAAU,GAAG,CAAC,CAAC,kBAAkB,CAAC,WAAW,EAAE;IACnD,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IAChE,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,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AAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACtH,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YACjF,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;SACzD,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IAAC,CAAC;IAChH,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,6GAA6G,CAAC,CAAC;IAC1J,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IAC5F,IAAI,OAAgB,CAAC;IACrB,IAAI,CAAC;QAAC,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAAC,CAAC;IACtC,MAAM,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAAC,CAAC;IAC7E,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,yHAAyH,CAAC,CAAC;IAChK,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Credential } from "./credentials.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Sign in through the browser and leave a saved credential behind.
|
|
4
|
+
*
|
|
5
|
+
* Shared with `carrick init`, which signs a machine in rather than stopping to
|
|
6
|
+
* say "run carrick login" (carrick#955): the first thing a new install does is
|
|
7
|
+
* the one thing it was refusing to do. The steps are the same either way, so
|
|
8
|
+
* there is one copy of them.
|
|
9
|
+
*/
|
|
10
|
+
export declare function signIn(say?: (message: string) => void, signal?: AbortSignal): Promise<Credential>;
|
|
11
|
+
export declare function login(argv: string[]): Promise<number>;
|
|
12
|
+
export declare function logout(argv: string[]): number;
|
package/dist/auth/run.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { API_BASE, readCredential, saveCredential, removeCredential } from "./credentials.js";
|
|
2
|
+
import { authorize } from "./oauth.js";
|
|
3
|
+
import { resolveRepos } from "./read.js";
|
|
4
|
+
/**
|
|
5
|
+
* Sign in through the browser and leave a saved credential behind.
|
|
6
|
+
*
|
|
7
|
+
* Shared with `carrick init`, which signs a machine in rather than stopping to
|
|
8
|
+
* say "run carrick login" (carrick#955): the first thing a new install does is
|
|
9
|
+
* the one thing it was refusing to do. The steps are the same either way, so
|
|
10
|
+
* there is one copy of them.
|
|
11
|
+
*/
|
|
12
|
+
export async function signIn(say = (message) => process.stdout.write(`${message}\n`), signal) {
|
|
13
|
+
// An explicit override must be verified, never silently replaced by a browser login.
|
|
14
|
+
const override = process.env["CARRICK_TOKEN"] !== undefined ? readCredential() : null;
|
|
15
|
+
const token = override?.token ?? await authorize(signal ? { signal } : {});
|
|
16
|
+
// Keep an issued token if the new metadata endpoint is temporarily unavailable.
|
|
17
|
+
if (!override)
|
|
18
|
+
saveCredential(token, null);
|
|
19
|
+
const resolved = await resolveRepos(token, []);
|
|
20
|
+
if (!override)
|
|
21
|
+
saveCredential(token, resolved.workspace.slug);
|
|
22
|
+
say(`Signed in to Carrick workspace ${resolved.workspace.slug}${override ? " using CARRICK_TOKEN" : ""}.`);
|
|
23
|
+
return (override ?? {
|
|
24
|
+
api_base: API_BASE,
|
|
25
|
+
token,
|
|
26
|
+
workspace_slug: resolved.workspace.slug,
|
|
27
|
+
obtained_at: new Date().toISOString(),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export async function login(argv) {
|
|
31
|
+
if (argv.length) {
|
|
32
|
+
process.stdout.write("carrick login\n\nSign in through your browser. CARRICK_TOKEN overrides the saved credential.\n");
|
|
33
|
+
return argv.length === 1 && ["--help", "-h"].includes(argv[0]) ? 0 : 2;
|
|
34
|
+
}
|
|
35
|
+
const controller = new AbortController();
|
|
36
|
+
const cancel = () => controller.abort();
|
|
37
|
+
process.once("SIGINT", cancel);
|
|
38
|
+
try {
|
|
39
|
+
await signIn(undefined, controller.signal);
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
process.stderr.write(`${error.message}\n`);
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
process.removeListener("SIGINT", cancel);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function logout(argv) {
|
|
51
|
+
if (argv.length) {
|
|
52
|
+
process.stdout.write("carrick logout\n\nRemove the saved local credential. Revoke the key at https://app.carrick.tools/account.\n");
|
|
53
|
+
return argv.length === 1 && ["--help", "-h"].includes(argv[0]) ? 0 : 2;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const removed = removeCredential();
|
|
57
|
+
process.stdout.write(removed ? "Removed the saved Carrick credential.\n" : "No saved Carrick credential.\n");
|
|
58
|
+
if (process.env["CARRICK_TOKEN"] !== undefined)
|
|
59
|
+
process.stdout.write("CARRICK_TOKEN still overrides login; unset it in your shell to sign out.\n");
|
|
60
|
+
process.stdout.write("To revoke the key on the server, visit https://app.carrick.tools/account.\n");
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
process.stderr.write(`${error.message}\n`);
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/auth/run.ts"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AAC,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;QACnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,yCAAyC,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC;QAC7G,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,SAAS;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4EAA4E,CAAC,CAAC;QACnJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6EAA6E,CAAC,CAAC;QACpG,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAI,KAAe,CAAC,OAAO,IAAI,CAAC,CAAC;QAAC,OAAO,CAAC,CAAC;IAAC,CAAC;AACtF,CAAC"}
|
package/dist/contract.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export type Boundary = {
|
|
|
26
26
|
bare_checkout?: boolean;
|
|
27
27
|
};
|
|
28
28
|
export type Counterpart = {
|
|
29
|
+
/** Hosted-only GitHub owner/repo; it never names a local navigation target. */
|
|
30
|
+
remote?: string | null;
|
|
29
31
|
/**
|
|
30
32
|
* `peer` is a shared external contract: both sides call the same third
|
|
31
33
|
* party and neither serves the other, so it gets no producer/consumer word.
|
|
@@ -111,6 +113,12 @@ export type StatusService = {
|
|
|
111
113
|
boundary?: Boundary;
|
|
112
114
|
boundary_note?: string;
|
|
113
115
|
boundary_lines?: string[];
|
|
116
|
+
/**
|
|
117
|
+
* What the hosted index held for this service at the last index or refresh.
|
|
118
|
+
* `no_index_yet` is a connected repo whose first CI scan has not landed —
|
|
119
|
+
* the one state a session start can do something about (carrick#955).
|
|
120
|
+
*/
|
|
121
|
+
hosted_state?: "enriched" | "no_index_yet" | "not_connected" | "not_signed_in" | "version_mismatch" | "commit_missing" | "read_failed";
|
|
114
122
|
};
|
|
115
123
|
/** `carrick status --json`: the workspace, with no file in the question. */
|
|
116
124
|
export type StatusResult = {
|
|
@@ -119,6 +127,8 @@ export type StatusResult = {
|
|
|
119
127
|
workspace?: string;
|
|
120
128
|
indexed_at?: string;
|
|
121
129
|
scanner_version?: string;
|
|
130
|
+
/** RFC 3339, when this index last read the hosted side. */
|
|
131
|
+
hosted_checked_at?: string;
|
|
122
132
|
services: StatusService[];
|
|
123
133
|
};
|
|
124
134
|
/**
|
package/dist/contract.js
CHANGED
|
@@ -99,6 +99,9 @@ export function parseStatusResult(stdout) {
|
|
|
99
99
|
if (typeof parsed["scanner_version"] === "string") {
|
|
100
100
|
result.scanner_version = parsed["scanner_version"];
|
|
101
101
|
}
|
|
102
|
+
if (typeof parsed["hosted_checked_at"] === "string") {
|
|
103
|
+
result.hosted_checked_at = parsed["hosted_checked_at"];
|
|
104
|
+
}
|
|
102
105
|
const services = Array.isArray(parsed["services"]) ? parsed["services"] : [];
|
|
103
106
|
for (const entry of services) {
|
|
104
107
|
if (!isRecord(entry))
|
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,yDAAyD;AACzD,+EAA+E;AAC/E,4DAA4D;AAC5D,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,0CAA0C;
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,yDAAyD;AACzD,+EAA+E;AAC/E,4DAA4D;AAC5D,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,0CAA0C;AA0G1C,MAAM,CAAC,MAAM,MAAM,GAAG,iBAAiB,CAAC;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AA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Y,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type CheckItem, type CheckResult } from "./contract.ts";
|
|
2
|
+
import { type Range } from "./diagnostics.ts";
|
|
3
|
+
/** An LSP `Location`. `Location[]` is the answer shape; `[]` is "no answer". */
|
|
4
|
+
export type Location = {
|
|
5
|
+
uri: string;
|
|
6
|
+
range: Range;
|
|
7
|
+
};
|
|
8
|
+
export type DefinitionOptions = {
|
|
9
|
+
/** Injectable for tests; the real one hits the disk. */
|
|
10
|
+
exists?: (target: string) => boolean;
|
|
11
|
+
};
|
|
12
|
+
/** LSP positions are 0-based; the payload's line and column are 1-based. */
|
|
13
|
+
export type Position = {
|
|
14
|
+
line: number;
|
|
15
|
+
character: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* True when the position sits in the row's span: on its line, at or right of
|
|
19
|
+
* its anchor column. A row with no line covers nothing, because a row that
|
|
20
|
+
* cannot say where it is cannot claim a position.
|
|
21
|
+
*/
|
|
22
|
+
export declare function coversPosition(item: CheckItem, position: Position): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Every counterpart of every row covering `position`, deduplicated, facts
|
|
25
|
+
* first.
|
|
26
|
+
*
|
|
27
|
+
* Both directions fall out of one rule: a row's counterparts are its other
|
|
28
|
+
* side, so a call jumps to the producer and a route jumps to its consumers,
|
|
29
|
+
* and several locations is a valid answer the editor renders as a picker.
|
|
30
|
+
*/
|
|
31
|
+
export declare function definitionsAt(result: CheckResult, position: Position, options?: DefinitionOptions): Location[];
|
|
32
|
+
/** The position out of a `textDocument/definition` request, or null. */
|
|
33
|
+
export declare function positionOf(params: Record<string, unknown> | undefined): Position | null;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Cross-repo go to definition: from a call site to the producer handler in
|
|
2
|
+
// another repo, and from a route to the consumers that call it (carrick#881).
|
|
3
|
+
//
|
|
4
|
+
// This is the one jump nothing else in the editor can make, and the whole risk
|
|
5
|
+
// is answering a question that was not about Carrick. Four rules hold it down,
|
|
6
|
+
// and every one of them is a test in test/definition.test.ts.
|
|
7
|
+
//
|
|
8
|
+
// **Fall through, never hijack.** A position outside every row's span returns
|
|
9
|
+
// nothing at all, so the client's other definition providers answer as they did
|
|
10
|
+
// before Carrick was installed. A row states an anchor, `line` plus `col`, and
|
|
11
|
+
// no end: the span used here therefore runs from the anchor to the end of that
|
|
12
|
+
// line. The anchor column is a fact, so a position left of it is not the row;
|
|
13
|
+
// end of line is the honest upper bound, and taking the whole line instead
|
|
14
|
+
// would claim the `const user =` in front of a call.
|
|
15
|
+
//
|
|
16
|
+
// `col` is a 1-based column the index recorded. Where it counts bytes and the
|
|
17
|
+
// line holds multi-byte text, this span starts a little right of the anchor and
|
|
18
|
+
// the answer is empty rather than wrong, which is the direction to fail in.
|
|
19
|
+
//
|
|
20
|
+
// **Never a guessed path.** A counterpart is `repo` plus `file`, stated
|
|
21
|
+
// absolutely by the payload, and it is offered only when that path exists on
|
|
22
|
+
// this machine. Nothing here searches for a repo by service name or tries the
|
|
23
|
+
// workspace root: a counterpart this machine cannot point at yields no
|
|
24
|
+
// location, not a best-effort one. `resolveCounterpart` in diagnostics.ts is
|
|
25
|
+
// the one place that rule lives.
|
|
26
|
+
//
|
|
27
|
+
// The switch is `carrick.definition`, in surfaces.ts with the other off
|
|
28
|
+
// switches; off means an empty answer here rather than a withdrawn capability.
|
|
29
|
+
//
|
|
30
|
+
// **A candidate may answer, but never alone beside a fact.** A jump was asked
|
|
31
|
+
// for and a wrong one costs a keystroke back, so the model's reading may answer
|
|
32
|
+
// where nothing else does. Where a fact row matches the same position, the
|
|
33
|
+
// fact's locations come first and the candidate's follow.
|
|
34
|
+
//
|
|
35
|
+
// Known deviation from the design record, which says the peek title labels a
|
|
36
|
+
// candidate: LSP's `Location` and `LocationLink` carry no title, and the peek
|
|
37
|
+
// renders the target file and line only. There is nowhere to put the label, so
|
|
38
|
+
// ordering is what is enforced. Hosted model answers can supply candidate
|
|
39
|
+
// rows on local files unchanged since the hosted commit.
|
|
40
|
+
import { isCandidate } from "./contract.js";
|
|
41
|
+
import { resolveCounterpart } from "./diagnostics.js";
|
|
42
|
+
import { pathToFileURL } from "node:url";
|
|
43
|
+
/**
|
|
44
|
+
* True when the position sits in the row's span: on its line, at or right of
|
|
45
|
+
* its anchor column. A row with no line covers nothing, because a row that
|
|
46
|
+
* cannot say where it is cannot claim a position.
|
|
47
|
+
*/
|
|
48
|
+
export function coversPosition(item, position) {
|
|
49
|
+
if (typeof item.line !== "number")
|
|
50
|
+
return false;
|
|
51
|
+
if (position.line !== item.line - 1)
|
|
52
|
+
return false;
|
|
53
|
+
const startCharacter = Math.max(0, (item.col ?? 1) - 1);
|
|
54
|
+
return position.character >= startCharacter;
|
|
55
|
+
}
|
|
56
|
+
function locationsFor(item, exists) {
|
|
57
|
+
const locations = [];
|
|
58
|
+
for (const counterpart of item.counterparts ?? []) {
|
|
59
|
+
const resolved = resolveCounterpart(counterpart, exists);
|
|
60
|
+
if (!resolved)
|
|
61
|
+
continue;
|
|
62
|
+
const line = Math.max(0, (counterpart.line ?? 1) - 1);
|
|
63
|
+
locations.push({
|
|
64
|
+
uri: pathToFileURL(resolved).toString(),
|
|
65
|
+
// A counterpart states a line and no column, so the range is the start of
|
|
66
|
+
// that line: an editor reveals the line, and a guessed column would only
|
|
67
|
+
// put the cursor in the wrong place.
|
|
68
|
+
range: { start: { line, character: 0 }, end: { line, character: 0 } },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return locations;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Every counterpart of every row covering `position`, deduplicated, facts
|
|
75
|
+
* first.
|
|
76
|
+
*
|
|
77
|
+
* Both directions fall out of one rule: a row's counterparts are its other
|
|
78
|
+
* side, so a call jumps to the producer and a route jumps to its consumers,
|
|
79
|
+
* and several locations is a valid answer the editor renders as a picker.
|
|
80
|
+
*/
|
|
81
|
+
export function definitionsAt(result, position, options = {}) {
|
|
82
|
+
if (result.error)
|
|
83
|
+
return [];
|
|
84
|
+
const covering = (result.items ?? []).filter((item) => coversPosition(item, position));
|
|
85
|
+
const facts = covering.filter((item) => !isCandidate(item));
|
|
86
|
+
const candidates = covering.filter((item) => isCandidate(item));
|
|
87
|
+
const seen = new Set();
|
|
88
|
+
const locations = [];
|
|
89
|
+
for (const item of [...facts, ...candidates]) {
|
|
90
|
+
for (const location of locationsFor(item, options.exists)) {
|
|
91
|
+
const key = `${location.uri}:${location.range.start.line}`;
|
|
92
|
+
if (seen.has(key))
|
|
93
|
+
continue;
|
|
94
|
+
seen.add(key);
|
|
95
|
+
locations.push(location);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return locations;
|
|
99
|
+
}
|
|
100
|
+
/** The position out of a `textDocument/definition` request, or null. */
|
|
101
|
+
export function positionOf(params) {
|
|
102
|
+
const position = params?.["position"];
|
|
103
|
+
if (typeof position?.line !== "number" || typeof position?.character !== "number")
|
|
104
|
+
return null;
|
|
105
|
+
return { line: position.line, character: position.character };
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,8EAA8E;AAC9E,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,8DAA8D;AAC9D,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,qDAAqD;AACrD,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,4EAA4E;AAC5E,EAAE;AACF,wEAAwE;AACxE,6EAA6E;AAC7E,8EAA8E;AAC9E,uEAAuE;AACvE,6EAA6E;AAC7E,iCAAiC;AACjC,EAAE;AACF,wEAAwE;AACxE,+EAA+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,GAAG,CAAC,GAAG,CAAC,CAAC;YACd,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,MAA2C;IACpE,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,UAAU,CAAwD,CAAC;IAC7F,IAAI,OAAO,QAAQ,EAAE,IAAI,KAAK,QAAQ,IAAI,OAAO,QAAQ,EAAE,SAAS,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC/F,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;AAChE,CAAC"}
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CheckItem, type CheckResult, type Counterpart } from "./contract.ts";
|
|
2
|
+
import { type Surfaces } from "./surfaces.ts";
|
|
2
3
|
export declare const SOURCE = "carrick";
|
|
3
4
|
export declare const SEVERITY: {
|
|
4
5
|
readonly error: 1;
|
|
@@ -6,6 +7,18 @@ export declare const SEVERITY: {
|
|
|
6
7
|
readonly information: 3;
|
|
7
8
|
readonly hint: 4;
|
|
8
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Findings one file publishes before it says how many are left.
|
|
12
|
+
*
|
|
13
|
+
* The hook's `MAX_ITEM_LINES` is the same idea on the other channel and the two
|
|
14
|
+
* messages are written to read alike. The boundary fallback rides outside this
|
|
15
|
+
* cap: it is a statement about the workspace and not a finding, so a file with
|
|
16
|
+
* ten findings and a boundary publishes eleven rows and only one of them is the
|
|
17
|
+
* overflow row's business.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MAX_PER_FILE = 10;
|
|
20
|
+
/** Findings one check publishes across every file it touches. */
|
|
21
|
+
export declare const MAX_PER_CHECK = 30;
|
|
9
22
|
export type Position = {
|
|
10
23
|
line: number;
|
|
11
24
|
character: number;
|
|
@@ -28,8 +41,47 @@ export type Diagnostic = {
|
|
|
28
41
|
message: string;
|
|
29
42
|
}>;
|
|
30
43
|
};
|
|
31
|
-
/**
|
|
32
|
-
export declare function
|
|
44
|
+
/** A one-character range at a 1-based line and column, or at 1:1 without them. */
|
|
45
|
+
export declare function rangeAt(line: number | undefined, col: number | undefined): Range;
|
|
46
|
+
/**
|
|
47
|
+
* The text of one 1-based line of a file, or null when it cannot be read.
|
|
48
|
+
*
|
|
49
|
+
* The server backs this with the document the client has open, and with the
|
|
50
|
+
* file on disk for a counterpart file nobody opened (server.ts). Injectable so
|
|
51
|
+
* a test can state a line without a file.
|
|
52
|
+
*/
|
|
53
|
+
export type LineText = (absFile: string, line: number) => string | null;
|
|
54
|
+
/**
|
|
55
|
+
* What a diagnostic underlines on its line: first non-whitespace to last
|
|
56
|
+
* (carrick#922).
|
|
57
|
+
*
|
|
58
|
+
* The index stores line-only locators, so there is no column span to publish
|
|
59
|
+
* and a one-character range marks the indent rather than the code. The line's
|
|
60
|
+
* own text is the span: an editor underlines the statement, and a reader who
|
|
61
|
+
* cannot see the Problems list still knows which line is meant.
|
|
62
|
+
*
|
|
63
|
+
* `col` is deliberately not used to start the span. The locators the index
|
|
64
|
+
* holds are line-only and the column, when a payload carries one, is where a
|
|
65
|
+
* pass happened to anchor rather than where the statement begins. Without the
|
|
66
|
+
* line's text there is nothing to widen to and the one-character range stands.
|
|
67
|
+
*
|
|
68
|
+
* Characters are UTF-16 code units, which is what LSP means by `character` at
|
|
69
|
+
* the default position encoding and what a JavaScript string index already is.
|
|
70
|
+
* A line with a multi-byte character before the code is therefore right by
|
|
71
|
+
* construction here, which is not true of the byte offsets the scanner sends
|
|
72
|
+
* the sidecar (carrick#805).
|
|
73
|
+
*/
|
|
74
|
+
export declare function lineSpan(file: string, line: number | undefined, col: number | undefined, lineText: LineText | undefined): Range;
|
|
75
|
+
/**
|
|
76
|
+
* The severity policy, in one place.
|
|
77
|
+
*
|
|
78
|
+
* Error only for a finding on a fact row that claims something (R1c) and whose
|
|
79
|
+
* claim a reader can go and check. `resolvable` is whether any counterpart of
|
|
80
|
+
* this row is on this disk: a routing finding is entirely a statement about the
|
|
81
|
+
* other side, so when the other side cannot be opened it is a warning. Nothing
|
|
82
|
+
* here ever returns Hint.
|
|
83
|
+
*/
|
|
84
|
+
export declare function severityOf(item: CheckItem, resolvable?: boolean): number;
|
|
33
85
|
export declare function messageOf(item: CheckItem): string;
|
|
34
86
|
/**
|
|
35
87
|
* Where a counterpart lands on this disk, or null when it cannot be pointed at.
|
|
@@ -38,11 +90,28 @@ export declare function messageOf(item: CheckItem): string;
|
|
|
38
90
|
* a reader that also tried the workspace root or a directory named after the
|
|
39
91
|
* service would be guessing at paths the producer already knows.
|
|
40
92
|
*/
|
|
41
|
-
export declare function resolveCounterpart(counterpart: Counterpart, exists?: (target: string) => boolean): string | null;
|
|
93
|
+
export declare function resolveCounterpart(counterpart: Counterpart, exists?: ((target: string) => boolean) | undefined): string | null;
|
|
42
94
|
export type DiagnosticOptions = {
|
|
43
95
|
/** Injectable for tests. */
|
|
44
96
|
exists?: (target: string) => boolean;
|
|
97
|
+
/** The switches the client stated. Every surface is on when it stated none. */
|
|
98
|
+
surfaces?: Surfaces;
|
|
99
|
+
/**
|
|
100
|
+
* The text of a line, for the span each row underlines (carrick#922). Without
|
|
101
|
+
* it every row keeps the one-character range the locator alone can state.
|
|
102
|
+
*/
|
|
103
|
+
lineText?: LineText;
|
|
45
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* The cap, applied to a whole check.
|
|
107
|
+
*
|
|
108
|
+
* Ten findings per file with an eleventh row naming the remainder, thirty rows
|
|
109
|
+
* across the check with one more naming what the check as a whole did not show,
|
|
110
|
+
* and a file the budget drops publishes an empty list so its previous rows are
|
|
111
|
+
* cleared rather than left standing. The boundary fallback rides outside both
|
|
112
|
+
* counts: it states something about the workspace and is not a finding.
|
|
113
|
+
*/
|
|
114
|
+
export declare function capDiagnostics(byFile: Map<string, Diagnostic[]>, checkedAbs: string, checkedFile: string, lineText?: LineText): Map<string, Diagnostic[]>;
|
|
46
115
|
/**
|
|
47
116
|
* Diagnostics for one check payload, keyed by the absolute file they belong to.
|
|
48
117
|
*
|