mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LanguageServers/Cpp: Add FileDB and pass project_root in Greet()
FileDB wraps the access to the contents of project files. When asked to fetch a file, FileDB will either return its in-memory model of the file if it has been "opened" by the language-server protocol, or otherwise fetch it from the filesystem. Previously, the cpp language server did not pledge "rpath" and got access to the contents of files whenever they were opened by the language client. However, features like inspection of header files require the language server to get the content of files that were not opened by the client. The language server now pledges rpath but makes sure to only unveil the project's directory and /usr/include.
This commit is contained in:
@@ -52,8 +52,17 @@ void ClientConnection::die()
|
||||
exit(0);
|
||||
}
|
||||
|
||||
OwnPtr<Messages::LanguageServer::GreetResponse> ClientConnection::handle(const Messages::LanguageServer::Greet&)
|
||||
OwnPtr<Messages::LanguageServer::GreetResponse> ClientConnection::handle(const Messages::LanguageServer::Greet& message)
|
||||
{
|
||||
m_filedb.set_project_root(message.project_root());
|
||||
if (unveil(message.project_root().characters(), "r") < 0) {
|
||||
perror("unveil");
|
||||
exit(1);
|
||||
}
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
exit(1);
|
||||
}
|
||||
return make<Messages::LanguageServer::GreetResponse>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user