1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:47:35 +00:00

LanguageServers: Add ProjectLoaction, Declaration types and use in IPC

With this we can avoid passing (name, line, column) tuples in many
different places.
This commit is contained in:
Itamar 2021-02-27 09:31:05 +02:00 committed by Andreas Kling
parent daf18e7777
commit 4b483071fb
10 changed files with 93 additions and 33 deletions

View file

@ -64,4 +64,51 @@ inline bool decode(IPC::Decoder& decoder, GUI::AutocompleteProvider::Entry& resp
return ok;
}
template<>
inline bool encode(Encoder& encoder, const GUI::AutocompleteProvider::ProjectLocation& location)
{
encoder << location.file;
encoder << (u64)location.line;
encoder << (u64)location.column;
return true;
}
template<>
inline bool decode(Decoder& decoder, GUI::AutocompleteProvider::ProjectLocation& location)
{
u64 line = 0;
u64 column = 0;
if (!decoder.decode(location.file))
return false;
if (!decoder.decode(line))
return false;
if (!decoder.decode(column))
return false;
location.line = line;
location.column = column;
return true;
}
template<>
inline bool encode(Encoder& encoder, const GUI::AutocompleteProvider::Declaration& declaration)
{
encoder << declaration.name;
if (!encode(encoder, declaration.position))
return false;
return true;
}
template<>
inline bool decode(Decoder& decoder, GUI::AutocompleteProvider::Declaration& declaration)
{
if (!decoder.decode(declaration.name))
return false;
if (!decode(decoder, declaration.position))
return false;
return true;
}
}