60 lines
2.8 KiB
Python
60 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""The review round's §R3b phase: `renamewarn`.
|
|
|
|
`renametrace` fingerprints a rename's **edits**; a rename's warnings do not
|
|
travel in the `WorkspaceEdit` at all — the server sends them as
|
|
`window/logMessage` notifications (`server/client.rs::report_scope`), one per
|
|
sentence, and `schema.fingerprint` never sees them. So a change that reused a
|
|
file's index record instead of parsing it could in principle keep every edit
|
|
and lose a warning, and the existing phases would call that a pass.
|
|
|
|
This phase closes that hole: it issues the renames whose warnings are worth
|
|
comparing, reads every `lucisv: …` line the session logged back off
|
|
`window/logMessage`, and writes the **whole list, verbatim and in order**, into
|
|
the row. Two labels' rows are then compared line by line — no hash, no
|
|
summary, so a reader can see which sentence moved if one ever does.
|
|
|
|
`ms` is still the wire latency and nothing else (schema 2); the warnings are
|
|
the row's `titles`, which is the field schema 2 already keeps a list of
|
|
strings in.
|
|
"""
|
|
|
|
import phases_p2
|
|
from harness import ARGS, at, phase, record, samples, session, settled, sites
|
|
|
|
#: `(row, file, needle, occurrence, offset, new_name, also_open)` — the renames
|
|
#: that produce warnings, plus one that produces none as the control. Taken
|
|
#: from `phases_p2.RENAMES` so the two phases speak about the same requests.
|
|
WARNED = ["tail", "ordinary", "unique internal", "common port", "bind"]
|
|
|
|
|
|
@phase("renamewarn")
|
|
def phase_renamewarn():
|
|
"""Every warning sentence four renames say, verbatim."""
|
|
for row, relative, needle, occurrence, offset, new_name, also in phases_p2.RENAMES:
|
|
if not any(row.startswith(prefix) for prefix in WARNED):
|
|
continue
|
|
warn_row(row, relative, needle, occurrence, offset, new_name, also)
|
|
|
|
|
|
def warn_row(row, relative, needle, occurrence, offset, new_name, also):
|
|
"""One rename, with every sentence it logged written into the row."""
|
|
with session("workspace", storage_name="renamewarn") as s:
|
|
settled(s)
|
|
s.did_open(sites.path(relative))
|
|
if also:
|
|
s.did_open(sites.path(also))
|
|
s.wait_quiet(0.8)
|
|
s.take_notifications()
|
|
s.log_messages = []
|
|
params = dict(at(relative, needle, occurrence, offset), newName=new_name)
|
|
got = samples(s, "textDocument/rename", params, ARGS.tries + 1)
|
|
s.drain()
|
|
warnings = [text for text in s.log_messages if text.startswith("lucisv: ")]
|
|
record(phase="renamewarn", row=row, client=s.client_shape(),
|
|
file=relative, new_name=new_name,
|
|
**dict(got.row(), titles=warnings, result_count=len(warnings)),
|
|
note="every `lucisv: ` window/logMessage the session sent, in "
|
|
"order and repeated once per try; compared line by line "
|
|
"between labels, never hashed")
|