Page MenuHomePhabricator

Extract scope line selection logic from the diff rendering engine so it can reasonably be iterated on
ClosedPublic

Authored by epriestley on Feb 14 2019, 6:11 PM.
Tags
None
Referenced Files
F14092319: D20171.diff
Mon, Nov 25, 5:32 AM
Unknown Object (File)
Fri, Nov 15, 7:43 AM
Unknown Object (File)
Mon, Nov 11, 1:22 PM
Unknown Object (File)
Wed, Nov 6, 8:25 PM
Unknown Object (File)
Wed, Nov 6, 8:20 PM
Unknown Object (File)
Wed, Nov 6, 6:43 PM
Unknown Object (File)
Tue, Oct 29, 9:52 AM
Unknown Object (File)
Sun, Oct 27, 1:00 PM
Subscribers
None

Details

Summary

Ref T13249. Ref T11738. See PHI985. Currently, we have a crude heuristic for guessing what line in a source file provides the best context.

We get it wrong in a lot of cases, sometimes selecting very silly lines like "{". Although we can't always pick the same line a human would pick, we can pile on heuristics until this is less frequently completely wrong and perhaps eventually get it to work fairly well most of the time.

Pull the logic for this into a separate standalone class and make it testable to prepare for adding heuristics.

Test Plan

Ran unit tests, browsed various files in the web UI and saw as-good-or-better context selection.

Diff Detail

Repository
rP Phabricator
Branch
scope1
Lint
Lint Passed
SeverityLocationCodeMessage
Advicesrc/infrastructure/diff/PhabricatorDiffScopeEngine.php:115XHP16TODO Comment
Unit
Tests Passed
Build Status
Buildable 22000
Build 30052: Run Core Tests
Build 30051: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Feb 19 2019, 6:19 PM

This and two other followups also all have some flavor of "convert tabs to spaces" or vice versa. I suspect we can have fewer copies of this code eventually, but since it's like 10 lines of code I'm not worrying about it too much for now.

This revision was automatically updated to reflect the committed changes.