• 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_SUGGESTION_DIAGNOSTICS_H
17 #define ES2PANDA_LSP_INCLUDE_SUGGESTION_DIAGNOSTICS_H
18 
19 #include "ir/astNode.h"
20 #include "public/es2panda_lib.h"
21 #include "public/public.h"
22 #include "api.h"
23 #include <iostream>
24 #include <vector>
25 
26 namespace ark::es2panda::lsp {
27 
28 std::vector<FileDiagnostic> GetSuggestionDiagnosticsImpl(ir::AstNode *astNode);
29 void Check(ir::AstNode *node, std::vector<FileDiagnostic> &diag, std::unordered_map<std::string, bool> &visitedFunc);
30 void AddConvertToAsyncFunctionDiagnostics(ir::AstNode *node, std::vector<FileDiagnostic> &diag,
31                                           std::unordered_map<std::string, bool> &visitedFunc);
32 bool IsConvertibleFunction(ir::AstNode *node, std::unordered_map<std::string, bool> &visitedFunc);
33 bool HasReturnStatementWithPromiseHandler(ir::AstNode *node, std::unordered_map<std::string, bool> &visitedFunc);
34 bool IsReturnStatementWithFixablePromiseHandler(ir::AstNode *node, std::unordered_map<std::string, bool> &visitedFunc);
35 bool IsFixablePromiseHandler(ir::AstNode *node, std::unordered_map<std::string, bool> &visitedFunc);
36 bool IsPromiseHandler(ir::AstNode *node);
37 bool HasSupportedNumberOfArguments(ir::AstNode *node);
38 bool IsFixablePromiseArgument(ir::AstNode *node, std::unordered_map<std::string, bool> &visitedFunc);
39 std::string GetKeyFromNode(ir::AstNode *node);
40 bool CanBeConvertedToAsync(ir::AstNode *node);
41 bool HasPropertyAccessExpressionWithName(ir::AstNode *node, const std::string &func);
42 
43 }  // namespace ark::es2panda::lsp
44 
45 #endif
46