From cfca0f9462193ce87a3ba01574242b5834409e1d Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 24 Feb 2026 17:41:17 -0500 Subject: [PATCH 15/30] json: move pp_markup::quoted_json_pointer to its own header gcc/ChangeLog: * json-diagnostic.cc: Include "pretty-print-markup-json.h". (class pp_markup::quoted_json_pointer): Move to... * pretty-print-markup-json.h: ...this new file. Signed-off-by: David Malcolm --- gcc/json-diagnostic.cc | 27 +----------------- gcc/pretty-print-markup-json.h | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 gcc/pretty-print-markup-json.h diff --git a/gcc/json-diagnostic.cc b/gcc/json-diagnostic.cc index bf61cd0007e..fced0a48ecb 100644 --- a/gcc/json-diagnostic.cc +++ b/gcc/json-diagnostic.cc @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "diagnostics/text-sink.h" #include "diagnostics/physical-location-maker.h" #include "pretty-print-markup.h" +#include "pretty-print-markup-json.h" static bool emit_json_diagnostic (gcc_json_context &ctxt, @@ -184,32 +185,6 @@ private: const json::value &m_js_val; }; -namespace pp_markup { - -/* Print the JSON Pointer of a given json::value in quotes. */ - -class quoted_json_pointer : public pp_element -{ -public: - quoted_json_pointer (const json::value &js_val) - : m_js_val (js_val) - { - } - - void - add_to_phase_2 (context &ctxt) final override - { - ctxt.begin_quote (); - m_js_val.print_pointer (&ctxt.m_pp); - ctxt.end_quote (); - } - -private: - const json::value &m_js_val; -}; - -} // namespace pp_markup - /* text_sink starter for diagnostics relating to JSON. */ static void diff --git a/gcc/pretty-print-markup-json.h b/gcc/pretty-print-markup-json.h new file mode 100644 index 00000000000..d10e9fb4053 --- /dev/null +++ b/gcc/pretty-print-markup-json.h @@ -0,0 +1,51 @@ +/* Copyright (C) 2026 Free Software Foundation, Inc. + Contributed by David Malcolm + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_PRETTY_PRINT_MARKUP_JSON_H +#define GCC_PRETTY_PRINT_MARKUP_JSON_H + +#include "pretty-print-markup.h" + +namespace pp_markup { + +/* Print the JSON Pointer of a given json::value in quotes. */ + +class quoted_json_pointer : public pp_element +{ +public: + quoted_json_pointer (const json::value &js_val) + : m_js_val (js_val) + { + } + + void + add_to_phase_2 (context &ctxt) final override + { + ctxt.begin_quote (); + m_js_val.print_pointer (&ctxt.m_pp); + ctxt.end_quote (); + } + +private: + const json::value &m_js_val; +}; + +} // namespace pp_markup + +#endif /* GCC_PRETTY_PRINT_MARKUP_JSON_H */ -- 2.49.0