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

“Find All References” across files for a method/function in javascript #21507

Closed
MankalMR opened this issue Feb 27, 2017 · 17 comments · Fixed by microsoft/TypeScript#28221
Closed
Assignees
Labels
feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues

Comments

@MankalMR
Copy link

MankalMR commented Feb 27, 2017

  • VSCode Version:1.9.1
  • OS Version:OSX

Steps to Reproduce:

1.Select a method in javascript
2.Right click on Find all References

Expected Result: Find all references across files in a project
Actual Result: finds references in the current file.

Note: The project i'm working on uses requirejs to load and utilize module dependencies.

@mjbvz mjbvz self-assigned this Feb 27, 2017
@mjbvz mjbvz added javascript JavaScript support issues typescript Typescript support issues labels Feb 27, 2017
@MystK
Copy link

MystK commented Mar 8, 2017

I think related to #20924

@MankalMR
Copy link
Author

MankalMR commented Mar 8, 2017

I just looked at the thread. That does not have a resolution either? Any idea if this is being looked up on priority?

@mjbvz mjbvz added the feature-request Request for new features or functionality label Apr 21, 2017
@njgraf512
Copy link

njgraf512 commented Jun 12, 2017

Any update on this? Maybe I have something set incorrectly, but I have jsx files with extensions filename.react.js. I want to be able find all references of an exported function, react component class, etc., but I get no results when attempting this. Any suggestions?

@ghost
Copy link

ghost commented Jul 27, 2017

The original issue is certainly microsoft/TypeScript#6942; TypeScript doesn't resolve AMD-style imports.

@Hoishin
Copy link

Hoishin commented Feb 27, 2018

Is it intended that CommonJS module references don't get shown in Find All References too? I have jsconfig.json in the root but it doesn't work.

@ghost
Copy link

ghost commented Feb 27, 2018

@Hoishin Could you provide a repro?

@Hoishin
Copy link

Hoishin commented Feb 27, 2018

@andy-ms

EDIT: actually, as you can see, extensions were not disabled, but it was the same as below if I disable all extensions and all settings

Yes!

env:

  • Version 1.20.1 (1.20.1)
  • no extension enabled
  • config
{
  "editor.renderWhitespace": "all",
  "editor.rulers": [
    80,
    100
  ],
  "explorer.confirmDragAndDrop": false,
  "files.autoSave": "onFocusChange",
  "files.insertFinalNewline": true,
  "instantmarkdown.autoOpenBrowser": false,
  "sync.anonymousGist": false,
  "sync.askGistName": false,
  "sync.autoDownload": true,
  "sync.autoUpload": true,
  "sync.gist": "<removed but has gist id>",
  "sync.lastDownload": "2018-02-27T17:47:11.358Z",
  "sync.lastUpload": "2018-02-27T18:30:16.262Z",
  "sync.forceDownload": false,
  "sync.host": "",
  "sync.pathPrefix": "",
  "sync.quietSync": false,
  "workbench.colorTheme": "Dracula",
  "workbench.iconTheme": "material-icon-theme",
  "workbench.startupEditor": "none",
  "editor.quickSuggestions": {
    "other": true,
    "comments": true,
    "strings": true
  },
  "window.zoomLevel": 0,
  "markdown.extension.preview.autoShowPreviewToSide": true
}

procedure:

  1. module.export = something
  2. require() it in different file
  3. select Find All References on module.exports
  4. says "no result"

code-bug

@ghost
Copy link

ghost commented Feb 27, 2018

@Hoishin In that case the export has no name so we don't have references for it. If you write module.exports = function f() {} we can find references for f. We could add some special-casing to support module.exports though. microsoft/TypeScript#22205

@Hoishin
Copy link

Hoishin commented Feb 27, 2018

@andy-ms Ah, I see. You have to have name it and/or assign to variable, and find reference from those instead of module.exports.
It'd be nice to be able to list references from module.exports indeed. Looking forward to the feature if possible.

@Hoishin
Copy link

Hoishin commented Feb 27, 2018

@andy-ms Also, it might be unrelated, but it would be nice if I can also see require('...') itself when it is used directly as function or something. For example

server.plugin = {
  plugin: require('awsome-plugin'),
  options: require('./config/awesome-plugin'), // shown in find-all-references in awsome-plugin.js
};

Might be too much of asking though...

@Hoishin
Copy link

Hoishin commented Feb 28, 2018

@andy-ms I've been playing with Reference All References today. I found that the way you export affect Find All References, outside of what I have mentioned so far.

const something = 1234;
module.exports = {something}; // doesn't work
module.exports = {something: something}; // doesn't work
module.exports.something = something; // works

These are kind of reasonable from what you have said, since in the first two situations, the actual exported objects are not named, while the third one exports the named object directly.
Sorry if you are already aware of this, but just thought of sharing because why not :)

@mjbvz
Copy link
Contributor

mjbvz commented Sep 17, 2018

Closing this generic issue in favor of tracking individual case that are causing problems. Since Find All References not working has many possible causes, tracking individual issues will let us understand the problems people are hitting in real world code and hopefully get those cases addressed.

Please open a new issue with some example code or small example project if you see Find All References not working as expected

@mjbvz mjbvz closed this as completed Sep 17, 2018
@AlJohri
Copy link

AlJohri commented Oct 9, 2018

I also found that module.exports = {something}; isn't able to Find All References for me.

If I try to "Find All References" on the exported object it worked- if I do it earlier in the file, it doesn't.

@stephengardner
Copy link

I'm struggling with this as well.

Attempting to find usages of a file.
I wasn't the original creator of the code, but the file has: export default {}; and is imported due to other functionality within the file.

I need to find other files that import this file.

@ghost
Copy link

ghost commented Oct 18, 2018

@stephengardner You should be able to run find-all-references on the default keyword.

@garyking
Copy link

@andy-ms Similar to export default () => {}, is it possible to use Find all references for module.exports = () => {}? I tried selecting all parts of the exported function, but was unable to produce any results.

@ghost
Copy link

ghost commented Oct 29, 2018

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality javascript JavaScript support issues typescript Typescript support issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants