2011-09-06 11:35:14 -07:00
|
|
|
/**
|
|
|
|
|
* @provides javelin-behavior-repository-crossreference
|
|
|
|
|
* @requires javelin-behavior
|
|
|
|
|
* javelin-dom
|
|
|
|
|
* javelin-uri
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
JX.behavior('repository-crossreference', function(config) {
|
|
|
|
|
|
|
|
|
|
// NOTE: Pretty much everything in this file is a worst practice. We're
|
|
|
|
|
// constrained by the markup generated by the syntax highlighters.
|
|
|
|
|
|
|
|
|
|
var container = JX.$(config.container);
|
|
|
|
|
JX.DOM.alterClass(container, 'repository-crossreference', true);
|
|
|
|
|
JX.DOM.listen(
|
|
|
|
|
container,
|
|
|
|
|
'click',
|
|
|
|
|
'tag:span',
|
|
|
|
|
function(e) {
|
|
|
|
|
var target = e.getTarget();
|
|
|
|
|
var map = {nc : 'class', nf : 'function'};
|
|
|
|
|
if (JX.DOM.isNode(target, 'span') && (target.className in map)) {
|
2012-06-13 14:24:25 -07:00
|
|
|
var symbol = target.textContent || target.innerText;
|
|
|
|
|
var uri = JX.$U('/diffusion/symbol/' + symbol + '/');
|
2011-09-06 11:35:14 -07:00
|
|
|
uri.addQueryParams({
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-02 16:02:56 -07:00
|
|
|
type : map[target.className],
|
|
|
|
|
lang : config.lang,
|
|
|
|
|
projects : config.projects.join(','),
|
|
|
|
|
jump : true
|
2011-09-06 11:35:14 -07:00
|
|
|
});
|
|
|
|
|
window.open(uri);
|
|
|
|
|
e.kill();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|