@vue/language-core 3.0.8 → 3.0.10

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.
@@ -0,0 +1,12 @@
1
+ import type * as ts from 'typescript';
2
+ import type { TextRange } from '../types';
3
+ export declare function parseBindingRanges(ts: typeof import('typescript'), ast: ts.SourceFile): {
4
+ range: TextRange;
5
+ moduleName?: string;
6
+ isDefaultImport?: boolean;
7
+ isNamespace?: boolean;
8
+ }[];
9
+ export declare function getClosestMultiLineCommentRange(ts: typeof import('typescript'), node: ts.Node, parents: ts.Node[], ast: ts.SourceFile): {
10
+ start: number;
11
+ end: number;
12
+ } | undefined;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseBindingRanges = parseBindingRanges;
4
+ exports.getClosestMultiLineCommentRange = getClosestMultiLineCommentRange;
5
+ const collectBindings_1 = require("../utils/collectBindings");
6
+ const shared_1 = require("../utils/shared");
7
+ function parseBindingRanges(ts, ast) {
8
+ const bindings = [];
9
+ ts.forEachChild(ast, node => {
10
+ if (ts.isVariableStatement(node)) {
11
+ for (const decl of node.declarationList.declarations) {
12
+ const ranges = (0, collectBindings_1.collectBindingRanges)(ts, decl.name, ast);
13
+ bindings.push(...ranges.map(range => ({ range })));
14
+ }
15
+ }
16
+ else if (ts.isFunctionDeclaration(node)) {
17
+ if (node.name && ts.isIdentifier(node.name)) {
18
+ bindings.push({
19
+ range: _getStartEnd(node.name),
20
+ });
21
+ }
22
+ }
23
+ else if (ts.isClassDeclaration(node)) {
24
+ if (node.name) {
25
+ bindings.push({
26
+ range: _getStartEnd(node.name),
27
+ });
28
+ }
29
+ }
30
+ else if (ts.isEnumDeclaration(node)) {
31
+ bindings.push({
32
+ range: _getStartEnd(node.name),
33
+ });
34
+ }
35
+ if (ts.isImportDeclaration(node)) {
36
+ const moduleName = _getNodeText(node.moduleSpecifier).slice(1, -1);
37
+ if (node.importClause && !node.importClause.isTypeOnly) {
38
+ const { name, namedBindings } = node.importClause;
39
+ if (name) {
40
+ bindings.push({
41
+ range: _getStartEnd(name),
42
+ moduleName,
43
+ isDefaultImport: true,
44
+ });
45
+ }
46
+ if (namedBindings) {
47
+ if (ts.isNamedImports(namedBindings)) {
48
+ for (const element of namedBindings.elements) {
49
+ if (element.isTypeOnly) {
50
+ continue;
51
+ }
52
+ bindings.push({
53
+ range: _getStartEnd(element.name),
54
+ moduleName,
55
+ isDefaultImport: element.propertyName?.text === 'default',
56
+ });
57
+ }
58
+ }
59
+ else {
60
+ bindings.push({
61
+ range: _getStartEnd(namedBindings.name),
62
+ moduleName,
63
+ isNamespace: true,
64
+ });
65
+ }
66
+ }
67
+ }
68
+ }
69
+ });
70
+ return bindings;
71
+ function _getStartEnd(node) {
72
+ return (0, shared_1.getStartEnd)(ts, node, ast);
73
+ }
74
+ function _getNodeText(node) {
75
+ return (0, shared_1.getNodeText)(ts, node, ast);
76
+ }
77
+ }
78
+ function getClosestMultiLineCommentRange(ts, node, parents, ast) {
79
+ for (let i = parents.length - 1; i >= 0; i--) {
80
+ if (ts.isStatement(node)) {
81
+ break;
82
+ }
83
+ node = parents[i];
84
+ }
85
+ const comment = ts.getLeadingCommentRanges(ast.text, node.pos)
86
+ ?.reverse()
87
+ .find(range => range.kind === 3);
88
+ if (comment) {
89
+ return {
90
+ start: comment.pos,
91
+ end: comment.end,
92
+ };
93
+ }
94
+ }
95
+ //# sourceMappingURL=utils.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "3.0.8",
3
+ "version": "3.0.10",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -37,5 +37,5 @@
37
37
  "optional": true
38
38
  }
39
39
  },
40
- "gitHead": "f7bdeaa7bb476df1fc8ff46c504d75c1869b0be9"
40
+ "gitHead": "0f57e1df7261ba537de6078811e971e8da1a3c79"
41
41
  }