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_CLASSIFIER_H 17 #define ES2PANDA_LSP_INCLUDE_CLASSIFIER_H 18 19 #include <cstddef> 20 #include "lexer/lexer.h" 21 #include "lexer/token/token.h" 22 #include "public/es2panda_lib.h" 23 24 namespace ark::es2panda::lsp { 25 26 enum class ClassificationType { 27 IDENTIFIER, 28 KEYWORD, 29 NUMERIC_LITERAL, 30 STRING_LITERAL, 31 BOOLEAN_LITERAL, 32 NULL_LITERAL, 33 PUNCTUATION, 34 35 CLASS_NAME, 36 ENUM_NAME, 37 INTERFACE_NAME, 38 TYPE_PARAMETER_NAME, 39 TYPE_ALIAS_NAME, 40 PARAMETER_NAME, 41 }; 42 43 struct ClassifiedSpan { 44 size_t start; 45 size_t length; 46 char const *name; 47 }; 48 49 std::unique_ptr<lexer::Lexer> InitLexer(es2panda_Context *context); 50 ClassificationType GetClassificationType(const lexer::Token &token); 51 ClassificationType AstNodeTypeToClassificationType(ir::AstNodeType type); 52 char const *ClassificationTypeToString(ClassificationType type); 53 ArenaVector<ClassifiedSpan *> GetSyntacticClassifications(es2panda_Context *context, size_t startPos, size_t length); 54 ArenaVector<ClassifiedSpan *> GetSemanticClassifications(es2panda_Context *context, size_t startPos, size_t length); 55 56 } // namespace ark::es2panda::lsp 57 58 #endif 59