1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 11:27:36 +00:00

LibCpp: Store filename in ASTNodes

As part of the position information, we now also store the filename the
ASTNode belongs to.
This commit is contained in:
Itamar 2021-02-20 12:23:53 +02:00 committed by Andreas Kling
parent c4139be461
commit d3ff82ba80
5 changed files with 86 additions and 73 deletions

View file

@ -72,7 +72,7 @@ OwnPtr<ParserAutoComplete::DocumentData> ParserAutoComplete::create_document_dat
auto document = filedb().get(file);
ASSERT(document);
auto content = document->text();
auto document_data = make<DocumentData>(document->text());
auto document_data = make<DocumentData>(document->text(), file);
auto root = document_data->parser.parse();
for (auto& path : document_data->preprocessor.included_paths()) {
get_or_create_document_data(document_path_from_include_path(path));
@ -88,10 +88,10 @@ void ParserAutoComplete::set_document_data(const String& file, OwnPtr<DocumentDa
m_documents.set(filedb().to_absolute_path(file), move(data));
}
ParserAutoComplete::DocumentData::DocumentData(String&& _text)
ParserAutoComplete::DocumentData::DocumentData(String&& _text, const String& filename)
: text(move(_text))
, preprocessor(text.view())
, parser(preprocessor.process().view())
, parser(preprocessor.process().view(), filename)
{
}