gitnexus 1.6.6-rc.127 → 1.6.6-rc.129
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/_shared/graph/types.d.ts +17 -1
- package/dist/_shared/graph/types.d.ts.map +1 -1
- package/dist/core/ingestion/language-provider.d.ts +14 -1
- package/dist/core/ingestion/languages/vue/captures.d.ts +45 -0
- package/dist/core/ingestion/languages/vue/captures.js +58 -0
- package/dist/core/ingestion/languages/vue/import-target.d.ts +27 -0
- package/dist/core/ingestion/languages/vue/import-target.js +58 -0
- package/dist/core/ingestion/languages/vue/index.d.ts +49 -0
- package/dist/core/ingestion/languages/vue/index.js +49 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.d.ts +55 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.js +292 -0
- package/dist/core/ingestion/languages/vue.js +12 -0
- package/dist/core/ingestion/registry-primary-flag.js +1 -0
- package/dist/core/ingestion/scope-extractor-bridge.d.ts +2 -1
- package/dist/core/ingestion/scope-extractor-bridge.js +2 -2
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +58 -0
- package/dist/core/ingestion/scope-resolution/pipeline/phase.js +45 -10
- package/dist/core/ingestion/scope-resolution/pipeline/registry.js +2 -0
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +9 -0
- package/dist/core/ingestion/vue-sfc-extractor.d.ts +89 -0
- package/dist/core/ingestion/vue-sfc-extractor.js +416 -0
- package/dist/core/ingestion/workers/parse-worker.js +3 -1
- package/package.json +1 -1
- package/scripts/run-parity.ts +24 -13
|
@@ -47,7 +47,23 @@ export type NodeProperties = {
|
|
|
47
47
|
middleware?: string[];
|
|
48
48
|
[key: string]: unknown;
|
|
49
49
|
};
|
|
50
|
-
export type RelationshipType = 'CONTAINS' | 'CALLS' | 'INHERITS' | 'METHOD_OVERRIDES' | 'METHOD_IMPLEMENTS' | 'IMPORTS' | 'USES' | 'DEFINES' | 'DECORATES' | 'IMPLEMENTS' | 'EXTENDS' | 'HAS_METHOD' | 'HAS_PROPERTY' | 'ACCESSES' | 'MEMBER_OF' | 'STEP_IN_PROCESS' | 'HANDLES_ROUTE' | 'FETCHES' | 'HANDLES_TOOL' | 'ENTRY_POINT_OF' | 'WRAPS' | 'QUERIES'
|
|
50
|
+
export type RelationshipType = 'CONTAINS' | 'CALLS' | 'INHERITS' | 'METHOD_OVERRIDES' | 'METHOD_IMPLEMENTS' | 'IMPORTS' | 'USES' | 'DEFINES' | 'DECORATES' | 'IMPLEMENTS' | 'EXTENDS' | 'HAS_METHOD' | 'HAS_PROPERTY' | 'ACCESSES' | 'MEMBER_OF' | 'STEP_IN_PROCESS' | 'HANDLES_ROUTE' | 'FETCHES' | 'HANDLES_TOOL' | 'ENTRY_POINT_OF' | 'WRAPS' | 'QUERIES'
|
|
51
|
+
/** Vue component event system: a handler function in a parent component is
|
|
52
|
+
* bound to an event emitted by a child component (`@event="handlerFn"`).
|
|
53
|
+
* Source = handler Function/Method node in the parent.
|
|
54
|
+
* Target = the child component's File node.
|
|
55
|
+
* `reason` encodes the event name: `vue-event: @<eventName>`.
|
|
56
|
+
* Complements `EMITS_EVENT`; together they enable Cypher queries that
|
|
57
|
+
* trace which handlers receive which component's emitted events. */
|
|
58
|
+
| 'BINDS_EVENT_HANDLER'
|
|
59
|
+
/** Vue component event system: a component calls `emit('eventName', ...)`
|
|
60
|
+
* or `this.$emit('eventName', ...)`, advertising that it can emit that event.
|
|
61
|
+
* Source = the component's own File node (self-referential annotation).
|
|
62
|
+
* Target = the same File node.
|
|
63
|
+
* `reason` encodes the event name: `vue-emit: <eventName>`.
|
|
64
|
+
* Complements `BINDS_EVENT_HANDLER`; a Cypher query joining on the
|
|
65
|
+
* component File node reveals all (emitter, handler) pairs. */
|
|
66
|
+
| 'EMITS_EVENT';
|
|
51
67
|
export interface GraphNode {
|
|
52
68
|
id: string;
|
|
53
69
|
label: NodeLabel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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,CAAC;IACX,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,SAAS;QAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACxB,EAAE,CAAC;CACL"}
|
|
@@ -338,7 +338,20 @@ interface LanguageProviderConfig {
|
|
|
338
338
|
* Cache miss (parameter omitted or undefined) is always safe and
|
|
339
339
|
* MUST trigger a fresh parse.
|
|
340
340
|
*/
|
|
341
|
-
cachedTree?: unknown
|
|
341
|
+
cachedTree?: unknown,
|
|
342
|
+
/**
|
|
343
|
+
* Optional metadata about how `sourceText` was produced.
|
|
344
|
+
*
|
|
345
|
+
* Most providers ignore this and treat `sourceText` as full file content.
|
|
346
|
+
* Vue uses it to distinguish:
|
|
347
|
+
* - `full-file`: full `.vue` SFC source
|
|
348
|
+
* - `pre-extracted-script`: worker-preprocessed bare `<script>` content
|
|
349
|
+
*
|
|
350
|
+
* Default: `{ sourceKind: 'full-file' }`.
|
|
351
|
+
*/
|
|
352
|
+
sourceMeta?: {
|
|
353
|
+
readonly sourceKind?: 'full-file' | 'pre-extracted-script';
|
|
354
|
+
}) => readonly CaptureMatch[];
|
|
342
355
|
/**
|
|
343
356
|
* Interpret a raw `@import.statement` capture group into a `ParsedImport`.
|
|
344
357
|
* The central finalize algorithm resolves `ParsedImport.targetRaw` to a
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue SFC scope captures (RFC #909 Ring 3, issue #940).
|
|
3
|
+
*
|
|
4
|
+
* Extracts the `<script>` / `<script setup>` block from the SFC source
|
|
5
|
+
* and delegates to `emitTsScopeCaptures`. The parse-worker builds the
|
|
6
|
+
* cached tree from the extracted script content using the TypeScript
|
|
7
|
+
* grammar (see `[SupportedLanguages.Vue]: TypeScript.typescript` in
|
|
8
|
+
* `parse-worker.ts`), so passing that tree here keeps grammar identity
|
|
9
|
+
* consistent and avoids a redundant re-parse.
|
|
10
|
+
*
|
|
11
|
+
* Template expressions are intentionally out-of-scope: component-
|
|
12
|
+
* reference CALLS edges are already emitted by the legacy template
|
|
13
|
+
* extractor in the parse worker and would be double-counted here.
|
|
14
|
+
*
|
|
15
|
+
* Position note: all capture positions are relative to the *extracted*
|
|
16
|
+
* script block, not the full .vue file. This is consistent with the
|
|
17
|
+
* cached tree and with how the scope model uses positions (only for
|
|
18
|
+
* scope-containment walks within a single file), so no offset
|
|
19
|
+
* translation is required for graph-edge correctness.
|
|
20
|
+
*/
|
|
21
|
+
import type { CaptureMatch } from '../../../../_shared/index.js';
|
|
22
|
+
/**
|
|
23
|
+
* Emit scope captures for a Vue SFC.
|
|
24
|
+
*
|
|
25
|
+
* Handles three call-site shapes:
|
|
26
|
+
*
|
|
27
|
+
* 1. **Full SFC content** (sequential path, <15 files): `sourceText`
|
|
28
|
+
* contains the whole `.vue` file with `<template>`, `<script>`, etc.
|
|
29
|
+
* `extractVueScript` extracts the script block and we delegate to
|
|
30
|
+
* `emitTsScopeCaptures` with that extracted content.
|
|
31
|
+
*
|
|
32
|
+
* 2. **Already-extracted script content** (worker-mode path, ≥15 files):
|
|
33
|
+
* the parse worker calls `extractVueScript` itself before calling
|
|
34
|
+
* `extractParsedFile`, so `sourceText` is already the bare TypeScript
|
|
35
|
+
* text with no `<script>` tags. The caller marks this explicitly via
|
|
36
|
+
* `sourceMeta.sourceKind === 'pre-extracted-script'`.
|
|
37
|
+
*
|
|
38
|
+
* 3. **Supporting TS/JS files** included in Vue scope-resolution runs:
|
|
39
|
+
* when `filePath` is not `.vue`, delegate straight to TypeScript captures.
|
|
40
|
+
*
|
|
41
|
+
* Returns an empty array for render-function-only SFCs (no `<script>` block).
|
|
42
|
+
*/
|
|
43
|
+
export declare function emitVueScopeCaptures(sourceText: string, filePath: string, cachedTree?: unknown, sourceMeta?: {
|
|
44
|
+
sourceKind?: 'full-file' | 'pre-extracted-script';
|
|
45
|
+
}): readonly CaptureMatch[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue SFC scope captures (RFC #909 Ring 3, issue #940).
|
|
3
|
+
*
|
|
4
|
+
* Extracts the `<script>` / `<script setup>` block from the SFC source
|
|
5
|
+
* and delegates to `emitTsScopeCaptures`. The parse-worker builds the
|
|
6
|
+
* cached tree from the extracted script content using the TypeScript
|
|
7
|
+
* grammar (see `[SupportedLanguages.Vue]: TypeScript.typescript` in
|
|
8
|
+
* `parse-worker.ts`), so passing that tree here keeps grammar identity
|
|
9
|
+
* consistent and avoids a redundant re-parse.
|
|
10
|
+
*
|
|
11
|
+
* Template expressions are intentionally out-of-scope: component-
|
|
12
|
+
* reference CALLS edges are already emitted by the legacy template
|
|
13
|
+
* extractor in the parse worker and would be double-counted here.
|
|
14
|
+
*
|
|
15
|
+
* Position note: all capture positions are relative to the *extracted*
|
|
16
|
+
* script block, not the full .vue file. This is consistent with the
|
|
17
|
+
* cached tree and with how the scope model uses positions (only for
|
|
18
|
+
* scope-containment walks within a single file), so no offset
|
|
19
|
+
* translation is required for graph-edge correctness.
|
|
20
|
+
*/
|
|
21
|
+
import { extractVueScript } from '../../vue-sfc-extractor.js';
|
|
22
|
+
import { emitTsScopeCaptures } from '../typescript/captures.js';
|
|
23
|
+
/**
|
|
24
|
+
* Emit scope captures for a Vue SFC.
|
|
25
|
+
*
|
|
26
|
+
* Handles three call-site shapes:
|
|
27
|
+
*
|
|
28
|
+
* 1. **Full SFC content** (sequential path, <15 files): `sourceText`
|
|
29
|
+
* contains the whole `.vue` file with `<template>`, `<script>`, etc.
|
|
30
|
+
* `extractVueScript` extracts the script block and we delegate to
|
|
31
|
+
* `emitTsScopeCaptures` with that extracted content.
|
|
32
|
+
*
|
|
33
|
+
* 2. **Already-extracted script content** (worker-mode path, ≥15 files):
|
|
34
|
+
* the parse worker calls `extractVueScript` itself before calling
|
|
35
|
+
* `extractParsedFile`, so `sourceText` is already the bare TypeScript
|
|
36
|
+
* text with no `<script>` tags. The caller marks this explicitly via
|
|
37
|
+
* `sourceMeta.sourceKind === 'pre-extracted-script'`.
|
|
38
|
+
*
|
|
39
|
+
* 3. **Supporting TS/JS files** included in Vue scope-resolution runs:
|
|
40
|
+
* when `filePath` is not `.vue`, delegate straight to TypeScript captures.
|
|
41
|
+
*
|
|
42
|
+
* Returns an empty array for render-function-only SFCs (no `<script>` block).
|
|
43
|
+
*/
|
|
44
|
+
export function emitVueScopeCaptures(sourceText, filePath, cachedTree, sourceMeta) {
|
|
45
|
+
// Vue resolver may include supporting TS/JS files in the same run to
|
|
46
|
+
// preserve cross-file import/type context for `.vue` callers. These are
|
|
47
|
+
// already plain script files, so no SFC extraction is needed.
|
|
48
|
+
if (!filePath.endsWith('.vue')) {
|
|
49
|
+
return emitTsScopeCaptures(sourceText, filePath, cachedTree);
|
|
50
|
+
}
|
|
51
|
+
if (sourceMeta?.sourceKind === 'pre-extracted-script') {
|
|
52
|
+
return emitTsScopeCaptures(sourceText, filePath, cachedTree);
|
|
53
|
+
}
|
|
54
|
+
const extracted = extractVueScript(sourceText);
|
|
55
|
+
if (extracted === null)
|
|
56
|
+
return [];
|
|
57
|
+
return emitTsScopeCaptures(extracted.scriptContent, filePath, cachedTree);
|
|
58
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import-target resolver for Vue SFCs (RFC #909 Ring 3, issue #940).
|
|
3
|
+
*
|
|
4
|
+
* Vue `<script>` / `<script setup>` blocks are TypeScript (or plain
|
|
5
|
+
* JavaScript), so the resolver delegates to `resolveTsTarget` with
|
|
6
|
+
* `language: SupportedLanguages.TypeScript` to get:
|
|
7
|
+
*
|
|
8
|
+
* - tsconfig path-alias rewriting (Vue projects universally use TS)
|
|
9
|
+
* - `.ts` / `.tsx` / `.js` / `.jsx` extension-suffix fallback
|
|
10
|
+
*
|
|
11
|
+
* `.vue` imports are written with explicit extensions (`'./Button.vue'`),
|
|
12
|
+
* so no Vue-specific suffix guessing is required: the standard
|
|
13
|
+
* resolver finds them via the exact-path branch before any extension
|
|
14
|
+
* logic fires.
|
|
15
|
+
*
|
|
16
|
+
* Memoization mirrors the TypeScript adapter: workspace file-list
|
|
17
|
+
* arrays, the suffix index, and the per-pass resolve cache are rebuilt
|
|
18
|
+
* lazily when `allFilePaths` reference changes (once per workspace pass).
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Build a memoized `resolveImportTarget` adapter for Vue SFCs.
|
|
22
|
+
*
|
|
23
|
+
* Uses `SupportedLanguages.TypeScript` so tsconfig path-alias resolution
|
|
24
|
+
* and `.ts`/`.tsx` extension guessing fire for relative and bare-specifier
|
|
25
|
+
* imports inside `<script>` blocks.
|
|
26
|
+
*/
|
|
27
|
+
export declare function makeVueResolveImportTarget(): (targetRaw: string, fromFile: string, allFilePaths: ReadonlySet<string>, resolutionConfig?: unknown) => string | readonly string[] | null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import-target resolver for Vue SFCs (RFC #909 Ring 3, issue #940).
|
|
3
|
+
*
|
|
4
|
+
* Vue `<script>` / `<script setup>` blocks are TypeScript (or plain
|
|
5
|
+
* JavaScript), so the resolver delegates to `resolveTsTarget` with
|
|
6
|
+
* `language: SupportedLanguages.TypeScript` to get:
|
|
7
|
+
*
|
|
8
|
+
* - tsconfig path-alias rewriting (Vue projects universally use TS)
|
|
9
|
+
* - `.ts` / `.tsx` / `.js` / `.jsx` extension-suffix fallback
|
|
10
|
+
*
|
|
11
|
+
* `.vue` imports are written with explicit extensions (`'./Button.vue'`),
|
|
12
|
+
* so no Vue-specific suffix guessing is required: the standard
|
|
13
|
+
* resolver finds them via the exact-path branch before any extension
|
|
14
|
+
* logic fires.
|
|
15
|
+
*
|
|
16
|
+
* Memoization mirrors the TypeScript adapter: workspace file-list
|
|
17
|
+
* arrays, the suffix index, and the per-pass resolve cache are rebuilt
|
|
18
|
+
* lazily when `allFilePaths` reference changes (once per workspace pass).
|
|
19
|
+
*/
|
|
20
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
21
|
+
import { resolveTsTarget } from '../typescript/import-target.js';
|
|
22
|
+
import { buildSuffixIndex } from '../../import-resolvers/utils.js';
|
|
23
|
+
/**
|
|
24
|
+
* Build a memoized `resolveImportTarget` adapter for Vue SFCs.
|
|
25
|
+
*
|
|
26
|
+
* Uses `SupportedLanguages.TypeScript` so tsconfig path-alias resolution
|
|
27
|
+
* and `.ts`/`.tsx` extension guessing fire for relative and bare-specifier
|
|
28
|
+
* imports inside `<script>` blocks.
|
|
29
|
+
*/
|
|
30
|
+
export function makeVueResolveImportTarget() {
|
|
31
|
+
let cached = null;
|
|
32
|
+
return (targetRaw, fromFile, allFilePaths, resolutionConfig) => {
|
|
33
|
+
if (cached === null || cached.key !== allFilePaths) {
|
|
34
|
+
const allFileList = Array.from(allFilePaths);
|
|
35
|
+
const normalizedFileList = allFileList.map((f) => f.toLowerCase());
|
|
36
|
+
cached = {
|
|
37
|
+
key: allFilePaths,
|
|
38
|
+
allFilePaths: new Set(allFilePaths),
|
|
39
|
+
allFileList,
|
|
40
|
+
normalizedFileList,
|
|
41
|
+
index: buildSuffixIndex(normalizedFileList, allFileList),
|
|
42
|
+
resolveCache: new Map(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const cfg = resolutionConfig;
|
|
46
|
+
const ws = {
|
|
47
|
+
fromFile,
|
|
48
|
+
language: SupportedLanguages.TypeScript,
|
|
49
|
+
allFilePaths: cached.allFilePaths,
|
|
50
|
+
allFileList: cached.allFileList,
|
|
51
|
+
normalizedFileList: cached.normalizedFileList,
|
|
52
|
+
index: cached.index,
|
|
53
|
+
resolveCache: cached.resolveCache,
|
|
54
|
+
tsconfigPaths: cfg?.tsconfigPaths ?? null,
|
|
55
|
+
};
|
|
56
|
+
return resolveTsTarget(targetRaw, ws);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue SFC scope-resolution hooks (RFC #909 Ring 3, issue #940).
|
|
3
|
+
*
|
|
4
|
+
* Public API barrel. Consumers should import from this file rather
|
|
5
|
+
* than the individual modules.
|
|
6
|
+
*
|
|
7
|
+
* Module layout (each file is a single concern):
|
|
8
|
+
*
|
|
9
|
+
* - `captures.ts` — `emitVueScopeCaptures` — extracts the
|
|
10
|
+
* `<script>` / `<script setup>` block and
|
|
11
|
+
* delegates to `emitTsScopeCaptures` (TypeScript
|
|
12
|
+
* grammar, same grammar the parse-worker uses).
|
|
13
|
+
* - `import-target.ts` — `makeVueResolveImportTarget` — memoized
|
|
14
|
+
* adapter using the TypeScript resolver with
|
|
15
|
+
* tsconfig path-alias support.
|
|
16
|
+
* - `scope-resolver.ts` — `vueScopeResolver` wiring object.
|
|
17
|
+
*
|
|
18
|
+
* ## Known limitations
|
|
19
|
+
*
|
|
20
|
+
* 1. **Template expressions** — Full template AST parsing is not performed.
|
|
21
|
+
* `vueScopeResolver.emitPostResolutionEdges` extracts five categories of
|
|
22
|
+
* template-derived edges via lightweight regex, all emitted after standard
|
|
23
|
+
* scope-resolution passes complete:
|
|
24
|
+
* - PascalCase/kebab-case component references → `vue-template-component` `CALLS`
|
|
25
|
+
* - `@event="handler"` on **native** elements → `vue-template-callback` `CALLS`
|
|
26
|
+
* - `@event="handler"` on **component** elements → `vue-event: @<name>` `BINDS_EVENT_HANDLER`
|
|
27
|
+
* - `emit(...)` / `this.$emit(...)` in script → `vue-emit: <name>` `EMITS_EVENT`
|
|
28
|
+
* - `:prop="varName"` single-identifier bindings → `vue-template-attribute` `ACCESSES`
|
|
29
|
+
* `BINDS_EVENT_HANDLER` and `EMITS_EVENT` are complementary "hanging" edges:
|
|
30
|
+
* a Cypher query joining on the shared component File node reveals which
|
|
31
|
+
* handlers receive which component's emitted events.
|
|
32
|
+
* Complex inline expressions (`@click="toggle(item)"`, `{{ a + b }}`,
|
|
33
|
+
* member-access bindings `:key="post.id"`) are intentionally excluded
|
|
34
|
+
* because they cannot be resolved to a single call/access target without
|
|
35
|
+
* a full template AST. Tracked in #1647.
|
|
36
|
+
* 2. **Options API `this` resolution** — `this.X()` in Options API
|
|
37
|
+
* components does not resolve through type-binding when the component
|
|
38
|
+
* uses a plain object literal rather than a class. `fieldFallbackOnMethodLookup`
|
|
39
|
+
* recovers common cases via field-name matching.
|
|
40
|
+
* 3. **`<script setup>` + `<script>` dual-block** — When both blocks are
|
|
41
|
+
* present, only `<script setup>` is processed (per `extractVueScript`
|
|
42
|
+
* priority). The non-setup block is skipped.
|
|
43
|
+
* 4. **JSX in `<template>`** — Vue's template compiler is not a
|
|
44
|
+
* tree-sitter grammar; JSX-style bindings inside templates are not
|
|
45
|
+
* processed by the scope-resolution pipeline.
|
|
46
|
+
*/
|
|
47
|
+
export { emitVueScopeCaptures } from './captures.js';
|
|
48
|
+
export { makeVueResolveImportTarget } from './import-target.js';
|
|
49
|
+
export { vueScopeResolver } from './scope-resolver.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue SFC scope-resolution hooks (RFC #909 Ring 3, issue #940).
|
|
3
|
+
*
|
|
4
|
+
* Public API barrel. Consumers should import from this file rather
|
|
5
|
+
* than the individual modules.
|
|
6
|
+
*
|
|
7
|
+
* Module layout (each file is a single concern):
|
|
8
|
+
*
|
|
9
|
+
* - `captures.ts` — `emitVueScopeCaptures` — extracts the
|
|
10
|
+
* `<script>` / `<script setup>` block and
|
|
11
|
+
* delegates to `emitTsScopeCaptures` (TypeScript
|
|
12
|
+
* grammar, same grammar the parse-worker uses).
|
|
13
|
+
* - `import-target.ts` — `makeVueResolveImportTarget` — memoized
|
|
14
|
+
* adapter using the TypeScript resolver with
|
|
15
|
+
* tsconfig path-alias support.
|
|
16
|
+
* - `scope-resolver.ts` — `vueScopeResolver` wiring object.
|
|
17
|
+
*
|
|
18
|
+
* ## Known limitations
|
|
19
|
+
*
|
|
20
|
+
* 1. **Template expressions** — Full template AST parsing is not performed.
|
|
21
|
+
* `vueScopeResolver.emitPostResolutionEdges` extracts five categories of
|
|
22
|
+
* template-derived edges via lightweight regex, all emitted after standard
|
|
23
|
+
* scope-resolution passes complete:
|
|
24
|
+
* - PascalCase/kebab-case component references → `vue-template-component` `CALLS`
|
|
25
|
+
* - `@event="handler"` on **native** elements → `vue-template-callback` `CALLS`
|
|
26
|
+
* - `@event="handler"` on **component** elements → `vue-event: @<name>` `BINDS_EVENT_HANDLER`
|
|
27
|
+
* - `emit(...)` / `this.$emit(...)` in script → `vue-emit: <name>` `EMITS_EVENT`
|
|
28
|
+
* - `:prop="varName"` single-identifier bindings → `vue-template-attribute` `ACCESSES`
|
|
29
|
+
* `BINDS_EVENT_HANDLER` and `EMITS_EVENT` are complementary "hanging" edges:
|
|
30
|
+
* a Cypher query joining on the shared component File node reveals which
|
|
31
|
+
* handlers receive which component's emitted events.
|
|
32
|
+
* Complex inline expressions (`@click="toggle(item)"`, `{{ a + b }}`,
|
|
33
|
+
* member-access bindings `:key="post.id"`) are intentionally excluded
|
|
34
|
+
* because they cannot be resolved to a single call/access target without
|
|
35
|
+
* a full template AST. Tracked in #1647.
|
|
36
|
+
* 2. **Options API `this` resolution** — `this.X()` in Options API
|
|
37
|
+
* components does not resolve through type-binding when the component
|
|
38
|
+
* uses a plain object literal rather than a class. `fieldFallbackOnMethodLookup`
|
|
39
|
+
* recovers common cases via field-name matching.
|
|
40
|
+
* 3. **`<script setup>` + `<script>` dual-block** — When both blocks are
|
|
41
|
+
* present, only `<script setup>` is processed (per `extractVueScript`
|
|
42
|
+
* priority). The non-setup block is skipped.
|
|
43
|
+
* 4. **JSX in `<template>`** — Vue's template compiler is not a
|
|
44
|
+
* tree-sitter grammar; JSX-style bindings inside templates are not
|
|
45
|
+
* processed by the scope-resolution pipeline.
|
|
46
|
+
*/
|
|
47
|
+
export { emitVueScopeCaptures } from './captures.js';
|
|
48
|
+
export { makeVueResolveImportTarget } from './import-target.js';
|
|
49
|
+
export { vueScopeResolver } from './scope-resolver.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue `ScopeResolver` registered in `SCOPE_RESOLVERS` and consumed by
|
|
3
|
+
* the generic `runScopeResolution` orchestrator (RFC #909 Ring 3, issue #940).
|
|
4
|
+
*
|
|
5
|
+
* ## Design rationale
|
|
6
|
+
*
|
|
7
|
+
* Vue SFCs compile down to TypeScript/JavaScript — the `<script>` /
|
|
8
|
+
* `<script setup>` block is pure TS/JS, parsed with the TypeScript
|
|
9
|
+
* grammar and captured by `emitVueScopeCaptures` (which delegates
|
|
10
|
+
* to `emitTsScopeCaptures`). Because of this, nearly all hooks are
|
|
11
|
+
* identical to the TypeScript resolver:
|
|
12
|
+
*
|
|
13
|
+
* - `mergeBindings` — TypeScript LEGB semantics apply in script blocks.
|
|
14
|
+
* - `arityCompatibility` — same positional + rest rules.
|
|
15
|
+
* - `buildMro` / `populateOwners` — shared with TypeScript.
|
|
16
|
+
* - `isSuperReceiver` — `super(...)` / `super.foo` / `super[x]` pattern.
|
|
17
|
+
* - `resolveImportTarget` — TypeScript resolver with `.vue` explicit-
|
|
18
|
+
* extension support; tsconfig paths loaded via
|
|
19
|
+
* `loadResolutionConfig`.
|
|
20
|
+
*
|
|
21
|
+
* ## Key differences from TypeScript
|
|
22
|
+
*
|
|
23
|
+
* - `language: SupportedLanguages.Vue` — routes the resolver to Vue
|
|
24
|
+
* files only; TypeScript files use the TypeScript resolver.
|
|
25
|
+
* - `languageProvider: vueProvider` — the Vue-specific language
|
|
26
|
+
* provider supplies the right built-ins and export checker for
|
|
27
|
+
* `<script setup>` (all top-level bindings implicitly exported).
|
|
28
|
+
* - `importEdgeReason: 'vue-scope: import'` — distinct tag for
|
|
29
|
+
* debugging / edge provenance.
|
|
30
|
+
* - `allowGlobalFreeCallFallback: false` — Vue uses explicit imports;
|
|
31
|
+
* workspace-wide unique-name fallback is unnecessary and would
|
|
32
|
+
* produce spurious edges for Vue built-ins (ref, reactive, …).
|
|
33
|
+
*
|
|
34
|
+
* ## Options API / this-binding
|
|
35
|
+
*
|
|
36
|
+
* Options API (`defineComponent({ methods: { … } })`) stores methods
|
|
37
|
+
* on the component instance, which tree-sitter sees as object property
|
|
38
|
+
* values. `this.X()` inside a method resolves via the existing
|
|
39
|
+
* `tsReceiverBinding` hook (inherited from TypeScript), which walks to
|
|
40
|
+
* the enclosing Class scope. For Options API the enclosing "class" is
|
|
41
|
+
* the `defineComponent({…})` object — not a true class — so `this`
|
|
42
|
+
* calls may not resolve through the type-binding layer. `fieldFallbackOnMethodLookup`
|
|
43
|
+
* is therefore set to `true` so the field-name fallback catches common
|
|
44
|
+
* patterns even without an explicit type annotation.
|
|
45
|
+
*
|
|
46
|
+
* ## `<script setup>` macro calls
|
|
47
|
+
*
|
|
48
|
+
* `defineProps`, `defineEmits`, `defineExpose`, `withDefaults`, etc.
|
|
49
|
+
* are compiler macros available as globals inside `<script setup>`.
|
|
50
|
+
* They are listed in `vueProvider.builtInNames` and therefore treated
|
|
51
|
+
* as resolved without requiring an import edge.
|
|
52
|
+
*/
|
|
53
|
+
import type { ScopeResolver } from '../../scope-resolution/contract/scope-resolver.js';
|
|
54
|
+
declare const vueScopeResolver: ScopeResolver;
|
|
55
|
+
export { vueScopeResolver };
|