• 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_INCLUDE_SIGNATURE_HELP_ITEMS_H
17 #define ES2PANDA_LSP_INCLUDE_SIGNATURE_HELP_ITEMS_H
18 
19 #include <cstddef>
20 #include <optional>
21 #include <vector>
22 #include "create_type_help_items.h"
23 
24 namespace ark::es2panda::lsp {
25 
26 inline constexpr std::string_view const GENSYM_CORE = "gensym%%_";
27 inline constexpr std::string_view const DUMMY_ID = "_";
28 
29 struct ArgumentListInfo {
30 private:
31     TextSpan applicableSpan_ {0, 0};
32     uint32_t argumentCount_ {0};
33     size_t argumentIndex_ {0};
34     Invocation invocation_;
35 
36 public:
SetApplicableSpanArgumentListInfo37     void SetApplicableSpan(TextSpan applicableSpan)
38     {
39         applicableSpan_ = applicableSpan;
40     }
41 
SetArgumentCountArgumentListInfo42     void SetArgumentCount(uint32_t argumentCount)
43     {
44         argumentCount_ = argumentCount;
45     }
46 
SetArgumentIndexArgumentListInfo47     void SetArgumentIndex(size_t argumentIndex)
48     {
49         argumentIndex_ = argumentIndex;
50     }
51 
GetApplicableSpanArgumentListInfo52     TextSpan GetApplicableSpan()
53     {
54         return applicableSpan_;
55     }
56 
GetArgumentCountArgumentListInfo57     uint32_t GetArgumentCount()
58     {
59         return argumentCount_;
60     }
61 
GetArgumentIndexArgumentListInfo62     size_t GetArgumentIndex()
63     {
64         return argumentIndex_;
65     }
SetInvocationArgumentListInfo66     void SetInvocation(Invocation invocation)
67     {
68         invocation_ = invocation;
69     }
GetInvocationArgumentListInfo70     const Invocation &GetInvocation() const
71     {
72         return invocation_;
73     }
74 };
75 
76 SignatureHelpItems CreateSignatureHelpItems(std::vector<checker::Signature *> &signatures,
77                                             checker::Signature *signature,
78                                             std::optional<ArgumentListInfo> argumentListInfo);
79 
80 std::vector<SignatureHelpItem> GetSignatureHelpItem(const std::vector<checker::Signature *> &signatures);
81 
82 SignatureHelpItem CreateSignatureHelpItem(checker::Signature &signature);
83 
84 void SetSignatureHelpParameter(const checker::SignatureInfo *signatureInfo, SignatureHelpItem &signatureHelpItem);
85 
86 }  // namespace ark::es2panda::lsp
87 
88 #endif  // ES2PANDA_LSP_INCLUDE_SIGNATURE_HELP_ITEMS_H