Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
This repository was 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

Description

@njx
  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).

Activity

  1. njx commented on Aug 29, 2013

    @njx
    Author

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

  2. ghost assigned on Aug 29, 2013
  3. njx commented on Aug 29, 2013

    @njx
    Author

    To @dangoor, nominating for sprint 31.

  4. ghost assigned on Sep 16, 2013
  5. njx commented on Sep 16, 2013

    @njx
    Author

    Reassigning for me to look at for now.

  6. dangoor commented on Sep 18, 2013

    @dangoor
    Contributor

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

  7. ghost assigned on Sep 18, 2013
  8. dangoor commented on Oct 25, 2013

    @dangoor
    Contributor

    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.

  9. dangoor commented on Nov 12, 2013

    @dangoor
    Contributor

    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.

  10. dangoor commented on Nov 12, 2013

    @dangoor
    Contributor
  11. dangoor commented on Nov 12, 2013

    @dangoor
    Contributor

    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.

  12. dangoor commented on Nov 13, 2013

    @dangoor
    Contributor

    Moving to sprint 35.

  13. dangoor commented on Dec 5, 2013

    @dangoor
    Contributor

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

  14. added this to the milestone on Mar 17, 2014
  15. peterflynn commented on Apr 11, 2014

    @peterflynn
    Member

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

  16. removed this from the milestone on Aug 15, 2014
  17. peterflynn commented on Aug 15, 2014

    @peterflynn
    Member

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

  18. dangoor commented on Aug 21, 2014

    @dangoor
    Contributor

    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions