@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

When users click a symbol in Differential to jump to the definition, include path/line context

Summary:
Ref T13047. In some reasonable cases, knowing the path and line number where a symbol appears is useful in ranking or filtering the set of matching symbols.

Giving symbol sources more information can't hurt, and it's generally free for us to include this context since we just need to grab it out of the document and pass it along.

We can't always get this data (for example, if a user types `s idx` into global search, we have no clue) but this is similar to other types of context which are only available sometimes (like which repository a symbol appears in).

Test Plan: Command-clicked some symbols in 1-up (unified) and 2-up (side-by-side) diff views with symbol indexes configured. Got accurate path and line information in the URI I was redirected to.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13047

Differential Revision: https://secure.phabricator.com/D18936

+72 -9
+9 -9
resources/celerity/map.php
··· 13 13 'core.pkg.js' => '4c79d74f', 14 14 'darkconsole.pkg.js' => '1f9a31bc', 15 15 'differential.pkg.css' => '45951e9e', 16 - 'differential.pkg.js' => '500a75c5', 16 + 'differential.pkg.js' => 'c1af2de3', 17 17 'diffusion.pkg.css' => 'a2d17c7d', 18 18 'diffusion.pkg.js' => '6134c5a1', 19 19 'favicon.ico' => '30672e08', ··· 443 443 'rsrc/js/application/releeph/releeph-preview-branch.js' => 'b2b4fbaf', 444 444 'rsrc/js/application/releeph/releeph-request-state-change.js' => 'a0b57eb8', 445 445 'rsrc/js/application/releeph/releeph-request-typeahead.js' => 'de2e896f', 446 - 'rsrc/js/application/repository/repository-crossreference.js' => '7fe9bc12', 446 + 'rsrc/js/application/repository/repository-crossreference.js' => 'c5627622', 447 447 'rsrc/js/application/search/behavior-reorder-profile-menu-items.js' => 'e2e0a072', 448 448 'rsrc/js/application/search/behavior-reorder-queries.js' => 'e9581f08', 449 449 'rsrc/js/application/slowvote/behavior-slowvote-embed.js' => '887ad43f', ··· 692 692 'javelin-behavior-reorder-applications' => '76b9fc3e', 693 693 'javelin-behavior-reorder-columns' => 'e1d25dfb', 694 694 'javelin-behavior-reorder-profile-menu-items' => 'e2e0a072', 695 - 'javelin-behavior-repository-crossreference' => '7fe9bc12', 695 + 'javelin-behavior-repository-crossreference' => 'c5627622', 696 696 'javelin-behavior-scrollbar' => '834a1173', 697 697 'javelin-behavior-search-reorder-queries' => 'e9581f08', 698 698 'javelin-behavior-select-content' => 'bf5374ef', ··· 1555 1555 '7f243deb' => array( 1556 1556 'javelin-install', 1557 1557 ), 1558 - '7fe9bc12' => array( 1559 - 'javelin-behavior', 1560 - 'javelin-dom', 1561 - 'javelin-stratcom', 1562 - 'javelin-uri', 1563 - ), 1564 1558 '834a1173' => array( 1565 1559 'javelin-behavior', 1566 1560 'javelin-scrollbar', ··· 1927 1921 'javelin-behavior-device', 1928 1922 'javelin-stratcom', 1929 1923 'phabricator-tooltip', 1924 + ), 1925 + 'c5627622' => array( 1926 + 'javelin-behavior', 1927 + 'javelin-dom', 1928 + 'javelin-stratcom', 1929 + 'javelin-uri', 1930 1930 ), 1931 1931 'c587b80f' => array( 1932 1932 'javelin-install',
+1
src/applications/differential/view/DifferentialChangesetDetailView.php
··· 204 204 'loaded' => $this->getLoaded(), 205 205 'undoTemplates' => hsprintf('%s', $renderer->renderUndoTemplates()), 206 206 'displayPath' => hsprintf('%s', $display_parts), 207 + 'path' => $display_filename, 207 208 'icon' => $display_icon, 208 209 ), 209 210 'class' => $class,
+62
webroot/rsrc/js/application/repository/repository-crossreference.js
··· 96 96 if (target.hasAttribute('data-symbol-name')) { 97 97 symbol = target.getAttribute('data-symbol-name'); 98 98 } 99 + 100 + var line = getLineNumber(target); 101 + if (line !== null) { 102 + query.line = line; 103 + } 104 + 105 + var path = getPath(target); 106 + if (path !== null) { 107 + query.path = path; 108 + } 109 + 99 110 var uri = JX.$U('/diffusion/symbol/' + symbol + '/'); 100 111 uri.addQueryParams(query); 101 112 window.open(uri); ··· 109 120 link(blocks[i], lang); 110 121 } 111 122 } 123 + } 124 + 125 + function getLineNumber(target) { 126 + 127 + // Figure out the line number by finding the most recent "<th />" in this 128 + // row with a number in it. We may need to skip over one "<th />" if the 129 + // diff is being displayed in unified mode. 130 + 131 + var cell = JX.DOM.findAbove(target, 'td'); 132 + if (!cell) { 133 + return null; 134 + } 135 + 136 + var row = JX.DOM.findAbove(target, 'tr'); 137 + if (!row) { 138 + return null; 139 + } 140 + 141 + var ii; 142 + 143 + var cell_list = []; 144 + for (ii = 0; ii < row.childNodes.length; ii++) { 145 + cell_list.push(row.childNodes[ii]); 146 + } 147 + cell_list.reverse(); 148 + 149 + var found = false; 150 + for (ii = 0; ii < cell_list.length; ii++) { 151 + if (cell_list[ii] === cell) { 152 + found = true; 153 + } 154 + 155 + if (found && JX.DOM.isType(cell_list[ii], 'th')) { 156 + var int_value = parseInt(cell_list[ii].textContent, 10); 157 + if (int_value) { 158 + return int_value; 159 + } 160 + } 161 + } 162 + 163 + return null; 164 + } 165 + 166 + function getPath(target) { 167 + var changeset = JX.DOM.findAbove(target, 'div', 'differential-changeset'); 168 + 169 + if (!changeset) { 170 + return null; 171 + } 172 + 173 + return JX.Stratcom.getData(changeset).path; 112 174 } 113 175 114 176 if (config.container) {