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_INLAY_HINTS_H 17 #define ES2PANDA_LSP_INLAY_HINTS_H 18 19 #include "api.h" 20 #include "ir/astNode.h" 21 #include "cancellation_token.h" 22 #include <string> 23 #include <vector> 24 #include "user_preferences.h" 25 26 namespace ark::es2panda::lsp { 27 28 struct ParamInfoObj { 29 std::string paramName; 30 bool isFirstVariadicArgument; 31 }; 32 33 int GetFullWidth(const ir::AstNode *node); 34 void AddEnumMemberValueHints(const std::string &text, const int position, InlayHintList *result); 35 void AddTypeHints(const std::string &text, const int position, InlayHintList *result); 36 void AddParameterHints(const std::string &text, const int position, const bool isFirstVariadicArgument, 37 InlayHintList *result); 38 bool DecodedTextSpanIntersectsWith(const int start1, const int length1, const int start2, const int length2); 39 bool TextSpanIntersectsWith(const TextSpan span, const int position, const int nodeSize); 40 bool IsExpressionWithTypeArguments(const ir::AstNode *node); 41 void GetVariableDeclarationTypeForHints(const ir::AstNode *decl, InlayHintList *result); 42 void GetCallExpTypeForHints(const ir::AstNode *expr, const ir::AstNode *parent, InlayHintList *result); 43 bool ShouldShowParameterNameHints(const UserPreferences &preferences); 44 void SaveToList(const ir::Expression *mem, const ir::AstNode *asignNode, InlayHintList *list); 45 void GetEnumTypeForHints(const ir::AstNode *member, const ir::AstNode *parent, InlayHintList *result); 46 void GetFunctionReturnTypeForHints(const ir::AstNode *decl, InlayHintList *result); 47 void GetFunctionParameterTypeForHints(const ir::AstNode *node, InlayHintList *result); 48 bool IsSignatureSupportingReturnAnnotation(const ir::AstNode *node); 49 void Visitor(const ir::AstNode *node, const TextSpan *span, const ir::AstNode *parent, 50 CancellationToken cancellationToken, InlayHintList *result); 51 InlayHintList ProvideInlayHintsImpl(es2panda_Context *context, const TextSpan *span, 52 CancellationToken &cancellationToken, UserPreferences &preferences); 53 54 } // namespace ark::es2panda::lsp 55 56 #endif 57