@lzehrung/codegraph 2.3.28 → 2.3.30
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 +7008 -4340
- package/dist/bin/query-index-worker.js +1357 -724
- 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 +12 -2
- 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/ast.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/ast.js +3 -0
- package/dist/graphs/symbol-graph-detailed/ast.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 +157 -91
- package/dist/graphs/symbol-graph-detailed/edge-passes.js.map +1 -1
- package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts +34 -0
- package/dist/graphs/symbol-graph-detailed/receiver-calls.d.ts.map +1 -1
- package/dist/graphs/symbol-graph-detailed/receiver-calls.js +531 -24
- package/dist/graphs/symbol-graph-detailed/receiver-calls.js.map +1 -1
- package/dist/impact/analyzer.d.ts.map +1 -1
- package/dist/impact/analyzer.js +82 -4
- package/dist/impact/analyzer.js.map +1 -1
- package/dist/impact/call-compatibility/providers/index.d.ts +3 -1
- package/dist/impact/call-compatibility/providers/index.d.ts.map +1 -1
- package/dist/impact/call-compatibility/providers/index.js +11 -4
- package/dist/impact/call-compatibility/providers/index.js.map +1 -1
- package/dist/impact/call-compatibility.d.ts.map +1 -1
- package/dist/impact/call-compatibility.js +2 -7
- package/dist/impact/call-compatibility.js.map +1 -1
- package/dist/impact/map.d.ts.map +1 -1
- package/dist/impact/map.js +58 -1
- package/dist/impact/map.js.map +1 -1
- package/dist/impact/member-resolution-coverage.d.ts.map +1 -1
- package/dist/impact/member-resolution-coverage.js +2 -5
- 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 +20 -2
- package/dist/indexer/build-cache/options.d.ts.map +1 -1
- package/dist/indexer/build-cache/options.js +21 -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 +1 -1
- 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/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.map +1 -1
- package/dist/indexer/imports/language-specific.js +58 -215
- 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/locals-and-exports.d.ts.map +1 -1
- package/dist/indexer/locals-and-exports.js +26 -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 +406 -276
- 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 +49 -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 +34 -53
- 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 +47 -53
- 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 +5 -1
- package/dist/languages/definitions/python.d.ts.map +1 -1
- package/dist/languages/definitions/python.js +62 -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 +36 -30
- 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 +65 -79
- 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/sql/graph.d.ts +1 -1
- package/dist/sql/graph.d.ts.map +1 -1
- package/dist/sql/graph.js.map +1 -1
- package/dist/sql/lookup.d.ts +7 -0
- package/dist/sql/lookup.d.ts.map +1 -1
- package/dist/sql/lookup.js +17 -0
- package/dist/sql/lookup.js.map +1 -1
- package/dist/sql/source-graph.d.ts +2 -0
- package/dist/sql/source-graph.d.ts.map +1 -1
- package/dist/sql/source-graph.js +20 -1
- package/dist/sql/source-graph.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/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.d.ts +2 -0
- package/dist/util/member-access.d.ts.map +1 -1
- package/dist/util/member-access.js +18 -5
- 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 +8 -0
- package/dist/util/resolution/csharp.d.ts.map +1 -0
- package/dist/util/resolution/csharp.js +103 -0
- package/dist/util/resolution/csharp.js.map +1 -0
- 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 +95 -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 +213 -164
- 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,49 +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 === "type_alias_declaration")
|
|
302
|
-
return "type";
|
|
303
|
-
if (t === "enum_declaration" || t === "internal_module" || t === "module")
|
|
304
|
-
return "type";
|
|
305
|
-
return "variable";
|
|
306
|
-
},
|
|
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
|
+
}),
|
|
307
1124
|
isDeclarationName: (node) => {
|
|
308
1125
|
const parent = node.parent;
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (parent?.type === "public_field_definition" || parent?.type === "enum_assignment") {
|
|
314
|
-
const name = parent.childForFieldName("name") ?? parent.childForFieldName("property");
|
|
315
|
-
return name?.id === node.id;
|
|
316
|
-
}
|
|
1126
|
+
if (isEcmaScriptVariableDeclaratorName(node))
|
|
1127
|
+
return true;
|
|
1128
|
+
if (isNameOrPropertyFieldOnParent(node, ["public_field_definition", "enum_assignment"]))
|
|
1129
|
+
return true;
|
|
317
1130
|
if (parent?.type === "enum_body") {
|
|
318
1131
|
return node.type === "property_identifier";
|
|
319
1132
|
}
|
|
320
|
-
return
|
|
321
|
-
|
|
322
|
-
"function_declaration",
|
|
323
|
-
"class_declaration",
|
|
1133
|
+
return hasParentType(node, [
|
|
1134
|
+
...ECMASCRIPT_DECLARATION_NAME_PARENTS,
|
|
324
1135
|
"abstract_class_declaration",
|
|
325
1136
|
"interface_declaration",
|
|
326
1137
|
"type_alias_declaration",
|
|
@@ -328,27 +1139,29 @@ var BASE_HELPERS = {
|
|
|
328
1139
|
"function_signature",
|
|
329
1140
|
"internal_module",
|
|
330
1141
|
"module",
|
|
331
|
-
"import_specifier",
|
|
332
|
-
"namespace_import",
|
|
333
|
-
"import_clause",
|
|
334
1142
|
"import_equals_declaration",
|
|
335
1143
|
// Method names in classes and abstract method signatures: needed so
|
|
336
1144
|
// that editing a method name is classified as a definition change.
|
|
337
|
-
"method_definition",
|
|
338
1145
|
"method_signature",
|
|
339
|
-
"abstract_method_signature"
|
|
340
|
-
|
|
1146
|
+
"abstract_method_signature",
|
|
1147
|
+
// A named function expression binds its own name inside its body:
|
|
1148
|
+
// `const f = function inner() {}` and `$scope.refresh = function refresh() {}`.
|
|
1149
|
+
"generator_function"
|
|
1150
|
+
]);
|
|
341
1151
|
},
|
|
342
1152
|
// Scope construction has structural handling for the ordinary declaration forms. Ambient
|
|
343
|
-
// overload signatures
|
|
344
|
-
// `isDeclarationName` already accepts
|
|
1153
|
+
// overload signatures, `namespace X {}`, and a named function expression's own name are not
|
|
1154
|
+
// in it, so opt their name nodes in here; `isDeclarationName` already accepts every parent.
|
|
1155
|
+
// The function-expression name is registered after the function scope is pushed, so it lands
|
|
1156
|
+
// in that scope: visible to the body (and recursive calls) but never to the module.
|
|
345
1157
|
scopeDeclarationNames: (node) => {
|
|
346
1158
|
const parent = node.parent?.type;
|
|
347
|
-
return parent === "function_signature" || parent === "internal_module" || parent === "module";
|
|
1159
|
+
return parent === "function_signature" || parent === "internal_module" || parent === "module" || parent === "function_expression" || parent === "generator_function";
|
|
348
1160
|
},
|
|
349
|
-
createsBlockScope: (
|
|
350
|
-
|
|
351
|
-
|
|
1161
|
+
createsBlockScope: nodeTypeIn([...ECMASCRIPT_BLOCK_SCOPE_TYPES, "enum_body"]),
|
|
1162
|
+
// A generator function expression has its own body scope: without this, its own name
|
|
1163
|
+
// (registered above) and its parameters would land in the enclosing scope.
|
|
1164
|
+
createsFunctionScope: nodeTypeIn([...ECMASCRIPT_FUNCTION_SCOPE_TYPES, "generator_function"]),
|
|
352
1165
|
supportsCrossModuleSymbols: true
|
|
353
1166
|
};
|
|
354
1167
|
var TYPESCRIPT_DEF = {
|
|
@@ -358,7 +1171,7 @@ var TYPESCRIPT_DEF = {
|
|
|
358
1171
|
graph: BASE_GRAPH,
|
|
359
1172
|
supportsExportFromReferences: true,
|
|
360
1173
|
...BASE_HELPERS,
|
|
361
|
-
isTypeOnly:
|
|
1174
|
+
isTypeOnly: isEcmaScriptTypeOnlyStatement,
|
|
362
1175
|
native: {
|
|
363
1176
|
normalizeQuery: normalizeTypeScriptNativeQuery,
|
|
364
1177
|
authoritativeKinds: ["exports"],
|
|
@@ -380,7 +1193,7 @@ var TSX_DEF = {
|
|
|
380
1193
|
graph: BASE_GRAPH,
|
|
381
1194
|
supportsExportFromReferences: true,
|
|
382
1195
|
...BASE_HELPERS,
|
|
383
|
-
isTypeOnly:
|
|
1196
|
+
isTypeOnly: isEcmaScriptTypeOnlyStatement,
|
|
384
1197
|
native: {
|
|
385
1198
|
normalizeQuery: normalizeTypeScriptNativeQuery,
|
|
386
1199
|
authoritativeKinds: ["exports"],
|
|
@@ -415,10 +1228,10 @@ var JAVASCRIPT_DEF = {
|
|
|
415
1228
|
},
|
|
416
1229
|
graph: {
|
|
417
1230
|
imports: `
|
|
418
|
-
(import_statement (string) @
|
|
419
|
-
(export_statement (string) @
|
|
420
|
-
(call_expression function: (import) arguments: (arguments (string) @
|
|
421
|
-
((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
|
|
422
1235
|
(#eq? @fn "require"))
|
|
423
1236
|
`,
|
|
424
1237
|
exports: `
|
|
@@ -434,8 +1247,10 @@ var JAVASCRIPT_DEF = {
|
|
|
434
1247
|
(export_statement (export_clause (export_specifier name: (identifier) @src !alias)) (string) @from)
|
|
435
1248
|
(export_statement (export_clause (export_specifier name: (identifier) @src alias: (identifier) @alias)))
|
|
436
1249
|
(export_statement (export_clause (export_specifier name: (identifier) @src !alias)))
|
|
1250
|
+
(export_statement "*" @wild (string) @from)
|
|
437
1251
|
(export_statement (string) @from)
|
|
438
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.
|
|
439
1254
|
((expression_statement (assignment_expression
|
|
440
1255
|
left: (member_expression object: (identifier) @mod property: (property_identifier) @cjs_export_name)
|
|
441
1256
|
right: [ (function) (arrow_function) ] @cjs_fn))
|
|
@@ -520,55 +1335,28 @@ var JAVASCRIPT_DEF = {
|
|
|
520
1335
|
shorthandPropertyIdentifier: ["shorthand_property_identifier", "shorthand_property_identifier_pattern"],
|
|
521
1336
|
memberExpression: "member_expression"
|
|
522
1337
|
},
|
|
523
|
-
classifyDefinition: (
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
return "class";
|
|
535
|
-
return "variable";
|
|
536
|
-
},
|
|
537
|
-
isDeclarationName: (node) => {
|
|
538
|
-
const parent = node.parent;
|
|
539
|
-
const p = parent?.type;
|
|
540
|
-
if (parent?.type === "variable_declarator") {
|
|
541
|
-
return parent.childForFieldName("name")?.id === node.id;
|
|
542
|
-
}
|
|
543
|
-
if (parent?.type === "field_definition") {
|
|
544
|
-
const name = parent.childForFieldName("name") ?? parent.childForFieldName("property");
|
|
545
|
-
return name?.id === node.id;
|
|
546
|
-
}
|
|
547
|
-
return !!p && [
|
|
548
|
-
"function_declaration",
|
|
549
|
-
"generator_function_declaration",
|
|
550
|
-
"class_declaration",
|
|
551
|
-
"import_specifier",
|
|
552
|
-
"namespace_import",
|
|
553
|
-
"import_clause",
|
|
554
|
-
// Method names in classes: needed so that editing a method name is
|
|
555
|
-
// classified as a definition change, not an unrecognised node.
|
|
556
|
-
"method_definition",
|
|
557
|
-
// A named function expression binds its own name; `$scope.x = function x() {}` and
|
|
558
|
-
// `const f = function inner() {}` are the common shapes.
|
|
559
|
-
"function",
|
|
560
|
-
"function_expression"
|
|
561
|
-
].includes(p);
|
|
562
|
-
},
|
|
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"]),
|
|
563
1349
|
// Scope construction has no structural handling for a function expression's own name.
|
|
564
1350
|
scopeDeclarationNames: (node) => {
|
|
565
1351
|
const parent = node.parent?.type;
|
|
566
1352
|
return parent === "function" || parent === "function_expression";
|
|
567
1353
|
},
|
|
568
|
-
createsBlockScope: (
|
|
569
|
-
createsFunctionScope: (
|
|
570
|
-
membersAreImplicitlyInScope: false,
|
|
1354
|
+
createsBlockScope: nodeTypeIn([...ECMASCRIPT_BLOCK_SCOPE_TYPES]),
|
|
1355
|
+
createsFunctionScope: nodeTypeIn([...ECMASCRIPT_FUNCTION_SCOPE_TYPES, "function"]),
|
|
571
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,
|
|
572
1360
|
native: {
|
|
573
1361
|
normalizeQuery: (_kind, query) => query.replace(/\(function\)/g, "(function_expression)").replace(JS_OBJECT_METHOD_EXPORT_PATTERN, JS_OBJECT_METHOD_EXPORT_NATIVE_PATTERN),
|
|
574
1362
|
authoritativeKinds: ["exports"],
|
|
@@ -603,16 +1391,48 @@ function isTypeAliasLeftName(node) {
|
|
|
603
1391
|
if (!parent)
|
|
604
1392
|
return false;
|
|
605
1393
|
if (parent.type === "type") {
|
|
606
|
-
const
|
|
607
|
-
return
|
|
1394
|
+
const stmt4 = parent.parent;
|
|
1395
|
+
return stmt4?.type === "type_alias_statement" && stmt4.childForFieldName("left")?.id === parent.id;
|
|
608
1396
|
}
|
|
609
1397
|
if (parent.type === "generic_type") {
|
|
610
1398
|
const typeNode = parent.parent;
|
|
611
|
-
const
|
|
612
|
-
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;
|
|
613
1401
|
}
|
|
614
1402
|
return false;
|
|
615
1403
|
}
|
|
1404
|
+
function isPythonImplicitReceiverName(name) {
|
|
1405
|
+
return name === "self" || name === "cls";
|
|
1406
|
+
}
|
|
1407
|
+
function isPythonReceiverAttributeAssignmentName(node) {
|
|
1408
|
+
const attr = node.parent;
|
|
1409
|
+
if (attr?.type !== "attribute")
|
|
1410
|
+
return false;
|
|
1411
|
+
if (attr.childForFieldName("attribute")?.id !== node.id)
|
|
1412
|
+
return false;
|
|
1413
|
+
const object = attr.childForFieldName("object");
|
|
1414
|
+
if (!object || !isPythonImplicitReceiverName(object.text))
|
|
1415
|
+
return false;
|
|
1416
|
+
const assignment = attr.parent;
|
|
1417
|
+
if (assignment?.type !== "assignment")
|
|
1418
|
+
return false;
|
|
1419
|
+
return assignment.childForFieldName("left")?.id === attr.id;
|
|
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
|
+
`;
|
|
616
1436
|
var PYTHON_DEF = {
|
|
617
1437
|
id: "python",
|
|
618
1438
|
extensions: [".py", ".pyi", ".pyw"],
|
|
@@ -662,11 +1482,7 @@ var PYTHON_DEF = {
|
|
|
662
1482
|
comments: ["comment"]
|
|
663
1483
|
},
|
|
664
1484
|
graph: {
|
|
665
|
-
imports:
|
|
666
|
-
(import_statement) @stmt
|
|
667
|
-
(import_from_statement) @stmt
|
|
668
|
-
(future_import_statement) @stmt
|
|
669
|
-
`,
|
|
1485
|
+
imports: PYTHON_GRAPH_IMPORT_QUERY,
|
|
670
1486
|
// NOTE: These __all__ queries only capture module-level assignments.
|
|
671
1487
|
// Dynamic __all__ definitions inside functions, conditionals, or loops
|
|
672
1488
|
// (e.g., `if PY3: __all__ = [...]`) are not detected by these patterns.
|
|
@@ -709,6 +1525,13 @@ var PYTHON_DEF = {
|
|
|
709
1525
|
(class_definition name: (identifier) @name)
|
|
710
1526
|
(assignment left: (identifier) @name)
|
|
711
1527
|
(assignment left: [(pattern_list (identifier) @name) (tuple_pattern (identifier) @name)])
|
|
1528
|
+
;; Instance / class attributes declared as \`self.x = ...\` or \`cls.x = ...\`.
|
|
1529
|
+
((assignment
|
|
1530
|
+
left: (attribute object: (identifier) @receiver attribute: (identifier) @name))
|
|
1531
|
+
(#eq? @receiver "self"))
|
|
1532
|
+
((assignment
|
|
1533
|
+
left: (attribute object: (identifier) @receiver attribute: (identifier) @name))
|
|
1534
|
+
(#eq? @receiver "cls"))
|
|
712
1535
|
(named_expression name: (identifier) @name)
|
|
713
1536
|
(type_alias_statement left: (type [(identifier) @name (generic_type (identifier) @name)]))
|
|
714
1537
|
;; \`case Point(x=px, y=py):\` is case_pattern -> class_pattern ->
|
|
@@ -730,11 +1553,7 @@ var PYTHON_DEF = {
|
|
|
730
1553
|
;; \`case [head, *tail]:\` binds the capture after the splat.
|
|
731
1554
|
(splat_pattern (identifier) @name)
|
|
732
1555
|
`,
|
|
733
|
-
importBindings:
|
|
734
|
-
(import_statement) @stmt
|
|
735
|
-
(import_from_statement) @stmt
|
|
736
|
-
(future_import_statement) @stmt
|
|
737
|
-
`
|
|
1556
|
+
importBindings: PYTHON_BINDING_QUERY
|
|
738
1557
|
},
|
|
739
1558
|
nodeTypes: {
|
|
740
1559
|
identifier: ["identifier"],
|
|
@@ -767,9 +1586,11 @@ var PYTHON_DEF = {
|
|
|
767
1586
|
if (t === "splat_pattern")
|
|
768
1587
|
return true;
|
|
769
1588
|
if (t === "named_expression")
|
|
770
|
-
return
|
|
1589
|
+
return isNameFieldOnParent(node, ["named_expression"]);
|
|
771
1590
|
if (t === "pattern_list" || t === "tuple_pattern")
|
|
772
1591
|
return true;
|
|
1592
|
+
if (isPythonReceiverAttributeAssignmentName(node))
|
|
1593
|
+
return true;
|
|
773
1594
|
if (t === "assignment")
|
|
774
1595
|
return parent?.childForFieldName("left")?.id === node.id;
|
|
775
1596
|
if (t === "aliased_import")
|
|
@@ -778,9 +1599,8 @@ var PYTHON_DEF = {
|
|
|
778
1599
|
return true;
|
|
779
1600
|
return !!t && ["function_definition", "class_definition"].includes(t);
|
|
780
1601
|
},
|
|
781
|
-
createsBlockScope: (
|
|
782
|
-
createsFunctionScope: (
|
|
783
|
-
membersAreImplicitlyInScope: false,
|
|
1602
|
+
createsBlockScope: nodeTypeIn(["module", "block"]),
|
|
1603
|
+
createsFunctionScope: nodeTypeIn(["function_definition", "lambda"]),
|
|
784
1604
|
supportsCrossModuleSymbols: true,
|
|
785
1605
|
// A function body and a class body are both `block`, so only the function form blocks exports.
|
|
786
1606
|
exportScopeBlockers: ["function_definition>block"],
|
|
@@ -789,6 +1609,17 @@ var PYTHON_DEF = {
|
|
|
789
1609
|
registerLanguage(PYTHON_DEF);
|
|
790
1610
|
|
|
791
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
|
+
`;
|
|
792
1623
|
var PHP_DEF = {
|
|
793
1624
|
id: "php",
|
|
794
1625
|
extensions: [".php", ".phtml", ".php4", ".php8"],
|
|
@@ -849,13 +1680,11 @@ var PHP_DEF = {
|
|
|
849
1680
|
comments: ["comment"]
|
|
850
1681
|
},
|
|
851
1682
|
graph: {
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
(namespace_use_declaration) @stmt
|
|
858
|
-
`,
|
|
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,
|
|
859
1688
|
exports: `
|
|
860
1689
|
(namespace_definition name: (namespace_name) @name)
|
|
861
1690
|
(class_declaration name: (name) @name)
|
|
@@ -877,73 +1706,77 @@ var PHP_DEF = {
|
|
|
877
1706
|
(const_declaration (const_element . (name) @name))
|
|
878
1707
|
(property_element name: (variable_name) @name)
|
|
879
1708
|
`,
|
|
880
|
-
importBindings:
|
|
881
|
-
(require_expression) @stmt
|
|
882
|
-
(include_expression) @stmt
|
|
883
|
-
(require_once_expression) @stmt
|
|
884
|
-
(include_once_expression) @stmt
|
|
885
|
-
(namespace_use_declaration) @stmt
|
|
886
|
-
`
|
|
1709
|
+
importBindings: PHP_IMPORT_QUERY
|
|
887
1710
|
},
|
|
888
1711
|
nodeTypes: {
|
|
889
1712
|
identifier: ["name", "variable_name", "namespace_name", "qualified_name", "relative_name"],
|
|
890
1713
|
propertyIdentifier: ["name"],
|
|
891
1714
|
memberExpression: "member_access_expression"
|
|
892
1715
|
},
|
|
893
|
-
classifyDefinition: (
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if (parentType === "function_definition")
|
|
906
|
-
return "function";
|
|
907
|
-
if (parentType === "method_declaration")
|
|
908
|
-
return "method";
|
|
909
|
-
if (parentType === "namespace_definition")
|
|
910
|
-
return "namespace";
|
|
911
|
-
if (parentType === "const_element" || parentType === "const_declaration") {
|
|
912
|
-
return "constant";
|
|
913
|
-
}
|
|
914
|
-
return "variable";
|
|
915
|
-
},
|
|
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
|
+
}),
|
|
916
1728
|
normalizeIdentifier: (name) => name.replace(/^\$/, ""),
|
|
917
|
-
isDeclarationName: (node) =>
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
return parent.childForFieldName("name")?.id === node.id;
|
|
936
|
-
}
|
|
937
|
-
return parent.type === "const_element" && parent.namedChildren[0]?.id === node.id && node.type === "name";
|
|
938
|
-
},
|
|
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",
|
|
939
1747
|
scopeDeclarationNames: (node) => node.type === "variable_name" && node.parent?.type === "property_element",
|
|
940
1748
|
createsFunctionScope: (node) => node.type === "function_definition" || node.type === "method_declaration",
|
|
941
|
-
|
|
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"],
|
|
942
1755
|
supportsCrossModuleSymbols: true
|
|
943
1756
|
};
|
|
944
1757
|
registerLanguage(PHP_DEF);
|
|
945
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
|
+
|
|
946
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");
|
|
947
1780
|
var HTML_DEF = {
|
|
948
1781
|
id: "html",
|
|
949
1782
|
extensions: [".html", ".htm", ".xhtml"],
|
|
@@ -961,24 +1794,12 @@ var HTML_DEF = {
|
|
|
961
1794
|
comments: ["comment"]
|
|
962
1795
|
},
|
|
963
1796
|
graph: {
|
|
964
|
-
imports:
|
|
965
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @mod)))) @stmt
|
|
966
|
-
((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)$"))
|
|
967
|
-
((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)$"))
|
|
968
|
-
((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$"))
|
|
969
|
-
((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$"))
|
|
970
|
-
`,
|
|
1797
|
+
imports: htmlAssetImports,
|
|
971
1798
|
exports: "",
|
|
972
1799
|
locals: `
|
|
973
1800
|
(attribute (attribute_name) @attr (#match? @attr "^(?i)id$") (quoted_attribute_value (attribute_value) @name))
|
|
974
1801
|
`,
|
|
975
|
-
importBindings:
|
|
976
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#match? @attr "^(?i)src$") (quoted_attribute_value (attribute_value) @from)))) @stmt
|
|
977
|
-
((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)$"))
|
|
978
|
-
((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)$"))
|
|
979
|
-
((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$"))
|
|
980
|
-
((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$"))
|
|
981
|
-
`
|
|
1802
|
+
importBindings: htmlAssetImports
|
|
982
1803
|
},
|
|
983
1804
|
nodeTypes: {
|
|
984
1805
|
identifier: ["attribute_value", "tag_name"]
|
|
@@ -1033,6 +1854,15 @@ var ADOC_DEF = htmlStubLanguage("adoc", [".adoc", ".asciidoc"]);
|
|
|
1033
1854
|
registerLanguage(ADOC_DEF);
|
|
1034
1855
|
|
|
1035
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
|
+
`;
|
|
1036
1866
|
function cssLikeStructure() {
|
|
1037
1867
|
return {
|
|
1038
1868
|
blocks: [
|
|
@@ -1046,17 +1876,10 @@ function cssLikeStructure() {
|
|
|
1046
1876
|
}
|
|
1047
1877
|
function cssLikeGraph() {
|
|
1048
1878
|
return {
|
|
1049
|
-
imports:
|
|
1050
|
-
(import_statement (string_value) @mod) @stmt
|
|
1051
|
-
`,
|
|
1879
|
+
imports: cssLikeImportQuery,
|
|
1052
1880
|
exports: "",
|
|
1053
|
-
locals:
|
|
1054
|
-
|
|
1055
|
-
(id_selector (id_name) @name)
|
|
1056
|
-
`,
|
|
1057
|
-
importBindings: `
|
|
1058
|
-
(import_statement (string_value) @from) @stmt
|
|
1059
|
-
`
|
|
1881
|
+
locals: cssLikeLocalsQuery,
|
|
1882
|
+
importBindings: cssLikeImportQuery
|
|
1060
1883
|
};
|
|
1061
1884
|
}
|
|
1062
1885
|
function cssLikeNodeTypes() {
|
|
@@ -1076,6 +1899,22 @@ var CSS_DEF = {
|
|
|
1076
1899
|
registerLanguage(CSS_DEF);
|
|
1077
1900
|
|
|
1078
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
|
+
`;
|
|
1079
1918
|
var SCSS_DEF = {
|
|
1080
1919
|
id: "scss",
|
|
1081
1920
|
extensions: [".scss"],
|
|
@@ -1092,46 +1931,30 @@ var SCSS_DEF = {
|
|
|
1092
1931
|
comments: ["comment", "js_comment"]
|
|
1093
1932
|
},
|
|
1094
1933
|
graph: {
|
|
1095
|
-
imports:
|
|
1096
|
-
(import_statement (string_value) @mod) @stmt
|
|
1097
|
-
(import_statement (_ (string_value) @mod)) @stmt
|
|
1098
|
-
(use_statement (string_value) @mod) @stmt
|
|
1099
|
-
(use_statement (_ (string_value) @mod)) @stmt
|
|
1100
|
-
(forward_statement (string_value) @mod) @stmt
|
|
1101
|
-
(forward_statement (_ (string_value) @mod)) @stmt
|
|
1102
|
-
`,
|
|
1934
|
+
imports: `${cssGraph.imports}${sassImportQueries}`,
|
|
1103
1935
|
exports: `
|
|
1104
1936
|
(stylesheet (mixin_statement name: (identifier) @name))
|
|
1105
1937
|
(stylesheet (function_statement name: (identifier) @name))
|
|
1106
1938
|
((stylesheet (declaration (property_name) @name)) (#match? @name "^[$]"))
|
|
1107
1939
|
(stylesheet (rule_set (selectors (placeholder (identifier) @name))))
|
|
1108
1940
|
`,
|
|
1109
|
-
locals:
|
|
1110
|
-
|
|
1111
|
-
(function_statement name: (identifier) @name)
|
|
1112
|
-
((declaration (property_name) @name) (#match? @name "^[$]"))
|
|
1113
|
-
(placeholder (identifier) @name)
|
|
1114
|
-
(class_selector (class_name) @name)
|
|
1115
|
-
(id_selector (id_name) @name)
|
|
1116
|
-
`,
|
|
1117
|
-
importBindings: `
|
|
1118
|
-
(import_statement (string_value) @from) @stmt
|
|
1119
|
-
(import_statement (_ (string_value) @from)) @stmt
|
|
1120
|
-
(use_statement (string_value) @from) @stmt
|
|
1121
|
-
(use_statement (_ (string_value) @from)) @stmt
|
|
1122
|
-
(forward_statement (string_value) @from) @stmt
|
|
1123
|
-
(forward_statement (_ (string_value) @from)) @stmt
|
|
1124
|
-
`
|
|
1941
|
+
locals: `${sassLocalQueries}${cssGraph.locals}`,
|
|
1942
|
+
importBindings: `${cssGraph.importBindings}${sassImportQueries}`
|
|
1125
1943
|
},
|
|
1126
1944
|
nodeTypes: {
|
|
1127
1945
|
identifier: ["identifier", "variable", "class_name", "id_name", "property_name"]
|
|
1128
1946
|
},
|
|
1129
|
-
classifyDefinition: (
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
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
|
+
]),
|
|
1957
|
+
scopeDeclarationNames: "all"
|
|
1135
1958
|
};
|
|
1136
1959
|
registerLanguage(SCSS_DEF);
|
|
1137
1960
|
|
|
@@ -1145,6 +1968,21 @@ var LESS_DEF = {
|
|
|
1145
1968
|
};
|
|
1146
1969
|
registerLanguage(LESS_DEF);
|
|
1147
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
|
+
|
|
1148
1986
|
// dist/languages/definitions/vue.js
|
|
1149
1987
|
var VUE_DEF = {
|
|
1150
1988
|
id: "vue",
|
|
@@ -1155,19 +1993,10 @@ var VUE_DEF = {
|
|
|
1155
1993
|
{ type: "script_element", captureId: "script" },
|
|
1156
1994
|
{ type: "style_element", captureId: "style" }
|
|
1157
1995
|
],
|
|
1158
|
-
splitPoints: ["template_element", "script_element", "style_element"],
|
|
1159
|
-
comments: ["comment"]
|
|
1160
|
-
},
|
|
1161
|
-
graph: {
|
|
1162
|
-
imports: `
|
|
1163
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @mod)))) @stmt
|
|
1164
|
-
`,
|
|
1165
|
-
exports: "",
|
|
1166
|
-
locals: "",
|
|
1167
|
-
importBindings: `
|
|
1168
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @from)))) @stmt
|
|
1169
|
-
`
|
|
1996
|
+
splitPoints: ["template_element", "script_element", "style_element"],
|
|
1997
|
+
comments: ["comment"]
|
|
1170
1998
|
},
|
|
1999
|
+
graph: sfcExternalScriptGraph(),
|
|
1171
2000
|
nodeTypes: {
|
|
1172
2001
|
identifier: ["attribute_value"]
|
|
1173
2002
|
}
|
|
@@ -1187,16 +2016,7 @@ var SVELTE_DEF = {
|
|
|
1187
2016
|
splitPoints: ["script_element", "style_element"],
|
|
1188
2017
|
comments: ["comment"]
|
|
1189
2018
|
},
|
|
1190
|
-
graph:
|
|
1191
|
-
imports: `
|
|
1192
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @mod)))) @stmt
|
|
1193
|
-
`,
|
|
1194
|
-
exports: "",
|
|
1195
|
-
locals: "",
|
|
1196
|
-
importBindings: `
|
|
1197
|
-
(script_element (start_tag (attribute (attribute_name) @attr (#eq? @attr "src") (quoted_attribute_value (attribute_value) @from)))) @stmt
|
|
1198
|
-
`
|
|
1199
|
-
},
|
|
2019
|
+
graph: sfcExternalScriptGraph(),
|
|
1200
2020
|
nodeTypes: {
|
|
1201
2021
|
identifier: ["attribute_value"]
|
|
1202
2022
|
}
|
|
@@ -1206,6 +2026,7 @@ registerLanguage(SVELTE_DEF);
|
|
|
1206
2026
|
// dist/languages/definitions/ruby.js
|
|
1207
2027
|
var RUBY_DEF = {
|
|
1208
2028
|
id: "ruby",
|
|
2029
|
+
usesQueryDrivenLocals: true,
|
|
1209
2030
|
extensions: [".rb", ".rbw", ".rake", ".gemspec"],
|
|
1210
2031
|
structure: {
|
|
1211
2032
|
blocks: [
|
|
@@ -1235,7 +2056,7 @@ var RUBY_DEF = {
|
|
|
1235
2056
|
},
|
|
1236
2057
|
graph: {
|
|
1237
2058
|
imports: `
|
|
1238
|
-
(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
|
|
1239
2060
|
`,
|
|
1240
2061
|
exports: `
|
|
1241
2062
|
(class name: [(constant) (scope_resolution)] @name)
|
|
@@ -1261,7 +2082,16 @@ var RUBY_DEF = {
|
|
|
1261
2082
|
memberExpression: "call"
|
|
1262
2083
|
},
|
|
1263
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.
|
|
1264
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";
|
|
1265
2095
|
const assignment = node.parent;
|
|
1266
2096
|
const value = assignment?.childForFieldName("right");
|
|
1267
2097
|
if (assignment?.type === "assignment" && assignment.childForFieldName("left")?.id === node.id && value?.type === "call" && value.childForFieldName("receiver")?.text === "Struct" && value.childForFieldName("method")?.text === "new") {
|
|
@@ -1272,22 +2102,7 @@ var RUBY_DEF = {
|
|
|
1272
2102
|
scopeDeclarationNames: (node) => node.type === "constant" && node.parent?.type === "assignment",
|
|
1273
2103
|
createsFunctionScope: (node) => node.type === "method" || node.type === "singleton_method",
|
|
1274
2104
|
createsBlockScope: (node) => node.type === "do_block" || node.type === "block",
|
|
1275
|
-
isDeclarationName: (node) =>
|
|
1276
|
-
const p = node.parent;
|
|
1277
|
-
if (!p)
|
|
1278
|
-
return false;
|
|
1279
|
-
if (p.type === "class" && p.childForFieldName("name")?.id === node.id)
|
|
1280
|
-
return true;
|
|
1281
|
-
if (p.type === "module" && p.childForFieldName("name")?.id === node.id)
|
|
1282
|
-
return true;
|
|
1283
|
-
if (p.type === "method" && p.childForFieldName("name")?.id === node.id)
|
|
1284
|
-
return true;
|
|
1285
|
-
if (p.type === "singleton_method" && p.childForFieldName("name")?.id === node.id)
|
|
1286
|
-
return true;
|
|
1287
|
-
if (p.type === "assignment" && p.childForFieldName("left")?.id === node.id)
|
|
1288
|
-
return true;
|
|
1289
|
-
return false;
|
|
1290
|
-
}
|
|
2105
|
+
isDeclarationName: (node) => isNameFieldOnParent(node, ["class", "module", "method", "singleton_method"]) || isNameFieldOnParent(node, ["assignment"], "left")
|
|
1291
2106
|
};
|
|
1292
2107
|
registerLanguage(RUBY_DEF);
|
|
1293
2108
|
|
|
@@ -1325,7 +2140,7 @@ var GO_DEF = {
|
|
|
1325
2140
|
},
|
|
1326
2141
|
graph: {
|
|
1327
2142
|
imports: `
|
|
1328
|
-
(import_spec path: (interpreted_string_literal) @
|
|
2143
|
+
(import_spec path: (interpreted_string_literal) @from) @stmt
|
|
1329
2144
|
`,
|
|
1330
2145
|
exports: `
|
|
1331
2146
|
(function_declaration name: (identifier) @name)
|
|
@@ -1348,7 +2163,9 @@ var GO_DEF = {
|
|
|
1348
2163
|
(range_clause left: (expression_list (identifier) @name) (#not-eq? @name "_"))
|
|
1349
2164
|
`,
|
|
1350
2165
|
importBindings: `
|
|
2166
|
+
(import_spec name: (dot) @wild path: (interpreted_string_literal) @from) @stmt
|
|
1351
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
|
|
1352
2169
|
(import_spec path: (interpreted_string_literal) @from) @stmt
|
|
1353
2170
|
`
|
|
1354
2171
|
},
|
|
@@ -1357,52 +2174,33 @@ var GO_DEF = {
|
|
|
1357
2174
|
memberExpression: "selector_expression"
|
|
1358
2175
|
},
|
|
1359
2176
|
supportsCrossModuleSymbols: true,
|
|
1360
|
-
classifyDefinition: (
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
if (!p)
|
|
1378
|
-
return false;
|
|
1379
|
-
if (p.type === "function_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1380
|
-
return true;
|
|
1381
|
-
if (p.type === "method_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1382
|
-
return true;
|
|
1383
|
-
if (p.type === "type_spec" && p.childForFieldName("name")?.id === node.id)
|
|
1384
|
-
return true;
|
|
1385
|
-
if ((p.type === "var_spec" || p.type === "const_spec") && node.type === "identifier")
|
|
1386
|
-
return true;
|
|
1387
|
-
if (p.type === "type_parameter_declaration" && node.type === "identifier")
|
|
1388
|
-
return true;
|
|
1389
|
-
if (p.type === "expression_list" && p.parent?.type === "short_var_declaration")
|
|
1390
|
-
return node.type === "identifier";
|
|
1391
|
-
if (p.type === "expression_list" && p.parent?.type === "range_clause")
|
|
1392
|
-
return node.type === "identifier" && node.text !== "_";
|
|
1393
|
-
if (p.type === "parameter_declaration" || p.type === "variadic_parameter_declaration") {
|
|
1394
|
-
return node.type === "identifier";
|
|
1395
|
-
}
|
|
1396
|
-
if (p.type === "field_declaration" && node.type === "field_identifier")
|
|
1397
|
-
return true;
|
|
1398
|
-
return false;
|
|
1399
|
-
},
|
|
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 !== "_",
|
|
1400
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"
|
|
1401
2195
|
};
|
|
1402
2196
|
registerLanguage(GO_DEF);
|
|
1403
2197
|
|
|
1404
2198
|
// dist/languages/definitions/java.js
|
|
1405
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
|
+
`;
|
|
1406
2204
|
var JAVA_DEF = {
|
|
1407
2205
|
id: "java",
|
|
1408
2206
|
extensions: [".java"],
|
|
@@ -1449,9 +2247,7 @@ var JAVA_DEF = {
|
|
|
1449
2247
|
comments: ["line_comment", "block_comment"]
|
|
1450
2248
|
},
|
|
1451
2249
|
graph: {
|
|
1452
|
-
imports:
|
|
1453
|
-
(import_declaration . (_) @mod) @stmt
|
|
1454
|
-
`,
|
|
2250
|
+
imports: JAVA_IMPORT_QUERY,
|
|
1455
2251
|
exports: `
|
|
1456
2252
|
(class_declaration name: (identifier) @name)
|
|
1457
2253
|
(record_declaration name: (identifier) @name)
|
|
@@ -1475,58 +2271,40 @@ var JAVA_DEF = {
|
|
|
1475
2271
|
(spread_parameter (variable_declarator name: (identifier) @name))
|
|
1476
2272
|
(receiver_parameter (identifier) @name)
|
|
1477
2273
|
`,
|
|
1478
|
-
importBindings:
|
|
1479
|
-
(import_declaration . (_) @from) @stmt
|
|
1480
|
-
`
|
|
2274
|
+
importBindings: JAVA_IMPORT_QUERY
|
|
1481
2275
|
},
|
|
1482
2276
|
nodeTypes: {
|
|
1483
2277
|
identifier: ["identifier", "type_identifier"],
|
|
1484
2278
|
memberExpression: "field_access"
|
|
1485
2279
|
},
|
|
1486
2280
|
supportsCrossModuleSymbols: true,
|
|
2281
|
+
membersAreImplicitlyInScope: true,
|
|
1487
2282
|
exportScopeBlockers: ["block", "constructor_body"],
|
|
1488
|
-
classifyDefinition: (
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
return true;
|
|
1514
|
-
if (p.type === "annotation_type_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1515
|
-
return true;
|
|
1516
|
-
if (p.type === "enum_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1517
|
-
return true;
|
|
1518
|
-
if (p.type === "enum_constant" && p.childForFieldName("name")?.id === node.id)
|
|
1519
|
-
return true;
|
|
1520
|
-
if (p.type === "method_declaration" && p.childForFieldName("name")?.id === node.id)
|
|
1521
|
-
return true;
|
|
1522
|
-
if (p.type === "variable_declarator" && p.childForFieldName("name")?.id === node.id)
|
|
1523
|
-
return true;
|
|
1524
|
-
if (p.type === "formal_parameter" && p.childForFieldName("name")?.id === node.id)
|
|
1525
|
-
return true;
|
|
1526
|
-
if (p.type === "receiver_parameter" && node.type === "identifier")
|
|
1527
|
-
return true;
|
|
1528
|
-
return false;
|
|
1529
|
-
},
|
|
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",
|
|
1530
2308
|
normalizeIdentifier: (name) => hasNonAsciiCodePoint(name, true) ? name.replace(JAVA_IDENTIFIER_IGNORABLE_PATTERN, "") : name
|
|
1531
2309
|
};
|
|
1532
2310
|
registerLanguage(JAVA_DEF);
|
|
@@ -1591,10 +2369,11 @@ var CSHARP_DEF = {
|
|
|
1591
2369
|
comments: ["comment"]
|
|
1592
2370
|
},
|
|
1593
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 `(_)`.
|
|
1594
2374
|
imports: `
|
|
1595
|
-
(using_directive !name (_) @
|
|
1596
|
-
(using_directive name: (identifier) (_) @
|
|
1597
|
-
(extern_alias_directive name: (identifier) @mod) @stmt
|
|
2375
|
+
(using_directive !name (_) @from) @stmt
|
|
2376
|
+
(using_directive name: (identifier) (_) @from) @stmt
|
|
1598
2377
|
`,
|
|
1599
2378
|
exports: `
|
|
1600
2379
|
(class_declaration name: (identifier) @name)
|
|
@@ -1612,6 +2391,9 @@ var CSHARP_DEF = {
|
|
|
1612
2391
|
locals: `
|
|
1613
2392
|
(class_declaration name: (identifier) @name)
|
|
1614
2393
|
(record_declaration name: (identifier) @name)
|
|
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)))
|
|
1615
2397
|
(struct_declaration name: (identifier) @name)
|
|
1616
2398
|
(interface_declaration name: (identifier) @name)
|
|
1617
2399
|
(enum_declaration name: (identifier) @name)
|
|
@@ -1623,6 +2405,8 @@ var CSHARP_DEF = {
|
|
|
1623
2405
|
(variable_declarator name: (identifier) @name)
|
|
1624
2406
|
(declaration_pattern name: (identifier) @name)
|
|
1625
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 `(_)`.
|
|
1626
2410
|
importBindings: `
|
|
1627
2411
|
(using_directive name: (identifier) @alias (_) @from) @stmt
|
|
1628
2412
|
(using_directive !name (_) @from) @stmt
|
|
@@ -1634,36 +2418,43 @@ var CSHARP_DEF = {
|
|
|
1634
2418
|
memberExpression: "member_access_expression"
|
|
1635
2419
|
},
|
|
1636
2420
|
supportsCrossModuleSymbols: true,
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
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
|
+
]),
|
|
1667
2458
|
normalizeIdentifier: (name) => {
|
|
1668
2459
|
const withoutVerbatimPrefix = name.startsWith("@") ? name.slice(1) : name;
|
|
1669
2460
|
return hasNonAsciiCodePoint(withoutVerbatimPrefix) ? withoutVerbatimPrefix.replace(CSHARP_IDENTIFIER_FORMAT_PATTERN, "") : withoutVerbatimPrefix;
|
|
@@ -1714,9 +2505,9 @@ var RUST_DEF = {
|
|
|
1714
2505
|
},
|
|
1715
2506
|
graph: {
|
|
1716
2507
|
imports: `
|
|
1717
|
-
(mod_item name: (identifier) @
|
|
1718
|
-
(extern_crate_declaration name: (identifier) @
|
|
1719
|
-
(use_declaration argument: (_) @
|
|
2508
|
+
(mod_item name: (identifier) @from) @stmt
|
|
2509
|
+
(extern_crate_declaration name: (identifier) @from) @stmt
|
|
2510
|
+
(use_declaration argument: (_) @from) @stmt
|
|
1720
2511
|
`,
|
|
1721
2512
|
exports: `
|
|
1722
2513
|
(function_item name: (identifier) @name) @stmt
|
|
@@ -1766,6 +2557,7 @@ var RUST_DEF = {
|
|
|
1766
2557
|
(use_declaration argument: (use_as_clause path: (identifier) @from alias: (identifier) @alias)) @stmt
|
|
1767
2558
|
(use_declaration argument: (use_as_clause path: (scoped_identifier path: (_) @from name: (identifier) @iname) alias: (identifier) @alias)) @stmt
|
|
1768
2559
|
(use_declaration argument: (scoped_identifier path: (_) @from name: (identifier) @iname)) @stmt
|
|
2560
|
+
(use_declaration argument: (use_wildcard) @from @wild) @stmt
|
|
1769
2561
|
(use_declaration argument: (identifier) @from) @stmt
|
|
1770
2562
|
(use_declaration argument: (scoped_use_list path: (_) @from list: (use_list (identifier) @iname))) @stmt
|
|
1771
2563
|
;; Aliased members inside a group (\`use foo::{Bar as Baz}\`): import
|
|
@@ -1780,53 +2572,31 @@ var RUST_DEF = {
|
|
|
1780
2572
|
supportsCrossModuleSymbols: true,
|
|
1781
2573
|
exportScopeBlockers: ["block"],
|
|
1782
2574
|
scopeDeclarationNames: (node) => node.parent?.type === "macro_definition",
|
|
1783
|
-
classifyDefinition: (
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
if (p.type === "trait_item" && p.childForFieldName("name")?.id === node.id)
|
|
1809
|
-
return true;
|
|
1810
|
-
if (p.type === "type_item" && p.childForFieldName("name")?.id === node.id)
|
|
1811
|
-
return true;
|
|
1812
|
-
if (p.type === "associated_type" && p.childForFieldName("name")?.id === node.id)
|
|
1813
|
-
return true;
|
|
1814
|
-
if (p.type === "enum_item" && p.childForFieldName("name")?.id === node.id)
|
|
1815
|
-
return true;
|
|
1816
|
-
if (p.type === "enum_variant" && p.childForFieldName("name")?.id === node.id)
|
|
1817
|
-
return true;
|
|
1818
|
-
if (p.type === "const_item" && p.childForFieldName("name")?.id === node.id)
|
|
1819
|
-
return true;
|
|
1820
|
-
if (p.type === "static_item" && p.childForFieldName("name")?.id === node.id)
|
|
1821
|
-
return true;
|
|
1822
|
-
if (p.type === "macro_definition" && p.childForFieldName("name")?.id === node.id)
|
|
1823
|
-
return true;
|
|
1824
|
-
if (p.type === "let_declaration" && p.childForFieldName("pattern")?.id === node.id)
|
|
1825
|
-
return true;
|
|
1826
|
-
if (p.type === "parameter" && p.childForFieldName("pattern")?.id === node.id)
|
|
1827
|
-
return true;
|
|
1828
|
-
return false;
|
|
1829
|
-
},
|
|
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"),
|
|
1830
2600
|
normalizeIdentifier: (name) => hasNonAsciiCodePoint(name) ? name.normalize("NFC") : name
|
|
1831
2601
|
};
|
|
1832
2602
|
registerLanguage(RUST_DEF);
|
|
@@ -1848,12 +2618,7 @@ var cFamilyControlSplitPoints = [
|
|
|
1848
2618
|
"switch_statement",
|
|
1849
2619
|
"case_statement"
|
|
1850
2620
|
];
|
|
1851
|
-
var
|
|
1852
|
-
(preproc_include path: (string_literal) @mod) @stmt
|
|
1853
|
-
(preproc_include path: (system_lib_string) @mod) @stmt
|
|
1854
|
-
(preproc_include path: (identifier) @mod) @stmt
|
|
1855
|
-
`;
|
|
1856
|
-
var cFamilyIncludeBindingsQuery = `
|
|
2621
|
+
var cFamilyIncludeQuery = `
|
|
1857
2622
|
(preproc_include path: (string_literal) @from) @stmt
|
|
1858
2623
|
(preproc_include path: (system_lib_string) @from) @stmt
|
|
1859
2624
|
(preproc_include path: (identifier) @from) @stmt
|
|
@@ -1940,16 +2705,16 @@ function createCFamilyLanguageDefinition(options) {
|
|
|
1940
2705
|
comments: ["comment"]
|
|
1941
2706
|
},
|
|
1942
2707
|
graph: {
|
|
1943
|
-
imports:
|
|
2708
|
+
imports: cFamilyIncludeQuery,
|
|
1944
2709
|
exports: joinQueryPatterns([
|
|
1945
2710
|
...cFamilyCoreExportQueries(graphFunctionNameQuery),
|
|
1946
|
-
...options.
|
|
2711
|
+
...options.extraSymbolQueries ?? []
|
|
1947
2712
|
]),
|
|
1948
2713
|
locals: joinQueryPatterns([
|
|
1949
2714
|
...cFamilyCoreLocalQueries(graphFunctionNameQuery),
|
|
1950
|
-
...options.
|
|
2715
|
+
...options.extraSymbolQueries ?? []
|
|
1951
2716
|
]),
|
|
1952
|
-
importBindings:
|
|
2717
|
+
importBindings: cFamilyIncludeQuery
|
|
1953
2718
|
},
|
|
1954
2719
|
nodeTypes: options.nodeTypes,
|
|
1955
2720
|
classifyDefinition: options.classifyDefinition,
|
|
@@ -1958,10 +2723,13 @@ function createCFamilyLanguageDefinition(options) {
|
|
|
1958
2723
|
createsFunctionScope: options.createsFunctionScope,
|
|
1959
2724
|
createsBlockScope: (node) => node.type === "compound_statement",
|
|
1960
2725
|
supportsCrossModuleSymbols: true,
|
|
1961
|
-
// A name declared inside a function body
|
|
1962
|
-
//
|
|
1963
|
-
|
|
1964
|
-
|
|
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 } : {}
|
|
1965
2733
|
};
|
|
1966
2734
|
}
|
|
1967
2735
|
function isWithin(node, ancestor) {
|
|
@@ -1988,6 +2756,29 @@ function findAncestor(node, types) {
|
|
|
1988
2756
|
function isInParameterList(node) {
|
|
1989
2757
|
return !!findAncestor(node, cFamilyParameterListTypes);
|
|
1990
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
|
+
}
|
|
1991
2782
|
function resolveDeclaratorRoot(ancestor) {
|
|
1992
2783
|
let declaratorNode = ancestor.childForFieldName("declarator");
|
|
1993
2784
|
if (!declaratorNode)
|
|
@@ -2040,13 +2831,7 @@ var C_DEF = createCFamilyLanguageDefinition({
|
|
|
2040
2831
|
cFamilyBlock("preproc_def", "name: (identifier) @chunk.name", "macro"),
|
|
2041
2832
|
cFamilyBlock("preproc_function_def", "name: (identifier) @chunk.name", "macro")
|
|
2042
2833
|
],
|
|
2043
|
-
|
|
2044
|
-
`(union_specifier name: (type_identifier) @name)`,
|
|
2045
|
-
`(enumerator name: (identifier) @name)`,
|
|
2046
|
-
`(preproc_def name: (identifier) @name)`,
|
|
2047
|
-
`(preproc_function_def name: (identifier) @name)`
|
|
2048
|
-
],
|
|
2049
|
-
extraLocalQueries: [
|
|
2834
|
+
extraSymbolQueries: [
|
|
2050
2835
|
`(union_specifier name: (type_identifier) @name)`,
|
|
2051
2836
|
`(enumerator name: (identifier) @name)`,
|
|
2052
2837
|
`(preproc_def name: (identifier) @name)`,
|
|
@@ -2067,45 +2852,22 @@ var C_DEF = createCFamilyLanguageDefinition({
|
|
|
2067
2852
|
return "class";
|
|
2068
2853
|
if (parent.type === "type_definition" && isInField(node, parent, "declarator"))
|
|
2069
2854
|
return "type";
|
|
2070
|
-
|
|
2071
|
-
if (container?.type === "function_definition")
|
|
2072
|
-
return "function";
|
|
2073
|
-
if (container?.type === "declaration" && isFunctionDeclarator(node))
|
|
2074
|
-
return "function";
|
|
2075
|
-
if (container?.type === "type_definition")
|
|
2076
|
-
return "type";
|
|
2077
|
-
return "variable";
|
|
2078
|
-
},
|
|
2079
|
-
isDeclarationName: (node) => {
|
|
2080
|
-
const parent = node.parent;
|
|
2081
|
-
if (!parent)
|
|
2082
|
-
return false;
|
|
2083
|
-
if ((parent.type === "struct_specifier" || parent.type === "union_specifier" || parent.type === "enum_specifier") && isInField(node, parent, "name"))
|
|
2084
|
-
return true;
|
|
2085
|
-
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"])))
|
|
2086
|
-
return true;
|
|
2087
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["function_definition"])) && !isInParameterList(node))
|
|
2088
|
-
return true;
|
|
2089
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["declaration"])) && !isInParameterList(node))
|
|
2090
|
-
return true;
|
|
2091
|
-
if (parent.type === "enumerator" && isInField(node, parent, "name"))
|
|
2092
|
-
return true;
|
|
2093
|
-
if (parent.type === "preproc_def" && isInField(node, parent, "name"))
|
|
2094
|
-
return true;
|
|
2095
|
-
if (parent.type === "preproc_function_def" && isInField(node, parent, "name"))
|
|
2096
|
-
return true;
|
|
2097
|
-
return false;
|
|
2855
|
+
return cFamilyContainerClassifyDefinition(node);
|
|
2098
2856
|
},
|
|
2099
|
-
|
|
2857
|
+
isDeclarationName: (node) => isSpecifierNameField(node, ["struct_specifier", "union_specifier", "enum_specifier"]) || cFamilyIsDeclarationName(node),
|
|
2858
|
+
createsFunctionScope: nodeTypeIn(["function_definition"])
|
|
2100
2859
|
});
|
|
2101
2860
|
registerLanguage(C_DEF);
|
|
2102
2861
|
|
|
2103
2862
|
// dist/languages/definitions/cpp.js
|
|
2104
2863
|
var CPP_DEF = createCFamilyLanguageDefinition({
|
|
2105
2864
|
id: "cpp",
|
|
2106
|
-
|
|
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"],
|
|
2107
2868
|
includeFieldIdentifier: true,
|
|
2108
2869
|
usesQueryDrivenLocals: true,
|
|
2870
|
+
membersAreImplicitlyInScope: true,
|
|
2109
2871
|
blocks: (functionNameQuery) => [
|
|
2110
2872
|
cFamilyFunctionBlock(functionNameQuery),
|
|
2111
2873
|
cFamilyTypeIdentifierBlock("class_specifier", "class"),
|
|
@@ -2116,25 +2878,9 @@ var CPP_DEF = createCFamilyLanguageDefinition({
|
|
|
2116
2878
|
cFamilyBlock("type_definition", "declarator: (type_identifier) @chunk.name", "type")
|
|
2117
2879
|
],
|
|
2118
2880
|
splitPoints: [...cFamilyControlSplitPoints, "try_statement", "catch_clause"],
|
|
2119
|
-
|
|
2120
|
-
`(class_specifier name: (type_identifier) @name)`,
|
|
2121
|
-
`(class_specifier name: (template_type name: (type_identifier) @name))`,
|
|
2122
|
-
`(union_specifier name: (type_identifier) @name)`,
|
|
2123
|
-
`(enumerator name: (identifier) @name)`,
|
|
2124
|
-
`(namespace_definition name: (namespace_identifier) @name)`,
|
|
2125
|
-
`(namespace_definition name: (nested_namespace_specifier (namespace_identifier) @name))`,
|
|
2126
|
-
`(alias_declaration name: (type_identifier) @name)`,
|
|
2127
|
-
`(concept_definition name: (identifier) @name)`,
|
|
2128
|
-
`(preproc_def name: (identifier) @name)`,
|
|
2129
|
-
`(preproc_function_def name: (identifier) @name)`,
|
|
2130
|
-
`(class_specifier body: (field_declaration_list (field_declaration declarator: (function_declarator declarator: (field_identifier) @name))))`,
|
|
2131
|
-
`(class_specifier body: (field_declaration_list (field_declaration declarator: (reference_declarator (function_declarator declarator: (operator_name) @name)))))`,
|
|
2132
|
-
`(class_specifier body: (field_declaration_list (declaration declarator: (function_declarator declarator: (destructor_name) @name))))`
|
|
2133
|
-
],
|
|
2134
|
-
extraLocalQueries: [
|
|
2881
|
+
extraSymbolQueries: [
|
|
2135
2882
|
`(class_specifier name: (type_identifier) @name)`,
|
|
2136
2883
|
`(class_specifier name: (template_type name: (type_identifier) @name))`,
|
|
2137
|
-
`(enum_specifier name: (type_identifier) @name)`,
|
|
2138
2884
|
`(union_specifier name: (type_identifier) @name)`,
|
|
2139
2885
|
`(enumerator name: (identifier) @name)`,
|
|
2140
2886
|
`(namespace_definition name: (namespace_identifier) @name)`,
|
|
@@ -2145,7 +2891,8 @@ var CPP_DEF = createCFamilyLanguageDefinition({
|
|
|
2145
2891
|
`(preproc_function_def name: (identifier) @name)`,
|
|
2146
2892
|
`(class_specifier body: (field_declaration_list (field_declaration declarator: (function_declarator declarator: (field_identifier) @name))))`,
|
|
2147
2893
|
`(class_specifier body: (field_declaration_list (field_declaration declarator: (reference_declarator (function_declarator declarator: (operator_name) @name)))))`,
|
|
2148
|
-
`(class_specifier body: (field_declaration_list (declaration declarator: (function_declarator declarator: (destructor_name) @name))))
|
|
2894
|
+
`(class_specifier body: (field_declaration_list (declaration declarator: (function_declarator declarator: (destructor_name) @name))))`,
|
|
2895
|
+
`(module_declaration name: (module_name) @name)`
|
|
2149
2896
|
],
|
|
2150
2897
|
nodeTypes: {
|
|
2151
2898
|
identifier: ["identifier", "field_identifier", "type_identifier", "namespace_identifier"],
|
|
@@ -2158,27 +2905,32 @@ var CPP_DEF = createCFamilyLanguageDefinition({
|
|
|
2158
2905
|
return "variable";
|
|
2159
2906
|
if (parent.type === "enum_specifier")
|
|
2160
2907
|
return "type";
|
|
2161
|
-
if (parent.type === "class_specifier" || parent.type === "struct_specifier" || parent.type === "union_specifier" || parent.type === "namespace_definition" || parent.type === "nested_namespace_specifier")
|
|
2908
|
+
if (parent.type === "class_specifier" || parent.type === "struct_specifier" || parent.type === "union_specifier" || parent.type === "namespace_definition" || parent.type === "nested_namespace_specifier" || parent.type === "module_declaration")
|
|
2162
2909
|
return "class";
|
|
2910
|
+
if (parent.type === "module_name") {
|
|
2911
|
+
const moduleDeclaration = findAncestor(node, /* @__PURE__ */ new Set(["module_declaration"]));
|
|
2912
|
+
if (moduleDeclaration)
|
|
2913
|
+
return "class";
|
|
2914
|
+
}
|
|
2163
2915
|
if (parent.type === "alias_declaration" || parent.type === "type_definition" && isInField(node, parent, "declarator"))
|
|
2164
2916
|
return "type";
|
|
2165
|
-
|
|
2166
|
-
if (container?.type === "function_definition")
|
|
2167
|
-
return "function";
|
|
2168
|
-
if (container?.type === "declaration" && isFunctionDeclarator(node))
|
|
2169
|
-
return "function";
|
|
2170
|
-
if (container?.type === "type_definition")
|
|
2171
|
-
return "type";
|
|
2172
|
-
return "variable";
|
|
2917
|
+
return cFamilyContainerClassifyDefinition(node);
|
|
2173
2918
|
},
|
|
2174
2919
|
isDeclarationName: (node) => {
|
|
2920
|
+
if (isSpecifierNameField(node, ["class_specifier", "struct_specifier", "union_specifier", "enum_specifier"]))
|
|
2921
|
+
return true;
|
|
2175
2922
|
const parent = node.parent;
|
|
2176
2923
|
if (!parent)
|
|
2177
2924
|
return false;
|
|
2178
|
-
if ((parent.type === "class_specifier" || parent.type === "struct_specifier" || parent.type === "union_specifier" || parent.type === "enum_specifier") && isInField(node, parent, "name"))
|
|
2179
|
-
return true;
|
|
2180
2925
|
if (parent.type === "namespace_definition" && isInField(node, parent, "name"))
|
|
2181
2926
|
return true;
|
|
2927
|
+
if (parent.type === "module_declaration" && isInField(node, parent, "name"))
|
|
2928
|
+
return true;
|
|
2929
|
+
if (parent.type === "module_name") {
|
|
2930
|
+
const moduleDeclaration = findAncestor(node, /* @__PURE__ */ new Set(["module_declaration"]));
|
|
2931
|
+
if (moduleDeclaration && isInField(node, moduleDeclaration, "name"))
|
|
2932
|
+
return true;
|
|
2933
|
+
}
|
|
2182
2934
|
if (parent.type === "nested_namespace_specifier") {
|
|
2183
2935
|
const namespaceDefinition = findAncestor(node, /* @__PURE__ */ new Set(["namespace_definition"]));
|
|
2184
2936
|
if (namespaceDefinition && isInField(node, namespaceDefinition, "name"))
|
|
@@ -2188,27 +2940,33 @@ var CPP_DEF = createCFamilyLanguageDefinition({
|
|
|
2188
2940
|
return true;
|
|
2189
2941
|
if (parent.type === "concept_definition" && isInField(node, parent, "name"))
|
|
2190
2942
|
return true;
|
|
2191
|
-
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"])))
|
|
2192
|
-
return true;
|
|
2193
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["function_definition"])) && !isInParameterList(node))
|
|
2194
|
-
return true;
|
|
2195
|
-
if (isInAncestorDeclarator(node, /* @__PURE__ */ new Set(["declaration"])) && !isInParameterList(node))
|
|
2196
|
-
return true;
|
|
2197
2943
|
if (parent.type === "qualified_identifier" && parent.parent?.type === "using_declaration" && isInField(node, parent, "name"))
|
|
2198
2944
|
return true;
|
|
2199
|
-
|
|
2200
|
-
return true;
|
|
2201
|
-
if (parent.type === "preproc_def" && isInField(node, parent, "name"))
|
|
2202
|
-
return true;
|
|
2203
|
-
if (parent.type === "preproc_function_def" && isInField(node, parent, "name"))
|
|
2204
|
-
return true;
|
|
2205
|
-
return false;
|
|
2945
|
+
return cFamilyIsDeclarationName(node);
|
|
2206
2946
|
},
|
|
2207
|
-
createsFunctionScope: (
|
|
2947
|
+
createsFunctionScope: nodeTypeIn(["function_definition", "lambda_expression"])
|
|
2208
2948
|
});
|
|
2949
|
+
var cppModuleQuery = `
|
|
2950
|
+
(import_declaration name: (module_name) @from) @stmt
|
|
2951
|
+
(import_declaration header: (string_literal) @from) @stmt
|
|
2952
|
+
(import_declaration header: (system_lib_string) @from) @stmt
|
|
2953
|
+
`;
|
|
2954
|
+
CPP_DEF.graph.imports += cppModuleQuery;
|
|
2955
|
+
CPP_DEF.graph.importBindings += cppModuleQuery;
|
|
2209
2956
|
registerLanguage(CPP_DEF);
|
|
2210
2957
|
|
|
2211
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
|
+
];
|
|
2212
2970
|
var KOTLIN_DEF = {
|
|
2213
2971
|
id: "kotlin",
|
|
2214
2972
|
extensions: [".kt", ".kts", ".ktm"],
|
|
@@ -2255,7 +3013,7 @@ var KOTLIN_DEF = {
|
|
|
2255
3013
|
},
|
|
2256
3014
|
graph: {
|
|
2257
3015
|
imports: `
|
|
2258
|
-
(import (qualified_identifier) @
|
|
3016
|
+
(import (qualified_identifier) @from) @stmt
|
|
2259
3017
|
`,
|
|
2260
3018
|
exports: `
|
|
2261
3019
|
(source_file
|
|
@@ -2298,46 +3056,20 @@ var KOTLIN_DEF = {
|
|
|
2298
3056
|
propertyIdentifier: ["identifier"],
|
|
2299
3057
|
memberExpression: "navigation_expression"
|
|
2300
3058
|
},
|
|
2301
|
-
classifyDefinition: (
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
return "type";
|
|
2311
|
-
return "variable";
|
|
2312
|
-
},
|
|
2313
|
-
isDeclarationName: (node) => {
|
|
2314
|
-
const parent = node.parent;
|
|
2315
|
-
if (!parent)
|
|
2316
|
-
return false;
|
|
2317
|
-
if (parent.type === "class_declaration" && node.type === "identifier")
|
|
2318
|
-
return true;
|
|
2319
|
-
if (parent.type === "object_declaration" && node.type === "identifier")
|
|
2320
|
-
return true;
|
|
2321
|
-
if (parent.type === "function_declaration" && node.type === "identifier")
|
|
2322
|
-
return true;
|
|
2323
|
-
if (parent.type === "type_alias" && node.type === "identifier")
|
|
2324
|
-
return true;
|
|
2325
|
-
if (parent.type === "variable_declaration" && node.type === "identifier")
|
|
2326
|
-
return true;
|
|
2327
|
-
if (parent.type === "parameter" && node.type === "identifier")
|
|
2328
|
-
return true;
|
|
2329
|
-
if (parent.type === "class_parameter" && node.type === "identifier")
|
|
2330
|
-
return true;
|
|
2331
|
-
if (parent.type === "enum_entry" && node.type === "identifier")
|
|
2332
|
-
return true;
|
|
2333
|
-
if (parent.type === "type_parameter" && node.type === "identifier")
|
|
2334
|
-
return true;
|
|
2335
|
-
return false;
|
|
2336
|
-
},
|
|
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),
|
|
2337
3068
|
scopeDeclarationNames: "all",
|
|
2338
|
-
createsFunctionScope: (
|
|
2339
|
-
createsBlockScope: (
|
|
3069
|
+
createsFunctionScope: nodeTypeIn(["function_declaration", "anonymous_function", "lambda_literal"]),
|
|
3070
|
+
createsBlockScope: nodeTypeIn(["function_body", "class_body", "block", "catch_block", "finally_block"]),
|
|
2340
3071
|
supportsCrossModuleSymbols: true,
|
|
3072
|
+
membersAreImplicitlyInScope: true,
|
|
2341
3073
|
exportScopeBlockers: ["function_body", "lambda_literal", "anonymous_function"]
|
|
2342
3074
|
};
|
|
2343
3075
|
registerLanguage(KOTLIN_DEF);
|
|
@@ -2420,8 +3152,12 @@ var SWIFT_DEF = {
|
|
|
2420
3152
|
comments: ["comment", "multiline_comment"]
|
|
2421
3153
|
},
|
|
2422
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.
|
|
2423
3159
|
imports: `
|
|
2424
|
-
(import_declaration (identifier) @
|
|
3160
|
+
(import_declaration (identifier) @from) @stmt
|
|
2425
3161
|
`,
|
|
2426
3162
|
exports: `
|
|
2427
3163
|
(source_file (class_declaration declaration_kind: "class" name: (_) @name))
|
|
@@ -2482,6 +3218,7 @@ var SWIFT_DEF = {
|
|
|
2482
3218
|
(macro_declaration (simple_identifier) @name)
|
|
2483
3219
|
(operator_declaration [(custom_operator) (simple_identifier) (bang)] @name)
|
|
2484
3220
|
`,
|
|
3221
|
+
// Same path node as `imports`; Swift has no import alias or star token.
|
|
2485
3222
|
importBindings: `
|
|
2486
3223
|
(import_declaration (identifier) @from) @stmt
|
|
2487
3224
|
`
|
|
@@ -2513,19 +3250,20 @@ var SWIFT_DEF = {
|
|
|
2513
3250
|
const parent = node.parent;
|
|
2514
3251
|
if (!parent)
|
|
2515
3252
|
return false;
|
|
2516
|
-
if (
|
|
3253
|
+
if (isNameFieldOnParent(node, ["class_declaration"]))
|
|
2517
3254
|
return true;
|
|
2518
3255
|
if (parent.type === "user_type" && parent.parent?.type === "class_declaration" && parent.parent.childForFieldName("name")?.id === parent.id)
|
|
2519
3256
|
return true;
|
|
2520
|
-
if (
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
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
|
+
]))
|
|
2529
3267
|
return true;
|
|
2530
3268
|
if (parent.type === "macro_declaration" && node.type === "simple_identifier")
|
|
2531
3269
|
return true;
|
|
@@ -2537,20 +3275,25 @@ var SWIFT_DEF = {
|
|
|
2537
3275
|
return true;
|
|
2538
3276
|
if (parent.type === "subscript_declaration" && node.type === "subscript")
|
|
2539
3277
|
return true;
|
|
2540
|
-
|
|
2541
|
-
return true;
|
|
2542
|
-
if (parent.type === "protocol_function_declaration" && parent.childForFieldName("name")?.id === node.id)
|
|
2543
|
-
return true;
|
|
2544
|
-
if (parent.type === "protocol_property_declaration" && parent.childForFieldName("name")?.id === node.id)
|
|
2545
|
-
return true;
|
|
2546
|
-
if (parent.type === "pattern" && parent.childForFieldName("bound_identifier")?.id === node.id && (parent.parent?.type === "property_declaration" || parent.parent?.type === "protocol_property_declaration"))
|
|
2547
|
-
return true;
|
|
2548
|
-
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");
|
|
2549
3279
|
},
|
|
2550
3280
|
scopeDeclarationNames: "all",
|
|
2551
|
-
createsFunctionScope: (
|
|
2552
|
-
|
|
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
|
+
]),
|
|
2553
3295
|
supportsCrossModuleSymbols: true,
|
|
3296
|
+
membersAreImplicitlyInScope: true,
|
|
2554
3297
|
exportScopeBlockers: ["function_body", "lambda_literal"]
|
|
2555
3298
|
};
|
|
2556
3299
|
registerLanguage(SWIFT_DEF);
|
|
@@ -2580,6 +3323,7 @@ var SQL_DEF = {
|
|
|
2580
3323
|
comments: ["comment"]
|
|
2581
3324
|
},
|
|
2582
3325
|
graph: {
|
|
3326
|
+
// SQL has no import specifier node; statements are the only capture.
|
|
2583
3327
|
imports: "(statement) @stmt",
|
|
2584
3328
|
exports: "",
|
|
2585
3329
|
locals: "",
|
|
@@ -2613,8 +3357,9 @@ var ZIG_DEF = {
|
|
|
2613
3357
|
},
|
|
2614
3358
|
graph: {
|
|
2615
3359
|
imports: `
|
|
2616
|
-
(builtin_function (builtin_identifier) @fn (arguments (string) @
|
|
2617
|
-
|
|
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
|
|
2618
3363
|
`,
|
|
2619
3364
|
exports: `
|
|
2620
3365
|
(source_file (function_declaration name: (identifier) @name))
|
|
@@ -2670,19 +3415,13 @@ var ZIG_DEF = {
|
|
|
2670
3415
|
return "type";
|
|
2671
3416
|
return "variable";
|
|
2672
3417
|
},
|
|
2673
|
-
createsFunctionScope: (
|
|
2674
|
-
createsBlockScope: (
|
|
2675
|
-
isDeclarationName: (node) =>
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
return true;
|
|
2681
|
-
if (parent.type !== "variable_declaration")
|
|
2682
|
-
return false;
|
|
2683
|
-
const declaredName = parent.namedChildren.find((child) => child.type === "identifier");
|
|
2684
|
-
return declaredName?.id === node.id;
|
|
2685
|
-
}
|
|
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
|
|
2686
3425
|
};
|
|
2687
3426
|
registerLanguage(ZIG_DEF);
|
|
2688
3427
|
|
|
@@ -2784,112 +3523,6 @@ import { Buffer as Buffer2 } from "node:buffer";
|
|
|
2784
3523
|
// dist/languages.js
|
|
2785
3524
|
import fs from "node:fs";
|
|
2786
3525
|
import path from "node:path";
|
|
2787
|
-
|
|
2788
|
-
// dist/util/comments.js
|
|
2789
|
-
function transformJsLikeTrivia(src, options) {
|
|
2790
|
-
let out = "";
|
|
2791
|
-
let i = 0;
|
|
2792
|
-
let inSingle = false;
|
|
2793
|
-
let inDouble = false;
|
|
2794
|
-
let inTemplate = false;
|
|
2795
|
-
let escapeNext = false;
|
|
2796
|
-
const maskStrings = options?.maskStrings ?? false;
|
|
2797
|
-
const preserveLength = options?.preserveLength ?? false;
|
|
2798
|
-
const maskedChar = (ch) => ch === "\n" || ch === "\r" ? ch : " ";
|
|
2799
|
-
while (i < src.length) {
|
|
2800
|
-
const ch = src[i];
|
|
2801
|
-
const next = src[i + 1] ?? "";
|
|
2802
|
-
if (inSingle || inDouble || inTemplate) {
|
|
2803
|
-
const isClosingQuote = !escapeNext && (inSingle && ch === "'" || inDouble && ch === '"' || inTemplate && ch === "`");
|
|
2804
|
-
if (maskStrings) {
|
|
2805
|
-
out += isClosingQuote ? ch : maskedChar(ch);
|
|
2806
|
-
} else {
|
|
2807
|
-
out += ch;
|
|
2808
|
-
}
|
|
2809
|
-
if (escapeNext) {
|
|
2810
|
-
escapeNext = false;
|
|
2811
|
-
} else if (ch === "\\") {
|
|
2812
|
-
escapeNext = true;
|
|
2813
|
-
} else if (inSingle && ch === "'") {
|
|
2814
|
-
inSingle = false;
|
|
2815
|
-
} else if (inDouble && ch === '"') {
|
|
2816
|
-
inDouble = false;
|
|
2817
|
-
} else if (inTemplate && ch === "`") {
|
|
2818
|
-
inTemplate = false;
|
|
2819
|
-
}
|
|
2820
|
-
i += 1;
|
|
2821
|
-
continue;
|
|
2822
|
-
}
|
|
2823
|
-
if (ch === "'") {
|
|
2824
|
-
inSingle = true;
|
|
2825
|
-
out += ch;
|
|
2826
|
-
i += 1;
|
|
2827
|
-
continue;
|
|
2828
|
-
}
|
|
2829
|
-
if (ch === '"') {
|
|
2830
|
-
inDouble = true;
|
|
2831
|
-
out += ch;
|
|
2832
|
-
i += 1;
|
|
2833
|
-
continue;
|
|
2834
|
-
}
|
|
2835
|
-
if (ch === "`") {
|
|
2836
|
-
inTemplate = true;
|
|
2837
|
-
out += ch;
|
|
2838
|
-
i += 1;
|
|
2839
|
-
continue;
|
|
2840
|
-
}
|
|
2841
|
-
if (ch === "/" && next === "*") {
|
|
2842
|
-
if (preserveLength)
|
|
2843
|
-
out += " ";
|
|
2844
|
-
i += 2;
|
|
2845
|
-
let depth = 1;
|
|
2846
|
-
while (i < src.length && depth > 0) {
|
|
2847
|
-
if (options?.nestedBlockComments && src[i] === "/" && src[i + 1] === "*") {
|
|
2848
|
-
if (preserveLength)
|
|
2849
|
-
out += " ";
|
|
2850
|
-
depth += 1;
|
|
2851
|
-
i += 2;
|
|
2852
|
-
continue;
|
|
2853
|
-
}
|
|
2854
|
-
if (src[i] === "*" && src[i + 1] === "/") {
|
|
2855
|
-
if (preserveLength)
|
|
2856
|
-
out += " ";
|
|
2857
|
-
depth -= 1;
|
|
2858
|
-
i += 2;
|
|
2859
|
-
continue;
|
|
2860
|
-
}
|
|
2861
|
-
if (preserveLength)
|
|
2862
|
-
out += maskedChar(src[i]);
|
|
2863
|
-
else if (src[i] === "\n")
|
|
2864
|
-
out += "\n";
|
|
2865
|
-
i += 1;
|
|
2866
|
-
}
|
|
2867
|
-
continue;
|
|
2868
|
-
}
|
|
2869
|
-
if (ch === "/" && next === "/") {
|
|
2870
|
-
if (preserveLength)
|
|
2871
|
-
out += " ";
|
|
2872
|
-
i += 2;
|
|
2873
|
-
while (i < src.length && src[i] !== "\n") {
|
|
2874
|
-
if (preserveLength)
|
|
2875
|
-
out += " ";
|
|
2876
|
-
i += 1;
|
|
2877
|
-
}
|
|
2878
|
-
continue;
|
|
2879
|
-
}
|
|
2880
|
-
out += ch;
|
|
2881
|
-
i += 1;
|
|
2882
|
-
}
|
|
2883
|
-
return out;
|
|
2884
|
-
}
|
|
2885
|
-
function maskJsLikeCommentsAndStrings(src) {
|
|
2886
|
-
return transformJsLikeTrivia(src, {
|
|
2887
|
-
maskStrings: true,
|
|
2888
|
-
preserveLength: true
|
|
2889
|
-
});
|
|
2890
|
-
}
|
|
2891
|
-
|
|
2892
|
-
// dist/languages.js
|
|
2893
3526
|
function adaptDefinition(def) {
|
|
2894
3527
|
return {
|
|
2895
3528
|
id: def.id,
|
|
@@ -2901,7 +3534,7 @@ function adaptDefinition(def) {
|
|
|
2901
3534
|
scopeDeclarationNames: def.scopeDeclarationNames === "all" ? () => true : def.scopeDeclarationNames ?? (() => false),
|
|
2902
3535
|
createsBlockScope: def.createsBlockScope || (() => false),
|
|
2903
3536
|
createsFunctionScope: def.createsFunctionScope || (() => false),
|
|
2904
|
-
membersAreImplicitlyInScope: def.membersAreImplicitlyInScope ??
|
|
3537
|
+
membersAreImplicitlyInScope: def.membersAreImplicitlyInScope ?? false,
|
|
2905
3538
|
supportsCrossModuleSymbols: def.supportsCrossModuleSymbols || false,
|
|
2906
3539
|
isTypeOnly: def.isTypeOnly || (() => false),
|
|
2907
3540
|
exportScopeBlockers: def.exportScopeBlockers ?? [],
|