@lzehrung/codegraph 2.3.29 → 2.3.31
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/bin/cli.js +6602 -4453
- package/dist/bin/query-index-worker.js +1302 -753
- package/dist/document-links/asciidoc.d.ts.map +1 -1
- package/dist/document-links/asciidoc.js +3 -4
- package/dist/document-links/asciidoc.js.map +1 -1
- package/dist/document-links/html-forms.d.ts +39 -0
- package/dist/document-links/html-forms.d.ts.map +1 -0
- package/dist/document-links/html-forms.js +94 -0
- package/dist/document-links/html-forms.js.map +1 -0
- package/dist/document-links/html.d.ts +8 -0
- package/dist/document-links/html.d.ts.map +1 -1
- package/dist/document-links/html.js +30 -15
- package/dist/document-links/html.js.map +1 -1
- package/dist/document-links/markdown.d.ts.map +1 -1
- package/dist/document-links/markdown.js +6 -7
- package/dist/document-links/markdown.js.map +1 -1
- package/dist/document-links/rst.d.ts.map +1 -1
- package/dist/document-links/rst.js +6 -0
- package/dist/document-links/rst.js.map +1 -1
- package/dist/document-links/sfc.d.ts.map +1 -1
- package/dist/document-links/sfc.js +4 -4
- package/dist/document-links/sfc.js.map +1 -1
- package/dist/graphs/angularjs.d.ts.map +1 -1
- package/dist/graphs/angularjs.js +9 -1
- package/dist/graphs/angularjs.js.map +1 -1
- package/dist/graphs/edge-resolution.d.ts.map +1 -1
- package/dist/graphs/edge-resolution.js +8 -3
- package/dist/graphs/edge-resolution.js.map +1 -1
- package/dist/graphs/specifiers.d.ts.map +1 -1
- package/dist/graphs/specifiers.js +62 -104
- package/dist/graphs/specifiers.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/edge-passes.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/edge-passes.js +118 -86
- package/dist/graphs/symbol-graph-detailed/edge-passes.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts +27 -0
- package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/receiver-calls.js +509 -42
- package/dist/graphs/symbol-graph-detailed/receiver-calls.js.map +1 -1
- package/dist/impact/call-compatibility/providers/index.d.ts +15 -1
- package/dist/impact/call-compatibility/providers/index.d.ts.map +1 -1
- package/dist/impact/call-compatibility/providers/index.js +21 -20
- package/dist/impact/call-compatibility/providers/index.js.map +1 -1
- package/dist/impact/call-compatibility/providers/profiles.d.ts +80 -0
- package/dist/impact/call-compatibility/providers/profiles.d.ts.map +1 -0
- package/dist/impact/call-compatibility/providers/profiles.js +164 -0
- package/dist/impact/call-compatibility/providers/profiles.js.map +1 -0
- package/dist/impact/call-compatibility.d.ts.map +1 -1
- package/dist/impact/call-compatibility.js +73 -108
- package/dist/impact/call-compatibility.js.map +1 -1
- package/dist/impact/member-resolution-coverage.d.ts.map +1 -1
- package/dist/impact/member-resolution-coverage.js +2 -2
- package/dist/impact/member-resolution-coverage.js.map +1 -1
- package/dist/indexer/build-cache/manifest.d.ts +7 -0
- package/dist/indexer/build-cache/manifest.d.ts.map +1 -1
- package/dist/indexer/build-cache/manifest.js +32 -1
- package/dist/indexer/build-cache/manifest.js.map +1 -1
- package/dist/indexer/build-cache/options.d.ts +16 -2
- package/dist/indexer/build-cache/options.d.ts.map +1 -1
- package/dist/indexer/build-cache/options.js +17 -3
- package/dist/indexer/build-cache/options.js.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.d.ts.map +1 -1
- package/dist/indexer/build-cache/project-snapshot.js +1 -0
- package/dist/indexer/build-cache/project-snapshot.js.map +1 -1
- package/dist/indexer/build-index.d.ts.map +1 -1
- package/dist/indexer/build-index.js +80 -2
- package/dist/indexer/build-index.js.map +1 -1
- package/dist/indexer/build-manifest.d.ts +1 -0
- package/dist/indexer/build-manifest.d.ts.map +1 -1
- package/dist/indexer/build-manifest.js +18 -0
- package/dist/indexer/build-manifest.js.map +1 -1
- package/dist/indexer/build-workers.js +1 -1
- package/dist/indexer/build-workers.js.map +1 -1
- package/dist/indexer/declaration-visibility.d.ts +43 -0
- package/dist/indexer/declaration-visibility.d.ts.map +1 -0
- package/dist/indexer/declaration-visibility.js +202 -0
- package/dist/indexer/declaration-visibility.js.map +1 -0
- package/dist/indexer/imports/binding-ranges.d.ts +2 -2
- package/dist/indexer/imports/binding-ranges.d.ts.map +1 -1
- package/dist/indexer/imports/binding-ranges.js +2 -123
- package/dist/indexer/imports/binding-ranges.js.map +1 -1
- package/dist/indexer/imports/import-binding-tables.d.ts +64 -0
- package/dist/indexer/imports/import-binding-tables.d.ts.map +1 -0
- package/dist/indexer/imports/import-binding-tables.js +419 -0
- package/dist/indexer/imports/import-binding-tables.js.map +1 -0
- package/dist/indexer/imports/js-text-imports.d.ts.map +1 -1
- package/dist/indexer/imports/js-text-imports.js +5 -2
- package/dist/indexer/imports/js-text-imports.js.map +1 -1
- package/dist/indexer/imports/language-specific.d.ts +3 -22
- package/dist/indexer/imports/language-specific.d.ts.map +1 -1
- package/dist/indexer/imports/language-specific.js +54 -573
- package/dist/indexer/imports/language-specific.js.map +1 -1
- package/dist/indexer/imports/native-captures.d.ts.map +1 -1
- package/dist/indexer/imports/native-captures.js +23 -32
- package/dist/indexer/imports/native-captures.js.map +1 -1
- package/dist/indexer/imports/text-import-extractors.d.ts +37 -0
- package/dist/indexer/imports/text-import-extractors.d.ts.map +1 -0
- package/dist/indexer/imports/text-import-extractors.js +358 -0
- package/dist/indexer/imports/text-import-extractors.js.map +1 -0
- package/dist/indexer/imports.d.ts.map +1 -1
- package/dist/indexer/imports.js +2 -1
- package/dist/indexer/imports.js.map +1 -1
- package/dist/indexer/locals-and-exports.d.ts.map +1 -1
- package/dist/indexer/locals-and-exports.js +23 -27
- package/dist/indexer/locals-and-exports.js.map +1 -1
- package/dist/indexer/navigation-goto.d.ts +1 -7
- package/dist/indexer/navigation-goto.d.ts.map +1 -1
- package/dist/indexer/navigation-goto.js +181 -381
- package/dist/indexer/navigation-goto.js.map +1 -1
- package/dist/indexer/navigation-resolve.d.ts.map +1 -1
- package/dist/indexer/navigation-resolve.js +20 -1
- package/dist/indexer/navigation-resolve.js.map +1 -1
- package/dist/indexer/navigation.d.ts.map +1 -1
- package/dist/indexer/navigation.js +39 -7
- package/dist/indexer/navigation.js.map +1 -1
- package/dist/indexer/parse-context.js +2 -2
- package/dist/indexer/parse-context.js.map +1 -1
- package/dist/indexer/scope-nodes.d.ts +108 -0
- package/dist/indexer/scope-nodes.d.ts.map +1 -0
- package/dist/indexer/scope-nodes.js +238 -0
- package/dist/indexer/scope-nodes.js.map +1 -0
- package/dist/indexer/scope.d.ts.map +1 -1
- package/dist/indexer/scope.js +70 -130
- package/dist/indexer/scope.js.map +1 -1
- package/dist/indexer/types.d.ts +7 -0
- package/dist/indexer/types.d.ts.map +1 -1
- package/dist/languages/definitions/c-family.d.ts +18 -4
- package/dist/languages/definitions/c-family.d.ts.map +1 -1
- package/dist/languages/definitions/c-family.js +51 -13
- package/dist/languages/definitions/c-family.js.map +1 -1
- package/dist/languages/definitions/c.d.ts.map +1 -1
- package/dist/languages/definitions/c.js +7 -43
- package/dist/languages/definitions/c.js.map +1 -1
- package/dist/languages/definitions/cpp.d.ts.map +1 -1
- package/dist/languages/definitions/cpp.js +15 -61
- package/dist/languages/definitions/cpp.js.map +1 -1
- package/dist/languages/definitions/csharp.d.ts.map +1 -1
- package/dist/languages/definitions/csharp.js +46 -52
- package/dist/languages/definitions/csharp.js.map +1 -1
- package/dist/languages/definitions/css-like.d.ts.map +1 -1
- package/dist/languages/definitions/css-like.js +13 -10
- package/dist/languages/definitions/css-like.js.map +1 -1
- package/dist/languages/definitions/go.d.ts.map +1 -1
- package/dist/languages/definitions/go.js +29 -42
- package/dist/languages/definitions/go.js.map +1 -1
- package/dist/languages/definitions/html.d.ts.map +1 -1
- package/dist/languages/definitions/html.js +15 -14
- package/dist/languages/definitions/html.js.map +1 -1
- package/dist/languages/definitions/java.d.ts.map +1 -1
- package/dist/languages/definitions/java.js +42 -48
- package/dist/languages/definitions/java.js.map +1 -1
- package/dist/languages/definitions/javascript.d.ts.map +1 -1
- package/dist/languages/definitions/javascript.js +26 -54
- package/dist/languages/definitions/javascript.js.map +1 -1
- package/dist/languages/definitions/js-family.d.ts +15 -1
- package/dist/languages/definitions/js-family.d.ts.map +1 -1
- package/dist/languages/definitions/js-family.js +51 -0
- package/dist/languages/definitions/js-family.js.map +1 -1
- package/dist/languages/definitions/kotlin.d.ts.map +1 -1
- package/dist/languages/definitions/kotlin.js +26 -43
- package/dist/languages/definitions/kotlin.js.map +1 -1
- package/dist/languages/definitions/php.d.ts.map +1 -1
- package/dist/languages/definitions/php.js +50 -60
- package/dist/languages/definitions/php.js.map +1 -1
- package/dist/languages/definitions/python.d.ts.map +1 -1
- package/dist/languages/definitions/python.js +23 -14
- package/dist/languages/definitions/python.js.map +1 -1
- package/dist/languages/definitions/ruby.d.ts.map +1 -1
- package/dist/languages/definitions/ruby.js +14 -17
- package/dist/languages/definitions/ruby.js.map +1 -1
- package/dist/languages/definitions/rust.d.ts.map +1 -1
- package/dist/languages/definitions/rust.js +30 -52
- package/dist/languages/definitions/rust.js.map +1 -1
- package/dist/languages/definitions/scss.d.ts.map +1 -1
- package/dist/languages/definitions/scss.js +33 -49
- package/dist/languages/definitions/scss.js.map +1 -1
- package/dist/languages/definitions/sfc-graph.d.ts +4 -0
- package/dist/languages/definitions/sfc-graph.d.ts.map +1 -0
- package/dist/languages/definitions/sfc-graph.js +16 -0
- package/dist/languages/definitions/sfc-graph.js.map +1 -0
- package/dist/languages/definitions/shared.d.ts +33 -0
- package/dist/languages/definitions/shared.d.ts.map +1 -0
- package/dist/languages/definitions/shared.js +63 -0
- package/dist/languages/definitions/shared.js.map +1 -0
- package/dist/languages/definitions/sql.d.ts.map +1 -1
- package/dist/languages/definitions/sql.js +1 -0
- package/dist/languages/definitions/sql.js.map +1 -1
- package/dist/languages/definitions/svelte.d.ts.map +1 -1
- package/dist/languages/definitions/svelte.js +2 -10
- package/dist/languages/definitions/svelte.js.map +1 -1
- package/dist/languages/definitions/swift.d.ts.map +1 -1
- package/dist/languages/definitions/swift.js +37 -31
- package/dist/languages/definitions/swift.js.map +1 -1
- package/dist/languages/definitions/typescript.d.ts.map +1 -1
- package/dist/languages/definitions/typescript.js +56 -90
- package/dist/languages/definitions/typescript.js.map +1 -1
- package/dist/languages/definitions/vue.d.ts.map +1 -1
- package/dist/languages/definitions/vue.js +2 -10
- package/dist/languages/definitions/vue.js.map +1 -1
- package/dist/languages/definitions/zig.d.ts.map +1 -1
- package/dist/languages/definitions/zig.js +9 -15
- package/dist/languages/definitions/zig.js.map +1 -1
- package/dist/languages/graph-captures.d.ts +40 -0
- package/dist/languages/graph-captures.d.ts.map +1 -0
- package/dist/languages/graph-captures.js +46 -0
- package/dist/languages/graph-captures.js.map +1 -0
- package/dist/languages/import-statement-parsers.d.ts +17 -0
- package/dist/languages/import-statement-parsers.d.ts.map +1 -1
- package/dist/languages/import-statement-parsers.js +108 -0
- package/dist/languages/import-statement-parsers.js.map +1 -1
- package/dist/languages/js-family.d.ts +2 -0
- package/dist/languages/js-family.d.ts.map +1 -1
- package/dist/languages/js-family.js +15 -6
- package/dist/languages/js-family.js.map +1 -1
- package/dist/languages/types.d.ts +4 -0
- package/dist/languages/types.d.ts.map +1 -1
- package/dist/languages/types.js +1 -1
- package/dist/languages/types.js.map +1 -1
- package/dist/languages.js +1 -1
- package/dist/languages.js.map +1 -1
- package/dist/native/contracts.d.ts +1 -1
- package/dist/native/contracts.d.ts.map +1 -1
- package/dist/native/js-bridge.d.ts +10 -0
- package/dist/native/js-bridge.d.ts.map +1 -1
- package/dist/native/js-bridge.js +10 -0
- package/dist/native/js-bridge.js.map +1 -1
- package/dist/native/native-backend-report.d.ts.map +1 -1
- package/dist/native/native-backend-report.js +2 -0
- package/dist/native/native-backend-report.js.map +1 -1
- package/dist/util/comments.d.ts +7 -7
- package/dist/util/comments.d.ts.map +1 -1
- package/dist/util/comments.js +15 -214
- package/dist/util/comments.js.map +1 -1
- package/dist/util/dynamic-import-tables.d.ts +88 -0
- package/dist/util/dynamic-import-tables.d.ts.map +1 -0
- package/dist/util/dynamic-import-tables.js +100 -0
- package/dist/util/dynamic-import-tables.js.map +1 -0
- package/dist/util/lines.d.ts.map +1 -1
- package/dist/util/lines.js +4 -1
- package/dist/util/lines.js.map +1 -1
- package/dist/util/member-access-tables.d.ts +72 -0
- package/dist/util/member-access-tables.d.ts.map +1 -0
- package/dist/util/member-access-tables.js +167 -0
- package/dist/util/member-access-tables.js.map +1 -0
- package/dist/util/member-access.d.ts +2 -0
- package/dist/util/member-access.d.ts.map +1 -1
- package/dist/util/member-access.js +61 -95
- package/dist/util/member-access.js.map +1 -1
- package/dist/util/paths.d.ts +4 -0
- package/dist/util/paths.d.ts.map +1 -1
- package/dist/util/paths.js +26 -0
- package/dist/util/paths.js.map +1 -1
- package/dist/util/project-files.js +1 -1
- package/dist/util/project-files.js.map +1 -1
- package/dist/util/resolution/cargo-targets.d.ts.map +1 -1
- package/dist/util/resolution/cargo-targets.js +17 -14
- package/dist/util/resolution/cargo-targets.js.map +1 -1
- package/dist/util/resolution/cpp.d.ts +6 -0
- package/dist/util/resolution/cpp.d.ts.map +1 -0
- package/dist/util/resolution/cpp.js +69 -0
- package/dist/util/resolution/cpp.js.map +1 -0
- package/dist/util/resolution/csharp.d.ts +4 -3
- package/dist/util/resolution/csharp.d.ts.map +1 -1
- package/dist/util/resolution/csharp.js +27 -113
- package/dist/util/resolution/csharp.js.map +1 -1
- package/dist/util/resolution/files.d.ts +6 -0
- package/dist/util/resolution/files.d.ts.map +1 -1
- package/dist/util/resolution/files.js +108 -4
- package/dist/util/resolution/files.js.map +1 -1
- package/dist/util/resolution/go.d.ts +1 -0
- package/dist/util/resolution/go.d.ts.map +1 -1
- package/dist/util/resolution/go.js +4 -3
- package/dist/util/resolution/go.js.map +1 -1
- package/dist/util/resolution/jvm.d.ts +3 -3
- package/dist/util/resolution/jvm.d.ts.map +1 -1
- package/dist/util/resolution/jvm.js +90 -54
- package/dist/util/resolution/jvm.js.map +1 -1
- package/dist/util/resolution/node.js +2 -2
- package/dist/util/resolution/node.js.map +1 -1
- package/dist/util/resolution/php-composer.d.ts.map +1 -1
- package/dist/util/resolution/php-composer.js +8 -7
- package/dist/util/resolution/php-composer.js.map +1 -1
- package/dist/util/resolution/php.d.ts.map +1 -1
- package/dist/util/resolution/php.js +30 -43
- package/dist/util/resolution/php.js.map +1 -1
- package/dist/util/resolution/project-symbols.d.ts +5 -7
- package/dist/util/resolution/project-symbols.d.ts.map +1 -1
- package/dist/util/resolution/project-symbols.js +23 -9
- package/dist/util/resolution/project-symbols.js.map +1 -1
- package/dist/util/resolution/python.d.ts.map +1 -1
- package/dist/util/resolution/python.js +107 -62
- package/dist/util/resolution/python.js.map +1 -1
- package/dist/util/resolution/rust.d.ts.map +1 -1
- package/dist/util/resolution/rust.js +45 -34
- package/dist/util/resolution/rust.js.map +1 -1
- package/dist/util/resolution/tsconfig.d.ts.map +1 -1
- package/dist/util/resolution/tsconfig.js +3 -9
- package/dist/util/resolution/tsconfig.js.map +1 -1
- package/dist/util/resolution-candidates.d.ts +5 -1
- package/dist/util/resolution-candidates.d.ts.map +1 -1
- package/dist/util/resolution-candidates.js +18 -0
- package/dist/util/resolution-candidates.js.map +1 -1
- package/dist/util/resolution.d.ts.map +1 -1
- package/dist/util/resolution.js +93 -49
- package/dist/util/resolution.js.map +1 -1
- package/dist/util/specifiers.d.ts +4 -10
- package/dist/util/specifiers.d.ts.map +1 -1
- package/dist/util/specifiers.js +131 -165
- package/dist/util/specifiers.js.map +1 -1
- package/dist/util/trivia-tables.d.ts +69 -0
- package/dist/util/trivia-tables.d.ts.map +1 -0
- package/dist/util/trivia-tables.js +186 -0
- package/dist/util/trivia-tables.js.map +1 -0
- package/dist/util/trivia.d.ts +24 -0
- package/dist/util/trivia.d.ts.map +1 -0
- package/dist/util/trivia.js +621 -0
- package/dist/util/trivia.js.map +1 -0
- package/dist/util.d.ts +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +1 -1
- package/dist/util.js.map +1 -1
- package/dist/worker/native-extract-worker.d.ts.map +1 -1
- package/dist/worker/native-extract-worker.js +4 -4
- package/dist/worker/native-extract-worker.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
3
|
-
import { CSHARP_IDENTIFIER_SOURCE, GO_IDENTIFIER_SOURCE, KOTLIN_IDENTIFIER_SOURCE } from "../../util/identifiers.js";
|
|
4
|
-
import { isRustCfgTestStatement } from "../../util/rust-test-modules.js";
|
|
2
|
+
import { GO_IDENTIFIER_SOURCE } from "../../util/identifiers.js";
|
|
5
3
|
import { getPhpComposerImplicitFiles } from "../../util/resolution.js";
|
|
6
|
-
import { resolveCsharpNamespaceImportPaths } from "../../util/resolution/csharp.js";
|
|
7
|
-
import { extractRustModPathAttribute, resolveRustImportPath } from "../../util/resolution/rust.js";
|
|
8
4
|
import { attributeNamedBindingRanges, maskImportBindingTrivia } from "./binding-ranges.js";
|
|
5
|
+
import { IMPORT_BINDING_ROWS, } from "./import-binding-tables.js";
|
|
6
|
+
import { collectTextImportBindingRequests, hasTextImportBindings } from "./text-import-extractors.js";
|
|
9
7
|
export function createStatementImportOverrideState() {
|
|
10
8
|
return { handledStatements: new Set() };
|
|
11
9
|
}
|
|
@@ -63,99 +61,35 @@ function normalizeGoImports(context) {
|
|
|
63
61
|
}
|
|
64
62
|
context.replaceBindings(normalized);
|
|
65
63
|
}
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Recovers import bindings from the shared text extractor registry.
|
|
66
|
+
*
|
|
67
|
+
* Java, Kotlin, C#, and PHP already own bindings when the native query ran, so their text path
|
|
68
|
+
* only fills in when it produced none. Rust always re-scans because its statement override
|
|
69
|
+
* de-duplicates against the bindings that already exist.
|
|
70
|
+
*/
|
|
71
|
+
async function appendTextImportBindings(context) {
|
|
72
|
+
if (!hasTextImportBindings(context.languageId))
|
|
68
73
|
return;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
for (const match of context.source.matchAll(importPattern)) {
|
|
72
|
-
const isStatic = !!match[1];
|
|
73
|
-
const rawSpec = match[2];
|
|
74
|
-
if (!rawSpec)
|
|
75
|
-
continue;
|
|
76
|
-
if (rawSpec.endsWith(".*")) {
|
|
77
|
-
const resolved = await context.resolveFrom(isStatic ? rawSpec.slice(0, -2) : rawSpec);
|
|
78
|
-
context.pushBinding({
|
|
79
|
-
kind: "star",
|
|
80
|
-
from: rawSpec,
|
|
81
|
-
resolved,
|
|
82
|
-
typeOnly: false,
|
|
83
|
-
});
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const parts = rawSpec.split(".");
|
|
87
|
-
const imported = parts[parts.length - 1];
|
|
88
|
-
if (!imported)
|
|
89
|
-
continue;
|
|
90
|
-
const fromValue = isStatic ? parts.slice(0, -1).join(".") : rawSpec;
|
|
91
|
-
const resolved = await context.resolveFrom(fromValue);
|
|
92
|
-
const namedBinding = {
|
|
93
|
-
kind: "named",
|
|
94
|
-
local: imported,
|
|
95
|
-
imported,
|
|
96
|
-
from: fromValue,
|
|
97
|
-
resolved,
|
|
98
|
-
typeOnly: false,
|
|
99
|
-
};
|
|
100
|
-
if (match.index !== undefined) {
|
|
101
|
-
attributeNamedBindingRanges({
|
|
102
|
-
bindings: [namedBinding],
|
|
103
|
-
fromIndex: 0,
|
|
104
|
-
text: maskImportBindingTrivia(match[0], context.languageId),
|
|
105
|
-
textStartIndex: match.index,
|
|
106
|
-
source: context.source,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
context.pushBinding(namedBinding);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
async function appendKotlinTextImports(context) {
|
|
113
|
-
if (context.languageId !== "kotlin" || context.getBindings().length) {
|
|
74
|
+
const row = IMPORT_BINDING_ROWS[context.languageId];
|
|
75
|
+
if (!row?.rescanTextBindings && context.getBindings().length)
|
|
114
76
|
return;
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
if (!
|
|
122
|
-
continue;
|
|
123
|
-
const normalizedSpec = rawSpec.replace(/\s+/gu, "");
|
|
124
|
-
if (normalizedSpec.endsWith(".*")) {
|
|
125
|
-
const fromValue = normalizedSpec.slice(0, -2);
|
|
126
|
-
const resolved = await context.resolveFrom(fromValue);
|
|
127
|
-
context.pushBinding({
|
|
128
|
-
kind: "star",
|
|
129
|
-
from: fromValue,
|
|
130
|
-
resolved,
|
|
131
|
-
typeOnly: false,
|
|
132
|
-
});
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
const parts = normalizedSpec.split(".");
|
|
136
|
-
const imported = parts[parts.length - 1];
|
|
137
|
-
if (!imported)
|
|
77
|
+
const state = createStatementImportOverrideState();
|
|
78
|
+
for (const request of collectTextImportBindingRequests(context.languageId, context.source, {
|
|
79
|
+
file: context.file,
|
|
80
|
+
})) {
|
|
81
|
+
const bindingCountBefore = context.getBindings().length;
|
|
82
|
+
const handled = await applyStatementImportOverride(context, state, request.raw, false, request.start);
|
|
83
|
+
if (!handled)
|
|
138
84
|
continue;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
...(
|
|
146
|
-
|
|
147
|
-
typeOnly: false,
|
|
148
|
-
};
|
|
149
|
-
if (match.index !== undefined) {
|
|
150
|
-
attributeNamedBindingRanges({
|
|
151
|
-
bindings: [namedBinding],
|
|
152
|
-
fromIndex: 0,
|
|
153
|
-
text: maskImportBindingTrivia(match[0], context.languageId),
|
|
154
|
-
textStartIndex: match.index,
|
|
155
|
-
source: context.source,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
context.pushBinding(namedBinding);
|
|
85
|
+
attributeNamedBindingRanges({
|
|
86
|
+
bindings: context.getBindings(),
|
|
87
|
+
fromIndex: bindingCountBefore,
|
|
88
|
+
text: maskImportBindingTrivia(request.raw, context.languageId),
|
|
89
|
+
textStartIndex: request.start,
|
|
90
|
+
source: context.source,
|
|
91
|
+
...(row?.alwaysAliased ? { alwaysAliased: true } : {}),
|
|
92
|
+
});
|
|
159
93
|
}
|
|
160
94
|
}
|
|
161
95
|
async function appendPhpComposerImplicitImports(context) {
|
|
@@ -188,499 +122,46 @@ async function appendPhpComposerImplicitImports(context) {
|
|
|
188
122
|
}
|
|
189
123
|
export async function finalizeLanguageSpecificImports(context) {
|
|
190
124
|
normalizeGoImports(context);
|
|
191
|
-
await
|
|
192
|
-
await appendKotlinTextImports(context);
|
|
193
|
-
await appendRustTextImports(context);
|
|
125
|
+
await appendTextImportBindings(context);
|
|
194
126
|
await appendPhpComposerImplicitImports(context);
|
|
195
127
|
}
|
|
196
|
-
function
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
kind: "star",
|
|
213
|
-
from: fromValue,
|
|
214
|
-
resolved,
|
|
215
|
-
typeOnly,
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
const CSHARP_EXTERN_ALIAS_PATTERN = new RegExp(String.raw `^extern\s+alias\s+(${CSHARP_IDENTIFIER_SOURCE})\s*;$`, "u");
|
|
219
|
-
async function applyCsharpStatementOverride(context, normalizedStmt, typeOnly) {
|
|
220
|
-
const externAlias = normalizedStmt.match(CSHARP_EXTERN_ALIAS_PATTERN)?.[1];
|
|
221
|
-
if (externAlias) {
|
|
222
|
-
// `extern alias X;` names a compiler-provided alias for an assembly's extern alias. It has no
|
|
223
|
-
// first-party or package target, so it stays an unresolved namespace binding and produces no
|
|
224
|
-
// dependency edge: the graph query does not treat it as an import specifier.
|
|
225
|
-
context.pushBinding({ kind: "namespace", localNS: externAlias, from: externAlias });
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
const parsed = parseCsharpUsingDirective(normalizedStmt);
|
|
229
|
-
if (!parsed)
|
|
230
|
-
return false;
|
|
231
|
-
// A target that is itself a declared namespace is a namespace alias, even when the alias is
|
|
232
|
-
// written in alias form. Resolving it here keeps the local name a namespace so member
|
|
233
|
-
// navigation can reach the declaring file instead of treating the last segment as a type.
|
|
234
|
-
// A namespace split across several files has no single target, so it keeps the local alias
|
|
235
|
-
// as an unresolved namespace rather than claiming one of the declaring files.
|
|
236
|
-
const namespaceTargets = await resolveCsharpNamespaceImportPaths(context.projectRoot, parsed.from);
|
|
237
|
-
if (parsed.alias && namespaceTargets.length) {
|
|
238
|
-
context.pushBinding({
|
|
239
|
-
kind: "namespace",
|
|
240
|
-
localNS: parsed.alias,
|
|
241
|
-
from: parsed.from,
|
|
242
|
-
...(namespaceTargets.length === 1 ? { resolved: namespaceTargets[0].replace(/\\/g, "/") } : {}),
|
|
243
|
-
typeOnly,
|
|
244
|
-
});
|
|
245
|
-
return true;
|
|
246
|
-
}
|
|
247
|
-
let fromValue = parsed.from;
|
|
248
|
-
let resolved = await context.resolveFrom(fromValue);
|
|
249
|
-
if (typeof resolved !== "string" && namespaceTargets.length === 1) {
|
|
250
|
-
resolved = namespaceTargets[0].replace(/\\/g, "/");
|
|
251
|
-
}
|
|
252
|
-
if (parsed.alias) {
|
|
253
|
-
const fromParts = parsed.from.split(".");
|
|
254
|
-
if (typeof resolved !== "string" && fromParts.length > 1) {
|
|
255
|
-
const fallbackFrom = fromParts.slice(0, -1).join(".");
|
|
256
|
-
if (fallbackFrom) {
|
|
257
|
-
const fallbackResolved = await context.resolveFrom(fallbackFrom);
|
|
258
|
-
if (typeof fallbackResolved === "string") {
|
|
259
|
-
fromValue = fallbackFrom;
|
|
260
|
-
resolved = fallbackResolved;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
pushCsharpOverride(context, parsed, typeOnly, fromValue, resolved);
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
async function applyJavaStatementOverride(context, normalizedStmt, typeOnly) {
|
|
269
|
-
return await applyJvmStatementOverride(context, normalizedStmt, typeOnly, parseJavaImportStatement, (parsed) => {
|
|
270
|
-
if (parsed.kind === "named")
|
|
271
|
-
return parsed.imported;
|
|
272
|
-
return undefined;
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
async function applyKotlinStatementOverride(context, normalizedStmt, typeOnly) {
|
|
276
|
-
return await applyJvmStatementOverride(context, normalizedStmt, typeOnly, parseKotlinImportStatement, (parsed) => {
|
|
277
|
-
if (parsed.kind === "named")
|
|
278
|
-
return parsed.local;
|
|
279
|
-
return undefined;
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
async function applyJvmStatementOverride(context, normalizedStmt, typeOnly, parseStatement, localNameFor) {
|
|
283
|
-
const parsed = parseStatement(normalizedStmt);
|
|
284
|
-
if (!parsed)
|
|
285
|
-
return false;
|
|
286
|
-
return await pushJvmImportBinding(context, parsed, localNameFor(parsed), typeOnly);
|
|
287
|
-
}
|
|
288
|
-
async function pushJvmImportBinding(context, parsed, local, typeOnly) {
|
|
289
|
-
const resolved = await context.resolveFrom(parsed.from);
|
|
290
|
-
if (parsed.kind === "star") {
|
|
291
|
-
context.pushBinding({
|
|
292
|
-
kind: "star",
|
|
293
|
-
from: parsed.from,
|
|
294
|
-
resolved,
|
|
295
|
-
typeOnly,
|
|
296
|
-
});
|
|
297
|
-
return true;
|
|
298
|
-
}
|
|
299
|
-
context.pushBinding({
|
|
300
|
-
kind: "named",
|
|
301
|
-
local: local ?? parsed.imported,
|
|
302
|
-
imported: parsed.imported,
|
|
303
|
-
from: parsed.from,
|
|
304
|
-
...(parsed.explicitAlias ? { explicitAlias: true } : {}),
|
|
305
|
-
resolved,
|
|
306
|
-
typeOnly,
|
|
307
|
-
});
|
|
308
|
-
return true;
|
|
309
|
-
}
|
|
310
|
-
async function applyRustStatementOverride(context, normalizedStmt, typeOnly, statementStartIndex) {
|
|
311
|
-
if (isRustTestOnlyStatement(context, normalizedStmt, statementStartIndex))
|
|
312
|
-
return true;
|
|
313
|
-
const parsedList = parseRustImportStatements(normalizedStmt);
|
|
314
|
-
if (!parsedList.length)
|
|
315
|
-
return false;
|
|
316
|
-
const seen = new Set(context.getBindings().map(rustBindingKey));
|
|
317
|
-
await pushParsedRustImports(context, parsedList, typeOnly, statementStartIndex, seen);
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
|
-
async function resolveRustParsedFrom(context, from, pathAttribute, statementStartIndex) {
|
|
321
|
-
if (pathAttribute) {
|
|
322
|
-
const attributed = await resolveRustImportPath(context.projectRoot, context.file, from, pathAttribute, statementStartIndex);
|
|
323
|
-
if (attributed)
|
|
324
|
-
return attributed.replace(/\\/g, "/");
|
|
325
|
-
return { external: from };
|
|
326
|
-
}
|
|
327
|
-
return context.resolveFrom(from);
|
|
328
|
-
}
|
|
329
|
-
function rustBindingKey(binding) {
|
|
330
|
-
const resolved = JSON.stringify(binding.resolved);
|
|
331
|
-
if (binding.kind === "named")
|
|
332
|
-
return `named:${binding.local}:${binding.imported}:${binding.from}:${resolved}`;
|
|
333
|
-
if (binding.kind === "namespace")
|
|
334
|
-
return `namespace:${binding.localNS}:${binding.from}:${resolved}`;
|
|
335
|
-
if (binding.kind === "star")
|
|
336
|
-
return `star:${binding.from}:${resolved}`;
|
|
337
|
-
return JSON.stringify(binding);
|
|
338
|
-
}
|
|
339
|
-
const RUST_IMPORT_KEYWORD_PATTERN = /^(?:pub(?:\s*\([^)]*\))?\s+)?(use|extern\s+crate|mod)\b/;
|
|
340
|
-
function scanRustImportStatements(sourceText) {
|
|
341
|
-
const results = [];
|
|
342
|
-
let index = 0;
|
|
343
|
-
while (index < sourceText.length) {
|
|
344
|
-
const skipped = skipRustCommentOrLiteral(sourceText, index) ?? skipRustMacroTokenTree(sourceText, index);
|
|
345
|
-
if (skipped) {
|
|
346
|
-
index = skipped.end;
|
|
347
|
-
continue;
|
|
348
|
-
}
|
|
349
|
-
if (/\s/.test(sourceText[index])) {
|
|
350
|
-
index += 1;
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
const statementStart = index;
|
|
354
|
-
let cursor = index;
|
|
355
|
-
for (;;) {
|
|
356
|
-
while (cursor < sourceText.length && /\s/.test(sourceText[cursor]))
|
|
357
|
-
cursor += 1;
|
|
358
|
-
const trivia = skipRustCommentOrLiteral(sourceText, cursor);
|
|
359
|
-
if (trivia) {
|
|
360
|
-
cursor = trivia.end;
|
|
361
|
-
continue;
|
|
362
|
-
}
|
|
363
|
-
const attrEnd = skipRustOuterAttribute(sourceText, cursor);
|
|
364
|
-
if (attrEnd === null)
|
|
365
|
-
break;
|
|
366
|
-
cursor = attrEnd;
|
|
367
|
-
}
|
|
368
|
-
const match = sourceText.slice(cursor).match(RUST_IMPORT_KEYWORD_PATTERN);
|
|
369
|
-
if (!match || !isRustItemStartBoundary(sourceText, cursor)) {
|
|
370
|
-
index = Math.max(index + 1, cursor);
|
|
371
|
-
continue;
|
|
372
|
-
}
|
|
373
|
-
let consumed = false;
|
|
374
|
-
let depth = 0;
|
|
375
|
-
for (let scan = statementStart; scan < sourceText.length;) {
|
|
376
|
-
const inner = skipRustCommentOrLiteral(sourceText, scan) ?? skipRustMacroTokenTree(sourceText, scan);
|
|
377
|
-
if (inner) {
|
|
378
|
-
scan = inner.end;
|
|
379
|
-
continue;
|
|
380
|
-
}
|
|
381
|
-
const character = sourceText[scan];
|
|
382
|
-
if (character === "{") {
|
|
383
|
-
const head = sourceText.slice(statementStart, scan);
|
|
384
|
-
if (/\bmod\b/.test(head) && !/\buse\b/.test(head)) {
|
|
385
|
-
index = scan + 1;
|
|
386
|
-
consumed = true;
|
|
387
|
-
break;
|
|
388
|
-
}
|
|
389
|
-
depth += 1;
|
|
390
|
-
scan += 1;
|
|
391
|
-
continue;
|
|
392
|
-
}
|
|
393
|
-
if (character === "}") {
|
|
394
|
-
depth = Math.max(0, depth - 1);
|
|
395
|
-
scan += 1;
|
|
396
|
-
continue;
|
|
397
|
-
}
|
|
398
|
-
if (character === ";" && !depth) {
|
|
399
|
-
results.push({ text: sourceText.slice(statementStart, scan + 1), start: statementStart });
|
|
400
|
-
index = scan + 1;
|
|
401
|
-
consumed = true;
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
scan += 1;
|
|
405
|
-
}
|
|
406
|
-
if (!consumed)
|
|
407
|
-
index += 1;
|
|
408
|
-
}
|
|
409
|
-
return results;
|
|
410
|
-
}
|
|
411
|
-
function buildRustBinding(parsed, resolved, typeOnly) {
|
|
412
|
-
if (parsed.kind === "member") {
|
|
413
|
-
return {
|
|
414
|
-
kind: "named",
|
|
415
|
-
local: parsed.local,
|
|
416
|
-
imported: parsed.imported,
|
|
417
|
-
from: parsed.from,
|
|
418
|
-
...(parsed.explicitAlias ? { explicitAlias: true } : {}),
|
|
419
|
-
resolved,
|
|
420
|
-
typeOnly,
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
if (parsed.kind === "module") {
|
|
424
|
-
return { kind: "namespace", localNS: parsed.local, from: parsed.from, resolved, typeOnly };
|
|
425
|
-
}
|
|
426
|
-
return { kind: "star", from: parsed.from, resolved, typeOnly };
|
|
427
|
-
}
|
|
428
|
-
async function pushParsedRustImports(context, parsedList, typeOnly, statementStartIndex, seen) {
|
|
429
|
-
const statementPathAttribute = extractRustModPathAttribute(context.source, undefined, statementStartIndex);
|
|
430
|
-
for (const parsed of parsedList) {
|
|
431
|
-
const pathAttribute = parsed.kind === "module" && !parsed.isExternCrate ? (parsed.pathAttribute ?? statementPathAttribute) : undefined;
|
|
432
|
-
const resolved = await resolveRustParsedFrom(context, parsed.from, pathAttribute, statementStartIndex);
|
|
433
|
-
const binding = buildRustBinding(parsed, resolved, typeOnly);
|
|
434
|
-
const key = rustBindingKey(binding);
|
|
435
|
-
if (seen.has(key))
|
|
436
|
-
continue;
|
|
437
|
-
seen.add(key);
|
|
438
|
-
context.pushBinding(binding);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
async function appendRustTextImports(context) {
|
|
442
|
-
if (context.languageId !== "rust")
|
|
443
|
-
return;
|
|
444
|
-
const seen = new Set(context.getBindings().map(rustBindingKey));
|
|
445
|
-
for (const statement of scanRustImportStatements(context.source)) {
|
|
446
|
-
const keywordOffset = rustImportKeywordOffset(statement.text);
|
|
447
|
-
const keywordIndex = keywordOffset >= 0 ? statement.start + keywordOffset : statement.start;
|
|
448
|
-
const keywordText = keywordOffset >= 0 ? statement.text.slice(keywordOffset) : statement.text;
|
|
449
|
-
if (isRustCfgTestStatement(context.source, keywordText, keywordIndex))
|
|
450
|
-
continue;
|
|
451
|
-
const parsedList = parseRustImportStatements(statement.text);
|
|
452
|
-
if (!parsedList.length)
|
|
453
|
-
continue;
|
|
454
|
-
const bindingCountBefore = context.getBindings().length;
|
|
455
|
-
await pushParsedRustImports(context, parsedList, false, statement.start, seen);
|
|
456
|
-
attributeNamedBindingRanges({
|
|
457
|
-
bindings: context.getBindings(),
|
|
458
|
-
fromIndex: bindingCountBefore,
|
|
459
|
-
text: maskImportBindingTrivia(statement.text, context.languageId),
|
|
460
|
-
textStartIndex: statement.start,
|
|
461
|
-
source: context.source,
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
function isRustTestOnlyStatement(context, normalizedStmt, statementStartIndex) {
|
|
466
|
-
if (context.languageId !== "rust")
|
|
467
|
-
return false;
|
|
468
|
-
if (statementStartIndex !== undefined) {
|
|
469
|
-
const keywordOffset = rustImportKeywordOffset(context.source.slice(statementStartIndex));
|
|
470
|
-
const keywordIndex = keywordOffset >= 0 ? statementStartIndex + keywordOffset : statementStartIndex;
|
|
471
|
-
const keywordText = keywordOffset >= 0 ? context.source.slice(keywordIndex) : normalizedStmt;
|
|
472
|
-
return isRustCfgTestStatement(context.source, keywordText, keywordIndex);
|
|
473
|
-
}
|
|
474
|
-
return isRustCfgTestStatement(context.source, normalizedStmt, statementStartIndex);
|
|
475
|
-
}
|
|
476
|
-
function rustImportKeywordOffset(text) {
|
|
477
|
-
let index = 0;
|
|
478
|
-
while (index < text.length) {
|
|
479
|
-
if (/\s/.test(text[index])) {
|
|
480
|
-
index += 1;
|
|
481
|
-
continue;
|
|
482
|
-
}
|
|
483
|
-
const skipped = skipRustCommentOrLiteral(text, index);
|
|
484
|
-
if (skipped) {
|
|
485
|
-
index = skipped.end;
|
|
486
|
-
continue;
|
|
487
|
-
}
|
|
488
|
-
const attrEnd = skipRustOuterAttribute(text, index);
|
|
489
|
-
if (attrEnd !== null) {
|
|
490
|
-
index = attrEnd;
|
|
491
|
-
continue;
|
|
492
|
-
}
|
|
493
|
-
const match = text.slice(index).match(RUST_IMPORT_KEYWORD_PATTERN);
|
|
494
|
-
if (match)
|
|
495
|
-
return index;
|
|
496
|
-
index += 1;
|
|
497
|
-
}
|
|
498
|
-
return -1;
|
|
499
|
-
}
|
|
500
|
-
async function applyPhpStatementOverride(context, normalizedStmt, typeOnly) {
|
|
501
|
-
const parsed = parsePhpImportStatement(normalizedStmt, context.file);
|
|
502
|
-
if (!parsed.length)
|
|
503
|
-
return false;
|
|
504
|
-
for (const entry of parsed) {
|
|
505
|
-
if (entry.kind === "include") {
|
|
506
|
-
const resolved = await context.resolveFrom(entry.from);
|
|
507
|
-
context.pushBinding({
|
|
508
|
-
kind: "star",
|
|
509
|
-
from: entry.from,
|
|
510
|
-
resolved,
|
|
511
|
-
typeOnly,
|
|
512
|
-
mechanism: "php",
|
|
513
|
-
});
|
|
514
|
-
continue;
|
|
515
|
-
}
|
|
516
|
-
const resolved = await context.resolveFrom(entry.from, entry.importType);
|
|
517
|
-
context.pushBinding({
|
|
518
|
-
kind: "named",
|
|
519
|
-
local: entry.local,
|
|
520
|
-
imported: entry.imported,
|
|
521
|
-
from: entry.from,
|
|
522
|
-
...(entry.explicitAlias ? { explicitAlias: true } : {}),
|
|
523
|
-
phpImportType: entry.importType,
|
|
524
|
-
resolved,
|
|
525
|
-
typeOnly,
|
|
526
|
-
mechanism: "php",
|
|
527
|
-
});
|
|
128
|
+
function masksStatementTrivia(row, normalizedStmt) {
|
|
129
|
+
if (row.maskTrivia === "use-keyword")
|
|
130
|
+
return /^\s*use\b/i.test(normalizedStmt);
|
|
131
|
+
return row.maskTrivia ?? false;
|
|
132
|
+
}
|
|
133
|
+
function parserTextForStatement(row, languageId, normalizedStmt) {
|
|
134
|
+
if (!masksStatementTrivia(row, normalizedStmt))
|
|
135
|
+
return normalizedStmt;
|
|
136
|
+
let parserStmt = maskImportBindingTrivia(normalizedStmt, languageId);
|
|
137
|
+
if (row.normalizeDots)
|
|
138
|
+
parserStmt = parserStmt.replace(/\s*\.\s*/gu, ".");
|
|
139
|
+
return parserStmt;
|
|
140
|
+
}
|
|
141
|
+
function statementImportOverrideKey(row, normalizedStmt, statementStartIndex) {
|
|
142
|
+
if (row.statementKeyUsesOffset && statementStartIndex !== undefined) {
|
|
143
|
+
return `${normalizedStmt}@${statementStartIndex}`;
|
|
528
144
|
}
|
|
529
|
-
return
|
|
145
|
+
return normalizedStmt;
|
|
530
146
|
}
|
|
531
147
|
export async function applyStatementImportOverride(context, state, stmtText, typeOnly, statementStartIndex) {
|
|
532
148
|
const normalizedStmt = stmtText.trim();
|
|
533
149
|
if (!normalizedStmt)
|
|
534
150
|
return false;
|
|
535
|
-
const
|
|
151
|
+
const row = IMPORT_BINDING_ROWS[context.languageId];
|
|
152
|
+
const applyStatement = row?.applyStatement;
|
|
153
|
+
if (!row || !applyStatement)
|
|
154
|
+
return false;
|
|
155
|
+
const statementKey = statementImportOverrideKey(row, normalizedStmt, statementStartIndex);
|
|
536
156
|
if (state.handledStatements.has(statementKey))
|
|
537
157
|
return true;
|
|
538
|
-
|
|
539
|
-
const canMaskStrings = context.languageId !== "rust" && (context.languageId !== "php" || /^\s*use\b/i.test(normalizedStmt));
|
|
540
|
-
if (canMaskStrings) {
|
|
541
|
-
parserStmt = maskImportBindingTrivia(normalizedStmt, context.languageId);
|
|
542
|
-
if (context.languageId === "csharp" || context.languageId === "java" || context.languageId === "kotlin") {
|
|
543
|
-
parserStmt = parserStmt.replace(/\s*\.\s*/gu, ".");
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
let handled = false;
|
|
547
|
-
if (context.languageId === "csharp") {
|
|
548
|
-
handled = await applyCsharpStatementOverride(context, parserStmt, typeOnly);
|
|
549
|
-
}
|
|
550
|
-
else if (context.languageId === "java") {
|
|
551
|
-
handled = await applyJavaStatementOverride(context, parserStmt, typeOnly);
|
|
552
|
-
}
|
|
553
|
-
else if (context.languageId === "kotlin") {
|
|
554
|
-
handled = await applyKotlinStatementOverride(context, parserStmt, typeOnly);
|
|
555
|
-
}
|
|
556
|
-
else if (context.languageId === "rust") {
|
|
557
|
-
handled = await applyRustStatementOverride(context, normalizedStmt, typeOnly, statementStartIndex);
|
|
558
|
-
}
|
|
559
|
-
else if (context.languageId === "php") {
|
|
560
|
-
handled = await applyPhpStatementOverride(context, parserStmt, typeOnly);
|
|
561
|
-
}
|
|
158
|
+
const handled = await applyStatement(context, parserTextForStatement(row, context.languageId, normalizedStmt), typeOnly, statementStartIndex);
|
|
562
159
|
if (!handled)
|
|
563
160
|
return false;
|
|
564
161
|
state.handledStatements.add(statementKey);
|
|
565
162
|
return true;
|
|
566
163
|
}
|
|
567
|
-
function statementImportOverrideKey(languageId, normalizedStmt, statementStartIndex) {
|
|
568
|
-
if (languageId === "rust" && statementStartIndex !== undefined) {
|
|
569
|
-
return `${normalizedStmt}@${statementStartIndex}`;
|
|
570
|
-
}
|
|
571
|
-
return normalizedStmt;
|
|
572
|
-
}
|
|
573
164
|
export function appendImplicitImportBinding(context, args) {
|
|
574
|
-
|
|
575
|
-
const pushNamed = (binding, alwaysAliased) => pushNamedImplicitBinding(context, binding, stmtText, stmtStartIndex, source, alwaysAliased);
|
|
576
|
-
if (context.languageId === "java") {
|
|
577
|
-
const parts = from.split(".");
|
|
578
|
-
const last = parts[parts.length - 1];
|
|
579
|
-
if (last === "*") {
|
|
580
|
-
context.pushBinding({ kind: "star", from, resolved, typeOnly });
|
|
581
|
-
}
|
|
582
|
-
else if (last) {
|
|
583
|
-
pushNamed({ kind: "named", local: last, imported: last, from, resolved, typeOnly });
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
else if (context.languageId === "csharp") {
|
|
587
|
-
if (alias) {
|
|
588
|
-
const fromParts = from.split(".");
|
|
589
|
-
const imported = fromParts[fromParts.length - 1] ?? alias;
|
|
590
|
-
pushNamed({ kind: "named", local: alias, imported, from, explicitAlias: true, resolved, typeOnly }, true);
|
|
591
|
-
}
|
|
592
|
-
else {
|
|
593
|
-
context.pushBinding({ kind: "star", from, resolved, typeOnly });
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
else if (context.languageId === "ruby") {
|
|
597
|
-
context.pushBinding({ kind: "star", from, resolved });
|
|
598
|
-
}
|
|
599
|
-
else if (context.languageId === "go") {
|
|
600
|
-
const goAlias = alias;
|
|
601
|
-
if (goAlias === "_")
|
|
602
|
-
return;
|
|
603
|
-
if (goAlias === ".") {
|
|
604
|
-
context.pushBinding({ kind: "star", from, resolved });
|
|
605
|
-
return;
|
|
606
|
-
}
|
|
607
|
-
if (goAlias) {
|
|
608
|
-
context.pushBinding({ kind: "namespace", localNS: goAlias, from, resolved });
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
const parts = from.replace(/"/g, "").split("/");
|
|
612
|
-
const last = parts[parts.length - 1];
|
|
613
|
-
if (last)
|
|
614
|
-
context.pushBinding({ kind: "namespace", localNS: last, from, resolved });
|
|
615
|
-
}
|
|
616
|
-
else if (context.languageId === "rust") {
|
|
617
|
-
if (stmtText.startsWith("mod ")) {
|
|
618
|
-
context.pushBinding({ kind: "namespace", localNS: from, from, resolved });
|
|
619
|
-
}
|
|
620
|
-
else {
|
|
621
|
-
const parts = from.split("::");
|
|
622
|
-
const last = parts[parts.length - 1];
|
|
623
|
-
if (!last)
|
|
624
|
-
return;
|
|
625
|
-
if (last === "*") {
|
|
626
|
-
context.pushBinding({ kind: "star", from, resolved });
|
|
627
|
-
}
|
|
628
|
-
else {
|
|
629
|
-
pushNamed({ kind: "named", local: last, imported: last, from, resolved });
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
else if (context.languageId === "kotlin") {
|
|
634
|
-
if (wildcard || from.endsWith(".*")) {
|
|
635
|
-
context.pushBinding({ kind: "star", from, resolved, typeOnly });
|
|
636
|
-
}
|
|
637
|
-
else {
|
|
638
|
-
const parts = from.split(".");
|
|
639
|
-
const imported = parts[parts.length - 1];
|
|
640
|
-
if (imported)
|
|
641
|
-
pushNamed({
|
|
642
|
-
kind: "named",
|
|
643
|
-
local: alias ?? imported,
|
|
644
|
-
imported,
|
|
645
|
-
from,
|
|
646
|
-
...(alias !== undefined ? { explicitAlias: true } : {}),
|
|
647
|
-
resolved,
|
|
648
|
-
typeOnly,
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
else if (context.languageId === "swift") {
|
|
653
|
-
const parts = from.split(".");
|
|
654
|
-
const last = parts[parts.length - 1];
|
|
655
|
-
if (!last)
|
|
656
|
-
return;
|
|
657
|
-
if (parts.length === 1) {
|
|
658
|
-
context.pushBinding({ kind: "namespace", localNS: last, from, resolved, typeOnly });
|
|
659
|
-
context.pushBinding({ kind: "star", from, resolved, typeOnly });
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
pushNamed({ kind: "named", local: last, imported: last, from, resolved, typeOnly });
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
else if (context.languageId === "zig") {
|
|
666
|
-
if (alias)
|
|
667
|
-
context.pushBinding({ kind: "namespace", localNS: alias, from, resolved, typeOnly });
|
|
668
|
-
}
|
|
669
|
-
else if (context.languageId === "c" || context.languageId === "cpp") {
|
|
670
|
-
context.pushBinding({ kind: "star", from, resolved, typeOnly });
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
function pushNamedImplicitBinding(context, binding, stmtText, stmtStartIndex, source, alwaysAliased) {
|
|
674
|
-
if (stmtStartIndex !== undefined && source !== undefined) {
|
|
675
|
-
attributeNamedBindingRanges({
|
|
676
|
-
bindings: [binding],
|
|
677
|
-
fromIndex: 0,
|
|
678
|
-
text: maskImportBindingTrivia(stmtText, context.languageId),
|
|
679
|
-
textStartIndex: stmtStartIndex,
|
|
680
|
-
source,
|
|
681
|
-
...(alwaysAliased !== undefined ? { alwaysAliased } : {}),
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
context.pushBinding(binding);
|
|
165
|
+
IMPORT_BINDING_ROWS[context.languageId]?.appendImplicit?.(context, args);
|
|
685
166
|
}
|
|
686
167
|
//# sourceMappingURL=language-specific.js.map
|