• 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_CREATE_TYPE_HELP_ITEMS_H
17 #define ES2PANDA_LSP_CREATE_TYPE_HELP_ITEMS_H
18 
19 #include "types.h"
20 #include <string>
21 #include "ir/astNode.h"
22 #include "lexer/token/sourceLocation.h"
23 #include "utils/arena_containers.h"
24 #include <checker/checker.h>
25 #include <checker/typeChecker/TypeChecker.h>
26 #include <utility>
27 #include <variant>
28 #include <vector>
29 
30 namespace ark::es2panda::lsp {
31 
32 enum class InvocationKind { CALL, TYPE_ARGS, CONTEXTUAL };
33 
34 struct CallInvocation {
35     InvocationKind kind = InvocationKind::CALL;
36     ir::AstNode *callExpressionNode = nullptr;
37 };
38 
39 struct TypeArgsInvocation {
40     InvocationKind kind = InvocationKind::TYPE_ARGS;
41     ir::AstNode *identifierNode = nullptr;
42 };
43 
44 struct ContextualInvocation {
45     InvocationKind kind = InvocationKind::CONTEXTUAL;
46     checker::Signature *signature = nullptr;
47     ir::AstNode *node = nullptr;
48 };
49 
50 using Invocation = std::variant<CallInvocation, TypeArgsInvocation, ContextualInvocation>;
51 
52 void GetLocalTypeParametersOfClassOrInterfaceOrTypeAlias(const ir::AstNode *node, std::vector<checker::Type *> &result);
53 std::vector<checker::Type *> GetEffectiveTypeParameterDeclarations(const ir::AstNode *node,
54                                                                    std::vector<checker::Type *> &result);
55 
56 void GetTypeHelpItem(std::vector<checker::Type *> *typeParameters, const ir::AstNode *node, SignatureHelpItem &result);
57 
58 SignatureHelpItems CreateTypeHelpItems(const ir::AstNode *node, lexer::SourceRange location, TextSpan applicableSpan);
59 
60 }  // namespace ark::es2panda::lsp
61 
62 #endif  // ES2PANDA_LSP_CREATE_TYPE_HELP_ITEMS_H