@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
|
@@ -75,7 +75,829 @@ function getLanguageById(id) {
|
|
|
75
75
|
return registry.get(id);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// dist/languages/definitions/shared.js
|
|
79
|
+
function isNameFieldOnParent(node, parentTypes, field = "name") {
|
|
80
|
+
const parent = node.parent;
|
|
81
|
+
if (!parent || !parentTypes.includes(parent.type))
|
|
82
|
+
return false;
|
|
83
|
+
return parent.childForFieldName(field)?.id === node.id;
|
|
84
|
+
}
|
|
85
|
+
function isNameOrPropertyFieldOnParent(node, parentTypes) {
|
|
86
|
+
const parent = node.parent;
|
|
87
|
+
if (!parent || !parentTypes.includes(parent.type))
|
|
88
|
+
return false;
|
|
89
|
+
const name = parent.childForFieldName("name") ?? parent.childForFieldName("property");
|
|
90
|
+
return name?.id === node.id;
|
|
91
|
+
}
|
|
92
|
+
function hasParentType(node, parentTypes) {
|
|
93
|
+
return parentTypes.includes(node.parent?.type ?? "");
|
|
94
|
+
}
|
|
95
|
+
function matchesParentTypePairs(node, pairs) {
|
|
96
|
+
const parentType = node.parent?.type;
|
|
97
|
+
if (!parentType)
|
|
98
|
+
return false;
|
|
99
|
+
return pairs.some(([parent, child]) => parent === parentType && child === node.type);
|
|
100
|
+
}
|
|
101
|
+
function classifyByParentType(mapping, fallback = "variable") {
|
|
102
|
+
return (node) => {
|
|
103
|
+
const parent = node.parent;
|
|
104
|
+
if (!parent)
|
|
105
|
+
return fallback;
|
|
106
|
+
const entry = mapping[parent.type];
|
|
107
|
+
if (entry === void 0)
|
|
108
|
+
return fallback;
|
|
109
|
+
if (typeof entry === "string")
|
|
110
|
+
return entry;
|
|
111
|
+
if (entry.nameField !== void 0 && parent.childForFieldName(entry.nameField)?.id !== node.id) {
|
|
112
|
+
return fallback;
|
|
113
|
+
}
|
|
114
|
+
return entry.kind;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function nodeTypeIn(types) {
|
|
118
|
+
const nodeTypes = new Set(types);
|
|
119
|
+
return (node) => nodeTypes.has(node.type);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// dist/util/trivia-tables.js
|
|
123
|
+
var SLASH_STAR_COMMENT = { open: "/*", close: "*/" };
|
|
124
|
+
var NESTED_SLASH_STAR_COMMENT = { open: "/*", close: "*/", nested: true };
|
|
125
|
+
var JS_LIKE_ROW = {
|
|
126
|
+
lineComments: ["//"],
|
|
127
|
+
blockComments: [SLASH_STAR_COMMENT],
|
|
128
|
+
strings: [
|
|
129
|
+
{ open: "'", close: "'", escape: "\\" },
|
|
130
|
+
{ open: '"', close: '"', escape: "\\" },
|
|
131
|
+
{ open: "`", close: "`", escape: "\\", interpolation: { start: "${", end: "}", excludeFromMask: true } }
|
|
132
|
+
]
|
|
133
|
+
};
|
|
134
|
+
var PYTHON_F_PREFIX = "(?:[fF]|[rR][fF]|[fF][rR])";
|
|
135
|
+
var PYTHON_PLAIN_PREFIX = "(?:[bBuU]|[bB][rR]|[rR][bB])?";
|
|
136
|
+
var PYTHON_INTERPOLATION = { start: "{", end: "}", doubled: true };
|
|
137
|
+
var PYTHON_ROW = {
|
|
138
|
+
lineComments: ["#"],
|
|
139
|
+
blockComments: [],
|
|
140
|
+
strings: [
|
|
141
|
+
{ prefix: PYTHON_F_PREFIX, open: '"""', close: '"""', escape: "\\", interpolation: PYTHON_INTERPOLATION },
|
|
142
|
+
{ prefix: PYTHON_F_PREFIX, open: "'''", close: "'''", escape: "\\", interpolation: PYTHON_INTERPOLATION },
|
|
143
|
+
{ prefix: PYTHON_F_PREFIX, open: '"', close: '"', escape: "\\", interpolation: PYTHON_INTERPOLATION },
|
|
144
|
+
{ prefix: PYTHON_F_PREFIX, open: "'", close: "'", escape: "\\", interpolation: PYTHON_INTERPOLATION },
|
|
145
|
+
{ prefix: PYTHON_PLAIN_PREFIX, open: '"""', close: '"""', escape: "\\" },
|
|
146
|
+
{ prefix: PYTHON_PLAIN_PREFIX, open: "'''", close: "'''", escape: "\\" },
|
|
147
|
+
{ prefix: PYTHON_PLAIN_PREFIX, open: '"', close: '"', escape: "\\" },
|
|
148
|
+
{ prefix: PYTHON_PLAIN_PREFIX, open: "'", close: "'", escape: "\\" }
|
|
149
|
+
]
|
|
150
|
+
};
|
|
151
|
+
var CSHARP_ROW = {
|
|
152
|
+
lineComments: ["//"],
|
|
153
|
+
blockComments: [SLASH_STAR_COMMENT],
|
|
154
|
+
strings: [
|
|
155
|
+
// A verbatim (or interpolated verbatim) string doubles its closing quote; the backslash is data.
|
|
156
|
+
{ prefix: "(?:[$][@]|[@][$]|[@])", open: '"', close: '"', doubled: true },
|
|
157
|
+
{ open: '"""', close: '"""', quoteRun: true },
|
|
158
|
+
{ open: '"', close: '"', escape: "\\" },
|
|
159
|
+
{ open: "'", close: "'", escape: "\\" }
|
|
160
|
+
]
|
|
161
|
+
};
|
|
162
|
+
var GO_ROW = {
|
|
163
|
+
lineComments: ["//"],
|
|
164
|
+
blockComments: [SLASH_STAR_COMMENT],
|
|
165
|
+
strings: [
|
|
166
|
+
{ open: "`", close: "`" },
|
|
167
|
+
{ open: '"', close: '"', escape: "\\" },
|
|
168
|
+
{ open: "'", close: "'", escape: "\\" }
|
|
169
|
+
]
|
|
170
|
+
};
|
|
171
|
+
var RUST_ROW = {
|
|
172
|
+
lineComments: ["//"],
|
|
173
|
+
blockComments: [NESTED_SLASH_STAR_COMMENT],
|
|
174
|
+
strings: [
|
|
175
|
+
{ prefix: "[bc]?r", open: '"', close: '"', hashes: true },
|
|
176
|
+
{ prefix: "b?", open: '"', close: '"', escape: "\\" },
|
|
177
|
+
{ prefix: "b?", open: "'", close: "'", escape: "\\", charLike: true }
|
|
178
|
+
]
|
|
179
|
+
};
|
|
180
|
+
var PHP_HEREDOC_OPENER = `<<<[ \\t]*(?:"([^"\\r\\n]*)"|'([^'\\r\\n]*)'|([A-Za-z_]\\w*))`;
|
|
181
|
+
var PHP_ROW = {
|
|
182
|
+
lineComments: ["//", "#"],
|
|
183
|
+
blockComments: [SLASH_STAR_COMMENT],
|
|
184
|
+
strings: [
|
|
185
|
+
{ open: "'", close: "'", escape: "\\" },
|
|
186
|
+
{ open: '"', close: '"', escape: "\\" }
|
|
187
|
+
],
|
|
188
|
+
heredocs: [{ opener: PHP_HEREDOC_OPENER, indentedTerminator: true }]
|
|
189
|
+
};
|
|
190
|
+
var RUBY_HEREDOC_ID = `(?:"([^"\\r\\n]*)"|'([^'\\r\\n]*)'|([A-Za-z_]\\w*))`;
|
|
191
|
+
var RUBY_ROW = {
|
|
192
|
+
lineComments: ["#"],
|
|
193
|
+
blockComments: [{ open: "=begin", close: "=end", lineStartOnly: true }],
|
|
194
|
+
strings: [
|
|
195
|
+
{ open: '"', close: '"', escape: "\\" },
|
|
196
|
+
{ open: "'", close: "'", escape: "\\" }
|
|
197
|
+
],
|
|
198
|
+
heredocs: [
|
|
199
|
+
{ opener: `<<[~-]${RUBY_HEREDOC_ID}`, indentedTerminator: true },
|
|
200
|
+
{ opener: `<<${RUBY_HEREDOC_ID}`, indentedTerminator: false }
|
|
201
|
+
],
|
|
202
|
+
percentLiterals: true
|
|
203
|
+
};
|
|
204
|
+
var SWIFT_INTERPOLATION = { start: "\\(", end: ")" };
|
|
205
|
+
var SWIFT_ROW = {
|
|
206
|
+
lineComments: ["//"],
|
|
207
|
+
blockComments: [NESTED_SLASH_STAR_COMMENT],
|
|
208
|
+
strings: [
|
|
209
|
+
{ open: '"""', close: '"""', escape: "\\", closeAloneOnLine: true, interpolation: SWIFT_INTERPOLATION },
|
|
210
|
+
{ open: '"', close: '"', escape: "\\", interpolation: SWIFT_INTERPOLATION },
|
|
211
|
+
{ hashes: true, open: '"""', close: '"""', closeAloneOnLine: true },
|
|
212
|
+
{ hashes: true, open: '"', close: '"' }
|
|
213
|
+
]
|
|
214
|
+
};
|
|
215
|
+
var KOTLIN_ROW = {
|
|
216
|
+
lineComments: ["//"],
|
|
217
|
+
blockComments: [NESTED_SLASH_STAR_COMMENT],
|
|
218
|
+
strings: [
|
|
219
|
+
{ open: '"""', close: '"""', interpolation: { start: "${", end: "}" } },
|
|
220
|
+
{ open: '"', close: '"', escape: "\\", interpolation: { start: "${", end: "}" } },
|
|
221
|
+
{ open: "'", close: "'", escape: "\\" }
|
|
222
|
+
]
|
|
223
|
+
};
|
|
224
|
+
var ZIG_ROW = {
|
|
225
|
+
lineComments: ["//"],
|
|
226
|
+
blockComments: [],
|
|
227
|
+
strings: [
|
|
228
|
+
{ open: '"', close: '"', escape: "\\" },
|
|
229
|
+
{ open: "'", close: "'", escape: "\\" }
|
|
230
|
+
],
|
|
231
|
+
zigMultiline: true
|
|
232
|
+
};
|
|
233
|
+
var CSS_FAMILY_ROW = {
|
|
234
|
+
lineComments: [],
|
|
235
|
+
blockComments: [SLASH_STAR_COMMENT],
|
|
236
|
+
strings: [
|
|
237
|
+
{ open: "'", close: "'", escape: "\\" },
|
|
238
|
+
{ open: '"', close: '"', escape: "\\" }
|
|
239
|
+
]
|
|
240
|
+
};
|
|
241
|
+
var C_FAMILY_ROW = {
|
|
242
|
+
lineComments: ["//"],
|
|
243
|
+
blockComments: [SLASH_STAR_COMMENT],
|
|
244
|
+
strings: [
|
|
245
|
+
{ open: '"', close: '"', escape: "\\" },
|
|
246
|
+
{ open: "'", close: "'", escape: "\\" }
|
|
247
|
+
]
|
|
248
|
+
};
|
|
249
|
+
var JAVA_ROW = {
|
|
250
|
+
lineComments: ["//"],
|
|
251
|
+
blockComments: [SLASH_STAR_COMMENT],
|
|
252
|
+
strings: [
|
|
253
|
+
{ open: '"""', close: '"""', escape: "\\" },
|
|
254
|
+
{ open: '"', close: '"', escape: "\\" },
|
|
255
|
+
{ open: "'", close: "'", escape: "\\" }
|
|
256
|
+
]
|
|
257
|
+
};
|
|
258
|
+
var SQL_ROW = {
|
|
259
|
+
lineComments: ["--"],
|
|
260
|
+
blockComments: [SLASH_STAR_COMMENT],
|
|
261
|
+
strings: [
|
|
262
|
+
{ open: "'", close: "'", doubled: true },
|
|
263
|
+
{ open: '"', close: '"', doubled: true }
|
|
264
|
+
]
|
|
265
|
+
};
|
|
266
|
+
var TRIVIA_ROWS = {
|
|
267
|
+
js: JS_LIKE_ROW,
|
|
268
|
+
ts: JS_LIKE_ROW,
|
|
269
|
+
tsx: JS_LIKE_ROW,
|
|
270
|
+
javascript: JS_LIKE_ROW,
|
|
271
|
+
typescript: JS_LIKE_ROW,
|
|
272
|
+
jsx: JS_LIKE_ROW,
|
|
273
|
+
python: PYTHON_ROW,
|
|
274
|
+
csharp: CSHARP_ROW,
|
|
275
|
+
go: GO_ROW,
|
|
276
|
+
rust: RUST_ROW,
|
|
277
|
+
php: PHP_ROW,
|
|
278
|
+
ruby: RUBY_ROW,
|
|
279
|
+
swift: SWIFT_ROW,
|
|
280
|
+
kotlin: KOTLIN_ROW,
|
|
281
|
+
zig: ZIG_ROW,
|
|
282
|
+
css: CSS_FAMILY_ROW,
|
|
283
|
+
less: CSS_FAMILY_ROW,
|
|
284
|
+
scss: CSS_FAMILY_ROW,
|
|
285
|
+
c: C_FAMILY_ROW,
|
|
286
|
+
cpp: C_FAMILY_ROW,
|
|
287
|
+
java: JAVA_ROW,
|
|
288
|
+
sql: SQL_ROW
|
|
289
|
+
};
|
|
290
|
+
function triviaRowFor(languageId) {
|
|
291
|
+
return TRIVIA_ROWS[languageId] ?? JS_LIKE_ROW;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// dist/util/trivia.js
|
|
295
|
+
function maskTrivia(source, languageId, options) {
|
|
296
|
+
const mask = buildMarkedMask(source, languageId, {
|
|
297
|
+
maskStrings: options?.maskStrings ?? true,
|
|
298
|
+
mode: "render"
|
|
299
|
+
});
|
|
300
|
+
const chars = source.split("");
|
|
301
|
+
for (let i = 0; i < chars.length; i += 1) {
|
|
302
|
+
const ch = chars[i];
|
|
303
|
+
if (mask[i] && ch !== "\n" && ch !== "\r")
|
|
304
|
+
chars[i] = " ";
|
|
305
|
+
}
|
|
306
|
+
return chars.join("");
|
|
307
|
+
}
|
|
308
|
+
function buildMarkedMask(source, languageId, options) {
|
|
309
|
+
const row = triviaRowFor(languageId);
|
|
310
|
+
const mask = new Uint8Array(source.length);
|
|
311
|
+
const starters = rowStarters(row);
|
|
312
|
+
let index = 0;
|
|
313
|
+
while (index < source.length) {
|
|
314
|
+
if (!starters.has(source[index] ?? "")) {
|
|
315
|
+
index += 1;
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
const commentEnd = commentSpanEnd(source, row, index);
|
|
319
|
+
if (commentEnd !== null) {
|
|
320
|
+
for (let i = index; i < commentEnd; i += 1)
|
|
321
|
+
mask[i] = 1;
|
|
322
|
+
index = commentEnd;
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
if (!options.maskStrings) {
|
|
326
|
+
const stringEnd = stringSpanEnd(source, row, index);
|
|
327
|
+
if (stringEnd !== null) {
|
|
328
|
+
index = stringEnd;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
index += 1;
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
const construct = nextTriviaConstruct(source, row, index);
|
|
335
|
+
if (!construct) {
|
|
336
|
+
index += 1;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
for (const [start, end] of constructSpans(construct, options.mode)) {
|
|
340
|
+
for (let i = start; i < end; i += 1)
|
|
341
|
+
mask[i] = 1;
|
|
342
|
+
}
|
|
343
|
+
index = construct.end;
|
|
344
|
+
}
|
|
345
|
+
return mask;
|
|
346
|
+
}
|
|
347
|
+
function constructSpans(construct, mode) {
|
|
348
|
+
if (construct.delimitersAreTrivia || mode === "full")
|
|
349
|
+
return [[construct.start, construct.end]];
|
|
350
|
+
if (mode === "render")
|
|
351
|
+
return construct.renderSpans;
|
|
352
|
+
return construct.maskSpans;
|
|
353
|
+
}
|
|
354
|
+
var starterCache = /* @__PURE__ */ new WeakMap();
|
|
355
|
+
var prefixRegexCache = /* @__PURE__ */ new WeakMap();
|
|
356
|
+
var openerRegexCache = /* @__PURE__ */ new WeakMap();
|
|
357
|
+
function rowStarters(row) {
|
|
358
|
+
const cached = starterCache.get(row);
|
|
359
|
+
if (cached)
|
|
360
|
+
return cached;
|
|
361
|
+
const starters = /* @__PURE__ */ new Set();
|
|
362
|
+
for (const prefix of row.lineComments)
|
|
363
|
+
starters.add(prefix[0] ?? "");
|
|
364
|
+
for (const comment of row.blockComments)
|
|
365
|
+
starters.add(comment.open[0] ?? "");
|
|
366
|
+
for (const form of row.strings) {
|
|
367
|
+
if (form.prefix) {
|
|
368
|
+
for (const ch of literalCharsInRegexSource(form.prefix))
|
|
369
|
+
starters.add(ch);
|
|
370
|
+
}
|
|
371
|
+
if (form.hashes)
|
|
372
|
+
starters.add("#");
|
|
373
|
+
starters.add(form.open[0] ?? "");
|
|
374
|
+
}
|
|
375
|
+
if (row.heredocs) {
|
|
376
|
+
for (const heredoc of row.heredocs)
|
|
377
|
+
starters.add(heredoc.opener[0] ?? "");
|
|
378
|
+
}
|
|
379
|
+
if (row.percentLiterals)
|
|
380
|
+
starters.add("%");
|
|
381
|
+
if (row.zigMultiline)
|
|
382
|
+
starters.add("\\");
|
|
383
|
+
starterCache.set(row, starters);
|
|
384
|
+
return starters;
|
|
385
|
+
}
|
|
386
|
+
function literalCharsInRegexSource(prefixSource) {
|
|
387
|
+
const bare = prefixSource.replace(/[()|[\]?]/g, "");
|
|
388
|
+
return Array.from(bare.match(/[A-Za-z0-9@$'"`#\\%<>&*=~,^!;:-]/g) ?? []);
|
|
389
|
+
}
|
|
390
|
+
function prefixRegexFor(form) {
|
|
391
|
+
let regex = prefixRegexCache.get(form);
|
|
392
|
+
if (!regex) {
|
|
393
|
+
regex = new RegExp(form.prefix ?? "", "y");
|
|
394
|
+
prefixRegexCache.set(form, regex);
|
|
395
|
+
}
|
|
396
|
+
return regex;
|
|
397
|
+
}
|
|
398
|
+
function openerRegexFor(heredoc) {
|
|
399
|
+
let regex = openerRegexCache.get(heredoc);
|
|
400
|
+
if (!regex) {
|
|
401
|
+
regex = new RegExp(heredoc.opener, "y");
|
|
402
|
+
openerRegexCache.set(heredoc, regex);
|
|
403
|
+
}
|
|
404
|
+
return regex;
|
|
405
|
+
}
|
|
406
|
+
function fullRangeConstruct(start, end, delimitersAreTrivia) {
|
|
407
|
+
return {
|
|
408
|
+
start,
|
|
409
|
+
end,
|
|
410
|
+
renderSpans: [[start, end]],
|
|
411
|
+
maskSpans: [[start, end]],
|
|
412
|
+
delimitersAreTrivia
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function nextTriviaConstruct(source, row, index) {
|
|
416
|
+
const commentEnd = commentSpanEnd(source, row, index);
|
|
417
|
+
if (commentEnd !== null)
|
|
418
|
+
return fullRangeConstruct(index, commentEnd, true);
|
|
419
|
+
const heredocConstruct = heredocConstructAt(source, row, index);
|
|
420
|
+
if (heredocConstruct !== null)
|
|
421
|
+
return heredocConstruct;
|
|
422
|
+
const stringConstruct = stringConstructAt(source, row, index);
|
|
423
|
+
if (stringConstruct !== null)
|
|
424
|
+
return stringConstruct;
|
|
425
|
+
if (row.percentLiterals) {
|
|
426
|
+
const percentConstruct = percentLiteralConstructAt(source, index);
|
|
427
|
+
if (percentConstruct !== null)
|
|
428
|
+
return percentConstruct;
|
|
429
|
+
}
|
|
430
|
+
if (row.zigMultiline && source.startsWith("\\\\", index)) {
|
|
431
|
+
return zigMultilineConstruct(source, index);
|
|
432
|
+
}
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
function commentSpanEnd(source, row, index) {
|
|
436
|
+
for (const prefix of row.lineComments) {
|
|
437
|
+
if (source.startsWith(prefix, index))
|
|
438
|
+
return lineCommentEnd(source, index + prefix.length);
|
|
439
|
+
}
|
|
440
|
+
for (const comment of row.blockComments) {
|
|
441
|
+
if (comment.lineStartOnly) {
|
|
442
|
+
const atLineStart = index === 0 || source[index - 1] === "\n";
|
|
443
|
+
if (!atLineStart || !source.startsWith(comment.open, index))
|
|
444
|
+
continue;
|
|
445
|
+
return lineStartOnlyBlockCommentEnd(source, index + comment.open.length, comment.close);
|
|
446
|
+
}
|
|
447
|
+
if (!source.startsWith(comment.open, index))
|
|
448
|
+
continue;
|
|
449
|
+
return blockCommentEnd(source, index + comment.open.length, comment, 1);
|
|
450
|
+
}
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
function lineCommentEnd(source, index) {
|
|
454
|
+
let end = index;
|
|
455
|
+
while (end < source.length && source[end] !== "\n" && source[end] !== "\r")
|
|
456
|
+
end += 1;
|
|
457
|
+
return end;
|
|
458
|
+
}
|
|
459
|
+
function blockCommentEnd(source, index, comment, depth) {
|
|
460
|
+
let cursor = index;
|
|
461
|
+
let remaining = depth;
|
|
462
|
+
while (cursor < source.length && remaining > 0) {
|
|
463
|
+
if (comment.nested && source.startsWith(comment.open, cursor)) {
|
|
464
|
+
remaining += 1;
|
|
465
|
+
cursor += comment.open.length;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (source.startsWith(comment.close, cursor)) {
|
|
469
|
+
remaining -= 1;
|
|
470
|
+
cursor += comment.close.length;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
cursor += 1;
|
|
474
|
+
}
|
|
475
|
+
return remaining > 0 ? source.length : cursor;
|
|
476
|
+
}
|
|
477
|
+
function lineStartOnlyBlockCommentEnd(source, index, close) {
|
|
478
|
+
let lineStart = index;
|
|
479
|
+
while (lineStart < source.length) {
|
|
480
|
+
if (source.startsWith(close, lineStart))
|
|
481
|
+
return lineStart + close.length;
|
|
482
|
+
const newline = source.indexOf("\n", lineStart);
|
|
483
|
+
if (newline < 0)
|
|
484
|
+
return source.length;
|
|
485
|
+
lineStart = newline + 1;
|
|
486
|
+
}
|
|
487
|
+
return source.length;
|
|
488
|
+
}
|
|
489
|
+
function precededByIdentifier(source, index) {
|
|
490
|
+
if (index <= 0)
|
|
491
|
+
return false;
|
|
492
|
+
return /[\p{ID_Continue}$_]/u.test(source[index - 1] ?? "");
|
|
493
|
+
}
|
|
494
|
+
function stringSpanEnd(source, row, index) {
|
|
495
|
+
return stringConstructAt(source, row, index)?.end ?? null;
|
|
496
|
+
}
|
|
497
|
+
function stringConstructAt(source, row, index) {
|
|
498
|
+
for (const form of row.strings) {
|
|
499
|
+
const construct = quotedStringConstruct(source, row, form, index);
|
|
500
|
+
if (construct !== null)
|
|
501
|
+
return construct;
|
|
502
|
+
}
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
function quotedStringConstruct(source, row, form, index) {
|
|
506
|
+
let cursor = index;
|
|
507
|
+
if (form.prefix) {
|
|
508
|
+
const prefixRe = prefixRegexFor(form);
|
|
509
|
+
prefixRe.lastIndex = cursor;
|
|
510
|
+
if (!prefixRe.exec(source))
|
|
511
|
+
return null;
|
|
512
|
+
cursor = prefixRe.lastIndex;
|
|
513
|
+
if (precededByIdentifier(source, index))
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
let hashCount = 0;
|
|
517
|
+
if (form.hashes) {
|
|
518
|
+
while (source[cursor] === "#") {
|
|
519
|
+
hashCount += 1;
|
|
520
|
+
cursor += 1;
|
|
521
|
+
}
|
|
522
|
+
if (precededByIdentifier(source, index))
|
|
523
|
+
return null;
|
|
524
|
+
if (!source.startsWith(form.open, cursor))
|
|
525
|
+
return null;
|
|
526
|
+
} else if (form.charLike) {
|
|
527
|
+
const charEnd = charLiteralEnd(source, cursor, form);
|
|
528
|
+
if (charEnd === null)
|
|
529
|
+
return null;
|
|
530
|
+
const body2 = [cursor + 1, charEnd - 1];
|
|
531
|
+
return {
|
|
532
|
+
start: index,
|
|
533
|
+
end: charEnd,
|
|
534
|
+
renderSpans: body2[0] < body2[1] ? [body2] : [],
|
|
535
|
+
maskSpans: [[index, charEnd]],
|
|
536
|
+
delimitersAreTrivia: false
|
|
537
|
+
};
|
|
538
|
+
} else if (form.quoteRun) {
|
|
539
|
+
let run = 0;
|
|
540
|
+
while (source[cursor + run] === form.open[0])
|
|
541
|
+
run += 1;
|
|
542
|
+
if (run < form.open.length)
|
|
543
|
+
return null;
|
|
544
|
+
const scanned = quoteRunStringEnd(source, cursor + run, form.open[0] ?? '"', run);
|
|
545
|
+
const bodyStart2 = cursor + run;
|
|
546
|
+
const body2 = [bodyStart2, scanned.closeStart];
|
|
547
|
+
return {
|
|
548
|
+
start: index,
|
|
549
|
+
end: scanned.end,
|
|
550
|
+
renderSpans: body2[0] < body2[1] ? [body2] : [],
|
|
551
|
+
maskSpans: [[index, scanned.end]],
|
|
552
|
+
delimitersAreTrivia: false
|
|
553
|
+
};
|
|
554
|
+
} else {
|
|
555
|
+
if (!source.startsWith(form.open, cursor))
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
558
|
+
const bodyStart = cursor + form.open.length;
|
|
559
|
+
const body = collectQuotedBody(source, row, form, bodyStart, form.close, hashCount);
|
|
560
|
+
return {
|
|
561
|
+
start: index,
|
|
562
|
+
end: body.end,
|
|
563
|
+
renderSpans: bodyStart < body.closeStart ? [[bodyStart, body.closeStart]] : [],
|
|
564
|
+
maskSpans: [[index, bodyStart], ...body.segments, [body.closeStart, body.end]],
|
|
565
|
+
delimitersAreTrivia: false
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function collectQuotedBody(source, row, form, start, close, hashCount) {
|
|
569
|
+
const segments = [];
|
|
570
|
+
let cursor = start;
|
|
571
|
+
let segmentStart = start;
|
|
572
|
+
const pushSegment = (upTo) => {
|
|
573
|
+
if (segmentStart < upTo)
|
|
574
|
+
segments.push([segmentStart, upTo]);
|
|
575
|
+
};
|
|
576
|
+
while (cursor < source.length) {
|
|
577
|
+
const ch = source[cursor];
|
|
578
|
+
if (form.interpolation) {
|
|
579
|
+
const interpolation = form.interpolation;
|
|
580
|
+
const doubled = interpolation.doubled && source.startsWith(interpolation.start, cursor) && source.startsWith(interpolation.start, cursor + interpolation.start.length);
|
|
581
|
+
if (doubled) {
|
|
582
|
+
cursor += interpolation.start.length * 2;
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
if (source.startsWith(interpolation.start, cursor)) {
|
|
586
|
+
if (interpolation.excludeFromMask) {
|
|
587
|
+
pushSegment(cursor);
|
|
588
|
+
const inner = collectInterpolationSpans(source, row, cursor, interpolation);
|
|
589
|
+
cursor = inner.end;
|
|
590
|
+
segmentStart = cursor;
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
cursor = interpolationEnd(source, row, cursor, interpolation);
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (form.escape && ch === form.escape) {
|
|
598
|
+
cursor += 2;
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
if (form.doubled && source.startsWith(close, cursor) && source.startsWith(close, cursor + close.length)) {
|
|
602
|
+
cursor += close.length * 2;
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
if (source.startsWith(close, cursor)) {
|
|
606
|
+
let closeEnd = cursor + close.length;
|
|
607
|
+
if (hashCount > 0) {
|
|
608
|
+
let hashes = 0;
|
|
609
|
+
while (source[closeEnd + hashes] === "#")
|
|
610
|
+
hashes += 1;
|
|
611
|
+
if (hashes < hashCount) {
|
|
612
|
+
cursor += 1;
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
closeEnd += hashCount;
|
|
616
|
+
}
|
|
617
|
+
if (form.closeAloneOnLine && !closeAloneOnItsLine(source, cursor)) {
|
|
618
|
+
cursor += 1;
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
pushSegment(cursor);
|
|
622
|
+
return { end: closeEnd, closeStart: cursor, segments };
|
|
623
|
+
}
|
|
624
|
+
cursor += 1;
|
|
625
|
+
}
|
|
626
|
+
pushSegment(source.length);
|
|
627
|
+
return { end: source.length, closeStart: source.length, segments };
|
|
628
|
+
}
|
|
629
|
+
function charLiteralEnd(source, quoteIndex, form) {
|
|
630
|
+
let cursor = quoteIndex + 1;
|
|
631
|
+
if (cursor >= source.length)
|
|
632
|
+
return null;
|
|
633
|
+
if (source[cursor] === form.escape) {
|
|
634
|
+
while (cursor < source.length && source[cursor] !== "'") {
|
|
635
|
+
cursor += source[cursor] === "\\" ? 2 : 1;
|
|
636
|
+
}
|
|
637
|
+
return cursor < source.length ? cursor + 1 : cursor;
|
|
638
|
+
}
|
|
639
|
+
if (source[cursor + 1] === "'")
|
|
640
|
+
return cursor + 2;
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
function quoteRunStringEnd(source, index, quote, runLength) {
|
|
644
|
+
let cursor = index;
|
|
645
|
+
while (cursor < source.length) {
|
|
646
|
+
if (source[cursor] !== quote) {
|
|
647
|
+
cursor += 1;
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
let run = 0;
|
|
651
|
+
while (source[cursor + run] === quote)
|
|
652
|
+
run += 1;
|
|
653
|
+
if (run >= runLength)
|
|
654
|
+
return { end: cursor + run, closeStart: cursor };
|
|
655
|
+
cursor += run;
|
|
656
|
+
}
|
|
657
|
+
return { end: source.length, closeStart: source.length };
|
|
658
|
+
}
|
|
659
|
+
function closeAloneOnItsLine(source, closeIndex) {
|
|
660
|
+
const lineStart = source.lastIndexOf("\n", closeIndex - 1) + 1;
|
|
661
|
+
for (let i = lineStart; i < closeIndex; i += 1) {
|
|
662
|
+
const ch = source[i];
|
|
663
|
+
if (ch !== " " && ch !== " " && ch !== "\r")
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
return true;
|
|
667
|
+
}
|
|
668
|
+
function interpolationEnd(source, row, start, interpolation) {
|
|
669
|
+
return collectInterpolationSpans(source, row, start, interpolation).end;
|
|
670
|
+
}
|
|
671
|
+
function collectInterpolationSpans(source, row, start, interpolation) {
|
|
672
|
+
const nestOpen = interpolation.start[interpolation.start.length - 1] ?? "";
|
|
673
|
+
const spans = [];
|
|
674
|
+
let depth = 1;
|
|
675
|
+
let cursor = start + interpolation.start.length;
|
|
676
|
+
while (cursor < source.length) {
|
|
677
|
+
const ch = source[cursor];
|
|
678
|
+
if (source.startsWith(interpolation.end, cursor)) {
|
|
679
|
+
depth -= 1;
|
|
680
|
+
if (!depth)
|
|
681
|
+
return { end: cursor + interpolation.end.length, spans };
|
|
682
|
+
cursor += interpolation.end.length;
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
if (ch === nestOpen) {
|
|
686
|
+
depth += 1;
|
|
687
|
+
cursor += 1;
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
const commentEnd = commentSpanEnd(source, row, cursor);
|
|
691
|
+
if (commentEnd !== null) {
|
|
692
|
+
spans.push([cursor, commentEnd]);
|
|
693
|
+
cursor = commentEnd;
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
const nested = stringConstructAt(source, row, cursor);
|
|
697
|
+
if (nested !== null) {
|
|
698
|
+
spans.push(...nested.maskSpans);
|
|
699
|
+
cursor = nested.end;
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
cursor += 1;
|
|
703
|
+
}
|
|
704
|
+
return { end: source.length, spans };
|
|
705
|
+
}
|
|
706
|
+
function heredocConstructAt(source, row, index) {
|
|
707
|
+
if (!row.heredocs)
|
|
708
|
+
return null;
|
|
709
|
+
for (const heredoc of row.heredocs) {
|
|
710
|
+
const openerRe = openerRegexFor(heredoc);
|
|
711
|
+
openerRe.lastIndex = index;
|
|
712
|
+
const match = openerRe.exec(source);
|
|
713
|
+
if (!match)
|
|
714
|
+
continue;
|
|
715
|
+
if (precededByIdentifier(source, index))
|
|
716
|
+
continue;
|
|
717
|
+
const terminatorId = match.slice(1).find((id) => id !== void 0) ?? "";
|
|
718
|
+
if (!terminatorId)
|
|
719
|
+
continue;
|
|
720
|
+
const indentedTerminator = heredoc.indentedTerminator ?? false;
|
|
721
|
+
const scanned = heredocBodyEnd(source, match.index + match[0].length, terminatorId, indentedTerminator);
|
|
722
|
+
const bodyStart = match.index + match[0].length;
|
|
723
|
+
return {
|
|
724
|
+
start: index,
|
|
725
|
+
end: scanned.end,
|
|
726
|
+
renderSpans: bodyStart < scanned.terminatorStart ? [[bodyStart, scanned.terminatorStart]] : [],
|
|
727
|
+
maskSpans: [[index, scanned.end]],
|
|
728
|
+
delimitersAreTrivia: false
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
return null;
|
|
732
|
+
}
|
|
733
|
+
function heredocBodyEnd(source, afterOpener, terminatorId, indentedTerminator) {
|
|
734
|
+
let lineStart = source.indexOf("\n", afterOpener);
|
|
735
|
+
if (lineStart < 0)
|
|
736
|
+
return { end: source.length, terminatorStart: source.length };
|
|
737
|
+
lineStart += 1;
|
|
738
|
+
while (lineStart < source.length) {
|
|
739
|
+
let cursor = lineStart;
|
|
740
|
+
if (indentedTerminator) {
|
|
741
|
+
while (source[cursor] === " " || source[cursor] === " " || source[cursor] === "\r")
|
|
742
|
+
cursor += 1;
|
|
743
|
+
}
|
|
744
|
+
if (source.startsWith(terminatorId, cursor)) {
|
|
745
|
+
const afterId = cursor + terminatorId.length;
|
|
746
|
+
const next = source[afterId];
|
|
747
|
+
if (next === void 0 || !/[\p{ID_Continue}$_]/u.test(next)) {
|
|
748
|
+
return { end: afterId, terminatorStart: cursor };
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
const newline = source.indexOf("\n", lineStart);
|
|
752
|
+
if (newline < 0)
|
|
753
|
+
return { end: source.length, terminatorStart: source.length };
|
|
754
|
+
lineStart = newline + 1;
|
|
755
|
+
}
|
|
756
|
+
return { end: source.length, terminatorStart: source.length };
|
|
757
|
+
}
|
|
758
|
+
var PERCENT_LITERAL_TYPES = "qQwWrsxiI";
|
|
759
|
+
var PERCENT_BRACKET_PAIRS = { "(": ")", "[": "]", "{": "}", "<": ">" };
|
|
760
|
+
function percentLiteralConstructAt(source, index) {
|
|
761
|
+
if (source[index] !== "%")
|
|
762
|
+
return null;
|
|
763
|
+
const typeChar = source[index + 1];
|
|
764
|
+
if (!typeChar || !PERCENT_LITERAL_TYPES.includes(typeChar))
|
|
765
|
+
return null;
|
|
766
|
+
const openChar = source[index + 2];
|
|
767
|
+
if (!openChar)
|
|
768
|
+
return null;
|
|
769
|
+
if (/[A-Za-z0-9 \t]/.test(openChar))
|
|
770
|
+
return null;
|
|
771
|
+
if (precededByIdentifier(source, index))
|
|
772
|
+
return null;
|
|
773
|
+
const closeChar = PERCENT_BRACKET_PAIRS[openChar];
|
|
774
|
+
const bodyStart = index + 3;
|
|
775
|
+
let cursor = bodyStart;
|
|
776
|
+
let depth = 1;
|
|
777
|
+
while (cursor < source.length) {
|
|
778
|
+
const ch = source[cursor];
|
|
779
|
+
if (ch === "\\") {
|
|
780
|
+
cursor += 2;
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
if (closeChar !== void 0) {
|
|
784
|
+
if (ch === openChar) {
|
|
785
|
+
depth += 1;
|
|
786
|
+
} else if (ch === closeChar) {
|
|
787
|
+
depth -= 1;
|
|
788
|
+
if (!depth) {
|
|
789
|
+
return {
|
|
790
|
+
start: index,
|
|
791
|
+
end: cursor + 1,
|
|
792
|
+
renderSpans: bodyStart < cursor ? [[bodyStart, cursor]] : [],
|
|
793
|
+
maskSpans: [[index, cursor + 1]],
|
|
794
|
+
delimitersAreTrivia: false
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
} else if (ch === openChar) {
|
|
799
|
+
return {
|
|
800
|
+
start: index,
|
|
801
|
+
end: cursor + 1,
|
|
802
|
+
renderSpans: bodyStart < cursor ? [[bodyStart, cursor]] : [],
|
|
803
|
+
maskSpans: [[index, cursor + 1]],
|
|
804
|
+
delimitersAreTrivia: false
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
cursor += 1;
|
|
808
|
+
}
|
|
809
|
+
return {
|
|
810
|
+
start: index,
|
|
811
|
+
end: source.length,
|
|
812
|
+
renderSpans: bodyStart < source.length ? [[bodyStart, source.length]] : [],
|
|
813
|
+
maskSpans: [[index, source.length]],
|
|
814
|
+
delimitersAreTrivia: false
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
function zigMultilineConstruct(source, start) {
|
|
818
|
+
const renderSpans = [];
|
|
819
|
+
let cursor = start;
|
|
820
|
+
let end = source.length;
|
|
821
|
+
while (cursor < source.length) {
|
|
822
|
+
let lineEnd = cursor;
|
|
823
|
+
while (lineEnd < source.length && source[lineEnd] !== "\n")
|
|
824
|
+
lineEnd += 1;
|
|
825
|
+
if (cursor + 2 < lineEnd)
|
|
826
|
+
renderSpans.push([cursor + 2, lineEnd]);
|
|
827
|
+
if (lineEnd >= source.length) {
|
|
828
|
+
end = source.length;
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
let probe = lineEnd + 1;
|
|
832
|
+
while (probe < source.length && (source[probe] === " " || source[probe] === " " || source[probe] === "\r")) {
|
|
833
|
+
probe += 1;
|
|
834
|
+
}
|
|
835
|
+
if (source[probe] === "\\" && source[probe + 1] === "\\") {
|
|
836
|
+
cursor = probe;
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
end = lineEnd;
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
return {
|
|
843
|
+
start,
|
|
844
|
+
end,
|
|
845
|
+
renderSpans,
|
|
846
|
+
maskSpans: [[start, end]],
|
|
847
|
+
delimitersAreTrivia: false
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// dist/util/comments.js
|
|
852
|
+
function stripJsLikeComments(src) {
|
|
853
|
+
return maskTrivia(src, "js", { maskStrings: false });
|
|
854
|
+
}
|
|
855
|
+
function maskJsLikeCommentsAndStrings(src) {
|
|
856
|
+
return maskTrivia(src, "js");
|
|
857
|
+
}
|
|
858
|
+
|
|
78
859
|
// dist/languages/definitions/js-family.js
|
|
860
|
+
function isStatementLevelTypeKeywordClause(clause) {
|
|
861
|
+
const trimmed = clause.trim();
|
|
862
|
+
if (!/^type(?:\s+|(?=\{))/.test(trimmed))
|
|
863
|
+
return false;
|
|
864
|
+
return !trimmed.slice(4).trimStart().startsWith(",");
|
|
865
|
+
}
|
|
866
|
+
function isEcmaScriptTypeOnlyStatement(stmtText) {
|
|
867
|
+
const text = stripJsLikeComments(stmtText).trim();
|
|
868
|
+
const fromMatch = /^(?:import|export)\b\s*([\s\S]*?)\bfrom\s*["']/.exec(text);
|
|
869
|
+
if (fromMatch)
|
|
870
|
+
return isStatementLevelTypeKeywordClause(fromMatch[1] ?? "");
|
|
871
|
+
return /^(?:import|export)\b\s+type(?:\s+|(?=\{|$))/.test(text);
|
|
872
|
+
}
|
|
873
|
+
var ECMASCRIPT_DECLARATION_NAME_PARENTS = [
|
|
874
|
+
"function_declaration",
|
|
875
|
+
"generator_function_declaration",
|
|
876
|
+
"class_declaration",
|
|
877
|
+
"import_specifier",
|
|
878
|
+
"namespace_import",
|
|
879
|
+
"import_clause",
|
|
880
|
+
// Method names in classes: needed so that editing a method name is
|
|
881
|
+
// classified as a definition change, not an unrecognised node.
|
|
882
|
+
"method_definition",
|
|
883
|
+
// A named function expression binds its own name; `$scope.x = function x() {}` and
|
|
884
|
+
// `const f = function inner() {}` are the common shapes.
|
|
885
|
+
"function_expression"
|
|
886
|
+
];
|
|
887
|
+
var ECMASCRIPT_BLOCK_SCOPE_TYPES = ["program", "block", "class_body", "class_static_block"];
|
|
888
|
+
var ECMASCRIPT_FUNCTION_SCOPE_TYPES = [
|
|
889
|
+
"function_declaration",
|
|
890
|
+
"generator_function_declaration",
|
|
891
|
+
"function_expression",
|
|
892
|
+
"arrow_function",
|
|
893
|
+
"method_definition"
|
|
894
|
+
];
|
|
895
|
+
function isEcmaScriptVariableDeclaratorName(node) {
|
|
896
|
+
return isNameFieldOnParent(node, ["variable_declarator"]);
|
|
897
|
+
}
|
|
898
|
+
function isEcmaScriptFieldDefinitionName(node, parentType) {
|
|
899
|
+
return isNameOrPropertyFieldOnParent(node, [parentType]);
|
|
900
|
+
}
|
|
79
901
|
var ECMASCRIPT_CONTROL_SPLIT_POINTS = [
|
|
80
902
|
"if_statement",
|
|
81
903
|
"else_clause",
|
|
@@ -205,17 +1027,17 @@ var BASE_STRUCTURE = {
|
|
|
205
1027
|
};
|
|
206
1028
|
var BASE_GRAPH = {
|
|
207
1029
|
imports: `
|
|
208
|
-
(import_statement (string) @
|
|
1030
|
+
(import_statement (string) @from) @stmt
|
|
209
1031
|
;; import x = require("...") is represented via import_require_clause
|
|
210
|
-
(import_statement (import_require_clause (string) @
|
|
211
|
-
(export_statement (string) @
|
|
212
|
-
(call_expression function: (import) arguments: (arguments (string) @
|
|
1032
|
+
(import_statement (import_require_clause (string) @from)) @stmt
|
|
1033
|
+
(export_statement (string) @from) @stmt
|
|
1034
|
+
(call_expression function: (import) arguments: (arguments (string) @from)) @stmt
|
|
213
1035
|
;; declare module "foo" {} \u2014 ambient module augmentations create a type-only
|
|
214
1036
|
;; dependency on the named module and must appear in the file graph so that
|
|
215
1037
|
;; changes to "foo" propagate to augmenting files (and vice-versa).
|
|
216
1038
|
;; The inner node type is "module" (not "module_declaration"); its string
|
|
217
1039
|
;; child uses field-name "name".
|
|
218
|
-
(ambient_declaration (module name: (string) @
|
|
1040
|
+
(ambient_declaration (module name: (string) @from)) @stmt
|
|
219
1041
|
`,
|
|
220
1042
|
exports: `
|
|
221
1043
|
(export_statement) @stmt
|
|
@@ -239,6 +1061,7 @@ var BASE_GRAPH = {
|
|
|
239
1061
|
(export_statement (export_clause (export_specifier "type"? @type_kw name: (identifier) @src !alias)) (string) @from) @stmt
|
|
240
1062
|
(export_statement (export_clause (export_specifier "type"? @type_kw name: (identifier) @src alias: (identifier) @alias))) @stmt
|
|
241
1063
|
(export_statement (export_clause (export_specifier "type"? @type_kw name: (identifier) @src !alias))) @stmt
|
|
1064
|
+
(export_statement "*" @wild (string) @from) @stmt
|
|
242
1065
|
(export_statement (string) @from) @stmt
|
|
243
1066
|
(export_assignment (identifier) @ts_export_assign)
|
|
244
1067
|
`,
|
|
@@ -278,53 +1101,37 @@ var BASE_HELPERS = {
|
|
|
278
1101
|
shorthandPropertyIdentifier: ["shorthand_property_identifier", "shorthand_property_identifier_pattern"],
|
|
279
1102
|
memberExpression: "member_expression"
|
|
280
1103
|
},
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (t === "abstract_class_declaration")
|
|
302
|
-
return "class";
|
|
303
|
-
if (t === "interface_declaration")
|
|
304
|
-
return "interface";
|
|
305
|
-
if (t === "type_alias_declaration")
|
|
306
|
-
return "type";
|
|
307
|
-
if (t === "enum_declaration" || t === "internal_module" || t === "module")
|
|
308
|
-
return "type";
|
|
309
|
-
return "variable";
|
|
310
|
-
},
|
|
1104
|
+
// A named function expression's own name is a function-kind binding, matching the
|
|
1105
|
+
// declaration forms; the grammar spells the expression forms without the `_declaration`
|
|
1106
|
+
// suffix (`function_expression`, `generator_function`).
|
|
1107
|
+
classifyDefinition: classifyByParentType({
|
|
1108
|
+
function_declaration: "function",
|
|
1109
|
+
generator_function_declaration: "function",
|
|
1110
|
+
function_expression: "function",
|
|
1111
|
+
generator_function: "function",
|
|
1112
|
+
method_definition: "function",
|
|
1113
|
+
method_signature: "function",
|
|
1114
|
+
abstract_method_signature: "function",
|
|
1115
|
+
function_signature: "function",
|
|
1116
|
+
class_declaration: "class",
|
|
1117
|
+
abstract_class_declaration: "class",
|
|
1118
|
+
interface_declaration: "interface",
|
|
1119
|
+
type_alias_declaration: "type",
|
|
1120
|
+
enum_declaration: "type",
|
|
1121
|
+
internal_module: "type",
|
|
1122
|
+
module: "type"
|
|
1123
|
+
}),
|
|
311
1124
|
isDeclarationName: (node) => {
|
|
312
1125
|
const parent = node.parent;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (parent?.type === "public_field_definition" || parent?.type === "enum_assignment") {
|
|
318
|
-
const name = parent.childForFieldName("name") ?? parent.childForFieldName("property");
|
|
319
|
-
return name?.id === node.id;
|
|
320
|
-
}
|
|
1126
|
+
if (isEcmaScriptVariableDeclaratorName(node))
|
|
1127
|
+
return true;
|
|
1128
|
+
if (isNameOrPropertyFieldOnParent(node, ["public_field_definition", "enum_assignment"]))
|
|
1129
|
+
return true;
|
|
321
1130
|
if (parent?.type === "enum_body") {
|
|
322
1131
|
return node.type === "property_identifier";
|
|
323
1132
|
}
|
|
324
|
-
return
|
|
325
|
-
|
|
326
|
-
"function_declaration",
|
|
327
|
-
"class_declaration",
|
|
1133
|
+
return hasParentType(node, [
|
|
1134
|
+
...ECMASCRIPT_DECLARATION_NAME_PARENTS,
|
|
328
1135
|
"abstract_class_declaration",
|
|
329
1136
|
"interface_declaration",
|
|
330
1137
|
"type_alias_declaration",
|
|
@@ -332,20 +1139,15 @@ var BASE_HELPERS = {
|
|
|
332
1139
|
"function_signature",
|
|
333
1140
|
"internal_module",
|
|
334
1141
|
"module",
|
|
335
|
-
"import_specifier",
|
|
336
|
-
"namespace_import",
|
|
337
|
-
"import_clause",
|
|
338
1142
|
"import_equals_declaration",
|
|
339
1143
|
// Method names in classes and abstract method signatures: needed so
|
|
340
1144
|
// that editing a method name is classified as a definition change.
|
|
341
|
-
"method_definition",
|
|
342
1145
|
"method_signature",
|
|
343
1146
|
"abstract_method_signature",
|
|
344
1147
|
// A named function expression binds its own name inside its body:
|
|
345
1148
|
// `const f = function inner() {}` and `$scope.refresh = function refresh() {}`.
|
|
346
|
-
"function_expression",
|
|
347
1149
|
"generator_function"
|
|
348
|
-
]
|
|
1150
|
+
]);
|
|
349
1151
|
},
|
|
350
1152
|
// Scope construction has structural handling for the ordinary declaration forms. Ambient
|
|
351
1153
|
// overload signatures, `namespace X {}`, and a named function expression's own name are not
|
|
@@ -356,11 +1158,10 @@ var BASE_HELPERS = {
|
|
|
356
1158
|
const parent = node.parent?.type;
|
|
357
1159
|
return parent === "function_signature" || parent === "internal_module" || parent === "module" || parent === "function_expression" || parent === "generator_function";
|
|
358
1160
|
},
|
|
359
|
-
createsBlockScope: (
|
|
360
|
-
|
|
1161
|
+
createsBlockScope: nodeTypeIn([...ECMASCRIPT_BLOCK_SCOPE_TYPES, "enum_body"]),
|
|
1162
|
+
// A generator function expression has its own body scope: without this, its own name
|
|
361
1163
|
// (registered above) and its parameters would land in the enclosing scope.
|
|
362
|
-
|
|
363
|
-
membersAreImplicitlyInScope: false,
|
|
1164
|
+
createsFunctionScope: nodeTypeIn([...ECMASCRIPT_FUNCTION_SCOPE_TYPES, "generator_function"]),
|
|
364
1165
|
supportsCrossModuleSymbols: true
|
|
365
1166
|
};
|
|
366
1167
|
var TYPESCRIPT_DEF = {
|
|
@@ -370,7 +1171,7 @@ var TYPESCRIPT_DEF = {
|
|
|
370
1171
|
graph: BASE_GRAPH,
|
|
371
1172
|
supportsExportFromReferences: true,
|
|
372
1173
|
...BASE_HELPERS,
|
|
373
|
-
isTypeOnly:
|
|
1174
|
+
isTypeOnly: isEcmaScriptTypeOnlyStatement,
|
|
374
1175
|
native: {
|
|
375
1176
|
normalizeQuery: normalizeTypeScriptNativeQuery,
|
|
376
1177
|
authoritativeKinds: ["exports"],
|
|
@@ -392,7 +1193,7 @@ var TSX_DEF = {
|
|
|
392
1193
|
graph: BASE_GRAPH,
|
|
393
1194
|
supportsExportFromReferences: true,
|
|
394
1195
|
...BASE_HELPERS,
|
|
395
|
-
isTypeOnly:
|
|
1196
|
+
isTypeOnly: isEcmaScriptTypeOnlyStatement,
|
|
396
1197
|
native: {
|
|
397
1198
|
normalizeQuery: normalizeTypeScriptNativeQuery,
|
|
398
1199
|
authoritativeKinds: ["exports"],
|
|
@@ -427,10 +1228,10 @@ var JAVASCRIPT_DEF = {
|
|
|
427
1228
|
},
|
|
428
1229
|
graph: {
|
|
429
1230
|
imports: `
|
|
430
|
-
(import_statement (string) @
|
|
431
|
-
(export_statement (string) @
|
|
432
|
-
(call_expression function: (import) arguments: (arguments (string) @
|
|
433
|
-
((call_expression function: (identifier) @fn arguments: (arguments (string) @
|
|
1231
|
+
(import_statement (string) @from) @stmt
|
|
1232
|
+
(export_statement (string) @from) @stmt
|
|
1233
|
+
(call_expression function: (import) arguments: (arguments (string) @from)) @stmt
|
|
1234
|
+
((call_expression function: (identifier) @fn arguments: (arguments (string) @from)) @stmt
|
|
434
1235
|
(#eq? @fn "require"))
|
|
435
1236
|
`,
|
|
436
1237
|
exports: `
|
|
@@ -446,8 +1247,10 @@ var JAVASCRIPT_DEF = {
|
|
|
446
1247
|
(export_statement (export_clause (export_specifier name: (identifier) @src !alias)) (string) @from)
|
|
447
1248
|
(export_statement (export_clause (export_specifier name: (identifier) @src alias: (identifier) @alias)))
|
|
448
1249
|
(export_statement (export_clause (export_specifier name: (identifier) @src !alias)))
|
|
1250
|
+
(export_statement "*" @wild (string) @from)
|
|
449
1251
|
(export_statement (string) @from)
|
|
450
1252
|
;; CJS whole-module export: module.exports = function () {} / = () => {}
|
|
1253
|
+
;; @mod is the identifier module in module.exports, not a specifier; keep it out of GraphImportCapture.
|
|
451
1254
|
((expression_statement (assignment_expression
|
|
452
1255
|
left: (member_expression object: (identifier) @mod property: (property_identifier) @cjs_export_name)
|
|
453
1256
|
right: [ (function) (arrow_function) ] @cjs_fn))
|
|
@@ -532,55 +1335,28 @@ var JAVASCRIPT_DEF = {
|
|
|
532
1335
|
shorthandPropertyIdentifier: ["shorthand_property_identifier", "shorthand_property_identifier_pattern"],
|
|
533
1336
|
memberExpression: "member_expression"
|
|
534
1337
|
},
|
|
535
|
-
classifyDefinition: (
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
return "class";
|
|
547
|
-
return "variable";
|
|
548
|
-
},
|
|
549
|
-
isDeclarationName: (node) => {
|
|
550
|
-
const parent = node.parent;
|
|
551
|
-
const p = parent?.type;
|
|
552
|
-
if (parent?.type === "variable_declarator") {
|
|
553
|
-
return parent.childForFieldName("name")?.id === node.id;
|
|
554
|
-
}
|
|
555
|
-
if (parent?.type === "field_definition") {
|
|
556
|
-
const name = parent.childForFieldName("name") ?? parent.childForFieldName("property");
|
|
557
|
-
return name?.id === node.id;
|
|
558
|
-
}
|
|
559
|
-
return !!p && [
|
|
560
|
-
"function_declaration",
|
|
561
|
-
"generator_function_declaration",
|
|
562
|
-
"class_declaration",
|
|
563
|
-
"import_specifier",
|
|
564
|
-
"namespace_import",
|
|
565
|
-
"import_clause",
|
|
566
|
-
// Method names in classes: needed so that editing a method name is
|
|
567
|
-
// classified as a definition change, not an unrecognised node.
|
|
568
|
-
"method_definition",
|
|
569
|
-
// A named function expression binds its own name; `$scope.x = function x() {}` and
|
|
570
|
-
// `const f = function inner() {}` are the common shapes.
|
|
571
|
-
"function",
|
|
572
|
-
"function_expression"
|
|
573
|
-
].includes(p);
|
|
574
|
-
},
|
|
1338
|
+
classifyDefinition: classifyByParentType({
|
|
1339
|
+
function_declaration: "function",
|
|
1340
|
+
generator_function_declaration: "function",
|
|
1341
|
+
method_definition: "function",
|
|
1342
|
+
function: "function",
|
|
1343
|
+
function_expression: "function",
|
|
1344
|
+
class_declaration: "class"
|
|
1345
|
+
}),
|
|
1346
|
+
isDeclarationName: (node) => isEcmaScriptVariableDeclaratorName(node) || isEcmaScriptFieldDefinitionName(node, "field_definition") || // `function` is the JS grammar's function-expression node; the TS grammar spells it
|
|
1347
|
+
// `function_expression` instead.
|
|
1348
|
+
hasParentType(node, [...ECMASCRIPT_DECLARATION_NAME_PARENTS, "function"]),
|
|
575
1349
|
// Scope construction has no structural handling for a function expression's own name.
|
|
576
1350
|
scopeDeclarationNames: (node) => {
|
|
577
1351
|
const parent = node.parent?.type;
|
|
578
1352
|
return parent === "function" || parent === "function_expression";
|
|
579
1353
|
},
|
|
580
|
-
createsBlockScope: (
|
|
581
|
-
createsFunctionScope: (
|
|
582
|
-
membersAreImplicitlyInScope: false,
|
|
1354
|
+
createsBlockScope: nodeTypeIn([...ECMASCRIPT_BLOCK_SCOPE_TYPES]),
|
|
1355
|
+
createsFunctionScope: nodeTypeIn([...ECMASCRIPT_FUNCTION_SCOPE_TYPES, "function"]),
|
|
583
1356
|
supportsCrossModuleSymbols: true,
|
|
1357
|
+
// JSDoc-typed `.js` files use `import type` / `export type`; the JS grammar has no type-only
|
|
1358
|
+
// syntax, so classification matches statement text. A binding named `type` stays runtime.
|
|
1359
|
+
isTypeOnly: isEcmaScriptTypeOnlyStatement,
|
|
584
1360
|
native: {
|
|
585
1361
|
normalizeQuery: (_kind, query) => query.replace(/\(function\)/g, "(function_expression)").replace(JS_OBJECT_METHOD_EXPORT_PATTERN, JS_OBJECT_METHOD_EXPORT_NATIVE_PATTERN),
|
|
586
1362
|
authoritativeKinds: ["exports"],
|
|
@@ -615,13 +1391,13 @@ function isTypeAliasLeftName(node) {
|
|
|
615
1391
|
if (!parent)
|
|
616
1392
|
return false;
|
|
617
1393
|
if (parent.type === "type") {
|
|
618
|
-
const
|
|
619
|
-
return
|
|
1394
|
+
const stmt4 = parent.parent;
|
|
1395
|
+
return stmt4?.type === "type_alias_statement" && stmt4.childForFieldName("left")?.id === parent.id;
|
|
620
1396
|
}
|
|
621
1397
|
if (parent.type === "generic_type") {
|
|
622
1398
|
const typeNode = parent.parent;
|
|
623
|
-
const
|
|
624
|
-
return typeNode?.type === "type" &&
|
|
1399
|
+
const stmt4 = typeNode?.parent;
|
|
1400
|
+
return typeNode?.type === "type" && stmt4?.type === "type_alias_statement" && stmt4.childForFieldName("left")?.id === typeNode.id;
|
|
625
1401
|
}
|
|
626
1402
|
return false;
|
|
627
1403
|
}
|
|
@@ -642,6 +1418,21 @@ function isPythonReceiverAttributeAssignmentName(node) {
|
|
|
642
1418
|
return false;
|
|
643
1419
|
return assignment.childForFieldName("left")?.id === attr.id;
|
|
644
1420
|
}
|
|
1421
|
+
var PYTHON_GRAPH_IMPORT_QUERY = `
|
|
1422
|
+
(import_statement name: (dotted_name) @from) @stmt
|
|
1423
|
+
(import_statement name: (aliased_import name: (dotted_name) @from alias: (identifier) @alias)) @stmt
|
|
1424
|
+
(import_from_statement module_name: (dotted_name) @from (wildcard_import)* @wild) @stmt
|
|
1425
|
+
(import_from_statement (relative_import) @from (wildcard_import)* @wild) @stmt
|
|
1426
|
+
;; tree-sitter-python's future_import_statement has no named node for the
|
|
1427
|
+
;; \`__future__\` module; only the imported names are named children.
|
|
1428
|
+
(future_import_statement) @stmt
|
|
1429
|
+
`;
|
|
1430
|
+
var PYTHON_BINDING_QUERY = `
|
|
1431
|
+
(import_statement . (_) @from) @stmt
|
|
1432
|
+
(import_from_statement module_name: (dotted_name) @from) @stmt
|
|
1433
|
+
(import_from_statement (relative_import) @from) @stmt
|
|
1434
|
+
(future_import_statement) @stmt
|
|
1435
|
+
`;
|
|
645
1436
|
var PYTHON_DEF = {
|
|
646
1437
|
id: "python",
|
|
647
1438
|
extensions: [".py", ".pyi", ".pyw"],
|
|
@@ -691,11 +1482,7 @@ var PYTHON_DEF = {
|
|
|
691
1482
|
comments: ["comment"]
|
|
692
1483
|
},
|
|
693
1484
|
graph: {
|
|
694
|
-
imports:
|
|
695
|
-
(import_statement) @stmt
|
|
696
|
-
(import_from_statement) @stmt
|
|
697
|
-
(future_import_statement) @stmt
|
|
698
|
-
`,
|
|
1485
|
+
imports: PYTHON_GRAPH_IMPORT_QUERY,
|
|
699
1486
|
// NOTE: These __all__ queries only capture module-level assignments.
|
|
700
1487
|
// Dynamic __all__ definitions inside functions, conditionals, or loops
|
|
701
1488
|
// (e.g., `if PY3: __all__ = [...]`) are not detected by these patterns.
|
|
@@ -766,11 +1553,7 @@ var PYTHON_DEF = {
|
|
|
766
1553
|
;; \`case [head, *tail]:\` binds the capture after the splat.
|
|
767
1554
|
(splat_pattern (identifier) @name)
|
|
768
1555
|
`,
|
|
769
|
-
importBindings:
|
|
770
|
-
(import_statement) @stmt
|
|
771
|
-
(import_from_statement) @stmt
|
|
772
|
-
(future_import_statement) @stmt
|
|
773
|
-
`
|
|
1556
|
+
importBindings: PYTHON_BINDING_QUERY
|
|
774
1557
|
},
|
|
775
1558
|
nodeTypes: {
|
|
776
1559
|
identifier: ["identifier"],
|
|
@@ -803,7 +1586,7 @@ var PYTHON_DEF = {
|
|
|
803
1586
|
if (t === "splat_pattern")
|
|
804
1587
|
return true;
|
|
805
1588
|
if (t === "named_expression")
|
|
806
|
-
return
|
|
1589
|
+
return isNameFieldOnParent(node, ["named_expression"]);
|
|
807
1590
|
if (t === "pattern_list" || t === "tuple_pattern")
|
|
808
1591
|
return true;
|
|
809
1592
|
if (isPythonReceiverAttributeAssignmentName(node))
|
|
@@ -816,9 +1599,8 @@ var PYTHON_DEF = {
|
|
|
816
1599
|
return true;
|
|
817
1600
|
return !!t && ["function_definition", "class_definition"].includes(t);
|
|
818
1601
|
},
|
|
819
|
-
createsBlockScope: (
|
|
820
|
-
createsFunctionScope: (
|
|
821
|
-
membersAreImplicitlyInScope: false,
|
|
1602
|
+
createsBlockScope: nodeTypeIn(["module", "block"]),
|
|
1603
|
+
createsFunctionScope: nodeTypeIn(["function_definition", "lambda"]),
|
|
822
1604
|
supportsCrossModuleSymbols: true,
|
|
823
1605
|
// A function body and a class body are both `block`, so only the function form blocks exports.
|
|
824
1606
|
exportScopeBlockers: ["function_definition>block"],
|
|
@@ -827,6 +1609,17 @@ var PYTHON_DEF = {
|
|
|
827
1609
|
registerLanguage(PYTHON_DEF);
|
|
828
1610
|
|
|
829
1611
|
// dist/languages/definitions/php.js
|
|
1612
|
+
var PHP_IMPORT_QUERY = `
|
|
1613
|
+
(require_expression (_) @from) @stmt
|
|
1614
|
+
(include_expression (_) @from) @stmt
|
|
1615
|
+
(require_once_expression (_) @from) @stmt
|
|
1616
|
+
(include_once_expression (_) @from) @stmt
|
|
1617
|
+
(namespace_use_declaration (namespace_use_clause (qualified_name) @from alias: (name) @alias)) @stmt
|
|
1618
|
+
(namespace_use_declaration (namespace_use_clause (qualified_name) @from !alias)) @stmt
|
|
1619
|
+
(namespace_use_declaration (namespace_use_clause (name) @from alias: (name) @alias)) @stmt
|
|
1620
|
+
(namespace_use_declaration (namespace_use_clause (name) @from !alias)) @stmt
|
|
1621
|
+
(namespace_use_declaration (namespace_name) @from (namespace_use_group)) @stmt
|
|
1622
|
+
`;
|
|
830
1623
|
var PHP_DEF = {
|
|
831
1624
|
id: "php",
|
|
832
1625
|
extensions: [".php", ".phtml", ".php4", ".php8"],
|
|
@@ -887,13 +1680,11 @@ var PHP_DEF = {
|
|
|
887
1680
|
comments: ["comment"]
|
|
888
1681
|
},
|
|
889
1682
|
graph: {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
(namespace_use_declaration) @stmt
|
|
896
|
-
`,
|
|
1683
|
+
// Path-bearing nodes: include/require argument, `use Foo\Bar` qualified_name.
|
|
1684
|
+
// Grouped `use Foo\{A}` has no single node for `Foo\A` (prefix + clause); the
|
|
1685
|
+
// prefix is `@from`. Concatenated includes (`__DIR__ . "/x"`) capture the
|
|
1686
|
+
// expression. PHP has no star-import token, so there is no `@wild`.
|
|
1687
|
+
imports: PHP_IMPORT_QUERY,
|
|
897
1688
|
exports: `
|
|
898
1689
|
(namespace_definition name: (namespace_name) @name)
|
|
899
1690
|
(class_declaration name: (name) @name)
|
|
@@ -915,73 +1706,77 @@ var PHP_DEF = {
|
|
|
915
1706
|
(const_declaration (const_element . (name) @name))
|
|
916
1707
|
(property_element name: (variable_name) @name)
|
|
917
1708
|
`,
|
|
918
|
-
importBindings:
|
|
919
|
-
(require_expression) @stmt
|
|
920
|
-
(include_expression) @stmt
|
|
921
|
-
(require_once_expression) @stmt
|
|
922
|
-
(include_once_expression) @stmt
|
|
923
|
-
(namespace_use_declaration) @stmt
|
|
924
|
-
`
|
|
1709
|
+
importBindings: PHP_IMPORT_QUERY
|
|
925
1710
|
},
|
|
926
1711
|
nodeTypes: {
|
|
927
1712
|
identifier: ["name", "variable_name", "namespace_name", "qualified_name", "relative_name"],
|
|
928
1713
|
propertyIdentifier: ["name"],
|
|
929
1714
|
memberExpression: "member_access_expression"
|
|
930
1715
|
},
|
|
931
|
-
classifyDefinition: (
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
if (parentType === "function_definition")
|
|
944
|
-
return "function";
|
|
945
|
-
if (parentType === "method_declaration")
|
|
946
|
-
return "method";
|
|
947
|
-
if (parentType === "namespace_definition")
|
|
948
|
-
return "namespace";
|
|
949
|
-
if (parentType === "const_element" || parentType === "const_declaration") {
|
|
950
|
-
return "constant";
|
|
951
|
-
}
|
|
952
|
-
return "variable";
|
|
953
|
-
},
|
|
1716
|
+
classifyDefinition: classifyByParentType({
|
|
1717
|
+
class_declaration: "class",
|
|
1718
|
+
interface_declaration: "interface",
|
|
1719
|
+
trait_declaration: "trait",
|
|
1720
|
+
enum_declaration: "type",
|
|
1721
|
+
enum_case: "constant",
|
|
1722
|
+
function_definition: "function",
|
|
1723
|
+
method_declaration: "method",
|
|
1724
|
+
namespace_definition: "namespace",
|
|
1725
|
+
const_element: "constant",
|
|
1726
|
+
const_declaration: "constant"
|
|
1727
|
+
}),
|
|
954
1728
|
normalizeIdentifier: (name) => name.replace(/^\$/, ""),
|
|
955
|
-
isDeclarationName: (node) =>
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
return parent.childForFieldName("name")?.id === node.id;
|
|
974
|
-
}
|
|
975
|
-
return parent.type === "const_element" && parent.namedChildren[0]?.id === node.id && node.type === "name";
|
|
976
|
-
},
|
|
1729
|
+
isDeclarationName: (node) => isNameFieldOnParent(node, [
|
|
1730
|
+
"namespace_definition",
|
|
1731
|
+
"class_declaration",
|
|
1732
|
+
"interface_declaration",
|
|
1733
|
+
"trait_declaration",
|
|
1734
|
+
"enum_declaration",
|
|
1735
|
+
"enum_case",
|
|
1736
|
+
"function_definition",
|
|
1737
|
+
"method_declaration",
|
|
1738
|
+
// `property_element` exposes the declared name via the `name` field and any
|
|
1739
|
+
// initializer via `default_value`; field identity keeps a default value that
|
|
1740
|
+
// happens to be a bare variable reference from being misread as a declaration.
|
|
1741
|
+
"property_element"
|
|
1742
|
+
]) || // `const_element` has no named fields (grammar: `seq($.name, '=', $.expression)`),
|
|
1743
|
+
// so the declared name is identified positionally as the first namedChild; a
|
|
1744
|
+
// value that is itself a bare `name` reference (e.g. `const X = SOME_CONST;`)
|
|
1745
|
+
// is the second namedChild and must not qualify.
|
|
1746
|
+
node.parent?.type === "const_element" && node.parent.namedChildren[0]?.id === node.id && node.type === "name",
|
|
977
1747
|
scopeDeclarationNames: (node) => node.type === "variable_name" && node.parent?.type === "property_element",
|
|
978
1748
|
createsFunctionScope: (node) => node.type === "function_definition" || node.type === "method_declaration",
|
|
979
|
-
|
|
1749
|
+
// PHP `if`/`while`/function bodies are all `compound_statement`; without a block scope a
|
|
1750
|
+
// nested declaration leaks into the enclosing scope.
|
|
1751
|
+
createsBlockScope: (node) => node.type === "compound_statement",
|
|
1752
|
+
// The exports query anchors unanchored, so a `function_definition` nested inside another
|
|
1753
|
+
// function's `compound_statement` would otherwise publish as a module export.
|
|
1754
|
+
exportScopeBlockers: ["compound_statement"],
|
|
980
1755
|
supportsCrossModuleSymbols: true
|
|
981
1756
|
};
|
|
982
1757
|
registerLanguage(PHP_DEF);
|
|
983
1758
|
|
|
1759
|
+
// dist/languages/graph-captures.js
|
|
1760
|
+
var GRAPH_IMPORT_REQUIRED_CAPTURES = ["stmt", "from"];
|
|
1761
|
+
var GRAPH_IMPORT_OPTIONAL_CAPTURES = ["alias", "wild", "iname", "def", "ns", "type_kw"];
|
|
1762
|
+
var GRAPH_IMPORT_CAPTURES = [...GRAPH_IMPORT_REQUIRED_CAPTURES, ...GRAPH_IMPORT_OPTIONAL_CAPTURES];
|
|
1763
|
+
function graphCapture(name) {
|
|
1764
|
+
return `@${name}`;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
984
1767
|
// dist/languages/definitions/html.js
|
|
1768
|
+
function htmlAssetImportQuery(valueCapture) {
|
|
1769
|
+
const value = graphCapture(valueCapture);
|
|
1770
|
+
const stmt4 = graphCapture("stmt");
|
|
1771
|
+
return `
|
|
1772
|
+
(script_element (start_tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) ${value})))) ${stmt4}
|
|
1773
|
+
((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) ${value})))) ${stmt4} (#match? @tag "^(?i)(link|a)$"))
|
|
1774
|
+
((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) ${value})))) ${stmt4} (#match? @tag "^(?i)(link|a)$"))
|
|
1775
|
+
((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) ${value})))) ${stmt4} (#match? @tag "^(?i)img$"))
|
|
1776
|
+
((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) ${value})))) ${stmt4} (#match? @tag "^(?i)img$"))
|
|
1777
|
+
`;
|
|
1778
|
+
}
|
|
1779
|
+
var htmlAssetImports = htmlAssetImportQuery("from");
|
|
985
1780
|
var HTML_DEF = {
|
|
986
1781
|
id: "html",
|
|
987
1782
|
extensions: [".html", ".htm", ".xhtml"],
|
|
@@ -999,24 +1794,12 @@ var HTML_DEF = {
|
|
|
999
1794
|
comments: ["comment"]
|
|
1000
1795
|
},
|
|
1001
1796
|
graph: {
|
|
1002
|
-
imports:
|
|
1003
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @mod)))) @stmt
|
|
1004
|
-
((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(?i)(link|a)$"))
|
|
1005
|
-
((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(?i)(link|a)$"))
|
|
1006
|
-
((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(?i)img$"))
|
|
1007
|
-
((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @mod)))) @stmt (#match? @tag "^(?i)img$"))
|
|
1008
|
-
`,
|
|
1797
|
+
imports: htmlAssetImports,
|
|
1009
1798
|
exports: "",
|
|
1010
1799
|
locals: `
|
|
1011
1800
|
(attribute (attribute_name) @attr (#match? @attr "^(?i)id$") (quoted_attribute_value (attribute_value) @name))
|
|
1012
1801
|
`,
|
|
1013
|
-
importBindings:
|
|
1014
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @from)))) @stmt
|
|
1015
|
-
((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(?i)(link|a)$"))
|
|
1016
|
-
((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)href$") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(?i)(link|a)$"))
|
|
1017
|
-
((element (start_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(?i)img$"))
|
|
1018
|
-
((element (self_closing_tag (tag_name) @tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @from)))) @stmt (#match? @tag "^(?i)img$"))
|
|
1019
|
-
`
|
|
1802
|
+
importBindings: htmlAssetImports
|
|
1020
1803
|
},
|
|
1021
1804
|
nodeTypes: {
|
|
1022
1805
|
identifier: ["attribute_value", "tag_name"]
|
|
@@ -1071,6 +1854,15 @@ var ADOC_DEF = htmlStubLanguage("adoc", [".adoc", ".asciidoc"]);
|
|
|
1071
1854
|
registerLanguage(ADOC_DEF);
|
|
1072
1855
|
|
|
1073
1856
|
// dist/languages/definitions/css-like.js
|
|
1857
|
+
var from = graphCapture("from");
|
|
1858
|
+
var stmt = graphCapture("stmt");
|
|
1859
|
+
var cssLikeImportQuery = `
|
|
1860
|
+
(import_statement (string_value) ${from}) ${stmt}
|
|
1861
|
+
`;
|
|
1862
|
+
var cssLikeLocalsQuery = `
|
|
1863
|
+
(class_selector (class_name) @name)
|
|
1864
|
+
(id_selector (id_name) @name)
|
|
1865
|
+
`;
|
|
1074
1866
|
function cssLikeStructure() {
|
|
1075
1867
|
return {
|
|
1076
1868
|
blocks: [
|
|
@@ -1084,17 +1876,10 @@ function cssLikeStructure() {
|
|
|
1084
1876
|
}
|
|
1085
1877
|
function cssLikeGraph() {
|
|
1086
1878
|
return {
|
|
1087
|
-
imports:
|
|
1088
|
-
(import_statement (string_value) @mod) @stmt
|
|
1089
|
-
`,
|
|
1879
|
+
imports: cssLikeImportQuery,
|
|
1090
1880
|
exports: "",
|
|
1091
|
-
locals:
|
|
1092
|
-
|
|
1093
|
-
(id_selector (id_name) @name)
|
|
1094
|
-
`,
|
|
1095
|
-
importBindings: `
|
|
1096
|
-
(import_statement (string_value) @from) @stmt
|
|
1097
|
-
`
|
|
1881
|
+
locals: cssLikeLocalsQuery,
|
|
1882
|
+
importBindings: cssLikeImportQuery
|
|
1098
1883
|
};
|
|
1099
1884
|
}
|
|
1100
1885
|
function cssLikeNodeTypes() {
|
|
@@ -1114,6 +1899,22 @@ var CSS_DEF = {
|
|
|
1114
1899
|
registerLanguage(CSS_DEF);
|
|
1115
1900
|
|
|
1116
1901
|
// dist/languages/definitions/scss.js
|
|
1902
|
+
var from2 = graphCapture("from");
|
|
1903
|
+
var stmt2 = graphCapture("stmt");
|
|
1904
|
+
var cssGraph = cssLikeGraph();
|
|
1905
|
+
var sassImportQueries = `
|
|
1906
|
+
(import_statement (_ (string_value) ${from2})) ${stmt2}
|
|
1907
|
+
(use_statement (string_value) ${from2}) ${stmt2}
|
|
1908
|
+
(use_statement (_ (string_value) ${from2})) ${stmt2}
|
|
1909
|
+
(forward_statement (string_value) ${from2}) ${stmt2}
|
|
1910
|
+
(forward_statement (_ (string_value) ${from2})) ${stmt2}
|
|
1911
|
+
`;
|
|
1912
|
+
var sassLocalQueries = `
|
|
1913
|
+
(mixin_statement name: (identifier) @name)
|
|
1914
|
+
(function_statement name: (identifier) @name)
|
|
1915
|
+
((declaration (property_name) @name) (#match? @name "^[$]"))
|
|
1916
|
+
(selectors (placeholder (identifier) @name))
|
|
1917
|
+
`;
|
|
1117
1918
|
var SCSS_DEF = {
|
|
1118
1919
|
id: "scss",
|
|
1119
1920
|
extensions: [".scss"],
|
|
@@ -1130,65 +1931,29 @@ var SCSS_DEF = {
|
|
|
1130
1931
|
comments: ["comment", "js_comment"]
|
|
1131
1932
|
},
|
|
1132
1933
|
graph: {
|
|
1133
|
-
imports:
|
|
1134
|
-
(import_statement (string_value) @mod) @stmt
|
|
1135
|
-
(import_statement (_ (string_value) @mod)) @stmt
|
|
1136
|
-
(use_statement (string_value) @mod) @stmt
|
|
1137
|
-
(use_statement (_ (string_value) @mod)) @stmt
|
|
1138
|
-
(forward_statement (string_value) @mod) @stmt
|
|
1139
|
-
(forward_statement (_ (string_value) @mod)) @stmt
|
|
1140
|
-
`,
|
|
1934
|
+
imports: `${cssGraph.imports}${sassImportQueries}`,
|
|
1141
1935
|
exports: `
|
|
1142
1936
|
(stylesheet (mixin_statement name: (identifier) @name))
|
|
1143
1937
|
(stylesheet (function_statement name: (identifier) @name))
|
|
1144
1938
|
((stylesheet (declaration (property_name) @name)) (#match? @name "^[$]"))
|
|
1145
1939
|
(stylesheet (rule_set (selectors (placeholder (identifier) @name))))
|
|
1146
1940
|
`,
|
|
1147
|
-
locals:
|
|
1148
|
-
|
|
1149
|
-
(function_statement name: (identifier) @name)
|
|
1150
|
-
((declaration (property_name) @name) (#match? @name "^[$]"))
|
|
1151
|
-
(selectors (placeholder (identifier) @name))
|
|
1152
|
-
(class_selector (class_name) @name)
|
|
1153
|
-
(id_selector (id_name) @name)
|
|
1154
|
-
`,
|
|
1155
|
-
importBindings: `
|
|
1156
|
-
(import_statement (string_value) @from) @stmt
|
|
1157
|
-
(import_statement (_ (string_value) @from)) @stmt
|
|
1158
|
-
(use_statement (string_value) @from) @stmt
|
|
1159
|
-
(use_statement (_ (string_value) @from)) @stmt
|
|
1160
|
-
(forward_statement (string_value) @from) @stmt
|
|
1161
|
-
(forward_statement (_ (string_value) @from)) @stmt
|
|
1162
|
-
`
|
|
1941
|
+
locals: `${sassLocalQueries}${cssGraph.locals}`,
|
|
1942
|
+
importBindings: `${cssGraph.importBindings}${sassImportQueries}`
|
|
1163
1943
|
},
|
|
1164
1944
|
nodeTypes: {
|
|
1165
1945
|
identifier: ["identifier", "variable", "class_name", "id_name", "property_name"]
|
|
1166
1946
|
},
|
|
1167
|
-
classifyDefinition: (
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
if (parent.type === "mixin_statement" || parent.type === "function_statement") {
|
|
1178
|
-
return parent.childForFieldName("name")?.id === node.id;
|
|
1179
|
-
}
|
|
1180
|
-
if (parent.type === "declaration" && node.type === "property_name") {
|
|
1181
|
-
return node.text.startsWith("$");
|
|
1182
|
-
}
|
|
1183
|
-
if (parent.type === "placeholder") {
|
|
1184
|
-
return parent.parent?.type === "selectors";
|
|
1185
|
-
}
|
|
1186
|
-
if (node.type === "class_name")
|
|
1187
|
-
return parent.type === "class_selector";
|
|
1188
|
-
if (node.type === "id_name")
|
|
1189
|
-
return parent.type === "id_selector";
|
|
1190
|
-
return false;
|
|
1191
|
-
},
|
|
1947
|
+
classifyDefinition: classifyByParentType({
|
|
1948
|
+
mixin_statement: "function",
|
|
1949
|
+
function_statement: "function"
|
|
1950
|
+
}),
|
|
1951
|
+
isDeclarationName: (node) => isNameFieldOnParent(node, ["mixin_statement", "function_statement"]) || node.parent?.type === "declaration" && node.type === "property_name" && node.text.startsWith("$") || // A placeholder in a selector list is a declaration. `@extend %name` is a use;
|
|
1952
|
+
// the pinned grammar currently wraps that form in ERROR rather than extend_statement.
|
|
1953
|
+
node.parent?.type === "placeholder" && node.parent.parent?.type === "selectors" || matchesParentTypePairs(node, [
|
|
1954
|
+
["class_selector", "class_name"],
|
|
1955
|
+
["id_selector", "id_name"]
|
|
1956
|
+
]),
|
|
1192
1957
|
scopeDeclarationNames: "all"
|
|
1193
1958
|
};
|
|
1194
1959
|
registerLanguage(SCSS_DEF);
|
|
@@ -1203,6 +1968,21 @@ var LESS_DEF = {
|
|
|
1203
1968
|
};
|
|
1204
1969
|
registerLanguage(LESS_DEF);
|
|
1205
1970
|
|
|
1971
|
+
// dist/languages/definitions/sfc-graph.js
|
|
1972
|
+
var from3 = graphCapture("from");
|
|
1973
|
+
var stmt3 = graphCapture("stmt");
|
|
1974
|
+
var sfcExternalScriptQuery = `
|
|
1975
|
+
(script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) ${from3})))) ${stmt3}
|
|
1976
|
+
`;
|
|
1977
|
+
function sfcExternalScriptGraph() {
|
|
1978
|
+
return {
|
|
1979
|
+
imports: sfcExternalScriptQuery,
|
|
1980
|
+
exports: "",
|
|
1981
|
+
locals: "",
|
|
1982
|
+
importBindings: sfcExternalScriptQuery
|
|
1983
|
+
};
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1206
1986
|
// dist/languages/definitions/vue.js
|
|
1207
1987
|
var VUE_DEF = {
|
|
1208
1988
|
id: "vue",
|
|
@@ -1211,21 +1991,12 @@ var VUE_DEF = {
|
|
|
1211
1991
|
blocks: [
|
|
1212
1992
|
{ type: "template_element", captureId: "template" },
|
|
1213
1993
|
{ type: "script_element", captureId: "script" },
|
|
1214
|
-
{ type: "style_element", captureId: "style" }
|
|
1215
|
-
],
|
|
1216
|
-
splitPoints: ["template_element", "script_element", "style_element"],
|
|
1217
|
-
comments: ["comment"]
|
|
1218
|
-
},
|
|
1219
|
-
graph: {
|
|
1220
|
-
imports: `
|
|
1221
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @mod)))) @stmt
|
|
1222
|
-
`,
|
|
1223
|
-
exports: "",
|
|
1224
|
-
locals: "",
|
|
1225
|
-
importBindings: `
|
|
1226
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @from)))) @stmt
|
|
1227
|
-
`
|
|
1994
|
+
{ type: "style_element", captureId: "style" }
|
|
1995
|
+
],
|
|
1996
|
+
splitPoints: ["template_element", "script_element", "style_element"],
|
|
1997
|
+
comments: ["comment"]
|
|
1228
1998
|
},
|
|
1999
|
+
graph: sfcExternalScriptGraph(),
|
|
1229
2000
|
nodeTypes: {
|
|
1230
2001
|
identifier: ["attribute_value"]
|
|
1231
2002
|
}
|
|
@@ -1245,16 +2016,7 @@ var SVELTE_DEF = {
|
|
|
1245
2016
|
splitPoints: ["script_element", "style_element"],
|
|
1246
2017
|
comments: ["comment"]
|
|
1247
2018
|
},
|
|
1248
|
-
graph:
|
|
1249
|
-
imports: `
|
|
1250
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @mod)))) @stmt
|
|
1251
|
-
`,
|
|
1252
|
-
exports: "",
|
|
1253
|
-
locals: "",
|
|
1254
|
-
importBindings: `
|
|
1255
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @from)))) @stmt
|
|
1256
|
-
`
|
|
1257
|
-
},
|
|
2019
|
+
graph: sfcExternalScriptGraph(),
|
|
1258
2020
|
nodeTypes: {
|
|
1259
2021
|
identifier: ["attribute_value"]
|
|
1260
2022
|
}
|
|
@@ -1264,6 +2026,7 @@ registerLanguage(SVELTE_DEF);
|
|
|
1264
2026
|
// dist/languages/definitions/ruby.js
|
|
1265
2027
|
var RUBY_DEF = {
|
|
1266
2028
|
id: "ruby",
|
|
2029
|
+
usesQueryDrivenLocals: true,
|
|
1267
2030
|
extensions: [".rb", ".rbw", ".rake", ".gemspec"],
|
|
1268
2031
|
structure: {
|
|
1269
2032
|
blocks: [
|
|
@@ -1293,7 +2056,7 @@ var RUBY_DEF = {
|
|
|
1293
2056
|
},
|
|
1294
2057
|
graph: {
|
|
1295
2058
|
imports: `
|
|
1296
|
-
(call method: (identifier) @method arguments: (argument_list (string (string_content) @
|
|
2059
|
+
(call method: (identifier) @method arguments: (argument_list (string (string_content) @from)) (#match? @method "^(require|require_relative|load|autoload)$")) @stmt
|
|
1297
2060
|
`,
|
|
1298
2061
|
exports: `
|
|
1299
2062
|
(class name: [(constant) (scope_resolution)] @name)
|
|
@@ -1319,7 +2082,16 @@ var RUBY_DEF = {
|
|
|
1319
2082
|
memberExpression: "call"
|
|
1320
2083
|
},
|
|
1321
2084
|
supportsCrossModuleSymbols: true,
|
|
2085
|
+
membersAreImplicitlyInScope: true,
|
|
2086
|
+
// Query-driven locals capture the declared name inside a `class`, `module`, `method`, or
|
|
2087
|
+
// `singleton_method`, so classification must read the parent type the same way the scope
|
|
2088
|
+
// walker's structural handling does.
|
|
1322
2089
|
classifyDefinition: (node) => {
|
|
2090
|
+
const parentType = node.parent?.type;
|
|
2091
|
+
if (parentType === "class" || parentType === "module")
|
|
2092
|
+
return "class";
|
|
2093
|
+
if (parentType === "method" || parentType === "singleton_method")
|
|
2094
|
+
return "method";
|
|
1323
2095
|
const assignment = node.parent;
|
|
1324
2096
|
const value = assignment?.childForFieldName("right");
|
|
1325
2097
|
if (assignment?.type === "assignment" && assignment.childForFieldName("left")?.id === node.id && value?.type === "call" && value.childForFieldName("receiver")?.text === "Struct" && value.childForFieldName("method")?.text === "new") {
|
|
@@ -1330,22 +2102,7 @@ var RUBY_DEF = {
|
|
|
1330
2102
|
scopeDeclarationNames: (node) => node.type === "constant" && node.parent?.type === "assignment",
|
|
1331
2103
|
createsFunctionScope: (node) => node.type === "method" || node.type === "singleton_method",
|
|
1332
2104
|
createsBlockScope: (node) => node.type === "do_block" || node.type === "block",
|
|
1333
|
-
isDeclarationName: (node) =>
|
|
1334
|
-
const p = node.parent;
|
|
1335
|
-
if (!p)
|
|
1336
|
-
return false;
|
|
1337
|
-
if (p.type === "class" && p.childForFieldName("name")?.id === node.id)
|
|
1338
|
-
return true;
|
|
1339
|
-
if (p.type === "module" && p.childForFieldName("name")?.id === node.id)
|
|
1340
|
-
return true;
|
|
1341
|
-
if (p.type === "method" && p.childForFieldName("name")?.id === node.id)
|
|
1342
|
-
return true;
|
|
1343
|
-
if (p.type === "singleton_method" && p.childForFieldName("name")?.id === node.id)
|
|
1344
|
-
return true;
|
|
1345
|
-
if (p.type === "assignment" && p.childForFieldName("left")?.id === node.id)
|
|
1346
|
-
return true;
|
|
1347
|
-
return false;
|
|
1348
|
-
}
|
|
2105
|
+
isDeclarationName: (node) => isNameFieldOnParent(node, ["class", "module", "method", "singleton_method"]) || isNameFieldOnParent(node, ["assignment"], "left")
|
|
1349
2106
|
};
|
|
1350
2107
|
registerLanguage(RUBY_DEF);
|
|
1351
2108
|
|
|
@@ -1383,7 +2140,7 @@ var GO_DEF = {
|
|
|
1383
2140
|
},
|
|
1384
2141
|
graph: {
|
|
1385
2142
|
imports: `
|
|
1386
|
-
(import_spec path: (interpreted_string_literal) @
|
|
2143
|
+
(import_spec path: (interpreted_string_literal) @from) @stmt
|
|
1387
2144
|
`,
|
|
1388
2145
|
exports: `
|
|
1389
2146
|
(function_declaration name: (identifier) @name)
|
|
@@ -1406,7 +2163,9 @@ var GO_DEF = {
|
|
|
1406
2163
|
(range_clause left: (expression_list (identifier) @name) (#not-eq? @name "_"))
|
|
1407
2164
|
`,
|
|
1408
2165
|
importBindings: `
|
|
2166
|
+
(import_spec name: (dot) @wild path: (interpreted_string_literal) @from) @stmt
|
|
1409
2167
|
(import_spec name: (package_identifier) @alias path: (interpreted_string_literal) @from) @stmt
|
|
2168
|
+
(import_spec name: (blank_identifier) @alias path: (interpreted_string_literal) @from) @stmt
|
|
1410
2169
|
(import_spec path: (interpreted_string_literal) @from) @stmt
|
|
1411
2170
|
`
|
|
1412
2171
|
},
|
|
@@ -1415,52 +2174,33 @@ var GO_DEF = {
|
|
|
1415
2174
|
memberExpression: "selector_expression"
|
|
1416
2175
|
},
|
|
1417
2176
|
supportsCrossModuleSymbols: true,
|
|
1418
|
-
classifyDefinition: (
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
if (!p)
|
|
1436
|
-
return false;
|
|
1437
|
-
if (p.type === "function_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1438
|
-
return true;
|
|
1439
|
-
if (p.type === "method_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1440
|
-
return true;
|
|
1441
|
-
if (p.type === "type_spec" && p.childForFieldName("name")?.id === node.id)
|
|
1442
|
-
return true;
|
|
1443
|
-
if ((p.type === "var_spec" || p.type === "const_spec") && node.type === "identifier")
|
|
1444
|
-
return true;
|
|
1445
|
-
if (p.type === "type_parameter_declaration" && node.type === "identifier")
|
|
1446
|
-
return true;
|
|
1447
|
-
if (p.type === "expression_list" && p.parent?.type === "short_var_declaration")
|
|
1448
|
-
return node.type === "identifier";
|
|
1449
|
-
if (p.type === "expression_list" && p.parent?.type === "range_clause")
|
|
1450
|
-
return node.type === "identifier" && node.text !== "_";
|
|
1451
|
-
if (p.type === "parameter_declaration" || p.type === "variadic_parameter_declaration") {
|
|
1452
|
-
return node.type === "identifier";
|
|
1453
|
-
}
|
|
1454
|
-
if (p.type === "field_declaration" && node.type === "field_identifier")
|
|
1455
|
-
return true;
|
|
1456
|
-
return false;
|
|
1457
|
-
},
|
|
2177
|
+
classifyDefinition: classifyByParentType({
|
|
2178
|
+
function_declaration: "function",
|
|
2179
|
+
method_declaration: "function",
|
|
2180
|
+
type_spec: { kind: "type", nameField: "name" },
|
|
2181
|
+
type_parameter_declaration: "type"
|
|
2182
|
+
}),
|
|
2183
|
+
createsFunctionScope: nodeTypeIn(["function_declaration", "method_declaration", "func_literal"]),
|
|
2184
|
+
createsBlockScope: nodeTypeIn(["block", "for_statement"]),
|
|
2185
|
+
isDeclarationName: (node) => isNameFieldOnParent(node, ["function_declaration", "method_declaration", "type_spec"]) || matchesParentTypePairs(node, [
|
|
2186
|
+
["var_spec", "identifier"],
|
|
2187
|
+
["const_spec", "identifier"],
|
|
2188
|
+
["type_parameter_declaration", "identifier"],
|
|
2189
|
+
// Only parameter *names* — never type-position identifiers (e.g. builtin `int` or type param `T`).
|
|
2190
|
+
["parameter_declaration", "identifier"],
|
|
2191
|
+
["variadic_parameter_declaration", "identifier"],
|
|
2192
|
+
["field_declaration", "field_identifier"]
|
|
2193
|
+
]) || node.parent?.type === "expression_list" && node.parent.parent?.type === "short_var_declaration" && node.type === "identifier" || node.parent?.type === "expression_list" && node.parent.parent?.type === "range_clause" && node.type === "identifier" && node.text !== "_",
|
|
1458
2194
|
scopeDeclarationNames: (node) => node.type === "field_identifier" && node.parent?.type === "field_declaration" || node.type === "identifier" && node.parent?.type === "expression_list" && node.parent.parent?.type === "range_clause"
|
|
1459
2195
|
};
|
|
1460
2196
|
registerLanguage(GO_DEF);
|
|
1461
2197
|
|
|
1462
2198
|
// dist/languages/definitions/java.js
|
|
1463
2199
|
var JAVA_IDENTIFIER_IGNORABLE_PATTERN = new RegExp(`[${JAVA_IDENTIFIER_IGNORABLE_SOURCE}]`, "gu");
|
|
2200
|
+
var JAVA_IMPORT_QUERY = `
|
|
2201
|
+
(import_declaration (scoped_identifier) @from (asterisk)? @wild) @stmt
|
|
2202
|
+
(import_declaration (identifier) @from (asterisk)? @wild) @stmt
|
|
2203
|
+
`;
|
|
1464
2204
|
var JAVA_DEF = {
|
|
1465
2205
|
id: "java",
|
|
1466
2206
|
extensions: [".java"],
|
|
@@ -1507,9 +2247,7 @@ var JAVA_DEF = {
|
|
|
1507
2247
|
comments: ["line_comment", "block_comment"]
|
|
1508
2248
|
},
|
|
1509
2249
|
graph: {
|
|
1510
|
-
imports:
|
|
1511
|
-
(import_declaration . (_) @mod) @stmt
|
|
1512
|
-
`,
|
|
2250
|
+
imports: JAVA_IMPORT_QUERY,
|
|
1513
2251
|
exports: `
|
|
1514
2252
|
(class_declaration name: (identifier) @name)
|
|
1515
2253
|
(record_declaration name: (identifier) @name)
|
|
@@ -1533,58 +2271,40 @@ var JAVA_DEF = {
|
|
|
1533
2271
|
(spread_parameter (variable_declarator name: (identifier) @name))
|
|
1534
2272
|
(receiver_parameter (identifier) @name)
|
|
1535
2273
|
`,
|
|
1536
|
-
importBindings:
|
|
1537
|
-
(import_declaration . (_) @from) @stmt
|
|
1538
|
-
`
|
|
2274
|
+
importBindings: JAVA_IMPORT_QUERY
|
|
1539
2275
|
},
|
|
1540
2276
|
nodeTypes: {
|
|
1541
2277
|
identifier: ["identifier", "type_identifier"],
|
|
1542
2278
|
memberExpression: "field_access"
|
|
1543
2279
|
},
|
|
1544
2280
|
supportsCrossModuleSymbols: true,
|
|
2281
|
+
membersAreImplicitlyInScope: true,
|
|
1545
2282
|
exportScopeBlockers: ["block", "constructor_body"],
|
|
1546
|
-
classifyDefinition: (
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
return true;
|
|
1572
|
-
if (p.type === "annotation_type_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1573
|
-
return true;
|
|
1574
|
-
if (p.type === "enum_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1575
|
-
return true;
|
|
1576
|
-
if (p.type === "enum_constant" && p.childForFieldName("name")?.id === node.id)
|
|
1577
|
-
return true;
|
|
1578
|
-
if (p.type === "method_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1579
|
-
return true;
|
|
1580
|
-
if (p.type === "variable_declarator" && p.childForFieldName("name")?.id === node.id)
|
|
1581
|
-
return true;
|
|
1582
|
-
if (p.type === "formal_parameter" && p.childForFieldName("name")?.id === node.id)
|
|
1583
|
-
return true;
|
|
1584
|
-
if (p.type === "receiver_parameter" && node.type === "identifier")
|
|
1585
|
-
return true;
|
|
1586
|
-
return false;
|
|
1587
|
-
},
|
|
2283
|
+
classifyDefinition: classifyByParentType({
|
|
2284
|
+
method_declaration: "method",
|
|
2285
|
+
constructor_declaration: "method",
|
|
2286
|
+
class_declaration: "class",
|
|
2287
|
+
record_declaration: "class",
|
|
2288
|
+
interface_declaration: "interface",
|
|
2289
|
+
annotation_type_declaration: "interface",
|
|
2290
|
+
enum_declaration: "type"
|
|
2291
|
+
}),
|
|
2292
|
+
createsFunctionScope: nodeTypeIn(["method_declaration", "constructor_declaration"]),
|
|
2293
|
+
createsBlockScope: nodeTypeIn(["block", "class_body"]),
|
|
2294
|
+
isDeclarationName: (node) => isNameFieldOnParent(node, [
|
|
2295
|
+
"class_declaration",
|
|
2296
|
+
"record_declaration",
|
|
2297
|
+
"interface_declaration",
|
|
2298
|
+
"annotation_type_declaration",
|
|
2299
|
+
"enum_declaration",
|
|
2300
|
+
"enum_constant",
|
|
2301
|
+
"method_declaration",
|
|
2302
|
+
"constructor_declaration",
|
|
2303
|
+
"variable_declarator",
|
|
2304
|
+
"formal_parameter"
|
|
2305
|
+
]) || // `spread_parameter` (`int... rest`) has no `name` field; its declared name is the
|
|
2306
|
+
// `variable_declarator` child, so that node is the declaration name.
|
|
2307
|
+
node.type === "variable_declarator" && node.parent?.type === "spread_parameter" || node.parent?.type === "receiver_parameter" && node.type === "identifier",
|
|
1588
2308
|
normalizeIdentifier: (name) => hasNonAsciiCodePoint(name, true) ? name.replace(JAVA_IDENTIFIER_IGNORABLE_PATTERN, "") : name
|
|
1589
2309
|
};
|
|
1590
2310
|
registerLanguage(JAVA_DEF);
|
|
@@ -1649,9 +2369,11 @@ var CSHARP_DEF = {
|
|
|
1649
2369
|
comments: ["comment"]
|
|
1650
2370
|
},
|
|
1651
2371
|
graph: {
|
|
2372
|
+
// Path node is `identifier` | `qualified_name` | `alias_qualified_name` (`global::System`).
|
|
2373
|
+
// An identifier/qualified_name alternation misses `alias_qualified_name`, so keep `(_)`.
|
|
1652
2374
|
imports: `
|
|
1653
|
-
(using_directive !name (_) @
|
|
1654
|
-
(using_directive name: (identifier) (_) @
|
|
2375
|
+
(using_directive !name (_) @from) @stmt
|
|
2376
|
+
(using_directive name: (identifier) (_) @from) @stmt
|
|
1655
2377
|
`,
|
|
1656
2378
|
exports: `
|
|
1657
2379
|
(class_declaration name: (identifier) @name)
|
|
@@ -1670,6 +2392,8 @@ var CSHARP_DEF = {
|
|
|
1670
2392
|
(class_declaration name: (identifier) @name)
|
|
1671
2393
|
(record_declaration name: (identifier) @name)
|
|
1672
2394
|
(record_declaration (parameter_list (parameter name: (identifier) @name)))
|
|
2395
|
+
(method_declaration (parameter_list (parameter name: (identifier) @name)))
|
|
2396
|
+
(constructor_declaration (parameter_list (parameter name: (identifier) @name)))
|
|
1673
2397
|
(struct_declaration name: (identifier) @name)
|
|
1674
2398
|
(interface_declaration name: (identifier) @name)
|
|
1675
2399
|
(enum_declaration name: (identifier) @name)
|
|
@@ -1681,6 +2405,8 @@ var CSHARP_DEF = {
|
|
|
1681
2405
|
(variable_declarator name: (identifier) @name)
|
|
1682
2406
|
(declaration_pattern name: (identifier) @name)
|
|
1683
2407
|
`,
|
|
2408
|
+
// extern alias has no path node in the grammar, so there is no @from.
|
|
2409
|
+
// using path node: identifier | qualified_name | alias_qualified_name — keep `(_)`.
|
|
1684
2410
|
importBindings: `
|
|
1685
2411
|
(using_directive name: (identifier) @alias (_) @from) @stmt
|
|
1686
2412
|
(using_directive !name (_) @from) @stmt
|
|
@@ -1692,36 +2418,43 @@ var CSHARP_DEF = {
|
|
|
1692
2418
|
memberExpression: "member_access_expression"
|
|
1693
2419
|
},
|
|
1694
2420
|
supportsCrossModuleSymbols: true,
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
2421
|
+
membersAreImplicitlyInScope: true,
|
|
2422
|
+
classifyDefinition: classifyByParentType({
|
|
2423
|
+
method_declaration: "method",
|
|
2424
|
+
constructor_declaration: "method",
|
|
2425
|
+
destructor_declaration: "method",
|
|
2426
|
+
local_function_statement: "method",
|
|
2427
|
+
class_declaration: "class",
|
|
2428
|
+
record_declaration: "class",
|
|
2429
|
+
struct_declaration: "class",
|
|
2430
|
+
interface_declaration: "interface",
|
|
2431
|
+
enum_declaration: "type",
|
|
2432
|
+
delegate_declaration: "type"
|
|
2433
|
+
}),
|
|
2434
|
+
createsFunctionScope: nodeTypeIn([
|
|
2435
|
+
"method_declaration",
|
|
2436
|
+
"constructor_declaration",
|
|
2437
|
+
"destructor_declaration",
|
|
2438
|
+
"local_function_statement"
|
|
2439
|
+
]),
|
|
2440
|
+
createsBlockScope: nodeTypeIn(["block", "declaration_list"]),
|
|
2441
|
+
isDeclarationName: (node) => isNameFieldOnParent(node, [
|
|
2442
|
+
"class_declaration",
|
|
2443
|
+
"record_declaration",
|
|
2444
|
+
"struct_declaration",
|
|
2445
|
+
"interface_declaration",
|
|
2446
|
+
"enum_declaration",
|
|
2447
|
+
"delegate_declaration",
|
|
2448
|
+
"enum_member_declaration",
|
|
2449
|
+
"method_declaration",
|
|
2450
|
+
"constructor_declaration",
|
|
2451
|
+
"destructor_declaration",
|
|
2452
|
+
"local_function_statement",
|
|
2453
|
+
"property_declaration",
|
|
2454
|
+
"variable_declarator",
|
|
2455
|
+
"parameter",
|
|
2456
|
+
"declaration_pattern"
|
|
2457
|
+
]),
|
|
1725
2458
|
normalizeIdentifier: (name) => {
|
|
1726
2459
|
const withoutVerbatimPrefix = name.startsWith("@") ? name.slice(1) : name;
|
|
1727
2460
|
return hasNonAsciiCodePoint(withoutVerbatimPrefix) ? withoutVerbatimPrefix.replace(CSHARP_IDENTIFIER_FORMAT_PATTERN, "") : withoutVerbatimPrefix;
|
|
@@ -1772,9 +2505,9 @@ var RUST_DEF = {
|
|
|
1772
2505
|
},
|
|
1773
2506
|
graph: {
|
|
1774
2507
|
imports: `
|
|
1775
|
-
(mod_item name: (identifier) @
|
|
1776
|
-
(extern_crate_declaration name: (identifier) @
|
|
1777
|
-
(use_declaration argument: (_) @
|
|
2508
|
+
(mod_item name: (identifier) @from) @stmt
|
|
2509
|
+
(extern_crate_declaration name: (identifier) @from) @stmt
|
|
2510
|
+
(use_declaration argument: (_) @from) @stmt
|
|
1778
2511
|
`,
|
|
1779
2512
|
exports: `
|
|
1780
2513
|
(function_item name: (identifier) @name) @stmt
|
|
@@ -1824,6 +2557,7 @@ var RUST_DEF = {
|
|
|
1824
2557
|
(use_declaration argument: (use_as_clause path: (identifier) @from alias: (identifier) @alias)) @stmt
|
|
1825
2558
|
(use_declaration argument: (use_as_clause path: (scoped_identifier path: (_) @from name: (identifier) @iname) alias: (identifier) @alias)) @stmt
|
|
1826
2559
|
(use_declaration argument: (scoped_identifier path: (_) @from name: (identifier) @iname)) @stmt
|
|
2560
|
+
(use_declaration argument: (use_wildcard) @from @wild) @stmt
|
|
1827
2561
|
(use_declaration argument: (identifier) @from) @stmt
|
|
1828
2562
|
(use_declaration argument: (scoped_use_list path: (_) @from list: (use_list (identifier) @iname))) @stmt
|
|
1829
2563
|
;; Aliased members inside a group (\`use foo::{Bar as Baz}\`): import
|
|
@@ -1838,53 +2572,31 @@ var RUST_DEF = {
|
|
|
1838
2572
|
supportsCrossModuleSymbols: true,
|
|
1839
2573
|
exportScopeBlockers: ["block"],
|
|
1840
2574
|
scopeDeclarationNames: (node) => node.parent?.type === "macro_definition",
|
|
1841
|
-
classifyDefinition: (
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
if (p.type === "trait_item" && p.childForFieldName("name")?.id === node.id)
|
|
1867
|
-
return true;
|
|
1868
|
-
if (p.type === "type_item" && p.childForFieldName("name")?.id === node.id)
|
|
1869
|
-
return true;
|
|
1870
|
-
if (p.type === "associated_type" && p.childForFieldName("name")?.id === node.id)
|
|
1871
|
-
return true;
|
|
1872
|
-
if (p.type === "enum_item" && p.childForFieldName("name")?.id === node.id)
|
|
1873
|
-
return true;
|
|
1874
|
-
if (p.type === "enum_variant" && p.childForFieldName("name")?.id === node.id)
|
|
1875
|
-
return true;
|
|
1876
|
-
if (p.type === "const_item" && p.childForFieldName("name")?.id === node.id)
|
|
1877
|
-
return true;
|
|
1878
|
-
if (p.type === "static_item" && p.childForFieldName("name")?.id === node.id)
|
|
1879
|
-
return true;
|
|
1880
|
-
if (p.type === "macro_definition" && p.childForFieldName("name")?.id === node.id)
|
|
1881
|
-
return true;
|
|
1882
|
-
if (p.type === "let_declaration" && p.childForFieldName("pattern")?.id === node.id)
|
|
1883
|
-
return true;
|
|
1884
|
-
if (p.type === "parameter" && p.childForFieldName("pattern")?.id === node.id)
|
|
1885
|
-
return true;
|
|
1886
|
-
return false;
|
|
1887
|
-
},
|
|
2575
|
+
classifyDefinition: classifyByParentType({
|
|
2576
|
+
function_item: "function",
|
|
2577
|
+
function_signature_item: "function",
|
|
2578
|
+
macro_definition: "function",
|
|
2579
|
+
enum_item: "type",
|
|
2580
|
+
type_item: "type",
|
|
2581
|
+
associated_type: "type",
|
|
2582
|
+
struct_item: "class",
|
|
2583
|
+
trait_item: "class"
|
|
2584
|
+
}),
|
|
2585
|
+
createsFunctionScope: nodeTypeIn(["function_item"]),
|
|
2586
|
+
createsBlockScope: nodeTypeIn(["block"]),
|
|
2587
|
+
isDeclarationName: (node) => isNameFieldOnParent(node, [
|
|
2588
|
+
"function_item",
|
|
2589
|
+
"function_signature_item",
|
|
2590
|
+
"struct_item",
|
|
2591
|
+
"trait_item",
|
|
2592
|
+
"type_item",
|
|
2593
|
+
"associated_type",
|
|
2594
|
+
"enum_item",
|
|
2595
|
+
"enum_variant",
|
|
2596
|
+
"const_item",
|
|
2597
|
+
"static_item",
|
|
2598
|
+
"macro_definition"
|
|
2599
|
+
]) || isNameFieldOnParent(node, ["let_declaration", "parameter"], "pattern"),
|
|
1888
2600
|
normalizeIdentifier: (name) => hasNonAsciiCodePoint(name) ? name.normalize("NFC") : name
|
|
1889
2601
|
};
|
|
1890
2602
|
registerLanguage(RUST_DEF);
|
|
@@ -1906,12 +2618,7 @@ var cFamilyControlSplitPoints = [
|
|
|
1906
2618
|
"switch_statement",
|
|
1907
2619
|
"case_statement"
|
|
1908
2620
|
];
|
|
1909
|
-
var
|
|
1910
|
-
(preproc_include path: (string_literal) @mod) @stmt
|
|
1911
|
-
(preproc_include path: (system_lib_string) @mod) @stmt
|
|
1912
|
-
(preproc_include path: (identifier) @mod) @stmt
|
|
1913
|
-
`;
|
|
1914
|
-
var cFamilyIncludeBindingsQuery = `
|
|
2621
|
+
var cFamilyIncludeQuery = `
|
|
1915
2622
|
(preproc_include path: (string_literal) @from) @stmt
|
|
1916
2623
|
(preproc_include path: (system_lib_string) @from) @stmt
|
|
1917
2624
|
(preproc_include path: (identifier) @from) @stmt
|
|
@@ -1998,16 +2705,16 @@ function createCFamilyLanguageDefinition(options) {
|
|
|
1998
2705
|
comments: ["comment"]
|
|
1999
2706
|
},
|
|
2000
2707
|
graph: {
|
|
2001
|
-
imports:
|
|
2708
|
+
imports: cFamilyIncludeQuery,
|
|
2002
2709
|
exports: joinQueryPatterns([
|
|
2003
2710
|
...cFamilyCoreExportQueries(graphFunctionNameQuery),
|
|
2004
|
-
...options.
|
|
2711
|
+
...options.extraSymbolQueries ?? []
|
|
2005
2712
|
]),
|
|
2006
2713
|
locals: joinQueryPatterns([
|
|
2007
2714
|
...cFamilyCoreLocalQueries(graphFunctionNameQuery),
|
|
2008
|
-
...options.
|
|
2715
|
+
...options.extraSymbolQueries ?? []
|
|
2009
2716
|
]),
|
|
2010
|
-
importBindings:
|
|
2717
|
+
importBindings: cFamilyIncludeQuery
|
|
2011
2718
|
},
|
|
2012
2719
|
nodeTypes: options.nodeTypes,
|
|
2013
2720
|
classifyDefinition: options.classifyDefinition,
|
|
@@ -2016,10 +2723,13 @@ function createCFamilyLanguageDefinition(options) {
|
|
|
2016
2723
|
createsFunctionScope: options.createsFunctionScope,
|
|
2017
2724
|
createsBlockScope: (node) => node.type === "compound_statement",
|
|
2018
2725
|
supportsCrossModuleSymbols: true,
|
|
2019
|
-
// A name declared inside a function body
|
|
2020
|
-
//
|
|
2021
|
-
|
|
2022
|
-
|
|
2726
|
+
// A name declared inside a function body or a class/struct/union body is not a module
|
|
2727
|
+
// export. C and C++ spell that type body `field_declaration_list`, not `class_body`.
|
|
2728
|
+
// The exports query cannot anchor on `translation_unit` because include guards nest
|
|
2729
|
+
// every header declaration.
|
|
2730
|
+
exportScopeBlockers: ["compound_statement", "field_declaration_list"],
|
|
2731
|
+
usesQueryDrivenLocals: options.usesQueryDrivenLocals || false,
|
|
2732
|
+
...options.membersAreImplicitlyInScope !== void 0 ? { membersAreImplicitlyInScope: options.membersAreImplicitlyInScope } : {}
|
|
2023
2733
|
};
|
|
2024
2734
|
}
|
|
2025
2735
|
function isWithin(node, ancestor) {
|
|
@@ -2046,6 +2756,29 @@ function findAncestor(node, types) {
|
|
|
2046
2756
|
function isInParameterList(node) {
|
|
2047
2757
|
return !!findAncestor(node, cFamilyParameterListTypes);
|
|
2048
2758
|
}
|
|
2759
|
+
function isSpecifierNameField(node, specifierTypes) {
|
|
2760
|
+
const parent = node.parent;
|
|
2761
|
+
return !!parent && specifierTypes.includes(parent.type) && isInField(node, parent, "name");
|
|
2762
|
+
}
|
|
2763
|
+
function cFamilyIsDeclarationName(node) {
|
|
2764
|
+
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["parameter_declaration"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["field_declaration"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["init_declarator"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["type_definition"])))
|
|
2765
|
+
return true;
|
|
2766
|
+
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["function_definition"])) && !isInParameterList(node))
|
|
2767
|
+
return true;
|
|
2768
|
+
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["declaration"])) && !isInParameterList(node))
|
|
2769
|
+
return true;
|
|
2770
|
+
return isSpecifierNameField(node, ["enumerator", "preproc_def", "preproc_function_def"]);
|
|
2771
|
+
}
|
|
2772
|
+
function cFamilyContainerClassifyDefinition(node) {
|
|
2773
|
+
const container = findAncestor(node, cFamilyContainerTypes);
|
|
2774
|
+
if (container?.type === "function_definition")
|
|
2775
|
+
return "function";
|
|
2776
|
+
if (container?.type === "declaration" && isFunctionDeclarator(node))
|
|
2777
|
+
return "function";
|
|
2778
|
+
if (container?.type === "type_definition")
|
|
2779
|
+
return "type";
|
|
2780
|
+
return "variable";
|
|
2781
|
+
}
|
|
2049
2782
|
function resolveDeclaratorRoot(ancestor) {
|
|
2050
2783
|
let declaratorNode = ancestor.childForFieldName("declarator");
|
|
2051
2784
|
if (!declaratorNode)
|
|
@@ -2098,13 +2831,7 @@ var C_DEF = createCFamilyLanguageDefinition({
|
|
|
2098
2831
|
cFamilyBlock("preproc_def", "name: (identifier) @chunk.name", "macro"),
|
|
2099
2832
|
cFamilyBlock("preproc_function_def", "name: (identifier) @chunk.name", "macro")
|
|
2100
2833
|
],
|
|
2101
|
-
|
|
2102
|
-
`(union_specifier name: (type_identifier) @name)`,
|
|
2103
|
-
`(enumerator name: (identifier) @name)`,
|
|
2104
|
-
`(preproc_def name: (identifier) @name)`,
|
|
2105
|
-
`(preproc_function_def name: (identifier) @name)`
|
|
2106
|
-
],
|
|
2107
|
-
extraLocalQueries: [
|
|
2834
|
+
extraSymbolQueries: [
|
|
2108
2835
|
`(union_specifier name: (type_identifier) @name)`,
|
|
2109
2836
|
`(enumerator name: (identifier) @name)`,
|
|
2110
2837
|
`(preproc_def name: (identifier) @name)`,
|
|
@@ -2125,45 +2852,22 @@ var C_DEF = createCFamilyLanguageDefinition({
|
|
|
2125
2852
|
return "class";
|
|
2126
2853
|
if (parent.type === "type_definition" && isInField(node, parent, "declarator"))
|
|
2127
2854
|
return "type";
|
|
2128
|
-
|
|
2129
|
-
if (container?.type === "function_definition")
|
|
2130
|
-
return "function";
|
|
2131
|
-
if (container?.type === "declaration" && isFunctionDeclarator(node))
|
|
2132
|
-
return "function";
|
|
2133
|
-
if (container?.type === "type_definition")
|
|
2134
|
-
return "type";
|
|
2135
|
-
return "variable";
|
|
2136
|
-
},
|
|
2137
|
-
isDeclarationName: (node) => {
|
|
2138
|
-
const parent = node.parent;
|
|
2139
|
-
if (!parent)
|
|
2140
|
-
return false;
|
|
2141
|
-
if ((parent.type === "struct_specifier" || parent.type === "union_specifier" || parent.type === "enum_specifier") && isInField(node, parent, "name"))
|
|
2142
|
-
return true;
|
|
2143
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["parameter_declaration"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["field_declaration"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["init_declarator"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["type_definition"])))
|
|
2144
|
-
return true;
|
|
2145
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["function_definition"])) && !isInParameterList(node))
|
|
2146
|
-
return true;
|
|
2147
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["declaration"])) && !isInParameterList(node))
|
|
2148
|
-
return true;
|
|
2149
|
-
if (parent.type === "enumerator" && isInField(node, parent, "name"))
|
|
2150
|
-
return true;
|
|
2151
|
-
if (parent.type === "preproc_def" && isInField(node, parent, "name"))
|
|
2152
|
-
return true;
|
|
2153
|
-
if (parent.type === "preproc_function_def" && isInField(node, parent, "name"))
|
|
2154
|
-
return true;
|
|
2155
|
-
return false;
|
|
2855
|
+
return cFamilyContainerClassifyDefinition(node);
|
|
2156
2856
|
},
|
|
2157
|
-
|
|
2857
|
+
isDeclarationName: (node) => isSpecifierNameField(node, ["struct_specifier", "union_specifier", "enum_specifier"]) || cFamilyIsDeclarationName(node),
|
|
2858
|
+
createsFunctionScope: nodeTypeIn(["function_definition"])
|
|
2158
2859
|
});
|
|
2159
2860
|
registerLanguage(C_DEF);
|
|
2160
2861
|
|
|
2161
2862
|
// dist/languages/definitions/cpp.js
|
|
2162
2863
|
var CPP_DEF = createCFamilyLanguageDefinition({
|
|
2163
2864
|
id: "cpp",
|
|
2164
|
-
|
|
2865
|
+
// Module-interface units use `.cppm`/`.ixx`/`.mxx` by convention; without them a declared
|
|
2866
|
+
// `export module foo;` is never discovered, so a first-party `import foo;` stays external.
|
|
2867
|
+
extensions: [".cc", ".cpp", ".cxx", ".c++", ".hpp", ".hh", ".hxx", ".ipp", ".tpp", ".inl", ".cppm", ".ixx", ".mxx"],
|
|
2165
2868
|
includeFieldIdentifier: true,
|
|
2166
2869
|
usesQueryDrivenLocals: true,
|
|
2870
|
+
membersAreImplicitlyInScope: true,
|
|
2167
2871
|
blocks: (functionNameQuery) => [
|
|
2168
2872
|
cFamilyFunctionBlock(functionNameQuery),
|
|
2169
2873
|
cFamilyTypeIdentifierBlock("class_specifier", "class"),
|
|
@@ -2174,26 +2878,9 @@ var CPP_DEF = createCFamilyLanguageDefinition({
|
|
|
2174
2878
|
cFamilyBlock("type_definition", "declarator: (type_identifier) @chunk.name", "type")
|
|
2175
2879
|
],
|
|
2176
2880
|
splitPoints: [...cFamilyControlSplitPoints, "try_statement", "catch_clause"],
|
|
2177
|
-
|
|
2178
|
-
`(class_specifier name: (type_identifier) @name)`,
|
|
2179
|
-
`(class_specifier name: (template_type name: (type_identifier) @name))`,
|
|
2180
|
-
`(union_specifier name: (type_identifier) @name)`,
|
|
2181
|
-
`(enumerator name: (identifier) @name)`,
|
|
2182
|
-
`(namespace_definition name: (namespace_identifier) @name)`,
|
|
2183
|
-
`(namespace_definition name: (nested_namespace_specifier (namespace_identifier) @name))`,
|
|
2184
|
-
`(alias_declaration name: (type_identifier) @name)`,
|
|
2185
|
-
`(concept_definition name: (identifier) @name)`,
|
|
2186
|
-
`(preproc_def name: (identifier) @name)`,
|
|
2187
|
-
`(preproc_function_def name: (identifier) @name)`,
|
|
2188
|
-
`(class_specifier body: (field_declaration_list (field_declaration declarator: (function_declarator declarator: (field_identifier) @name))))`,
|
|
2189
|
-
`(class_specifier body: (field_declaration_list (field_declaration declarator: (reference_declarator (function_declarator declarator: (operator_name) @name)))))`,
|
|
2190
|
-
`(class_specifier body: (field_declaration_list (declaration declarator: (function_declarator declarator: (destructor_name) @name))))`,
|
|
2191
|
-
`(module_declaration name: (module_name) @name)`
|
|
2192
|
-
],
|
|
2193
|
-
extraLocalQueries: [
|
|
2881
|
+
extraSymbolQueries: [
|
|
2194
2882
|
`(class_specifier name: (type_identifier) @name)`,
|
|
2195
2883
|
`(class_specifier name: (template_type name: (type_identifier) @name))`,
|
|
2196
|
-
`(enum_specifier name: (type_identifier) @name)`,
|
|
2197
2884
|
`(union_specifier name: (type_identifier) @name)`,
|
|
2198
2885
|
`(enumerator name: (identifier) @name)`,
|
|
2199
2886
|
`(namespace_definition name: (namespace_identifier) @name)`,
|
|
@@ -2227,21 +2914,14 @@ var CPP_DEF = createCFamilyLanguageDefinition({
|
|
|
2227
2914
|
}
|
|
2228
2915
|
if (parent.type === "alias_declaration" || parent.type === "type_definition" && isInField(node, parent, "declarator"))
|
|
2229
2916
|
return "type";
|
|
2230
|
-
|
|
2231
|
-
if (container?.type === "function_definition")
|
|
2232
|
-
return "function";
|
|
2233
|
-
if (container?.type === "declaration" && isFunctionDeclarator(node))
|
|
2234
|
-
return "function";
|
|
2235
|
-
if (container?.type === "type_definition")
|
|
2236
|
-
return "type";
|
|
2237
|
-
return "variable";
|
|
2917
|
+
return cFamilyContainerClassifyDefinition(node);
|
|
2238
2918
|
},
|
|
2239
2919
|
isDeclarationName: (node) => {
|
|
2920
|
+
if (isSpecifierNameField(node, ["class_specifier", "struct_specifier", "union_specifier", "enum_specifier"]))
|
|
2921
|
+
return true;
|
|
2240
2922
|
const parent = node.parent;
|
|
2241
2923
|
if (!parent)
|
|
2242
2924
|
return false;
|
|
2243
|
-
if ((parent.type === "class_specifier" || parent.type === "struct_specifier" || parent.type === "union_specifier" || parent.type === "enum_specifier") && isInField(node, parent, "name"))
|
|
2244
|
-
return true;
|
|
2245
2925
|
if (parent.type === "namespace_definition" && isInField(node, parent, "name"))
|
|
2246
2926
|
return true;
|
|
2247
2927
|
if (parent.type === "module_declaration" && isInField(node, parent, "name"))
|
|
@@ -2260,39 +2940,33 @@ var CPP_DEF = createCFamilyLanguageDefinition({
|
|
|
2260
2940
|
return true;
|
|
2261
2941
|
if (parent.type === "concept_definition" && isInField(node, parent, "name"))
|
|
2262
2942
|
return true;
|
|
2263
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["parameter_declaration"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["field_declaration"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["init_declarator"])) || isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["type_definition"])))
|
|
2264
|
-
return true;
|
|
2265
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["function_definition"])) && !isInParameterList(node))
|
|
2266
|
-
return true;
|
|
2267
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["declaration"])) && !isInParameterList(node))
|
|
2268
|
-
return true;
|
|
2269
2943
|
if (parent.type === "qualified_identifier" && parent.parent?.type === "using_declaration" && isInField(node, parent, "name"))
|
|
2270
2944
|
return true;
|
|
2271
|
-
|
|
2272
|
-
return true;
|
|
2273
|
-
if (parent.type === "preproc_def" && isInField(node, parent, "name"))
|
|
2274
|
-
return true;
|
|
2275
|
-
if (parent.type === "preproc_function_def" && isInField(node, parent, "name"))
|
|
2276
|
-
return true;
|
|
2277
|
-
return false;
|
|
2945
|
+
return cFamilyIsDeclarationName(node);
|
|
2278
2946
|
},
|
|
2279
|
-
createsFunctionScope: (
|
|
2947
|
+
createsFunctionScope: nodeTypeIn(["function_definition", "lambda_expression"])
|
|
2280
2948
|
});
|
|
2281
|
-
var
|
|
2282
|
-
(import_declaration name: (module_name) @mod) @stmt
|
|
2283
|
-
(import_declaration header: (string_literal) @mod) @stmt
|
|
2284
|
-
(import_declaration header: (system_lib_string) @mod) @stmt
|
|
2285
|
-
`;
|
|
2286
|
-
var cppModuleBindingQuery = `
|
|
2949
|
+
var cppModuleQuery = `
|
|
2287
2950
|
(import_declaration name: (module_name) @from) @stmt
|
|
2288
2951
|
(import_declaration header: (string_literal) @from) @stmt
|
|
2289
2952
|
(import_declaration header: (system_lib_string) @from) @stmt
|
|
2290
2953
|
`;
|
|
2291
|
-
CPP_DEF.graph.imports +=
|
|
2292
|
-
CPP_DEF.graph.importBindings +=
|
|
2954
|
+
CPP_DEF.graph.imports += cppModuleQuery;
|
|
2955
|
+
CPP_DEF.graph.importBindings += cppModuleQuery;
|
|
2293
2956
|
registerLanguage(CPP_DEF);
|
|
2294
2957
|
|
|
2295
2958
|
// dist/languages/definitions/kotlin.js
|
|
2959
|
+
var KOTLIN_DECLARATION_NAME_PARENT_TYPES = [
|
|
2960
|
+
"class_declaration",
|
|
2961
|
+
"object_declaration",
|
|
2962
|
+
"function_declaration",
|
|
2963
|
+
"type_alias",
|
|
2964
|
+
"variable_declaration",
|
|
2965
|
+
"parameter",
|
|
2966
|
+
"class_parameter",
|
|
2967
|
+
"enum_entry",
|
|
2968
|
+
"type_parameter"
|
|
2969
|
+
];
|
|
2296
2970
|
var KOTLIN_DEF = {
|
|
2297
2971
|
id: "kotlin",
|
|
2298
2972
|
extensions: [".kt", ".kts", ".ktm"],
|
|
@@ -2339,7 +3013,7 @@ var KOTLIN_DEF = {
|
|
|
2339
3013
|
},
|
|
2340
3014
|
graph: {
|
|
2341
3015
|
imports: `
|
|
2342
|
-
(import (qualified_identifier) @
|
|
3016
|
+
(import (qualified_identifier) @from) @stmt
|
|
2343
3017
|
`,
|
|
2344
3018
|
exports: `
|
|
2345
3019
|
(source_file
|
|
@@ -2382,46 +3056,20 @@ var KOTLIN_DEF = {
|
|
|
2382
3056
|
propertyIdentifier: ["identifier"],
|
|
2383
3057
|
memberExpression: "navigation_expression"
|
|
2384
3058
|
},
|
|
2385
|
-
classifyDefinition: (
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
return "type";
|
|
2395
|
-
return "variable";
|
|
2396
|
-
},
|
|
2397
|
-
isDeclarationName: (node) => {
|
|
2398
|
-
const parent = node.parent;
|
|
2399
|
-
if (!parent)
|
|
2400
|
-
return false;
|
|
2401
|
-
if (parent.type === "class_declaration" && node.type === "identifier")
|
|
2402
|
-
return true;
|
|
2403
|
-
if (parent.type === "object_declaration" && node.type === "identifier")
|
|
2404
|
-
return true;
|
|
2405
|
-
if (parent.type === "function_declaration" && node.type === "identifier")
|
|
2406
|
-
return true;
|
|
2407
|
-
if (parent.type === "type_alias" && node.type === "identifier")
|
|
2408
|
-
return true;
|
|
2409
|
-
if (parent.type === "variable_declaration" && node.type === "identifier")
|
|
2410
|
-
return true;
|
|
2411
|
-
if (parent.type === "parameter" && node.type === "identifier")
|
|
2412
|
-
return true;
|
|
2413
|
-
if (parent.type === "class_parameter" && node.type === "identifier")
|
|
2414
|
-
return true;
|
|
2415
|
-
if (parent.type === "enum_entry" && node.type === "identifier")
|
|
2416
|
-
return true;
|
|
2417
|
-
if (parent.type === "type_parameter" && node.type === "identifier")
|
|
2418
|
-
return true;
|
|
2419
|
-
return false;
|
|
2420
|
-
},
|
|
3059
|
+
classifyDefinition: classifyByParentType({
|
|
3060
|
+
class_declaration: "class",
|
|
3061
|
+
object_declaration: "class",
|
|
3062
|
+
function_declaration: "function",
|
|
3063
|
+
type_alias: "type"
|
|
3064
|
+
}),
|
|
3065
|
+
// The Kotlin grammar exposes no `name` field on these declarations, so the declared
|
|
3066
|
+
// name is identified by parent type with a plain `identifier` child.
|
|
3067
|
+
isDeclarationName: (node) => node.type === "identifier" && hasParentType(node, KOTLIN_DECLARATION_NAME_PARENT_TYPES),
|
|
2421
3068
|
scopeDeclarationNames: "all",
|
|
2422
|
-
createsFunctionScope: (
|
|
2423
|
-
createsBlockScope: (
|
|
3069
|
+
createsFunctionScope: nodeTypeIn(["function_declaration", "anonymous_function", "lambda_literal"]),
|
|
3070
|
+
createsBlockScope: nodeTypeIn(["function_body", "class_body", "block", "catch_block", "finally_block"]),
|
|
2424
3071
|
supportsCrossModuleSymbols: true,
|
|
3072
|
+
membersAreImplicitlyInScope: true,
|
|
2425
3073
|
exportScopeBlockers: ["function_body", "lambda_literal", "anonymous_function"]
|
|
2426
3074
|
};
|
|
2427
3075
|
registerLanguage(KOTLIN_DEF);
|
|
@@ -2504,8 +3152,12 @@ var SWIFT_DEF = {
|
|
|
2504
3152
|
comments: ["comment", "multiline_comment"]
|
|
2505
3153
|
},
|
|
2506
3154
|
graph: {
|
|
3155
|
+
// Pinned tree-sitter-swift: the path is always one `identifier` node, including
|
|
3156
|
+
// dotted paths (`Foundation.NSString`). Kind keywords (`class`, `struct`, `func`,
|
|
3157
|
+
// `enum`, `typealias`) are anonymous. `simple_identifier` is not a child of
|
|
3158
|
+
// `import_declaration` (Impossible pattern). No alias or wildcard node.
|
|
2507
3159
|
imports: `
|
|
2508
|
-
(import_declaration (identifier) @
|
|
3160
|
+
(import_declaration (identifier) @from) @stmt
|
|
2509
3161
|
`,
|
|
2510
3162
|
exports: `
|
|
2511
3163
|
(source_file (class_declaration declaration_kind: "class" name: (_) @name))
|
|
@@ -2566,6 +3218,7 @@ var SWIFT_DEF = {
|
|
|
2566
3218
|
(macro_declaration (simple_identifier) @name)
|
|
2567
3219
|
(operator_declaration [(custom_operator) (simple_identifier) (bang)] @name)
|
|
2568
3220
|
`,
|
|
3221
|
+
// Same path node as `imports`; Swift has no import alias or star token.
|
|
2569
3222
|
importBindings: `
|
|
2570
3223
|
(import_declaration (identifier) @from) @stmt
|
|
2571
3224
|
`
|
|
@@ -2597,19 +3250,20 @@ var SWIFT_DEF = {
|
|
|
2597
3250
|
const parent = node.parent;
|
|
2598
3251
|
if (!parent)
|
|
2599
3252
|
return false;
|
|
2600
|
-
if (
|
|
3253
|
+
if (isNameFieldOnParent(node, ["class_declaration"]))
|
|
2601
3254
|
return true;
|
|
2602
3255
|
if (parent.type === "user_type" && parent.parent?.type === "class_declaration" && parent.parent.childForFieldName("name")?.id === parent.id)
|
|
2603
3256
|
return true;
|
|
2604
|
-
if (
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
3257
|
+
if (isNameFieldOnParent(node, [
|
|
3258
|
+
"protocol_declaration",
|
|
3259
|
+
"enum_entry",
|
|
3260
|
+
"function_declaration",
|
|
3261
|
+
"typealias_declaration",
|
|
3262
|
+
"associatedtype_declaration",
|
|
3263
|
+
"parameter",
|
|
3264
|
+
"protocol_function_declaration",
|
|
3265
|
+
"protocol_property_declaration"
|
|
3266
|
+
]))
|
|
2613
3267
|
return true;
|
|
2614
3268
|
if (parent.type === "macro_declaration" && node.type === "simple_identifier")
|
|
2615
3269
|
return true;
|
|
@@ -2621,20 +3275,25 @@ var SWIFT_DEF = {
|
|
|
2621
3275
|
return true;
|
|
2622
3276
|
if (parent.type === "subscript_declaration" && node.type === "subscript")
|
|
2623
3277
|
return true;
|
|
2624
|
-
|
|
2625
|
-
return true;
|
|
2626
|
-
if (parent.type === "protocol_function_declaration" && parent.childForFieldName("name")?.id === node.id)
|
|
2627
|
-
return true;
|
|
2628
|
-
if (parent.type === "protocol_property_declaration" && parent.childForFieldName("name")?.id === node.id)
|
|
2629
|
-
return true;
|
|
2630
|
-
if (parent.type === "pattern" && parent.childForFieldName("bound_identifier")?.id === node.id && (parent.parent?.type === "property_declaration" || parent.parent?.type === "protocol_property_declaration"))
|
|
2631
|
-
return true;
|
|
2632
|
-
return false;
|
|
3278
|
+
return parent.type === "pattern" && parent.childForFieldName("bound_identifier")?.id === node.id && (parent.parent?.type === "property_declaration" || parent.parent?.type === "protocol_property_declaration");
|
|
2633
3279
|
},
|
|
2634
3280
|
scopeDeclarationNames: "all",
|
|
2635
|
-
createsFunctionScope: (
|
|
2636
|
-
|
|
3281
|
+
createsFunctionScope: nodeTypeIn([
|
|
3282
|
+
"function_declaration",
|
|
3283
|
+
"init_declaration",
|
|
3284
|
+
"deinit_declaration",
|
|
3285
|
+
"subscript_declaration"
|
|
3286
|
+
]),
|
|
3287
|
+
createsBlockScope: nodeTypeIn([
|
|
3288
|
+
"function_body",
|
|
3289
|
+
"class_body",
|
|
3290
|
+
"protocol_body",
|
|
3291
|
+
"enum_class_body",
|
|
3292
|
+
"catch_block",
|
|
3293
|
+
"willset_didset_block"
|
|
3294
|
+
]),
|
|
2637
3295
|
supportsCrossModuleSymbols: true,
|
|
3296
|
+
membersAreImplicitlyInScope: true,
|
|
2638
3297
|
exportScopeBlockers: ["function_body", "lambda_literal"]
|
|
2639
3298
|
};
|
|
2640
3299
|
registerLanguage(SWIFT_DEF);
|
|
@@ -2664,6 +3323,7 @@ var SQL_DEF = {
|
|
|
2664
3323
|
comments: ["comment"]
|
|
2665
3324
|
},
|
|
2666
3325
|
graph: {
|
|
3326
|
+
// SQL has no import specifier node; statements are the only capture.
|
|
2667
3327
|
imports: "(statement) @stmt",
|
|
2668
3328
|
exports: "",
|
|
2669
3329
|
locals: "",
|
|
@@ -2697,8 +3357,9 @@ var ZIG_DEF = {
|
|
|
2697
3357
|
},
|
|
2698
3358
|
graph: {
|
|
2699
3359
|
imports: `
|
|
2700
|
-
(builtin_function (builtin_identifier) @fn (arguments (string) @
|
|
2701
|
-
|
|
3360
|
+
(builtin_function (builtin_identifier) @fn (arguments (string) @from) (#eq? @fn "@import")) @stmt
|
|
3361
|
+
;; @cImport has no path argument; the builtin identifier is the specifier.
|
|
3362
|
+
(builtin_function (builtin_identifier) @from (arguments) (#eq? @from "@cImport")) @stmt
|
|
2702
3363
|
`,
|
|
2703
3364
|
exports: `
|
|
2704
3365
|
(source_file (function_declaration name: (identifier) @name))
|
|
@@ -2754,19 +3415,13 @@ var ZIG_DEF = {
|
|
|
2754
3415
|
return "type";
|
|
2755
3416
|
return "variable";
|
|
2756
3417
|
},
|
|
2757
|
-
createsFunctionScope: (
|
|
2758
|
-
createsBlockScope: (
|
|
2759
|
-
isDeclarationName: (node) =>
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
return true;
|
|
2765
|
-
if (parent.type !== "variable_declaration")
|
|
2766
|
-
return false;
|
|
2767
|
-
const declaredName = parent.namedChildren.find((child) => child.type === "identifier");
|
|
2768
|
-
return declaredName?.id === node.id;
|
|
2769
|
-
}
|
|
3418
|
+
createsFunctionScope: nodeTypeIn(["function_declaration"]),
|
|
3419
|
+
createsBlockScope: nodeTypeIn(["block"]),
|
|
3420
|
+
isDeclarationName: (node) => isNameFieldOnParent(node, ["function_declaration"]) || // No named field distinguishes the declared identifier from an initializer that is
|
|
3421
|
+
// itself a bare identifier (e.g. `const x = y;` puts both `x` and `y` directly under
|
|
3422
|
+
// `variable_declaration`); the declared name is always the first identifier child,
|
|
3423
|
+
// matching the lookup classifyDefinition above already relies on.
|
|
3424
|
+
node.parent?.type === "variable_declaration" && node.parent.namedChildren.find((child) => child.type === "identifier")?.id === node.id
|
|
2770
3425
|
};
|
|
2771
3426
|
registerLanguage(ZIG_DEF);
|
|
2772
3427
|
|
|
@@ -2868,112 +3523,6 @@ import { Buffer as Buffer2 } from "node:buffer";
|
|
|
2868
3523
|
// dist/languages.js
|
|
2869
3524
|
import fs from "node:fs";
|
|
2870
3525
|
import path from "node:path";
|
|
2871
|
-
|
|
2872
|
-
// dist/util/comments.js
|
|
2873
|
-
function transformJsLikeTrivia(src, options) {
|
|
2874
|
-
let out = "";
|
|
2875
|
-
let i = 0;
|
|
2876
|
-
let inSingle = false;
|
|
2877
|
-
let inDouble = false;
|
|
2878
|
-
let inTemplate = false;
|
|
2879
|
-
let escapeNext = false;
|
|
2880
|
-
const maskStrings = options?.maskStrings ?? false;
|
|
2881
|
-
const preserveLength = options?.preserveLength ?? false;
|
|
2882
|
-
const maskedChar = (ch) => ch === "\n" || ch === "\r" ? ch : " ";
|
|
2883
|
-
while (i < src.length) {
|
|
2884
|
-
const ch = src[i];
|
|
2885
|
-
const next = src[i + 1] ?? "";
|
|
2886
|
-
if (inSingle || inDouble || inTemplate) {
|
|
2887
|
-
const isClosingQuote = !escapeNext && (inSingle && ch === "'" || inDouble && ch === '"' || inTemplate && ch === "`");
|
|
2888
|
-
if (maskStrings) {
|
|
2889
|
-
out += isClosingQuote ? ch : maskedChar(ch);
|
|
2890
|
-
} else {
|
|
2891
|
-
out += ch;
|
|
2892
|
-
}
|
|
2893
|
-
if (escapeNext) {
|
|
2894
|
-
escapeNext = false;
|
|
2895
|
-
} else if (ch === "\\") {
|
|
2896
|
-
escapeNext = true;
|
|
2897
|
-
} else if (inSingle && ch === "'") {
|
|
2898
|
-
inSingle = false;
|
|
2899
|
-
} else if (inDouble && ch === '"') {
|
|
2900
|
-
inDouble = false;
|
|
2901
|
-
} else if (inTemplate && ch === "`") {
|
|
2902
|
-
inTemplate = false;
|
|
2903
|
-
}
|
|
2904
|
-
i += 1;
|
|
2905
|
-
continue;
|
|
2906
|
-
}
|
|
2907
|
-
if (ch === "'") {
|
|
2908
|
-
inSingle = true;
|
|
2909
|
-
out += ch;
|
|
2910
|
-
i += 1;
|
|
2911
|
-
continue;
|
|
2912
|
-
}
|
|
2913
|
-
if (ch === '"') {
|
|
2914
|
-
inDouble = true;
|
|
2915
|
-
out += ch;
|
|
2916
|
-
i += 1;
|
|
2917
|
-
continue;
|
|
2918
|
-
}
|
|
2919
|
-
if (ch === "`") {
|
|
2920
|
-
inTemplate = true;
|
|
2921
|
-
out += ch;
|
|
2922
|
-
i += 1;
|
|
2923
|
-
continue;
|
|
2924
|
-
}
|
|
2925
|
-
if (ch === "/" && next === "*") {
|
|
2926
|
-
if (preserveLength)
|
|
2927
|
-
out += " ";
|
|
2928
|
-
i += 2;
|
|
2929
|
-
let depth = 1;
|
|
2930
|
-
while (i < src.length && depth > 0) {
|
|
2931
|
-
if (options?.nestedBlockComments && src[i] === "/" && src[i + 1] === "*") {
|
|
2932
|
-
if (preserveLength)
|
|
2933
|
-
out += " ";
|
|
2934
|
-
depth += 1;
|
|
2935
|
-
i += 2;
|
|
2936
|
-
continue;
|
|
2937
|
-
}
|
|
2938
|
-
if (src[i] === "*" && src[i + 1] === "/") {
|
|
2939
|
-
if (preserveLength)
|
|
2940
|
-
out += " ";
|
|
2941
|
-
depth -= 1;
|
|
2942
|
-
i += 2;
|
|
2943
|
-
continue;
|
|
2944
|
-
}
|
|
2945
|
-
if (preserveLength)
|
|
2946
|
-
out += maskedChar(src[i]);
|
|
2947
|
-
else if (src[i] === "\n")
|
|
2948
|
-
out += "\n";
|
|
2949
|
-
i += 1;
|
|
2950
|
-
}
|
|
2951
|
-
continue;
|
|
2952
|
-
}
|
|
2953
|
-
if (ch === "/" && next === "/") {
|
|
2954
|
-
if (preserveLength)
|
|
2955
|
-
out += " ";
|
|
2956
|
-
i += 2;
|
|
2957
|
-
while (i < src.length && src[i] !== "\n") {
|
|
2958
|
-
if (preserveLength)
|
|
2959
|
-
out += " ";
|
|
2960
|
-
i += 1;
|
|
2961
|
-
}
|
|
2962
|
-
continue;
|
|
2963
|
-
}
|
|
2964
|
-
out += ch;
|
|
2965
|
-
i += 1;
|
|
2966
|
-
}
|
|
2967
|
-
return out;
|
|
2968
|
-
}
|
|
2969
|
-
function maskJsLikeCommentsAndStrings(src) {
|
|
2970
|
-
return transformJsLikeTrivia(src, {
|
|
2971
|
-
maskStrings: true,
|
|
2972
|
-
preserveLength: true
|
|
2973
|
-
});
|
|
2974
|
-
}
|
|
2975
|
-
|
|
2976
|
-
// dist/languages.js
|
|
2977
3526
|
function adaptDefinition(def) {
|
|
2978
3527
|
return {
|
|
2979
3528
|
id: def.id,
|
|
@@ -2985,7 +3534,7 @@ function adaptDefinition(def) {
|
|
|
2985
3534
|
scopeDeclarationNames: def.scopeDeclarationNames === "all" ? () => true : def.scopeDeclarationNames ?? (() => false),
|
|
2986
3535
|
createsBlockScope: def.createsBlockScope || (() => false),
|
|
2987
3536
|
createsFunctionScope: def.createsFunctionScope || (() => false),
|
|
2988
|
-
membersAreImplicitlyInScope: def.membersAreImplicitlyInScope ??
|
|
3537
|
+
membersAreImplicitlyInScope: def.membersAreImplicitlyInScope ?? false,
|
|
2989
3538
|
supportsCrossModuleSymbols: def.supportsCrossModuleSymbols || false,
|
|
2990
3539
|
isTypeOnly: def.isTypeOnly || (() => false),
|
|
2991
3540
|
exportScopeBlockers: def.exportScopeBlockers ?? [],
|