@g3nomaly/analyze 0.1.5 → 0.1.6
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 +21 -7
- package/dist/api/create-docs.d.ts +10 -4
- package/dist/api/graph.d.ts +3 -2
- package/dist/api/path.d.ts +143 -0
- package/dist/api/refs.d.ts +23 -14
- package/dist/api/search.d.ts +12 -10
- package/dist/api/target.d.ts +3 -2
- package/dist/cli.js +768 -162
- package/dist/index.d.ts +2 -1
- package/dist/index.js +654 -119
- package/dist/model/index.d.ts +4 -1
- package/dist/model/registry.d.ts +14 -0
- package/dist/query/graph.d.ts +2 -1
- package/dist/query/name-search.d.ts +19 -1
- package/dist/retrieval/describe.d.ts +33 -1
- package/dist/retrieval/graph-export.d.ts +21 -1
- package/dist/retrieval/index.d.ts +5 -4
- package/dist/retrieval/report.d.ts +14 -0
- package/dist/retrieval/resolve.d.ts +25 -1
- package/dist/retrieval/retriever.d.ts +67 -7
- package/dist/retrieval/walk.d.ts +66 -0
- package/dist/scanner/code/calls.d.ts +39 -12
- package/dist/scanner/code/exports.d.ts +70 -0
- package/dist/scanner/code/extract.d.ts +11 -3
- package/dist/scanner/code/imports.d.ts +42 -1
- package/dist/scanner/code/language.d.ts +4 -0
- package/dist/scanner/code/symbols.d.ts +2 -2
- package/dist/scanner/files.d.ts +3 -1
- package/dist/scanner/graph/communities.d.ts +3 -2
- package/dist/scanner/index.d.ts +1 -1
- package/dist/scanner/packages.d.ts +4 -0
- package/package.json +3 -3
package/dist/model/index.d.ts
CHANGED
|
@@ -281,6 +281,7 @@ export interface SymbolExample {
|
|
|
281
281
|
*
|
|
282
282
|
* @property anchor - Unique within the file and safe in a URL hash.
|
|
283
283
|
* @property line - Line of the file where the declaration starts.
|
|
284
|
+
* @property endLine - Line of the file where the declaration ends. Absent in a bundle written before end lines existed.
|
|
284
285
|
* @property signatureHtml - Highlighted declaration head. Empty for a type the scanner inferred from its members.
|
|
285
286
|
* @property modifiers - Keywords in front of the declaration, such as `export`, `static` or `async`.
|
|
286
287
|
* @property annotations - Decorators, attributes and annotations, verbatim.
|
|
@@ -292,6 +293,7 @@ export interface SymbolExample {
|
|
|
292
293
|
export interface SymbolNode extends NodeBase<SymbolKind> {
|
|
293
294
|
readonly anchor: string;
|
|
294
295
|
readonly line: number;
|
|
296
|
+
readonly endLine?: number;
|
|
295
297
|
readonly signatureHtml: string;
|
|
296
298
|
readonly modifiers: readonly string[];
|
|
297
299
|
readonly annotations: readonly string[];
|
|
@@ -717,7 +719,8 @@ export interface SemanticIndex {
|
|
|
717
719
|
*
|
|
718
720
|
* @property labels - Label of each community, by id: the name of its best-linked node. Id 0 is the largest community.
|
|
719
721
|
* @property of - Community id of each node, by `NodeRef`. A parameter or field has the id of the entry it belongs
|
|
720
|
-
* to. `-1` for a section, folder or package,
|
|
722
|
+
* to. `-1` for a section, folder or package, and for a page or entry that would be alone in its community, which
|
|
723
|
+
* belong to none.
|
|
721
724
|
*/
|
|
722
725
|
export interface CommunityIndex {
|
|
723
726
|
readonly labels: readonly string[];
|
package/dist/model/registry.d.ts
CHANGED
|
@@ -508,6 +508,11 @@ export declare const RELATION_FAMILY_REGISTRY: {
|
|
|
508
508
|
readonly description: 'What a source file includes, and what a function calls.';
|
|
509
509
|
readonly colorToken: '--edge-code';
|
|
510
510
|
};
|
|
511
|
+
readonly callback: {
|
|
512
|
+
readonly label: 'callback';
|
|
513
|
+
readonly description: 'A function another function hands on as a value.';
|
|
514
|
+
readonly colorToken: '--edge-callback';
|
|
515
|
+
};
|
|
511
516
|
};
|
|
512
517
|
/** Every relation kind other than `parent`, in the order the site lists them. */
|
|
513
518
|
export declare const RELATION_KIND_REGISTRY: {
|
|
@@ -643,6 +648,15 @@ export declare const RELATION_KIND_REGISTRY: {
|
|
|
643
648
|
readonly family: 'code';
|
|
644
649
|
readonly dashed: true;
|
|
645
650
|
};
|
|
651
|
+
readonly passes: {
|
|
652
|
+
readonly label: 'passes';
|
|
653
|
+
readonly description: 'A function or method hands that function or method on as a value, such as a callback, without calling it.';
|
|
654
|
+
readonly forward: 'passes';
|
|
655
|
+
readonly backward: 'is passed by';
|
|
656
|
+
readonly from: 'function or method';
|
|
657
|
+
readonly to: 'function or method';
|
|
658
|
+
readonly family: 'callback';
|
|
659
|
+
};
|
|
646
660
|
};
|
|
647
661
|
/** Slug of a top-level section, such as `code`. */
|
|
648
662
|
export type Section = keyof typeof SECTION_REGISTRY;
|
package/dist/query/graph.d.ts
CHANGED
|
@@ -60,7 +60,8 @@ export declare class Graph {
|
|
|
60
60
|
* @brief The community a node is in.
|
|
61
61
|
*
|
|
62
62
|
* @param ref - Index of the node in the bundle.
|
|
63
|
-
* @returns The id of its community, or `null` for a section, folder or package, and in a bundle
|
|
63
|
+
* @returns The id of its community, or `null` for a section, folder or package, for a node alone, and in a bundle
|
|
64
|
+
* without communities.
|
|
64
65
|
*/
|
|
65
66
|
communityOf(ref: NodeRef): number | null;
|
|
66
67
|
/**
|
|
@@ -9,7 +9,10 @@ import type { Graph } from './graph';
|
|
|
9
9
|
* @property group - Name of the section the node is in. Results are grouped by it.
|
|
10
10
|
* @property title - Name shown in the results.
|
|
11
11
|
* @property detail - Text shown beside the title, such as a file path.
|
|
12
|
-
* @property haystack - Lowercase text that names the node: its title, the words of its name, the words it replaces
|
|
12
|
+
* @property haystack - Lowercase text that names the node: its title, the words of its name, the words it replaces,
|
|
13
|
+
* and the names of its members.
|
|
14
|
+
* @property own - The part of `haystack` that names the node itself, without its members.
|
|
15
|
+
* @property members - Each parameter, field, operation or definition whose name `haystack` holds, with its own words.
|
|
13
16
|
* @property place - Lowercase words of `detail`, each with a space in front of it.
|
|
14
17
|
* @property text - Lowercase words that describe the node: its description, its definition, the page.
|
|
15
18
|
* Every word has a space in front of it, so a search can tell the start of a word from its middle.
|
|
@@ -24,18 +27,33 @@ export interface SearchEntry {
|
|
|
24
27
|
readonly title: string;
|
|
25
28
|
readonly detail: string;
|
|
26
29
|
readonly haystack: string;
|
|
30
|
+
readonly own: string;
|
|
31
|
+
readonly members: readonly SearchMember[];
|
|
27
32
|
readonly place: string;
|
|
28
33
|
readonly text: string;
|
|
29
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @brief A member whose name is in the entry of its owner.
|
|
37
|
+
*
|
|
38
|
+
* @property node - The member node, such as a field.
|
|
39
|
+
* @property haystack - Lowercase text that names the member, as the member entry holds it.
|
|
40
|
+
*/
|
|
41
|
+
export interface SearchMember {
|
|
42
|
+
readonly node: NodeRef;
|
|
43
|
+
readonly haystack: string;
|
|
44
|
+
}
|
|
30
45
|
/**
|
|
31
46
|
* One result of a search by words.
|
|
32
47
|
*
|
|
33
48
|
* @property entry - The entry that matched.
|
|
34
49
|
* @property found - `name` when every word of the query is in what names the node. `text` when at least one word is only in what describes it.
|
|
50
|
+
* @property member - For a match by name that needs the name of a member, the first member whose words, with the
|
|
51
|
+
* node's own, hold every word of the query. `null` when the node's own name holds them, and for a match by text.
|
|
35
52
|
*/
|
|
36
53
|
export interface SearchMatch {
|
|
37
54
|
readonly entry: SearchEntry;
|
|
38
55
|
readonly found: 'name' | 'text';
|
|
56
|
+
readonly member: NodeRef | null;
|
|
39
57
|
}
|
|
40
58
|
/**
|
|
41
59
|
* @brief Builds the index for search by words: one entry per file, symbol, glossary term, decision, table,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EdgeKind, type NodeRef } from '../model';
|
|
2
2
|
import { type Graph } from '../query';
|
|
3
|
-
import type { NodeReport, References } from './report';
|
|
3
|
+
import type { NodeReport, Reference, References } from './report';
|
|
4
4
|
/**
|
|
5
5
|
* @brief Which edges of a node to report.
|
|
6
6
|
*
|
|
@@ -13,6 +13,38 @@ export interface ReferenceOptions {
|
|
|
13
13
|
}
|
|
14
14
|
/** The options that keep every edge in both directions. */
|
|
15
15
|
export declare const ALL_REFERENCES: ReferenceOptions;
|
|
16
|
+
/**
|
|
17
|
+
* @brief One edge of a node, seen from the node: the relation, the page or entry at the other end, and the
|
|
18
|
+
* parameter or field it runs through.
|
|
19
|
+
*
|
|
20
|
+
* @property relation - Kind of the edge.
|
|
21
|
+
* @property node - The page or entry at the other end. A parameter or field there counts as its symbol.
|
|
22
|
+
* @property via - For a `type` edge, the name of the parameter or field of the node it starts at, else `null`.
|
|
23
|
+
*/
|
|
24
|
+
export interface Step {
|
|
25
|
+
readonly relation: EdgeKind;
|
|
26
|
+
readonly node: NodeRef;
|
|
27
|
+
readonly via: string | null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @brief Lists the edges of a node in one direction, each once. The edges of its parameters and fields count as its
|
|
31
|
+
* own, as on its page.
|
|
32
|
+
*
|
|
33
|
+
* @param graph - Graph the node belongs to.
|
|
34
|
+
* @param node - A page or an entry.
|
|
35
|
+
* @param direction - `out` for the edges that start at the node, `in` for those that end at it.
|
|
36
|
+
* @param kinds - Edge kinds to keep. Empty keeps every kind.
|
|
37
|
+
* @returns The steps in edge order.
|
|
38
|
+
*/
|
|
39
|
+
export declare function stepsOf(graph: Graph, node: NodeRef, direction: 'in' | 'out', kinds: readonly EdgeKind[]): Step[];
|
|
40
|
+
/**
|
|
41
|
+
* @brief Turns a step into the reference a report shows.
|
|
42
|
+
*
|
|
43
|
+
* @param graph - Graph the step belongs to.
|
|
44
|
+
* @param step - The step.
|
|
45
|
+
* @returns The relation, the summary of the other node, and the parameter or field it runs through.
|
|
46
|
+
*/
|
|
47
|
+
export declare function referenceOf(graph: Graph, step: Step): Reference;
|
|
16
48
|
/**
|
|
17
49
|
* @brief Lists the edges of a node in both directions. The edges of its parameters
|
|
18
50
|
* and fields count as its own, as on its page.
|
|
@@ -30,9 +30,13 @@ export interface GraphExportOptions {
|
|
|
30
30
|
* @property type - Type of the node, such as `source` or `method`.
|
|
31
31
|
* @property name - Name of the node. For a package, the name its manifest gives.
|
|
32
32
|
* @property package - Display path of the package the node is or is in, such as `libs/slam`, or `null`.
|
|
33
|
-
* @property community - Id of the community of the node, or `null` for a section, folder or package
|
|
33
|
+
* @property community - Id of the community of the node, or `null` for a section, folder or package and for a node
|
|
34
|
+
* that would be alone in one.
|
|
34
35
|
* @property parent - Id of the node it is drawn in, such as the folder of a file, or `null`. Always `null` at the
|
|
35
36
|
* `packages` and `communities` levels.
|
|
37
|
+
* @property size - For a community: the number of pages and entries in it. Absent on every other node.
|
|
38
|
+
* @property members - For a community: its best-linked pages and entries, the best first, at most
|
|
39
|
+
* `COMMUNITY_MEMBERS`. Absent on every other node.
|
|
36
40
|
*/
|
|
37
41
|
export interface ExportNode {
|
|
38
42
|
readonly id: string;
|
|
@@ -42,7 +46,23 @@ export interface ExportNode {
|
|
|
42
46
|
readonly package: string | null;
|
|
43
47
|
readonly community: number | null;
|
|
44
48
|
readonly parent: string | null;
|
|
49
|
+
readonly size?: number;
|
|
50
|
+
readonly members?: readonly CommunityMember[];
|
|
45
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* @brief A page or entry of a community, as the export of the community lists it.
|
|
54
|
+
*
|
|
55
|
+
* @property id - Id of the node, as `show` and `refs` take it.
|
|
56
|
+
* @property name - Path of a file, or the qualified name of an entry, such as `Retriever.search`.
|
|
57
|
+
* @property links - Number of edges of the node, both ways, that the `all` level of the graph page draws.
|
|
58
|
+
*/
|
|
59
|
+
export interface CommunityMember {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly links: number;
|
|
63
|
+
}
|
|
64
|
+
/** Most members the export of one community lists. */
|
|
65
|
+
export declare const COMMUNITY_MEMBERS = 5;
|
|
46
66
|
/**
|
|
47
67
|
* @brief Edges of one kind between two nodes of an export.
|
|
48
68
|
*
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { ALL_REFERENCES, describeNode, type ReferenceOptions, referencesOf } from './describe';
|
|
2
|
+
export { DEFAULT_WALK_LIMIT, shortestPath, type Walk, type WalkOptions, type WalkReference, walkReferences } from './walk';
|
|
2
3
|
export { NO_FILTER, type NodeFilter, nodeTest, resultOf, resultsOf } from './filter';
|
|
3
|
-
export { EXPORT_LEVELS, type ExportEdge, type ExportLevel, type ExportNode, type GraphExport, type GraphExportOptions, exportGraph, } from './graph-export';
|
|
4
|
+
export { COMMUNITY_MEMBERS, type CommunityMember, EXPORT_LEVELS, type ExportEdge, type ExportLevel, type ExportNode, type GraphExport, type GraphExportOptions, exportGraph, } from './graph-export';
|
|
4
5
|
export { codeBlock, htmlToMarkdown } from './markdown';
|
|
5
|
-
export type { ContentReport, DatabaseObjectReport, DeclarationReport, ForeignKeyReport, NodeReport, NodeSummary, OperationReport, QueryReport, Reference, References, TableReport, TagReport, TaskReport, } from './report';
|
|
6
|
-
export { type Resolution, resolveNode } from './resolve';
|
|
7
|
-
export { Retriever, SEARCH_MODES, type SearchHit, type SearchMode, type SearchOptions } from './retriever';
|
|
6
|
+
export type { ContentReport, DatabaseObjectReport, DeclarationReport, MemberMatch, ForeignKeyReport, NodeReport, NodeSummary, OperationReport, QueryReport, Reference, References, TableReport, TagReport, TaskReport, } from './report';
|
|
7
|
+
export { type Candidate, closestNames, type Resolution, resolveNode } from './resolve';
|
|
8
|
+
export { type HitPlace, Retriever, SEARCH_MODES, type SearchHit, type SearchMode, type SearchOptions } from './retriever';
|
|
8
9
|
export { nodeId, normalizeId, summarize } from './summary';
|
|
@@ -9,6 +9,8 @@ import type { ApiServer, DocTagKind, EdgeKind, NodeKind, NodeType, PackageRole,
|
|
|
9
9
|
* @property note - A short fact that belongs beside the title: the status of a decision, a plan, a phase or a task, the language of a source file, the version of an API, the verb of a query. `''` for other nodes.
|
|
10
10
|
* @property path - Path on disk of the file the node is or is in. For a catalog, the path of its directory. `null` for a section or a folder.
|
|
11
11
|
* @property line - Line of a symbol, a table or a query in its file. `null` for every other node.
|
|
12
|
+
* @property endLine - Last line of a symbol in its file. `null` for every other node, and for a symbol of a site
|
|
13
|
+
* written before end lines existed.
|
|
12
14
|
* @property summary - First paragraph of its description, as plain text. A table or a query without a description gets what its SQL states instead: the number of columns and the tables it is connected to, or the tables it reads and writes. `''` for any other node without a description.
|
|
13
15
|
*/
|
|
14
16
|
export interface NodeSummary {
|
|
@@ -19,8 +21,20 @@ export interface NodeSummary {
|
|
|
19
21
|
readonly note: string;
|
|
20
22
|
readonly path: string | null;
|
|
21
23
|
readonly line: number | null;
|
|
24
|
+
readonly endLine: number | null;
|
|
22
25
|
readonly summary: string;
|
|
23
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @brief The parameter, field, operation or definition of a node that a name or a search matched, when the node's
|
|
29
|
+
* own name did not.
|
|
30
|
+
*
|
|
31
|
+
* @property kind - Kind of the member, such as `field`.
|
|
32
|
+
* @property name - Name of the member, such as `hashFile`.
|
|
33
|
+
*/
|
|
34
|
+
export interface MemberMatch {
|
|
35
|
+
readonly kind: NodeKind;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
}
|
|
24
38
|
/**
|
|
25
39
|
* @brief A parameter or a field of a symbol, a parameter of an operation, a property of a definition, a column of a table, or a placeholder or a result column of a query.
|
|
26
40
|
*
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { type NodeRef } from '../model';
|
|
2
2
|
import type { Graph } from '../query';
|
|
3
|
+
/**
|
|
4
|
+
* @brief One node a name fits, with the parameter, field, operation or definition of it that the name matched.
|
|
5
|
+
*
|
|
6
|
+
* @property node - The node.
|
|
7
|
+
* @property member - The member whose name matched, such as the field `hashFile` of an interface. `null` when the
|
|
8
|
+
* name of the node itself matched.
|
|
9
|
+
*/
|
|
10
|
+
export interface Candidate {
|
|
11
|
+
readonly node: NodeRef;
|
|
12
|
+
readonly member: NodeRef | null;
|
|
13
|
+
}
|
|
3
14
|
/**
|
|
4
15
|
* @brief What a reference to a node turned out to name.
|
|
5
16
|
*
|
|
@@ -11,7 +22,7 @@ export type Resolution = {
|
|
|
11
22
|
readonly node: NodeRef;
|
|
12
23
|
} | {
|
|
13
24
|
readonly kind: 'ambiguous';
|
|
14
|
-
readonly candidates: readonly
|
|
25
|
+
readonly candidates: readonly Candidate[];
|
|
15
26
|
} | {
|
|
16
27
|
readonly kind: 'missing';
|
|
17
28
|
};
|
|
@@ -29,3 +40,16 @@ export type Resolution = {
|
|
|
29
40
|
* @returns The node, the candidates when several fit the deciding rule, or `missing`. A match by name on a parameter, field, operation or definition returns the node it belongs to, see `resultOf`; its id returns the node itself.
|
|
30
41
|
*/
|
|
31
42
|
export declare function resolveNode(graph: Graph, text: string, accepts: (node: NodeRef) => boolean): Resolution;
|
|
43
|
+
/**
|
|
44
|
+
* @brief Finds the names closest to a name that fits no node, such as `installSkillPackages` for
|
|
45
|
+
* `instalSkillPackages`, capitals ignored.
|
|
46
|
+
*
|
|
47
|
+
* A name counts when at most one edit in four characters turns it into the text, and at least one edit always
|
|
48
|
+
* counts.
|
|
49
|
+
*
|
|
50
|
+
* @param graph - Graph to search.
|
|
51
|
+
* @param text - The name that fit no node.
|
|
52
|
+
* @param accepts - Narrows the nodes that count, such as to one kind.
|
|
53
|
+
* @returns Up to three names, the closest first. Empty when none is close.
|
|
54
|
+
*/
|
|
55
|
+
export declare function closestNames(graph: Graph, text: string, accepts: (node: NodeRef) => boolean): string[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EdgeKind, type NodeRef, type Section } from '../model';
|
|
2
2
|
import { type Graph } from '../query';
|
|
3
|
-
import { type ReferenceOptions } from './describe';
|
|
4
3
|
import { type NodeFilter } from './filter';
|
|
5
4
|
import { type GraphExport, type GraphExportOptions } from './graph-export';
|
|
6
|
-
import type { NodeReport, NodeSummary,
|
|
5
|
+
import type { MemberMatch, NodeReport, NodeSummary, Reference } from './report';
|
|
7
6
|
import { type Resolution } from './resolve';
|
|
7
|
+
import { type Walk, type WalkOptions } from './walk';
|
|
8
8
|
/** The search modes a caller can pick from, the default first. */
|
|
9
9
|
export declare const SEARCH_MODES: readonly ['both', 'name', 'meaning'];
|
|
10
10
|
/** How a search matches: `name` by the words of a name or a description, `meaning` by the embedding model, `both` by words first and then by meaning. */
|
|
@@ -27,11 +27,30 @@ export interface SearchOptions {
|
|
|
27
27
|
* @property match - `name`: every word of the query is in the name or the path of the node. `text`: at least one word is only in its description. `meaning`: the node is close to the query in the embedding model.
|
|
28
28
|
* @property score - From 0 to 1 for a match by meaning. `null` for a match by words.
|
|
29
29
|
* @property weak - `true` for a match by meaning below the cut-off, which only a search that found nothing else returns. Absent on every other hit.
|
|
30
|
+
* @property member - The parameter, field, operation or definition of the node that matched, such as the field
|
|
31
|
+
* `hashFile` of an interface. `null` when the node matched by its own name, text or meaning.
|
|
32
|
+
* @property section - Section the node is in.
|
|
33
|
+
* @property duplicates - Other nodes the same search found that this hit stands for, because they match the same way
|
|
34
|
+
* with the same kind, type, title, summary and score, such as nine `hooks.json` files that say nothing. Each with
|
|
35
|
+
* its id and path. Empty for a hit that stands for itself only.
|
|
30
36
|
*/
|
|
31
37
|
export interface SearchHit extends NodeSummary {
|
|
32
38
|
readonly match: 'name' | 'text' | 'meaning';
|
|
33
39
|
readonly score: number | null;
|
|
34
40
|
readonly weak?: true;
|
|
41
|
+
readonly member: MemberMatch | null;
|
|
42
|
+
readonly section: Section;
|
|
43
|
+
readonly duplicates: readonly HitPlace[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @brief Where a node a search hit stands for is.
|
|
47
|
+
*
|
|
48
|
+
* @property id - Id of the node.
|
|
49
|
+
* @property path - Path on disk of the file the node is or is in, or `null`.
|
|
50
|
+
*/
|
|
51
|
+
export interface HitPlace {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly path: string | null;
|
|
35
54
|
}
|
|
36
55
|
/**
|
|
37
56
|
* @brief Answers queries on one bundle: search, list, look up, describe, export.
|
|
@@ -58,6 +77,12 @@ export declare class Retriever {
|
|
|
58
77
|
* @returns The name, or `null` when the bundle was built without embeddings.
|
|
59
78
|
*/
|
|
60
79
|
get model(): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* @brief Lists the sections the bundle has, in display order. A bundle can lack one, such as `database`.
|
|
82
|
+
*
|
|
83
|
+
* @returns The slugs of its sections.
|
|
84
|
+
*/
|
|
85
|
+
get sections(): readonly Section[];
|
|
61
86
|
/**
|
|
62
87
|
* @brief Finds pages and entries for a query. Matches by words come first, in the
|
|
63
88
|
* order the site lists them. Matches by meaning follow, best first.
|
|
@@ -76,6 +101,17 @@ export declare class Retriever {
|
|
|
76
101
|
* @returns The hits, best first, each with `weak: true`. Empty for a search by name or a bundle without embeddings.
|
|
77
102
|
*/
|
|
78
103
|
searchWeak(query: string, options: SearchOptions): SearchHit[];
|
|
104
|
+
/**
|
|
105
|
+
* @brief Builds the hit of one node, standing for itself only.
|
|
106
|
+
*
|
|
107
|
+
* @param node - The node the hit returns.
|
|
108
|
+
* @param member - The member of it that matched, or `null` when the node matched itself.
|
|
109
|
+
* @param match - How it matched.
|
|
110
|
+
* @param score - Its score by meaning, or `null` for a match by words.
|
|
111
|
+
* @returns The hit, without duplicates.
|
|
112
|
+
* @throws {Error} When the node is in no section, which a bundle never allows.
|
|
113
|
+
*/
|
|
114
|
+
private hitOf;
|
|
79
115
|
/**
|
|
80
116
|
* @brief Lists pages and entries in display order.
|
|
81
117
|
*
|
|
@@ -92,6 +128,21 @@ export declare class Retriever {
|
|
|
92
128
|
* @returns The node, the candidates when several fit, or `missing`.
|
|
93
129
|
*/
|
|
94
130
|
resolve(text: string, filter: NodeFilter): Resolution;
|
|
131
|
+
/**
|
|
132
|
+
* @brief Finds the names closest to a name that fits no node, for a caller who mistyped it.
|
|
133
|
+
*
|
|
134
|
+
* @param text - The name that fit no node.
|
|
135
|
+
* @param filter - Narrows the nodes that count, as for `resolve`.
|
|
136
|
+
* @returns Up to three names, the closest first. Empty when none is close.
|
|
137
|
+
*/
|
|
138
|
+
suggest(text: string, filter: NodeFilter): string[];
|
|
139
|
+
/**
|
|
140
|
+
* @brief Names a parameter, field, operation or definition that a name or a search matched.
|
|
141
|
+
*
|
|
142
|
+
* @param member - The member node.
|
|
143
|
+
* @returns Its kind and name.
|
|
144
|
+
*/
|
|
145
|
+
memberOf(member: NodeRef): MemberMatch;
|
|
95
146
|
/**
|
|
96
147
|
* @brief Describes a node in one row.
|
|
97
148
|
*
|
|
@@ -107,13 +158,22 @@ export declare class Retriever {
|
|
|
107
158
|
*/
|
|
108
159
|
describe(node: NodeRef): NodeReport;
|
|
109
160
|
/**
|
|
110
|
-
* @brief
|
|
161
|
+
* @brief Follows the edges of a node for some hops in each direction, the closest first.
|
|
111
162
|
*
|
|
112
163
|
* @param node - A page or an entry.
|
|
113
|
-
* @param options -
|
|
114
|
-
* @returns What the node links to and what links to it.
|
|
164
|
+
* @param options - Direction, edge kinds, depth and the most references to list.
|
|
165
|
+
* @returns What the node links to and what links to it, each with its next hop, and how many the limit left out.
|
|
166
|
+
*/
|
|
167
|
+
walk(node: NodeRef, options: WalkOptions): Walk;
|
|
168
|
+
/**
|
|
169
|
+
* @brief Finds the shortest chain of edges from one node to another, following edges the way they point.
|
|
170
|
+
*
|
|
171
|
+
* @param from - The node the chain starts at.
|
|
172
|
+
* @param to - The node the chain ends at.
|
|
173
|
+
* @param kinds - Edge kinds to follow. Empty follows every kind.
|
|
174
|
+
* @returns Each reference of the chain in order, or `null` when no chain leads from `from` to `to`.
|
|
115
175
|
*/
|
|
116
|
-
|
|
176
|
+
path(from: NodeRef, to: NodeRef, kinds: readonly EdgeKind[]): Reference[] | null;
|
|
117
177
|
/**
|
|
118
178
|
* @brief Exports one level of the bundle as nodes and edges.
|
|
119
179
|
*
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { EdgeKind, NodeRef } from '../model';
|
|
2
|
+
import type { Graph } from '../query';
|
|
3
|
+
import type { Reference } from './report';
|
|
4
|
+
/** Most references a walk lists without a limit. */
|
|
5
|
+
export declare const DEFAULT_WALK_LIMIT = 50;
|
|
6
|
+
/**
|
|
7
|
+
* @brief How far a walk of the references of a node goes.
|
|
8
|
+
*
|
|
9
|
+
* @property direction - `in` for what links to the node, `out` for what it links to, `both` for either.
|
|
10
|
+
* @property kinds - Edge kinds to follow. Empty follows every kind.
|
|
11
|
+
* @property depth - Hops to follow from the node. 1 lists its own references.
|
|
12
|
+
* @property limit - Most references to list, both directions and every hop together.
|
|
13
|
+
*/
|
|
14
|
+
export interface WalkOptions {
|
|
15
|
+
readonly direction: 'in' | 'out' | 'both';
|
|
16
|
+
readonly kinds: readonly EdgeKind[];
|
|
17
|
+
readonly depth: number;
|
|
18
|
+
readonly limit: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @brief A reference with the references of its node one hop further, in the same direction.
|
|
22
|
+
*
|
|
23
|
+
* @property next - What the node of this reference links to, or what links to it, on the next hop. Empty on the
|
|
24
|
+
* last hop, for a node listed under another reference already, and for a node the limit cut off.
|
|
25
|
+
*/
|
|
26
|
+
export interface WalkReference extends Reference {
|
|
27
|
+
readonly next: readonly WalkReference[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @brief The references of a node, followed for some hops in each direction.
|
|
31
|
+
*
|
|
32
|
+
* @property linksTo - What the node links to, each with what that links to on the next hop.
|
|
33
|
+
* @property linkedFrom - What links to the node, each with what links to that on the next hop.
|
|
34
|
+
* @property omitted - References the walk reached within its depth but did not list, because of its limit.
|
|
35
|
+
*/
|
|
36
|
+
export interface Walk {
|
|
37
|
+
readonly linksTo: readonly WalkReference[];
|
|
38
|
+
readonly linkedFrom: readonly WalkReference[];
|
|
39
|
+
readonly omitted: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @brief Follows the references of a node for some hops, breadth first, so the closest references are listed
|
|
43
|
+
* before the limit cuts the rest.
|
|
44
|
+
*
|
|
45
|
+
* Each hop takes its steps from both directions in turn, so neither direction uses up the limit alone. A node is
|
|
46
|
+
* listed once per direction: under the first reference that reaches it, with every relation that reference's node
|
|
47
|
+
* has to it. The start node is never listed again. Past the limit the walk goes on to its depth without listing,
|
|
48
|
+
* so it counts every reference it leaves out.
|
|
49
|
+
*
|
|
50
|
+
* @param graph - Graph the node belongs to.
|
|
51
|
+
* @param start - The node the walk starts at.
|
|
52
|
+
* @param options - Direction, edge kinds, depth and limit.
|
|
53
|
+
* @returns Both directions of the walk, and how many references the limit left out.
|
|
54
|
+
*/
|
|
55
|
+
export declare function walkReferences(graph: Graph, start: NodeRef, options: WalkOptions): Walk;
|
|
56
|
+
/**
|
|
57
|
+
* @brief Finds the shortest chain of edges from one node to another, following edges the way they point.
|
|
58
|
+
*
|
|
59
|
+
* @param graph - Graph both nodes belong to.
|
|
60
|
+
* @param from - The node the chain starts at.
|
|
61
|
+
* @param to - The node the chain ends at.
|
|
62
|
+
* @param kinds - Edge kinds to follow. Empty follows every kind.
|
|
63
|
+
* @returns The references from `from` to `to`, in order, each to the next node of the chain. Empty when `from` is
|
|
64
|
+
* `to`. `null` when no chain leads there.
|
|
65
|
+
*/
|
|
66
|
+
export declare function shortestPath(graph: Graph, from: NodeRef, to: NodeRef, kinds: readonly EdgeKind[]): Reference[] | null;
|
|
@@ -26,17 +26,32 @@ export interface RawCall {
|
|
|
26
26
|
readonly qualifier: readonly string[];
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* @brief
|
|
29
|
+
* @brief The calls in a function body, and the functions it passes on as values.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* @property calls - Every call, each once, in the order they first appear.
|
|
32
|
+
* @property passes - Every name the body hands on as a value without calling it, such as the callback in
|
|
33
|
+
* `run(onDone)` or the entry of `{ add: addCommand }`, each once. A name the body binds itself is left out.
|
|
34
|
+
*/
|
|
35
|
+
export interface BodyReferences {
|
|
36
|
+
readonly calls: readonly RawCall[];
|
|
37
|
+
readonly passes: readonly RawCall[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @brief Reads the calls of a function body, and the functions it passes on as values.
|
|
41
|
+
*
|
|
42
|
+
* Calls and values inside a nested definition belong to that definition and are left out. Those inside a lambda
|
|
43
|
+
* or a closure belong to the function around it. A call through a variable the body declares itself keeps no
|
|
33
44
|
* variable, since that local may hide a parameter or field of the same name and its type is unknown.
|
|
34
45
|
*
|
|
46
|
+
* A value counts when it is an argument of a call, an element of an array or a list, or the value of a key of an
|
|
47
|
+
* object or a dict, and names a function: `onDone`, `this.flush` or `Timer.once`. A name the body binds, as a
|
|
48
|
+
* local, a loop variable, a catch variable or a lambda parameter, never counts, since it is no function of the scan.
|
|
49
|
+
*
|
|
35
50
|
* @param body - Body node of the function.
|
|
36
51
|
* @param definitions - Ids of the definition nodes of the file.
|
|
37
|
-
* @returns The calls the body
|
|
52
|
+
* @returns The calls and the passed values of the body.
|
|
38
53
|
*/
|
|
39
|
-
export declare function
|
|
54
|
+
export declare function readReferences(body: Node, definitions: ReadonlySet<number>): BodyReferences;
|
|
40
55
|
/**
|
|
41
56
|
* @brief What a call can be resolved with: where it is, the names around its function, and the declared types
|
|
42
57
|
* of the variables it can go through.
|
|
@@ -55,7 +70,8 @@ export interface CallContext {
|
|
|
55
70
|
readonly implicitReceiver: boolean;
|
|
56
71
|
}
|
|
57
72
|
/**
|
|
58
|
-
* @brief Turns the calls of a function into `calls` edges
|
|
73
|
+
* @brief Turns the calls of a function into `calls` edges, and the functions it passes on into `passes` edges, to
|
|
74
|
+
* the functions of the scan they reach.
|
|
59
75
|
*
|
|
60
76
|
* A call only links when it names one function its file sees: one in the same file or in a file it imports, directly
|
|
61
77
|
* or not. For a language whose imports the scan does not read, a bare call only reaches a free function of the same
|
|
@@ -63,13 +79,14 @@ export interface CallContext {
|
|
|
63
79
|
* the declared type of the parameter or field it goes through, else a static method of a type of that name; a call
|
|
64
80
|
* through any other expression links nowhere, since its type is unknown.
|
|
65
81
|
*
|
|
66
|
-
* Holds the indexes it resolves against, the graph it adds edges to,
|
|
82
|
+
* Holds the indexes it resolves against, the graph it adds edges to, the fields of each type, and the getters and
|
|
83
|
+
* setters, which a value never hands on. Created per scan
|
|
67
84
|
* by `RepositoryScanner` in `scanner/scanner.ts`; `SymbolPlanner` in `symbols.ts` registers the fields of each type
|
|
68
85
|
* and links the calls of each function once every declaration is known.
|
|
69
86
|
*
|
|
70
87
|
* @example
|
|
71
88
|
* const calls = new CallLinker(types, callables, sources, graph);
|
|
72
|
-
* calls.link(functionRef, rawSymbol.calls, { scope, owners: ['geo'], variables: new Map() });
|
|
89
|
+
* calls.link(functionRef, rawSymbol.calls, { scope, owners: ['geo'], variables: new Map() }, 'calls');
|
|
73
90
|
*/
|
|
74
91
|
export declare class CallLinker {
|
|
75
92
|
private readonly types;
|
|
@@ -77,6 +94,7 @@ export declare class CallLinker {
|
|
|
77
94
|
private readonly sources;
|
|
78
95
|
private readonly graph;
|
|
79
96
|
private readonly fields;
|
|
97
|
+
private readonly accessors;
|
|
80
98
|
/**
|
|
81
99
|
* Takes the indexes the calls resolve against and the graph the edges are added to.
|
|
82
100
|
*
|
|
@@ -102,13 +120,22 @@ export declare class CallLinker {
|
|
|
102
120
|
*/
|
|
103
121
|
fieldsAround(context: Pick<CallContext, 'scope' | 'owners'>): ReadonlyMap<string, string>;
|
|
104
122
|
/**
|
|
105
|
-
* @brief Records
|
|
123
|
+
* @brief Records an edge from `from` to each function its calls or its passed values reach.
|
|
106
124
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
125
|
+
* A passed value resolves the way a call of the same name would.
|
|
126
|
+
*
|
|
127
|
+
* @param from - Node of the function.
|
|
128
|
+
* @param calls - The calls in its body, or the values it passes on.
|
|
109
129
|
* @param context - Where the function is.
|
|
130
|
+
* @param kind - `calls` for calls, `passes` for values passed on.
|
|
131
|
+
*/
|
|
132
|
+
link(from: NodeRef, calls: readonly RawCall[], context: CallContext, kind: 'calls' | 'passes'): void;
|
|
133
|
+
/**
|
|
134
|
+
* @brief Records that a method is a getter or a setter, which a value names without handing it on.
|
|
135
|
+
*
|
|
136
|
+
* @param method - Node of the getter or setter.
|
|
110
137
|
*/
|
|
111
|
-
|
|
138
|
+
registerAccessor(method: NodeRef): void;
|
|
112
139
|
/**
|
|
113
140
|
* @brief The function one call reaches.
|
|
114
141
|
*
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Node } from 'web-tree-sitter';
|
|
2
|
+
import type { SourceFileIndex } from './imports';
|
|
3
|
+
/**
|
|
4
|
+
* @brief One name an `export { … } from` statement hands on.
|
|
5
|
+
*
|
|
6
|
+
* @property name - Name the other file exports it under, such as `hashFile`.
|
|
7
|
+
* @property as - Name this file exports it under: the same name, or the alias of `name as alias`.
|
|
8
|
+
*/
|
|
9
|
+
export interface ReexportedName {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly as: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @brief One `export … from` statement.
|
|
15
|
+
*
|
|
16
|
+
* @property specifier - The file it names, as written, such as `./hash`.
|
|
17
|
+
* @property names - The names it hands on, or `null` for `export * from`, which hands on every name.
|
|
18
|
+
*/
|
|
19
|
+
export interface Reexport {
|
|
20
|
+
readonly specifier: string;
|
|
21
|
+
readonly names: readonly ReexportedName[] | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @brief What a file exports by name. A default export is left out.
|
|
25
|
+
*
|
|
26
|
+
* @property declared - What the file declares and exports itself, each with the name it is exported under:
|
|
27
|
+
* `export function load()`, `export { load }` or `export { load as start }`.
|
|
28
|
+
* @property reexports - The `export … from` statements of the file in file order, and each `export { name }` of a name
|
|
29
|
+
* the file imports, which hands that name on from the file it came from.
|
|
30
|
+
*/
|
|
31
|
+
export interface FileExports {
|
|
32
|
+
readonly declared: readonly ReexportedName[];
|
|
33
|
+
readonly reexports: readonly Reexport[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @brief How code outside a package imports a symbol: by the package name, or one of its subpaths, and the name the
|
|
37
|
+
* entry file there exports.
|
|
38
|
+
*
|
|
39
|
+
* @property specifier - What the import names: the package, such as `@g3nomaly/skills`, or a subpath of it, such as
|
|
40
|
+
* `@g3nomaly/core/hash`.
|
|
41
|
+
* @property name - Name the entry file exports the symbol under, such as `hashFile`.
|
|
42
|
+
*/
|
|
43
|
+
export interface PackageImport {
|
|
44
|
+
readonly specifier: string;
|
|
45
|
+
readonly name: string;
|
|
46
|
+
}
|
|
47
|
+
/** The exports of a file that exports nothing by name, or whose language has no exports. */
|
|
48
|
+
export declare const NO_EXPORTS: FileExports;
|
|
49
|
+
/**
|
|
50
|
+
* @brief Reads the exports of a JavaScript or TypeScript file.
|
|
51
|
+
*
|
|
52
|
+
* @param root - Root node of the parsed file.
|
|
53
|
+
* @returns The names it declares and exports, and the names it hands on from other files. `export default` and
|
|
54
|
+
* `export * as name from` are left out, since neither exports a name of the other file.
|
|
55
|
+
*/
|
|
56
|
+
export declare function readEcmascriptExports(root: Node): FileExports;
|
|
57
|
+
/**
|
|
58
|
+
* @brief Finds how code outside a package imports a symbol: through the first entry point of the package the file is
|
|
59
|
+
* in whose entry file exports the symbol, itself or through `export … from` statements.
|
|
60
|
+
*
|
|
61
|
+
* The entry points are the package name and the subpaths its manifest lists. The entry file of one is the file an
|
|
62
|
+
* import of it resolves to, such as `packages/core/src/hash/index.ts` for `@g3nomaly/core/hash`.
|
|
63
|
+
*
|
|
64
|
+
* @param sources - The source files and packages of the scan.
|
|
65
|
+
* @param path - Display path of the file that declares the symbol.
|
|
66
|
+
* @param name - Name the file declares the symbol under.
|
|
67
|
+
* @returns The specifier and the name the entry exports, or `null` when the file is in no package of the scan or
|
|
68
|
+
* no entry file exports the symbol.
|
|
69
|
+
*/
|
|
70
|
+
export declare function packageImportOf(sources: SourceFileIndex, path: string, name: string): PackageImport | null;
|