Komodo Edit autocompletion JS object literal

早过忘川 提交于 2019-12-19 11:16:12

问题


The problem is Komodo intelli-sense doesn't see object methods defined this way:

var App = window.App || {
  method: function() {
    ...
  }
}

Typing "App." gives no result.

However, defining an object like below works fine:

var App = {
   method: function(){
   }
}

How to make autocompletion working at first example pattern?


回答1:


Komodo has a macro API which can automate switching between the two patterns. Use the Add macro context menu option to create a new macro and paste the following code:

komodo.assertMacroVersion(2);
if (komodo.view && komodo.view.scintilla) { komodo.view.scintilla.focus(); } // bug 67103

// define visual mode pattern
var logical_or = RegExp(/\swindow.App\s\|\|/).exec(ko.views.manager.currentView.scimoz.text);

// check for visual mode pattern 
if (logical_or)
  {
  Find_ReplaceAllInMacro(window, 0, '\\s(window.App\\s\\|\\|)', '/*\\1*/', true, 2, 0, false, false);  // replace with intellisense mode pattern
  // show mode in status bar
  ko.statusBar.AddMessage("Intellisense Mode", "imap", 0); 
  }
// check for intellisense mode pattern
else
  {
  Find_ReplaceAllInMacro(window, 0, '/*window.App ||*/', ' window.App ||', true, 0, 0, false, false);
  ko.statusBar.AddMessage("Visual Mode", "vmap", 0);
  }

Click the macro in the toolbox to toggle between intellisense mode and visual mode.

As an alternative, a JSDoc comment may work as well.



来源:https://stackoverflow.com/questions/9392676/komodo-edit-autocompletion-js-object-literal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!