• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2/*
3 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17const path = require('path');
18const fs = require('fs');
19const etsComponentSet = new Set([
20  'AbilityComponent',
21  'AlphabetIndexer',
22  'Animator',
23  'Badge',
24  'Blank',
25  'Button',
26  'Calendar',
27  'CalendarPicker',
28  'Camera',
29  'Canvas',
30  'Checkbox',
31  'CheckboxGroup',
32  'Circle',
33  'ColorPicker',
34  'ColorPickerDialog',
35  'Column',
36  'ColumnSplit',
37  'Counter',
38  'DataPanel',
39  'DatePicker',
40  'Divider',
41  'Ellipse',
42  'Flex',
43  'FormComponent',
44  'FormLink',
45  'Gauge',
46  'GeometryView',
47  'Grid',
48  'GridItem',
49  'GridContainer',
50  'Hyperlink',
51  'Image',
52  'ImageAnimator',
53  'Line',
54  'List',
55  'ListItem',
56  'ListItemGroup',
57  'LoadingProgress',
58  'Marquee',
59  'Menu',
60  'Navigation',
61  'Navigator',
62  'Option',
63  'PageTransitionEnter',
64  'PageTransitionExit',
65  'Panel',
66  'Path',
67  'PatternLock',
68  'Piece',
69  'PluginComponent',
70  'Polygon',
71  'Polyline',
72  'Progress',
73  'QRCode',
74  'Radio',
75  'Rating',
76  'Rect',
77  'Refresh',
78  'RelativeContainer',
79  'RemoteWindow',
80  'Row',
81  'RowSplit',
82  'RichText',
83  'Scroll',
84  'ScrollBar',
85  'Search',
86  'Section',
87  'Select',
88  'Shape',
89  'Sheet',
90  'SideBarContainer',
91  'Slider',
92  'Span',
93  'Stack',
94  'Stepper',
95  'StepperItem',
96  'Swiper',
97  'TabContent',
98  'Tabs',
99  'Text',
100  'TextPicker',
101  'TextClock',
102  'TextArea',
103  'TextInput',
104  'TextTimer',
105  'TimePicker',
106  'Toggle',
107  'Video',
108  'Web',
109  'XComponent',
110  'GridRow',
111  'GridCol',
112  'CustomDialogController',
113  'PanGesture'
114]);
115exports.etsComponentSet = etsComponentSet;
116function readFile(dir, utFiles) {
117  try {
118    const files = fs.readdirSync(dir);
119    files.forEach((element) => {
120      const filePath = path.join(dir, element);
121      const status = fs.statSync(filePath);
122      if (status.isDirectory()) {
123        readFile(filePath, utFiles);
124      } else {
125        utFiles.push(filePath);
126      }
127    });
128  } catch (e) {
129    console.log('ETS ERROR: ' + e);
130  }
131}
132exports.readFile = readFile;
133
134function collectAllApi(url, sourcefile, moduleName, apiName, instantiateObject, interfaceName,
135  value, type, notes, node) {
136  const basePath = __dirname.replace('src', '');
137  const posOfNode = sourcefile.getLineAndCharacterOfPosition(node.pos);
138  return {
139    callLocation: `${url.replace(basePath, '')}(line:${posOfNode.line + 1},` +
140      ` col:${posOfNode.character + 1})`,
141    moduleName: moduleName,
142    apiName: apiName,
143    packageName: '',
144    instantiateObject: instantiateObject,
145    interfaceName: interfaceName,
146    value: value,
147    type: type,
148    notes: notes,
149  };
150}
151
152let callMethod = {
153
154  /**
155   * 调用方式示例代码
156   * const atManager = abilityAccessCtrl.createAtManager();
157   * let result = await atManager.verifyAccessToken(tokenID, array[i]);
158   */
159  firstCallMethod:'实例化调用方式1',
160
161  /**
162   * 调用方式示例代码
163   * private mCameraInput!: camera.CameraInput
164   * this.mCameraInput.release()
165   */
166  secondCallMethod:'实例化调用方式2',
167
168  /**
169   * 调用方式示例代码
170   * private mListeners:ArrayList<Listener> = new ArrayList();
171   * this.mListeners.add(listener);
172   */
173  thirdCallMethod:'实例化调用方式3',
174
175  /**
176   * 调用方式示例代码
177   * userAuthManager = new osAccount.UserAuth();
178   * this.userAuthManager.authUser();
179   */
180  fourthCallMethod:'实例化调用方式4',
181};
182exports.collectAllApi = collectAllApi;
183exports.callMethod = callMethod;