aboutsummaryrefslogtreecommitdiff
path: root/javascript/app/components/identifier-name.js
blob: 4b01b0396ac87f2a68853f9b3c8aaad5896994ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import Ember from 'ember';
import {goToDefinition} from '../utils/go-to-definition';

export default Ember.Component.extend({
  store : Ember.inject.service('store'),
  name : Ember.computed('identifierElement',function() {
    const element = this.get('identifierElement');
    if(element) {
      return element.innerText;
    }
  }),
  style : Ember.computed('identifierElement',function() {
    const element = this.get('identifierElement');
    if(element) {
      return new Ember.String.htmlSafe("color:"+element.style.color);
    }
  }),
  locationInfo : Ember.computed('identifierInfo','identifierOccurrence',function() {
    if(this.get('identifierOccurrence.sort.tag') === "ModuleId") {
      return this.get('identifierOccurrence.sort.contents');
    } else {
      return this.get('identifierInfo.locationInfo');
    }
  }),
  location : Ember.computed('locationInfo',function() {
    const loc = this.get('locationInfo');
    if(loc) {
      if(loc.tag === "ExactLocation") {
        return loc.modulePath;
      } else if(loc.tag === "ApproximateLocation") {
        if(loc.entity === "Mod") {
          return loc.packageId.name + "-" + loc.packageId.version;
        } else {
          return loc.packageId.name + "-" + loc.packageId.version + " " + loc.moduleName;
        }
      } else {
        return loc.contents;
      }
    } else {
      return "";
    }
  }),
  isExternalIdentifier : Ember.computed('identifierInfo',function () {
    return (this.get('identifierInfo.sort') === "External");
  }),
  actions : {
    goToDefinition (event) {
      goToDefinition(this.get('store'),
                     this.get('locationInfo'),
                     event.which,
                     this.get('currentLineNumber'));
      return false;
    },
    findReferences (identifierInfo,currentPackageId) {
      this.get('findReferences')(currentPackageId,
                                 identifierInfo.externalId,
                                 identifierInfo.demangledOccName,
                                 identifierInfo.locationInfo);
    }
  }
});