• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { KeyValueTypes } from '../common/constants';
17
18// 源文件路径
19export type rawFilePath = string;
20
21// mock后文件路径
22export type mockedFilePath = string;
23
24// KV节点
25export interface KeyValue {
26  key: string,
27  type: KeyValueTypes,
28  members: Members,
29  typeParameters: Members,
30  methodParams: Members,
31  constraint: Members,
32  sameName: KeyValue[],
33  sameDeclares: Declare[],
34  importedModulePath?: string,
35  heritage?: KeyValue,
36  property?: KeyValue,
37  parent?: KeyValue,
38  isExport?: boolean,
39  isDefault?: boolean,
40  isImportDefault?: boolean,
41  isNamespaceImport?: boolean,
42  isStatic?: boolean,
43  value?: string,
44  rawName?: string,
45  operateElements?: KeyValue[],
46  isNeedMock?: boolean,
47  isArrowFunction?: boolean,
48  isGlobalDeclare?: boolean,
49  dependOnGlobals: Set<KeyValue>,
50  isMocked?: boolean
51}
52
53// 成员对象
54export interface Members {
55  [key: string]: KeyValue
56}
57
58// 文件的mock信息
59export interface MockBuffer {
60  contents: KeyValue,
61  mockedFilePath: mockedFilePath,
62  rawFilePath: rawFilePath,
63}
64
65// 全局KV对象集
66export interface Declares {
67  [key: string]: Declare,
68}
69
70// 全局KV对象
71export interface Declare {
72  keyValue: KeyValue,
73  from: rawFilePath
74}
75
76// api目录
77export type ApiFolder = 'api' | 'component' | 'arkts' | 'kits';
78
79// reference 节点查询结果信息
80interface KeyValueInfo {
81  keyValue: KeyValue,
82  mockBuffer: MockBuffer,
83  isGlobalDeclaration?: boolean
84}
85
86// reference 节点查询结果
87export type ReferenceFindResult = KeyValueInfo | undefined;
88
89// 继承 KV节点
90export type HeritageKeyValue = KeyValue | undefined;
91
92// 函数重载的类型
93export type OverloadedFunctionType = 'single' | 'multiple';
94
95// 回调函数参数Mock数据
96export interface CallbackParamMockData {
97  paramName: string,
98  isAsyncCallback: boolean,
99  callBackParams: string[]
100}
101