Skip to content

Commit

Permalink
refactor!: rename jsonschema analyse method to inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
bavulapati committed Feb 8, 2025
1 parent 7af0ac4 commit 11e6a3e
Show file tree
Hide file tree
Showing 19 changed files with 195 additions and 195 deletions.
2 changes: 1 addition & 1 deletion benchmark/jsonschema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static void Schema_Frame_OMC_Full(benchmark::State &state) {

for (auto _ : state) {
sourcemeta::core::SchemaFrame frame;
frame.analyse(schema, sourcemeta::core::schema_official_walker,
frame.inspect(schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::schema_official_resolver);
benchmark::DoNotOptimize(frame);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/jsonschema/bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ auto bundle_schema(sourcemeta::core::JSON &root, const std::string &container,
const sourcemeta::core::SchemaWalker &walker,
const sourcemeta::core::SchemaResolver &resolver,
const std::optional<std::string> &default_dialect) -> void {
frame.analyse(subschema, walker, resolver, default_dialect);
frame.inspect(subschema, walker, resolver, default_dialect);
// Otherwise, given recursion, we would be modifying the
// references list *while* looping on it
const auto references_copy = frame.references();
Expand Down
2 changes: 1 addition & 1 deletion src/core/jsonschema/frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ auto find_adjacent_dependencies(const JSON::String &current, const JSON &schema,

namespace sourcemeta::core {

auto SchemaFrame::analyse(const JSON &schema, const SchemaWalker &walker,
auto SchemaFrame::inspect(const JSON &schema, const SchemaWalker &walker,
const SchemaResolver &resolver,
const std::optional<std::string> &default_dialect,
const std::optional<std::string> &default_id)
Expand Down
14 changes: 7 additions & 7 deletions src/core/jsonschema/include/sourcemeta/core/jsonschema_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace sourcemeta::core {
/// })JSON");
///
/// sourcemeta::core::SchemaFrame frame;
/// frame.analyse(document,
/// frame.inspect(document,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::schema_official_resolver);
///
Expand Down Expand Up @@ -150,7 +150,7 @@ class SOURCEMETA_CORE_JSONSCHEMA_EXPORT SchemaFrame {
std::string base_dialect;
// TODO: Support only populating these when needed, given
// how expensive they can be, by taking more options on the
// analyse method
// inspect method
std::vector<PointerTemplate> instance_locations;
std::vector<std::reference_wrapper<const LocationKey>> destination_of;
};
Expand All @@ -160,17 +160,17 @@ class SOURCEMETA_CORE_JSONSCHEMA_EXPORT SchemaFrame {
/// reference frame as this mapping is essential for resolving references.
using Locations = std::map<LocationKey, LocationsEntry>;

/// Analyse a given schema
auto analyse(const JSON &schema, const SchemaWalker &walker,
/// Inspect a given schema
auto inspect(const JSON &schema, const SchemaWalker &walker,
const SchemaResolver &resolver,
const std::optional<std::string> &default_dialect = std::nullopt,
const std::optional<std::string> &default_id = std::nullopt)
-> void;

/// Access the analysed schema locations
/// Access the inspected schema locations
auto locations() const noexcept -> const Locations &;

/// Access the analysed schema references
/// Access the inspected schema references
auto references() const noexcept -> const References &;

/// Get the vocabularies associated with a location entry
Expand Down Expand Up @@ -250,7 +250,7 @@ using SchemaUnevaluatedEntries = std::map<std::string, SchemaUnevaluatedEntry>;
/// })JSON");
///
/// sourcemeta::core::SchemaFrame frame;
/// frame.analyse(document,
/// frame.inspect(document,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::schema_official_resolver);
/// const auto result{sourcemeta::core::unevaluated(
Expand Down
4 changes: 2 additions & 2 deletions src/core/jsonschema/jsonschema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ auto sourcemeta::core::reference_visit(
const std::optional<std::string> &default_dialect,
const std::optional<std::string> &default_id) -> void {
sourcemeta::core::SchemaFrame frame;
frame.analyse(schema, walker, resolver, default_dialect, default_id);
frame.inspect(schema, walker, resolver, default_dialect, default_id);
for (const auto &entry : frame.locations()) {
if (entry.second.type !=
sourcemeta::core::SchemaFrame::LocationType::Resource &&
Expand Down Expand Up @@ -645,7 +645,7 @@ auto sourcemeta::core::unidentify(
const std::optional<std::string> &default_dialect) -> void {
// (1) Re-frame before changing anything
sourcemeta::core::SchemaFrame frame;
frame.analyse(schema, walker, resolver, default_dialect);
frame.inspect(schema, walker, resolver, default_dialect);

// (2) Remove all identifiers and anchors
for (const auto &entry : sourcemeta::core::SchemaIterator{
Expand Down
2 changes: 1 addition & 1 deletion src/core/jsonschema/resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ auto SchemaMapResolver::add(const JSON &schema,
// Registering the top-level schema is not enough. We need to check
// and register every embedded schema resource too
SchemaFrame frame;
frame.analyse(schema, schema_official_walker, *this, default_dialect,
frame.inspect(schema, schema_official_walker, *this, default_dialect,
default_id);

for (const auto &[key, entry] : frame.locations()) {
Expand Down
Loading

0 comments on commit 11e6a3e

Please sign in to comment.