mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 05:04:58 +00:00
HackStudio+LibCpp: Include class members in Locator
This commit is contained in:
parent
c8ad1df143
commit
c6c83bd80e
3 changed files with 23 additions and 12 deletions
|
@ -308,6 +308,11 @@ NonnullRefPtrVector<Declaration> ParserAutoComplete::get_global_declarations(con
|
||||||
if (decl.is_namespace()) {
|
if (decl.is_namespace()) {
|
||||||
declarations.append(get_global_declarations(decl));
|
declarations.append(get_global_declarations(decl));
|
||||||
}
|
}
|
||||||
|
if (decl.is_struct_or_class()) {
|
||||||
|
for (auto& member_decl : static_cast<StructOrClassDeclaration&>(decl).declarations()) {
|
||||||
|
declarations.append(member_decl);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return declarations;
|
return declarations;
|
||||||
|
@ -511,7 +516,6 @@ OwnPtr<ParserAutoComplete::DocumentData> ParserAutoComplete::create_document_dat
|
||||||
|
|
||||||
String ParserAutoComplete::scope_of_declaration(const Declaration& decl)
|
String ParserAutoComplete::scope_of_declaration(const Declaration& decl)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto parent = decl.parent();
|
auto parent = decl.parent();
|
||||||
if (!parent)
|
if (!parent)
|
||||||
return {};
|
return {};
|
||||||
|
@ -521,15 +525,17 @@ String ParserAutoComplete::scope_of_declaration(const Declaration& decl)
|
||||||
|
|
||||||
auto& parent_decl = static_cast<Declaration&>(*parent);
|
auto& parent_decl = static_cast<Declaration&>(*parent);
|
||||||
|
|
||||||
if (parent_decl.is_namespace()) {
|
auto parent_scope = scope_of_declaration(parent_decl);
|
||||||
auto& containing_namespace = static_cast<NamespaceDeclaration&>(parent_decl);
|
String containing_scope;
|
||||||
auto scope_of_parent = scope_of_declaration(parent_decl);
|
if (parent_decl.is_namespace())
|
||||||
if (scope_of_parent.is_null())
|
containing_scope = static_cast<NamespaceDeclaration&>(parent_decl).m_name;
|
||||||
return containing_namespace.m_name;
|
if (parent_decl.is_struct_or_class())
|
||||||
return String::formatted("{}::{}", scope_of_parent, containing_namespace.m_name);
|
containing_scope = static_cast<StructOrClassDeclaration&>(parent_decl).name();
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
if (parent_scope.is_null())
|
||||||
|
return containing_scope;
|
||||||
|
|
||||||
|
return String::formatted("{}::{}", parent_scope, containing_scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,6 +309,13 @@ void StructOrClassDeclaration::dump(size_t indent) const
|
||||||
member.dump(indent + 1);
|
member.dump(indent + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NonnullRefPtrVector<Declaration> StructOrClassDeclaration::declarations() const
|
||||||
|
{
|
||||||
|
NonnullRefPtrVector<Declaration> declarations;
|
||||||
|
for (auto& member : m_members)
|
||||||
|
declarations.append(member);
|
||||||
|
return declarations;
|
||||||
|
}
|
||||||
|
|
||||||
void MemberDeclaration::dump(size_t indent) const
|
void MemberDeclaration::dump(size_t indent) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -521,7 +521,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView m_name;
|
|
||||||
Vector<StringView> m_entries;
|
Vector<StringView> m_entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -537,7 +536,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Type> m_type;
|
RefPtr<Type> m_type;
|
||||||
StringView m_name;
|
|
||||||
RefPtr<Expression> m_initial_value;
|
RefPtr<Expression> m_initial_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -549,6 +547,7 @@ public:
|
||||||
virtual bool is_struct_or_class() const override { return true; }
|
virtual bool is_struct_or_class() const override { return true; }
|
||||||
virtual bool is_struct() const override { return m_type == Type::Struct; }
|
virtual bool is_struct() const override { return m_type == Type::Struct; }
|
||||||
virtual bool is_class() const override { return m_type == Type::Class; }
|
virtual bool is_class() const override { return m_type == Type::Class; }
|
||||||
|
virtual NonnullRefPtrVector<Declaration> declarations() const override;
|
||||||
|
|
||||||
enum class Type {
|
enum class Type {
|
||||||
Struct,
|
Struct,
|
||||||
|
@ -683,7 +682,6 @@ public:
|
||||||
|
|
||||||
virtual NonnullRefPtrVector<Declaration> declarations() const override { return m_declarations; }
|
virtual NonnullRefPtrVector<Declaration> declarations() const override { return m_declarations; }
|
||||||
|
|
||||||
StringView m_name;
|
|
||||||
NonnullRefPtrVector<Declaration> m_declarations;
|
NonnullRefPtrVector<Declaration> m_declarations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue