MCPcopy Create free account
hub / github.com/argotorg/solidity / semanticTokenTypeForType

Function semanticTokenTypeForType

libsolidity/lsp/SemanticTokensBuilder.cpp:35–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33{
34
35std::optional<SemanticTokenType> semanticTokenTypeForType(frontend::Type const* _type)
36{
37 if (!_type)
38 return std::nullopt;
39
40 switch (_type->category())
41 {
42 case frontend::Type::Category::Address: return SemanticTokenType::Class;
43 case frontend::Type::Category::Bool: return SemanticTokenType::Number;
44 case frontend::Type::Category::Enum: return SemanticTokenType::Enum;
45 case frontend::Type::Category::Function: return SemanticTokenType::Function;
46 case frontend::Type::Category::Integer: return SemanticTokenType::Number;
47 case frontend::Type::Category::RationalNumber: return SemanticTokenType::Number;
48 case frontend::Type::Category::StringLiteral: return SemanticTokenType::String;
49 case frontend::Type::Category::Struct: return SemanticTokenType::Struct;
50 case frontend::Type::Category::Contract: return SemanticTokenType::Class;
51 default:
52 lspDebug(fmt::format("semanticTokenTypeForType: unknown category: {}", static_cast<unsigned>(_type->category())));
53 return SemanticTokenType::Type;
54 }
55}
56
57SemanticTokenType semanticTokenTypeForExpression(frontend::Type const* _type)
58{

Callers 1

visitMethod · 0.85

Calls 1

categoryMethod · 0.45

Tested by

no test coverage detected