kdesc --coverage <target>: one target's view (from dev 931ea5490a5d)
For the designer building a target: the klammers that cover it, those that do so with an empty definition (a decision that the klammer has no meaning there), and the undecided ones (no definition). One klammer per line, alphabetical; "all" adds the explanations; an unknown word names the missing target. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
39edac9c94
commit
d14da90bbf
6 files changed
+152
-15
No files matched your search
@@ -233,6 +233,23 @@ std::vector<Klammer_coverage> klammer_coverage(const Machine& machine,
|
||||
if (!is_in(file, kc.m_files)) {
|
||||
kc.m_files.push_back(file);
|
||||
}
|
||||
// An empty body (nothing, or whitespace only) is a definition
|
||||
// that yields no text: the designer's statement that the
|
||||
// klammer has no meaning in that target. Recorded so a
|
||||
// target's report can tell it from a gap.
|
||||
if (def.target != Target_registry::declare_name &&
|
||||
def.target != Target_registry::general_name &&
|
||||
def.target != Target_registry::optionset_name) {
|
||||
auto body = klammer.m_body.find(def.target);
|
||||
bool empty = body == klammer.m_body.end();
|
||||
if (!empty) {
|
||||
empty = std::all_of(body->second.begin(), body->second.end(),
|
||||
[](const Katom& k) { return k.is_whitespace(); });
|
||||
}
|
||||
if (empty && !is_in(def.target, kc.m_empty)) {
|
||||
kc.m_empty.push_back(def.target);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto& [target, loc] : klammer.m_defloc) {
|
||||
if (target != Target_registry::declare_name &&
|
||||
@@ -509,3 +526,61 @@ void report_coverage(const Machine& machine,
|
||||
os << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// One target's view (kdesc --coverage <target>), 2026-09-26. Three lists, and
|
||||
// the middle one is the point: an EMPTY definition is a decision, not a gap.
|
||||
// One name per line, alphabetical, as the general report's rows are (Andy:
|
||||
// consistency, and no better order exists).
|
||||
|
||||
namespace {
|
||||
|
||||
void names_listed(std::ostream& os, std::vector<std::string> names)
|
||||
{
|
||||
std::sort(names.begin(), names.end());
|
||||
for (const auto& n : names) {
|
||||
os << " @" << n << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void report_target_coverage(const std::vector<Klammer_coverage>& coverage,
|
||||
const std::string& target, bool full, std::ostream& os)
|
||||
{
|
||||
std::vector<std::string> covered {}, empty {}, undecided {};
|
||||
for (const auto& kc : coverage) {
|
||||
if (is_in(target, kc.m_empty)) {
|
||||
empty.push_back(kc.m_name);
|
||||
} else if (is_in(target, kc.m_targets)) {
|
||||
covered.push_back(kc.m_name);
|
||||
} else {
|
||||
undecided.push_back(kc.m_name);
|
||||
}
|
||||
}
|
||||
os << "Klammer coverage of target \"" << target << "\"\n"
|
||||
<< std::string(29 + target.size(), '=') << "\n\n"
|
||||
<< coverage.size() << " " << plural("klammer", static_cast<int>(coverage.size()))
|
||||
<< ": " << covered.size() + empty.size() << " covered";
|
||||
if (!empty.empty()) {
|
||||
os << " (" << empty.size() << " by an empty definition)";
|
||||
}
|
||||
os << ", " << undecided.size() << " undecided\n";
|
||||
|
||||
section(os, "Covered", covered.size(),
|
||||
full ? " A definition for this target, or a general one that reaches it.\n" : "");
|
||||
names_listed(os, covered);
|
||||
if (!empty.empty() || full) {
|
||||
section(os, "Covered by an empty definition", empty.size(),
|
||||
full ? " Defined for this target with a body of nothing, so applying the\n"
|
||||
" klammer yields no text: the designer's decision that it has no\n"
|
||||
" meaning here (a presentation hint with no analogue, say). A\n"
|
||||
" decision, not a gap.\n" : "");
|
||||
names_listed(os, empty);
|
||||
}
|
||||
section(os, "Undecided", undecided.size(),
|
||||
full ? " No definition for this target. Nothing has been decided either\n"
|
||||
" way: this is what a designer of the target has not written yet,\n"
|
||||
" not what the target excludes.\n" : "");
|
||||
names_listed(os, undecided);
|
||||
}
|
||||
Reference in new issue
Block a user