1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-30 10:12:07 +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:
Itamar 2021-02-06 15:58:02 +02:00 committed by Andreas Kling
parent bed3261723
commit bed06b13f3
8 changed files with 248 additions and 21 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
* Copyright (c) 2021, Itamar S. <itamar8910@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,20 +36,21 @@
int main(int, char**)
{
Core::EventLoop event_loop;
if (pledge("stdio unix recvfd", nullptr) < 0) {
if (pledge("stdio unix recvfd rpath ", nullptr) < 0) {
perror("pledge");
return 1;
}
auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
IPC::new_client_connection<LanguageServers::Cpp::ClientConnection>(socket.release_nonnull(), 1);
if (pledge("stdio recvfd", nullptr) < 0) {
if (pledge("stdio recvfd rpath", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
if (unveil("/usr/include", "r") < 0)
perror("unveil");
return 1;
}
// unveil will be sealed later, when we know the project's root path.
return event_loop.exec();
}