diff options
author | Itamar <itamar8910@gmail.com> | 2021-06-26 15:34:23 +0300 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-29 00:07:19 +0430 |
commit | d7aa831a430800ed5ce16b00a0cdcc72e434eeba (patch) | |
tree | 0662f876f8dc199b2d6f0ce783d55232e839ca1f /Userland/DevTools/HackStudio | |
parent | 10cad8a87418a4507b5385d69f66eef349b0561d (diff) | |
download | serenity-d7aa831a430800ed5ce16b00a0cdcc72e434eeba.zip |
LibCpp: Differentiate between Type and NamedType
This adds a new ASTNode type called 'NamedType' which inherits from
the Type node.
Previously every Type node had a name field, but it was not logically
accurate. For example, pointer types do not have a name
(the pointed-to type may have one).
Diffstat (limited to 'Userland/DevTools/HackStudio')
-rw-r--r-- | Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp index 4f1a05296d..8f5628bb17 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/CppComprehensionEngine.cpp @@ -227,8 +227,8 @@ String CppComprehensionEngine::type_of_property(const DocumentData& document, co auto& parent = (const MemberExpression&)(*identifier.parent()); auto properties = properties_of_type(document, type_of(document, *parent.m_object)); for (auto& prop : properties) { - if (prop.name == identifier.m_name) - return prop.type->m_name->full_name(); + if (prop.name == identifier.m_name && prop.type->is_named_type()) + return ((NamedType&)prop.type).m_name->full_name(); } return {}; } @@ -240,8 +240,8 @@ String CppComprehensionEngine::type_of_variable(const Identifier& identifier) co for (auto& decl : current->declarations()) { if (decl.is_variable_or_parameter_declaration()) { auto& var_or_param = (VariableOrParameterDeclaration&)decl; - if (var_or_param.m_name == identifier.m_name) { - return var_or_param.m_type->m_name->full_name(); + if (var_or_param.m_name == identifier.m_name && var_or_param.m_type->is_named_type()) { + return ((NamedType&)(*var_or_param.m_type)).m_name->full_name(); } } } |