• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 - 2025 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 { Scope } from '../../model/Scope';
17
18export class CheckerStorage {
19    private static instance: CheckerStorage;
20    private scopeMap: Map<string, Scope> = new Map();
21    private apiVersion: number = 16;
22    private product: string = '';
23
24    public static dispose(): void {
25        // @ts-ignore
26        this.instance = null;
27    }
28
29    /**
30     * 获取 CheckerStorage 的单例实例
31     * @returns {CheckerStorage} CheckerStorage 的单例实例
32     */
33    public static getInstance(): CheckerStorage {
34        if (!CheckerStorage.instance) {
35            CheckerStorage.instance = new CheckerStorage();
36        }
37        return CheckerStorage.instance;
38    }
39
40    /**
41     * 根据文件路径获取Scope
42     * @param filePath - 文件路径
43     * @returns Scope | undefined - 返回Scope对象或undefined
44     */
45    public getScope(filePath: string): Scope | undefined {
46        return this.scopeMap.get(filePath);
47    }
48
49    /**
50     * 设置Scope映射
51     * @param scopeMap - Scope映射,类型为 Map<string, Scope>
52     */
53    public setScopeMap(scopeMap: Map<string, Scope>): void {
54        this.scopeMap = scopeMap;
55    }
56
57    /**
58     * 设置API版本
59     * @param api API版本号
60     */
61    public setApiVersion(api: number): void {
62        this.apiVersion = api;
63    }
64
65    /**
66     * 获取API版本号
67     * @returns {number} 返回API版本号
68     */
69    public getApiVersion(): number {
70        return this.apiVersion;
71    }
72
73    /**
74     * 设置product
75     * @param product
76     */
77    public setProduct(pro: string): void {
78        this.product = pro;
79    }
80
81    /**
82     * 获取product
83     * @returns {string} 返回product
84     */
85    public getProduct(): string {
86        return this.product;
87    }
88}