• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 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 
16 #ifndef ES2PANDA_LSP_CLASS_HIERARCHIES_INFO_H
17 #define ES2PANDA_LSP_CLASS_HIERARCHIES_INFO_H
18 
19 #include <memory>
20 #include <string>
21 #include <unordered_map>
22 #include <vector>
23 #include "public/es2panda_lib.h"
24 
25 namespace ark::es2panda::lsp {
26 
27 enum class ClassRelationKind { UNKNOWN, INTERFACE, CLASS, FIELD, METHOD, PROPERTY };
28 
29 // NOLINTBEGIN(misc-non-private-member-variables-in-classes)
30 struct ClassRelationDetails {
31     ClassRelationDetails() = default;
ClassRelationDetailsClassRelationDetails32     ClassRelationDetails(std::string f, size_t p, ClassRelationKind k) : fileName(std::move(f)), pos(p), kind(k) {}
33     std::string fileName;
34     size_t pos = 0;
35     ClassRelationKind kind = ClassRelationKind::UNKNOWN;
36 };
37 
38 struct ClassHierarchyItemInfo {
39     ClassHierarchyItemInfo() = default;
ClassHierarchyItemInfoClassHierarchyItemInfo40     ClassHierarchyItemInfo(std::string d, ClassRelationKind k, size_t p) : pos(p), kind(k), description(std::move(d)) {}
41     size_t pos = 0;
42     ClassRelationKind kind = ClassRelationKind::UNKNOWN;
43     std::vector<ClassRelationDetails> overridden;
44     std::vector<ClassRelationDetails> overriding;
45     std::vector<ClassRelationDetails> implemented;
46     std::vector<ClassRelationDetails> implementing;
47     std::string description;
48 };
49 // NOLINTEND(misc-non-private-member-variables-in-classes)
50 
51 /**
52  * @brief Returns class/interface hierarchys at a specific source position.
53  *
54  * @param context Parsing context for AST access.
55  * @param fileName Source file name.
56  * @param pos Character offset in source code.
57  */
58 std::vector<ClassHierarchyItemInfo> GetClassHierarchiesImpl(es2panda_Context *context, const std::string &fileName,
59                                                             size_t pos);
60 }  // namespace ark::es2panda::lsp
61 
62 #endif