/* * Copyright (c) 2020, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace IPC { template<> inline ErrorOr encode(Encoder& encoder, CodeComprehension::AutocompleteResultEntry const& response) { TRY(encoder.encode(response.completion)); TRY(encoder.encode(response.partial_input_length)); TRY(encoder.encode(response.language)); TRY(encoder.encode(response.display_text)); TRY(encoder.encode(response.hide_autocomplete_after_applying)); return {}; } template<> inline ErrorOr decode(Decoder& decoder) { auto completion = TRY(decoder.decode()); auto partial_input_length = TRY(decoder.decode()); auto language = TRY(decoder.decode()); auto display_text = TRY(decoder.decode()); auto hide_autocomplete_after_applying = TRY(decoder.decode()); return CodeComprehension::AutocompleteResultEntry { move(completion), partial_input_length, language, move(display_text), hide_autocomplete_after_applying }; } template<> inline ErrorOr encode(Encoder& encoder, CodeComprehension::ProjectLocation const& location) { TRY(encoder.encode(location.file)); TRY(encoder.encode(location.line)); TRY(encoder.encode(location.column)); return {}; } template<> inline ErrorOr decode(Decoder& decoder) { auto file = TRY(decoder.decode()); auto line = TRY(decoder.decode()); auto column = TRY(decoder.decode()); return CodeComprehension::ProjectLocation { move(file), line, column }; } template<> inline ErrorOr encode(Encoder& encoder, CodeComprehension::Declaration const& declaration) { TRY(encoder.encode(declaration.name)); TRY(encoder.encode(declaration.position)); TRY(encoder.encode(declaration.type)); TRY(encoder.encode(declaration.scope)); return {}; } template<> inline ErrorOr decode(Decoder& decoder) { auto name = TRY(decoder.decode()); auto position = TRY(decoder.decode()); auto type = TRY(decoder.decode()); auto scope = TRY(decoder.decode()); return CodeComprehension::Declaration { move(name), position, type, move(scope) }; } template<> inline ErrorOr encode(Encoder& encoder, CodeComprehension::TodoEntry const& entry) { TRY(encoder.encode(entry.content)); TRY(encoder.encode(entry.filename)); TRY(encoder.encode(entry.line)); TRY(encoder.encode(entry.column)); return {}; } template<> inline ErrorOr decode(Decoder& decoder) { auto content = TRY(decoder.decode()); auto filename = TRY(decoder.decode()); auto line = TRY(decoder.decode()); auto column = TRY(decoder.decode()); return CodeComprehension::TodoEntry { move(content), move(filename), line, column }; } template<> inline ErrorOr encode(Encoder& encoder, CodeComprehension::TokenInfo const& location) { TRY(encoder.encode(location.type)); TRY(encoder.encode(location.start_line)); TRY(encoder.encode(location.start_column)); TRY(encoder.encode(location.end_line)); TRY(encoder.encode(location.end_column)); return {}; } template<> inline ErrorOr decode(Decoder& decoder) { auto type = TRY(decoder.decode()); auto start_line = TRY(decoder.decode()); auto start_column = TRY(decoder.decode()); auto end_line = TRY(decoder.decode()); auto end_column = TRY(decoder.decode()); return CodeComprehension::TokenInfo { type, start_line, start_column, end_line, end_column }; } }