yomybaby / atom-titanium

[DEPRECATED] Atom package for Titanium Alloy
https://atom.io/packages/titanium-alloy
MIT License
49 stars 11 forks source link

open controller enhancement #5

Closed gimdongwoo closed 9 years ago

gimdongwoo commented 9 years ago

I think this. code for createContoller method, hyperclick to controller.js

example)

Alloy.createController('photoViewer',params);

in this case, link for 'photoViewer' to open 'controllers/photoViewer.js'

yomybaby commented 9 years ago

:+1: Great idea!!! Additionally if the controller file doesn't exist, open confirm dialog which makes new controller.

m1ga commented 9 years ago

feel free to join my ti-create (https://github.com/m1ga/ti-create) package into yours! That would add the create part

yomybaby commented 9 years ago

@m1ga Great!!! Thanks

yomybaby commented 9 years ago

Now, you can add new go to definition pattern easily.

I'll write about how to add that with more detail soon.

See below code https://github.com/yomybaby/atom-titanium/blob/master/lib/clickProvider.js#L54-L67

  js : [
    {
      regExp : /Alloy\.createController\(["']$/,
      targetPath : function(text,sourcePath){
        return sourcePath.replace(/app\/(.*)$/,`app/controllers/${text}.js`)
      }
    },
    {
      regExp : /Alloy\.Collections.instance\(["']$/,
      targetPath : function(text,sourcePath){
        return sourcePath.replace(/app\/(.*)$/,`app/models/${text}.js`)
      }
    }
  ]