Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Code hints: Support require() calls not in an AMD wrapper #3801

Open
ericelliott opened this issue May 13, 2013 · 8 comments
Open

Code hints: Support require() calls not in an AMD wrapper #3801

ericelliott opened this issue May 13, 2013 · 8 comments

Comments

@ericelliott
Copy link

Using Build 24

Command-E for inline edit sometimes works, but it's very slow. Usually, it just doesn't work at all.

Opening the developer tools doesn't give me any errors. Just a couple warnings about assigning unrelated hotkeys.

@peterflynn
Copy link
Member

@dilvie Is the file containing the definition of the function located within your project tree? Or is it elsewhere?

If it's within the project tree, Brackets should find it. Can you give an example of (a) the code your put your cursor on, and (b) the code for a function definition you expected it to find?

@ghost ghost assigned peterflynn May 14, 2013
@pthiess
Copy link
Contributor

pthiess commented May 14, 2013

Reviewed @peterflynn - need more information to decide on the priority.

@ericelliott
Copy link
Author

It is in the same project tree.

I see this issue intermittently for all functions which have been require()'d from another Node module. I have yet to find one that consistently works.

I have not tried AMD modules, so I don't know about that.

file1.js

module.exports = function () { return 'foo'; };

file2.js

var foo = require('./file1.js');
foo();

Place the cursor on foo(); in file2 and hit Command+E.

Result:

Nothing happens -- OR -- inline edit works very slowly. I have not been able to figure out if there's a deterministic repro case.

@peterflynn
Copy link
Member

@eztierney, any idea about this one? I know we don't grok Node-style require()s (per #3938, Tern's plugin for it isn't used), but I thought we still scan all sibling files regardless.

I can repro this even with a less exotic structure such as:

moduleA.js:

function bar() {
    return 'foo';
}
exports.bar = bar;

main.js: (in same folder)

var foo = require('moduleA.js');
foo.bar();

Even there, Jump to Definition on "bar" doesn't do anything, and Quick Edit falls back to simple string search...

@eztierney
Copy link
Contributor

@peterflynn We do scan all sibling files, but the problem is that we don't understand the call to require.

The requirejs plugin only understands the synchronous call to require when it's inside a simplified CommonJS wrapper. The node plugin referenced in issue #3938 understands that synchronous require calls could be anywhere, which is one reason why we want to turn that on for node files.

@ericelliott
Copy link
Author

Any progress on this issue?

@peterflynn
Copy link
Member

Marking needs review -- closely related to #3938. Whether we move them to the backlog or what, both should probably have the same resolution.

@peterflynn peterflynn changed the title Inline Edit Broken for Node Projects Code hints: Support require() calls not in a CommonJS wrapper Mar 18, 2014
@peterflynn
Copy link
Member

Clarifying title (was: "Inline Edit Broken for Node Projects")

@dangoor dangoor assigned dangoor and unassigned peterflynn Apr 1, 2014
@dangoor dangoor changed the title Code hints: Support require() calls not in a CommonJS wrapper Code hints: Support require() calls not in an AMD wrapper Apr 24, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants