vmware-archive / scripted

The Scripted code editor
Eclipse Public License 1.0
1.56k stars 166 forks source link

Support other dependency mechanisms through the plugin API #279

Open chrismarx opened 11 years ago

chrismarx commented 11 years ago

I'm using closure's dependency mechanism, seems like this should be an easy enough candidate for a plugin, so that instead of looking for "requires" it would look for "goog.require", etc.

kdvolder commented 11 years ago

How similar is goog.require to standard AMD require? If it is as simple as just looking for a different name then it would be realtively easy generalize current implementation to recognize goog.require.

But if the algorithms for configuring and resolving differ then it may be more difficult.

Also the dependency resolution is not really plugable at the moment. It is pretty much hard coded to support amd/requirejs and commonjs/node.

Making it plugable would be desirable of course, but probably take quite a bit more engineering/coding work.

chrismarx commented 11 years ago

hmm... well, actually its a bit different, instead of assuming any kind of file structure, closure reads through all the js files in a directory and looks for goog.provide statements (the modules), and assembles a goog/deps.js which has the module name to file location mapping. hmm... well sounds like this won't be possible in the near future. Is there any way to just specify a directory whose contents would just get added to the auto complete, regardless of what file you're working on?

cm325 commented 11 years ago

On the configuration page (https://github.com/scripted-editor/scripted/wiki/Configuration) I see an option for "search" -

search: { exclude: [ '/require.js', '/*.min.js' ],.....

But it's all about excluding or deemphasizing, could this be a location that is used to configure files that should get processed for content-assist?

kdvolder commented 11 years ago

Sorry for not ansering earlier. It's just not an easy question :-)

Unfortunately I don't think its as simple as just computing a list of files to be processed. The harder question is how to process them and how to use the information derived from them. I think that really depends on the mechanics of your particular module system.

Scripted does have some support for 'global' dependencies. I.e. when people just load up files via script tags rather than via require / exports mechanism.

I.e. in one fille you write:

function myGlobalFunction() {... }

Then in another file you write

var result = myGlobalFunction()

If all you wanted is this kind of support, then it may be possible to hack something up that just reads / processes all the other files for global definitions.

Is that what you wanted? Or does the google module system actually have some specific mechanim/syntax for importing / exporting things rather than just use global defines and global variables?

Kris

On Fri, May 24, 2013 at 12:08 PM, chris marx notifications@github.comwrote:

On the configuration page ( https://github.com/scripted-editor/scripted/wiki/Configuration) I see an option for "search" -

search: { exclude: [ '/require.js', '/*.min.js' ],.....

But it's all about excluding or deemphasizing, could this be a location that is used to configure files that should get processed for content-assist?

— Reply to this email directly or view it on GitHubhttps://github.com/scripted-editor/scripted/issues/279#issuecomment-18423975 .