aboutsummaryrefslogtreecommitdiff
path: root/javascript/app/components/type-component.js
blob: c19facc184cf94ef394805c6fc2e8cc054a4d43b (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
import Ember from 'ember';
import {goToDefinition} from '../utils/go-to-definition';

export default Ember.Component.extend({
  store : Ember.inject.service('store'),
  tagName : 'span',
  classNames: ["type-component"],
  contextMenu() {//right mouse button click to show kind of a type constructor or type variable
    if(this.get('identifiers') && this.get('internalId')) {
      this.set('expanded',true);
    }
    return false;
  },
  linkClass : Ember.computed('identifierInfo',function() {
    return this.get('identifierInfo') ? "link" : "";
  }),
  identifierInfo : Ember.computed('internalId',function() {
    return this.get('internalId') ? this.get('identifiers')[this.get('internalId')] : null;
  }),
  actions : {
    onmouseup (event) {
      if(this.get('identifierInfo') && (event.which !== 3 )) {
        const locationInfo = this.get('identifierInfo').locationInfo;
        goToDefinition(this.get('store'),locationInfo,event.which,this.get('currentLineNumber'));
        return false;
      }
    }
  }
});