arkanalyzer 1.0.15 → 1.0.16

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.
@@ -9,8 +9,8 @@ import { ArkError } from '../common/ArkError';
9
9
  * @category core/model
10
10
  */
11
11
  export declare class ArkNamespace extends ArkBaseModel implements ArkExport {
12
- private code;
13
- private lineCol;
12
+ private sourceCodes;
13
+ private lineCols;
14
14
  private declaringArkFile;
15
15
  private declaringArkNamespace;
16
16
  private declaringInstance;
@@ -30,11 +30,16 @@ export declare class ArkNamespace extends ArkBaseModel implements ArkExport {
30
30
  getNamespaceSignature(): NamespaceSignature;
31
31
  getName(): string;
32
32
  getCode(): string;
33
- setCode(code: string): void;
33
+ setCode(sourceCode: string): void;
34
+ getCodes(): string[];
35
+ setCodes(sourceCodes: string[]): void;
36
+ addCode(sourceCode: string): void;
34
37
  getLine(): number;
35
38
  setLine(line: number): void;
36
39
  getColumn(): number;
37
40
  setColumn(column: number): void;
41
+ getLineColPairs(): [number, number][];
42
+ setLineCols(lineColPairs: [number, number][]): void;
38
43
  getDeclaringInstance(): ArkFile | ArkNamespace;
39
44
  setDeclaringInstance(declaringInstance: ArkFile | ArkNamespace): void;
40
45
  getDeclaringArkFile(): ArkFile;
@@ -1 +1 @@
1
- {"version":3,"file":"ArkNamespace.d.ts","sourceRoot":"","sources":["../../../src/core/model/ArkNamespace.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAuB,cAAc,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGzF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAA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EAAE;IAIxB,WAAW,CAAC,QAAQ,EAAE,QAAQ;IAI9B,cAAc,IAAI,UAAU,EAAE;IAU9B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIrD,aAAa,CAAC,UAAU,EAAE,UAAU;IAIpC,eAAe;IAIf,eAAe,CAAC,YAAY,EAAE,QAAQ;IAItC,+BAA+B,IAAI,SAAS,EAAE;IAW9C,+BAA+B,IAAI,QAAQ,EAAE;IAS7C,kCAAkC,IAAI,YAAY,EAAE;IASpD,uBAAuB;IAI9B,aAAa,IAAI,UAAU;IAIpB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAM3C,eAAe,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO;IAMjD,QAAQ,IAAI,QAAQ;CAG9B"}
@@ -26,8 +26,8 @@ const ArkBaseModel_1 = require("./ArkBaseModel");
26
26
  class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
27
27
  constructor() {
28
28
  super();
29
- this.code = '';
30
- this.lineCol = 0;
29
+ this.sourceCodes = [''];
30
+ this.lineCols = [];
31
31
  this.declaringArkNamespace = null;
32
32
  this.exportInfos = new Map();
33
33
  // name to model
@@ -61,22 +61,51 @@ class ArkNamespace extends ArkBaseModel_1.ArkBaseModel {
61
61
  return this.namespaceSignature.getNamespaceName();
62
62
  }
63
63
  getCode() {
64
- return this.code;
64
+ return this.sourceCodes[0];
65
65
  }
66
- setCode(code) {
67
- this.code = code;
66
+ setCode(sourceCode) {
67
+ this.sourceCodes[0] = sourceCode;
68
+ }
69
+ /*
70
+ * Get multiple sourceCodes when the arkNamespace is merged from multiple namespace with the same name
71
+ */
72
+ getCodes() {
73
+ return this.sourceCodes;
74
+ }
75
+ /*
76
+ * Set multiple sourceCodes when the arkNamespace is merged from multiple namespace with the same name
77
+ */
78
+ setCodes(sourceCodes) {
79
+ this.sourceCodes = [];
80
+ this.sourceCodes.push(...sourceCodes);
81
+ }
82
+ addCode(sourceCode) {
83
+ this.sourceCodes.push(sourceCode);
68
84
  }
69
85
  getLine() {
70
- return (0, Position_1.getLineNo)(this.lineCol);
86
+ return (0, Position_1.getLineNo)(this.lineCols[0]);
71
87
  }
72
88
  setLine(line) {
73
- this.lineCol = (0, Position_1.setLine)(this.lineCol, line);
89
+ this.lineCols[0] = (0, Position_1.setLine)(this.lineCols[0], line);
74
90
  }
75
91
  getColumn() {
76
- return (0, Position_1.getColNo)(this.lineCol);
92
+ return (0, Position_1.getColNo)(this.lineCols[0]);
77
93
  }
78
94
  setColumn(column) {
79
- this.lineCol = (0, Position_1.setCol)(this.lineCol, column);
95
+ this.lineCols[0] = (0, Position_1.setCol)(this.lineCols[0], column);
96
+ }
97
+ getLineColPairs() {
98
+ const lineColPairs = [];
99
+ this.lineCols.forEach(lineCol => {
100
+ lineColPairs.push([(0, Position_1.getLineNo)(lineCol), (0, Position_1.getColNo)(lineCol)]);
101
+ });
102
+ return lineColPairs;
103
+ }
104
+ setLineCols(lineColPairs) {
105
+ this.lineCols = [];
106
+ lineColPairs.forEach(lineColPair => {
107
+ this.lineCols.push((0, Position_1.setLineCol)(lineColPair[0], lineColPair[1]));
108
+ });
80
109
  }
81
110
  getDeclaringInstance() {
82
111
  return this.declaringInstance;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2024 Huawei Device Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
6
6
  * You may obtain a copy of the License at
@@ -86,14 +86,13 @@ exports.buildArkFileFromFile = buildArkFileFromFile;
86
86
  */
87
87
  function buildArkFile(arkFile, astRoot) {
88
88
  const statements = astRoot.statements;
89
+ const namespaces = [];
89
90
  statements.forEach((child) => {
90
- if (ohos_typescript_1.default.isModuleDeclaration(child)
91
- //child.kind === ts.SyntaxKind.ModuleDeclaration
92
- ) {
91
+ if (ohos_typescript_1.default.isModuleDeclaration(child)) {
93
92
  let ns = new ArkNamespace_1.ArkNamespace();
94
93
  ns.setDeclaringArkFile(arkFile);
95
94
  (0, ArkNamespaceBuilder_1.buildArkNamespace)(child, arkFile, ns, astRoot);
96
- arkFile.addNamespace(ns);
95
+ namespaces.push(ns);
97
96
  if (ns.isExported()) {
98
97
  arkFile.addExportInfo((0, ArkExportBuilder_1.buildExportInfo)(ns, arkFile, Position_1.LineColPosition.buildFromNode(child, astRoot)));
99
98
  }
@@ -101,11 +100,7 @@ function buildArkFile(arkFile, astRoot) {
101
100
  else if (ohos_typescript_1.default.isClassDeclaration(child) ||
102
101
  ohos_typescript_1.default.isInterfaceDeclaration(child) ||
103
102
  ohos_typescript_1.default.isEnumDeclaration(child) ||
104
- ohos_typescript_1.default.isStructDeclaration(child)
105
- //child.kind === ts.SyntaxKind.ClassDeclaration
106
- //child.kind === ts.SyntaxKind.InterfaceDeclaration
107
- //child.kind === ts.SyntaxKind.EnumDeclaration
108
- ) {
103
+ ohos_typescript_1.default.isStructDeclaration(child)) {
109
104
  let cls = new ArkClass_1.ArkClass();
110
105
  (0, ArkClassBuilder_1.buildNormalArkClassFromArkFile)(child, arkFile, cls, astRoot);
111
106
  arkFile.addArkClass(cls);
@@ -115,7 +110,7 @@ function buildArkFile(arkFile, astRoot) {
115
110
  }
116
111
  // TODO: Check
117
112
  else if (ohos_typescript_1.default.isMethodDeclaration(child)) {
118
- logger.warn("This is a MethodDeclaration in ArkFile.");
113
+ logger.warn('This is a MethodDeclaration in ArkFile.');
119
114
  let mthd = new ArkMethod_1.ArkMethod();
120
115
  (0, ArkMethodBuilder_1.buildArkMethodFromArkClass)(child, arkFile.getDefaultClass(), mthd, astRoot);
121
116
  if (mthd.isExported()) {
@@ -153,6 +148,14 @@ function buildArkFile(arkFile, astRoot) {
153
148
  logger.info('Child joined default method of arkFile: ', ohos_typescript_1.default.SyntaxKind[child.kind]);
154
149
  }
155
150
  });
151
+ const mergedNameSpaces = (0, ArkNamespaceBuilder_1.mergeNameSpaces)(namespaces);
152
+ mergedNameSpaces.forEach(mergedNameSpace => {
153
+ arkFile.addNamespace(mergedNameSpace);
154
+ if (mergedNameSpace.isExport()) {
155
+ const linCol = new Position_1.LineColPosition(mergedNameSpace.getLine(), mergedNameSpace.getColumn());
156
+ arkFile.addExportInfo((0, ArkExportBuilder_1.buildExportInfo)(mergedNameSpace, arkFile, linCol));
157
+ }
158
+ });
156
159
  }
157
160
  function genDefaultArkClass(arkFile, astRoot) {
158
161
  let defaultClass = new ArkClass_1.ArkClass();
@@ -2,4 +2,5 @@ import { ArkFile } from '../ArkFile';
2
2
  import ts from 'ohos-typescript';
3
3
  import { ArkNamespace } from '../ArkNamespace';
4
4
  export declare function buildArkNamespace(node: ts.ModuleDeclaration, declaringInstance: ArkFile | ArkNamespace, ns: ArkNamespace, sourceFile: ts.SourceFile): void;
5
+ export declare function mergeNameSpaces(arkNamespaces: ArkNamespace[]): ArkNamespace[];
5
6
  //# sourceMappingURL=ArkNamespaceBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ArkNamespaceBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkNamespaceBuilder.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAW/C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,GAAG,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,QAuDnJ"}
1
+ {"version":3,"file":"ArkNamespaceBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/model/builder/ArkNamespaceBuilder.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAW/C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,GAAG,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,QAoDnJ;AAmFD,wBAAgB,eAAe,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CA4B7E"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2024 Huawei Device Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
6
6
  * You may obtain a copy of the License at
@@ -40,7 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
40
40
  return (mod && mod.__esModule) ? mod : { "default": mod };
41
41
  };
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.buildArkNamespace = void 0;
43
+ exports.mergeNameSpaces = exports.buildArkNamespace = void 0;
44
44
  const Position_1 = require("../../base/Position");
45
45
  const ArkClassBuilder_1 = require("./ArkClassBuilder");
46
46
  const ArkFile_1 = require("../ArkFile");
@@ -88,19 +88,19 @@ function buildArkNamespace(node, declaringInstance, ns, sourceFile) {
88
88
  // NamespaceDeclaration extends ModuleDeclaration
89
89
  //TODO: Check
90
90
  else if (ohos_typescript_1.default.isModuleDeclaration(node.body)) {
91
- logger.warn("This ModuleBody is an NamespaceDeclaration.");
91
+ logger.warn('This ModuleBody is an NamespaceDeclaration.');
92
92
  let childNs = new ArkNamespace_1.ArkNamespace();
93
93
  buildArkNamespace(node.body, ns, childNs, sourceFile);
94
94
  }
95
95
  else if (ohos_typescript_1.default.isIdentifier(node.body)) {
96
- logger.warn("ModuleBody is Identifier.");
96
+ logger.warn('ModuleBody is Identifier.');
97
97
  }
98
98
  else {
99
- logger.warn("JSDocNamespaceDeclaration found.");
99
+ logger.warn('JSDocNamespaceDeclaration found.');
100
100
  }
101
101
  }
102
102
  else {
103
- logger.warn("JSDocNamespaceDeclaration found.");
103
+ logger.warn('JSDocNamespaceDeclaration found.');
104
104
  }
105
105
  IRUtils_1.IRUtils.setComments(ns, node, sourceFile, ns.getDeclaringArkFile().getScene().getOptions());
106
106
  }
@@ -108,18 +108,14 @@ exports.buildArkNamespace = buildArkNamespace;
108
108
  // TODO: check and update
109
109
  function buildNamespaceMembers(node, namespace, sourceFile) {
110
110
  const statements = node.statements;
111
+ const nestedNamespaces = [];
111
112
  statements.forEach((child) => {
112
- if (ohos_typescript_1.default.isModuleDeclaration(child)
113
- //child.kind === ts.SyntaxKind.ModuleDeclaration
114
- ) {
113
+ if (ohos_typescript_1.default.isModuleDeclaration(child)) {
115
114
  let childNs = new ArkNamespace_1.ArkNamespace();
116
115
  childNs.setDeclaringArkNamespace(namespace);
117
116
  childNs.setDeclaringArkFile(namespace.getDeclaringArkFile());
118
117
  buildArkNamespace(child, namespace, childNs, sourceFile);
119
- namespace.addNamespace(childNs);
120
- if (childNs.isExported()) {
121
- namespace.addExportInfo((0, ArkExportBuilder_1.buildExportInfo)(childNs, namespace.getDeclaringArkFile(), Position_1.LineColPosition.buildFromNode(child, sourceFile)));
122
- }
118
+ nestedNamespaces.push(childNs);
123
119
  }
124
120
  else if (ohos_typescript_1.default.isClassDeclaration(child) ||
125
121
  ohos_typescript_1.default.isInterfaceDeclaration(child) ||
@@ -134,7 +130,7 @@ function buildNamespaceMembers(node, namespace, sourceFile) {
134
130
  }
135
131
  // TODO: Check
136
132
  else if (ohos_typescript_1.default.isMethodDeclaration(child)) {
137
- logger.warn("This is a MethodDeclaration in ArkNamespace.");
133
+ logger.warn('This is a MethodDeclaration in ArkNamespace.');
138
134
  let mthd = new ArkMethod_1.ArkMethod();
139
135
  (0, ArkMethodBuilder_1.buildArkMethodFromArkClass)(child, namespace.getDefaultClass(), mthd, sourceFile);
140
136
  if (mthd.isExported()) {
@@ -161,6 +157,14 @@ function buildNamespaceMembers(node, namespace, sourceFile) {
161
157
  // join default method
162
158
  }
163
159
  });
160
+ const nestedMergedNameSpaces = mergeNameSpaces(nestedNamespaces);
161
+ nestedMergedNameSpaces.forEach(nestedNameSpace => {
162
+ namespace.addNamespace(nestedNameSpace);
163
+ if (nestedNameSpace.isExport()) {
164
+ const linCol = new Position_1.LineColPosition(nestedNameSpace.getLine(), nestedNameSpace.getColumn());
165
+ namespace.addExportInfo((0, ArkExportBuilder_1.buildExportInfo)(nestedNameSpace, namespace.getDeclaringArkFile(), linCol));
166
+ }
167
+ });
164
168
  }
165
169
  function genDefaultArkClass(ns, node, sourceFile) {
166
170
  let defaultClass = new ArkClass_1.ArkClass();
@@ -168,3 +172,34 @@ function genDefaultArkClass(ns, node, sourceFile) {
168
172
  ns.setDefaultClass(defaultClass);
169
173
  ns.addArkClass(defaultClass);
170
174
  }
175
+ function mergeNameSpaces(arkNamespaces) {
176
+ const namespaceMap = new Map();
177
+ for (let i = 0; i < arkNamespaces.length; i++) {
178
+ const currNamespace = arkNamespaces[i];
179
+ const currName = currNamespace.getName();
180
+ if (namespaceMap.has(currName)) {
181
+ const prevNamespace = namespaceMap.get(currName);
182
+ const nestedPrevNamespaces = prevNamespace.getNamespaces();
183
+ const nestedCurrNamespaces = currNamespace.getNamespaces();
184
+ const nestedMergedNameSpaces = mergeNameSpaces([...nestedPrevNamespaces, ...nestedCurrNamespaces]);
185
+ nestedMergedNameSpaces.forEach(nestedNameSpace => {
186
+ prevNamespace.addNamespace(nestedNameSpace);
187
+ });
188
+ const classes = currNamespace.getClasses();
189
+ classes.forEach(cls => {
190
+ prevNamespace.addArkClass(cls);
191
+ });
192
+ const preSourceCodes = prevNamespace.getCodes();
193
+ const currSourceCodes = currNamespace.getCodes();
194
+ prevNamespace.setCodes([...preSourceCodes, ...currSourceCodes]);
195
+ const prevLineColPairs = prevNamespace.getLineColPairs();
196
+ const currLineColPairs = currNamespace.getLineColPairs();
197
+ prevNamespace.setLineCols([...prevLineColPairs, ...currLineColPairs]);
198
+ }
199
+ else {
200
+ namespaceMap.set(currName, currNamespace);
201
+ }
202
+ }
203
+ return [...namespaceMap.values()];
204
+ }
205
+ exports.mergeNameSpaces = mergeNameSpaces;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkanalyzer",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "files": [
5
5
  "docs",
6
6
  "lib",