Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use completion hook to manage node module inside require function. #348

Closed
wants to merge 1 commit into from
Closed

Conversation

angelozerr
Copy link
Contributor

Here a patch which manages completion of node module which uses your "completion" hook.

Ex :

require.(' // here Ctrl+Space shows list of modules

I don't know if it's a clean mean to manage module completion (inside string).

Here some info about this patch :

  1. Fix resolveProjectPath for WebBrowser
function resolveProjectPath(server, pth) {
  var base = server.options.projectDir ? normPath(server.options.projectDir) + "/" : "";
  return resolvePath(base, normPath(pth));
}

I had to modify resolveProjectPath function to support WebBrowser context where server.options.projectDir is null.

  1. moduleCompletion hook

In the moduleCompletion hook, I do callee.name === 'require' to check we are inside a string of require function. I don't know if it's clean mean.

  1. Improvment

When completion is opened, it shows modules and other keyword like setInterval, setTimeout...(which are not modules). It should be cool if we could avoid having those keyword which are not modules.

An idea is that hook function moduleCompletion could returns a boolean which tells "don't show other keywords than modules". What do you think about that?

@@ -82,7 +82,8 @@
function normPath(name) { return name.replace(/\\/g, "/"); }

function resolveProjectPath(server, pth) {
return resolvePath(normPath(server.options.projectDir) + "/", normPath(pth));
var base = server.options.projectDir ? normPath(server.options.projectDir) + "/" : "";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have added the comment in here instead. But will projectDir work correctly when one is provided in the config file? It doesn't seem like it would because the options are in server._node.options

@angelozerr
Copy link
Contributor Author

This issue is done in #430

@angelozerr angelozerr closed this Dec 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants