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

JS code hints aren't picking up new items added to exports #4991

Open
njx opened this issue Aug 29, 2013 · 13 comments
Open

JS code hints aren't picking up new items added to exports #4991

njx opened this issue Aug 29, 2013 · 13 comments

Comments

@njx
Copy link
Contributor

njx commented Aug 29, 2013

  1. Create a new empty project
  2. Create a file called MyModule.js containing:
define(function (require, exports, module) {
    function something() {
    }
});
  1. Create another file called MyCaller.js containing:
define(function (require, exports, module) {
    var MyModule = require("MyModule");
});
  1. In MyCaller, below the var statement, type MyModule. - nothing is hinted (correct)
  2. Switch back to MyModule.js and add exports.something = something below the function
  3. Save MyModule.js
  4. Switch back to MyCaller and bring up code hints after MyModule.

Result: Still no hints. If you reload Brackets, you'll get the proper hint list (something).

@njx
Copy link
Contributor Author

njx commented Aug 29, 2013

It seems like something's broken about how we update hints from other files.

@ghost ghost assigned dangoor Aug 29, 2013
@njx
Copy link
Contributor Author

njx commented Aug 29, 2013

To @dangoor, nominating for sprint 31.

@ghost ghost assigned njx Sep 16, 2013
@njx
Copy link
Contributor Author

njx commented Sep 16, 2013

Reassigning for me to look at for now.

@dangoor
Copy link
Contributor

dangoor commented Sep 18, 2013

I'm going to reclaim this and move it to sprint 32 since we're pencils down on sprint 31.

@dangoor
Copy link
Contributor

dangoor commented Oct 25, 2013

Some notes about this: I cannot reproduce this in the Tern demo, so it would seem that this is related to how we're using Tern.

Watching the behavior of ScopeManager, I can confirm that we're sending Tern an "update file" message for MyModule.js with the correct, updated text. To fix this bug, it looks like I'm going to have to dig a deeper into what's happening inside of Tern.

@dangoor
Copy link
Contributor

dangoor commented Nov 12, 2013

Finally getting back to this one to take a closer look. I think I understand the problem and why it works in the Tern demo but not in Brackets. In Brackets, when we update a file, we send the new text to Tern identifying the file by its full path. When Tern sees require("MyModule"), it asks us for "MyModule.js" and we happily send the file's contents over to Tern. When Tern then does hinting for MyModule, it's using the contents of MyModule.js that we provided when Tern asked for them. It doesn't update the hints when we send along updates for /full/path/to/MyModule.js. (To make things more confusing, we reset the Tern worker periodically... when that happens, the hints will update, so it will appear that the hints update randomly!)

The fix for this would seem to be either:

  1. we stop sending full paths to Tern
  2. a change to the require plugin to ask for the path differently
  3. a change to Tern itself to adjust paths

I don't think the first choice will work because of projects like Brackets itself. The files are all under src/, so we'd still run into the problem where we send Tern a file like src/strings.js and Tern asks for strings.js.

I can't find it now, but I know we ultimately would like to parse require configurations. I don't think we'd have to go that far to fix this, though.

@dangoor
Copy link
Contributor

dangoor commented Nov 12, 2013

Ahh, here's the card for require configuration.

@dangoor
Copy link
Contributor

dangoor commented Nov 12, 2013

I think the right solution here is probably to:

  1. send only project-relative paths to Tern
  2. provide a way to configure Tern's require JS (short of actually stumbling across the script with the require configuration and parsing that)

Strictly speaking, the first one will fix this bug as described. However, for projects like Brackets where the modules are in some directory other than the root, you'd still need the second step to do this right. Since JS Code Hints already has its own preferences code, we don't need to wait on the prefs system to implement that second step.

@dangoor
Copy link
Contributor

dangoor commented Nov 13, 2013

Moving to sprint 35.

@dangoor
Copy link
Contributor

dangoor commented Dec 5, 2013

Doesn't look like I'll get this wrapped up in 35. Moving to 36.

@dangoor dangoor added this to the Brackets 1.0 milestone Mar 17, 2014
@peterflynn
Copy link
Member

Marking needs review to consider 1.0 in/out question after JS code hints architecture research

@peterflynn peterflynn removed this from the Brackets 1.0 milestone Aug 15, 2014
@peterflynn
Copy link
Member

Reviewed -- doesn't seem necessary for 1.0 (CC @dangoor in case you have concerns with removing the milestone)

@dangoor
Copy link
Contributor

dangoor commented Aug 21, 2014

Yeah, I think we can remove this from 1.0. I think we should fix this when we fix code hints preferences

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

4 participants