From 866bfff6ff41a2796329c6bb28db688cbfeed2b8 Mon Sep 17 00:00:00 2001 From: Alexey Kiryushin Date: Fri, 16 Nov 2018 16:19:03 +0300 Subject: Add cross-package 'find references' --- javascript/app/components/haskell-module.js | 7 ++-- javascript/app/components/identifier-name.js | 3 +- javascript/app/controllers/package/show/file.js | 4 +- javascript/app/routes/package.js | 16 +++++++- javascript/app/services/store.js | 15 ++++++- javascript/app/styles/app.scss | 19 +++++++++ .../app/templates/components/paginated-list.hbs | 2 +- javascript/app/templates/package.hbs | 48 +++++++++++++++------- javascript/app/utils/api-urls.js | 3 ++ javascript/app/utils/color-themes.js | 5 ++- 10 files changed, 97 insertions(+), 25 deletions(-) (limited to 'javascript/app') diff --git a/javascript/app/components/haskell-module.js b/javascript/app/components/haskell-module.js index cf750b9..a509c58 100644 --- a/javascript/app/components/haskell-module.js +++ b/javascript/app/components/haskell-module.js @@ -162,10 +162,11 @@ function initializeIdentifiers (sourceCodeContainerElement,component) { event.which, currentLineNumber); } else { - if(identifierInfo.sort === "External") { + if(identifierInfo.sort === "External") { component.get('findReferences')(component.get('packageId'), identifierInfo.externalId, - identifierInfo.demangledOccName); + identifierInfo.demangledOccName, + identifierInfo.locationInfo); } } @@ -400,7 +401,7 @@ function initializeExpressionInfo(sourceCodeContainerElement,component) { } export default Ember.Component.extend({ - store : Ember.inject.service('store'), + store : Ember.inject.service('store'), selectedIdentifier : null, isHoveredOverIdentifier : false, hasSelectedExpression : false, diff --git a/javascript/app/components/identifier-name.js b/javascript/app/components/identifier-name.js index 950b8c7..e0f8c3c 100644 --- a/javascript/app/components/identifier-name.js +++ b/javascript/app/components/identifier-name.js @@ -54,7 +54,8 @@ export default Ember.Component.extend({ findReferences (identifierInfo,currentPackageId) { this.get('findReferences')(currentPackageId, identifierInfo.externalId, - identifierInfo.demangledOccName); + identifierInfo.demangledOccName, + identifierInfo.locationInfo); } } }); diff --git a/javascript/app/controllers/package/show/file.js b/javascript/app/controllers/package/show/file.js index c566e7e..b046bc2 100644 --- a/javascript/app/controllers/package/show/file.js +++ b/javascript/app/controllers/package/show/file.js @@ -2,8 +2,8 @@ import Ember from 'ember'; export default Ember.Controller.extend({ settings : Ember.inject.service('settings'), actions : { - findReferences(packageId,externalId,occName) { - this.send('updateReferences',packageId,externalId,occName); + findReferences(packageId,externalId,occName,locationInfo) { + this.send('updateReferences',packageId,externalId,occName,locationInfo); } } }); diff --git a/javascript/app/routes/package.js b/javascript/app/routes/package.js index 9d6772d..1076779 100644 --- a/javascript/app/routes/package.js +++ b/javascript/app/routes/package.js @@ -24,10 +24,24 @@ export default Ember.Route.extend({ this.set('controller.currentFile',filePath); } }, - updateReferences(packageId,externalId,occName) { + updateReferences(packageId,externalId,occName,locationInfo,noScrollIntoView) { + this.get('store').loadGlobalReferences(externalId).then((refs) => { + Ember.run.next(this,() => { + this.set('controller.globalReferences',refs); + if(!noScrollIntoView) { + Ember.run.schedule('afterRender', () => { + const element = document.getElementById('references-package-'+packageId); + if(element) { + element.scrollIntoView(); + } + }); + } + }); + }); this.set('controller.packageId',packageId); this.set('controller.externalId',externalId); this.set('controller.occName',occName); + this.set('controller.locationInfo',locationInfo); this.set('controller.bottomPanelVisible',true); this.set('controller.referencesUrl',urls.referencesUrl(packageId,externalId)+"?per_page=50"); }, diff --git a/javascript/app/services/store.js b/javascript/app/services/store.js index cf48f9d..8001061 100644 --- a/javascript/app/services/store.js +++ b/javascript/app/services/store.js @@ -52,6 +52,7 @@ export default Ember.Service.extend({ this.modulePaths = {}; this.expressions = {}; this.references = {}; + this.globalReferences = {}; }, loadPackage(packageId) { const packageInfo = this.packages[packageId]; @@ -137,5 +138,17 @@ export default Ember.Service.extend({ linkHeader:linkHeader }; }); - } + }, + loadGlobalReferences(externalId) { + const globalReferences = this.globalReferences[externalId]; + if(globalReferences) { + return new RSVP.Promise((resolve) => {resolve(globalReferences);}); + } else { + const url = urls.globalReferencesUrl(externalId); + return Ember.$.getJSON(url).then((refs) => { + this.globalReferences[externalId] = refs; + return refs; + }); + } + }, }); diff --git a/javascript/app/styles/app.scss b/javascript/app/styles/app.scss index f094187..bca1dce 100644 --- a/javascript/app/styles/app.scss +++ b/javascript/app/styles/app.scss @@ -8,6 +8,10 @@ a, a:visited, a:focus, a:active, a:hover{ outline:0 none; } +a.selected { + text-decoration:underline; +} + input:focus{ outline:none; } @@ -553,3 +557,18 @@ button { .identifier-menu-item { margin-right:10px; } +.references-packages { + position:absolute; + width:230px; + top:0px; + bottom:0px; + overflow:auto; + padding:5px; +} +.references { + position:absolute; + left:230px; + top:0px; + bottom:0px; + right:0px; +} diff --git a/javascript/app/templates/components/paginated-list.hbs b/javascript/app/templates/components/paginated-list.hbs index 2ae9813..82d4eee 100644 --- a/javascript/app/templates/components/paginated-list.hbs +++ b/javascript/app/templates/components/paginated-list.hbs @@ -1,5 +1,5 @@
- Found {{total}} + Found {{total}} {{{foundWhere}}} {{#if (or next prev)}}     diff --git a/javascript/app/templates/package.hbs b/javascript/app/templates/package.hbs index c8ed0dc..8c6d1a4 100644 --- a/javascript/app/templates/package.hbs +++ b/javascript/app/templates/package.hbs @@ -32,26 +32,44 @@ {{/resizable-panel}}
- {{outlet}} + {{outlet}}
{{#bottom-panel visible=bottomPanelVisible topPanelElementId="#file-container" containerElementId="#right-panel" as |section|}} {{#if (eq section "header")}} - References to {{occName}} in {{packageId}} + References to {{occName}} + {{#if locationInfo.packageId}} + (defined in {{locationInfo.packageId.name}}-{{locationInfo.packageId.version}} / {{locationInfo.moduleName}}) + {{/if}} {{else}} - {{#paginated-list url=referencesUrl as |files|}} - - {{/paginated-list}} +
+ {{#if globalReferences}} + + {{#each globalReferences as |ref|}} +
+ + {{ref.packageId}} + ({{ref.count}}) +
+ {{/each}} +
+ {{/if}} +
+
+ {{#paginated-list url=referencesUrl foundWhere=(concat "in " packageId "") as |files|}} + + {{/paginated-list}} +
{{/if}} - {{/bottom-panel}} + {{/bottom-panel}}
diff --git a/javascript/app/utils/api-urls.js b/javascript/app/utils/api-urls.js index b2748b6..2eb2e7c 100644 --- a/javascript/app/utils/api-urls.js +++ b/javascript/app/utils/api-urls.js @@ -25,5 +25,8 @@ export const urls = { }, identifierSearchUrl : function (packageId,query) { return config.APP.apiUrlPrefix + "/identifiers/"+packageId+"/"+encodeURIComponent(query).replace(/\./g, '%2E'); + }, + globalReferencesUrl : function (externalId) { + return config.APP.apiUrlPrefix + "/globalReferences/"+encodeURIComponent(externalId); } } diff --git a/javascript/app/utils/color-themes.js b/javascript/app/utils/color-themes.js index 0a563ff..13b5240 100644 --- a/javascript/app/utils/color-themes.js +++ b/javascript/app/utils/color-themes.js @@ -115,7 +115,10 @@ function colorThemeToCss(colorTheme) { } .type-info { border-top: 1px solid ${colorTheme.borderColor} !important; - }`; + } + .references-packages { + border-right:1px solid ${colorTheme.borderColor} !important; + }`; return css; } -- cgit v1.2.3