'Is there any way in vscode to know where the current the file has been imported?

Are there any extensions/features in vs-code which could let me know where the current file is imported? I usually do a global search of the filename but it is time consuming when the file name is similar to any variable or there are similar named files.



Solution 1:[1]

You can do a right-click on every function / variable or class. Then you choose "Find all references" to show where each function / variable or class is called. For this you do not need an extension, because it is a standard feature of vscode

Solution 2:[2]

Right-click > Go to References (Shift + F12) There is also an extension to change the appearance of how references show https://marketplace.visualstudio.com/items?itemName=jrieken.references-plusplus

Solution 3:[3]

If you are limiting your search to the current open workspace / folder, you can

  1. do a search for 'import' using the magnifying glass or pressing ctrl+shift+s
  2. open the results in editor by either clicking the link that says 'Open in editor' or by pressing alt+enter
  3. In the document that opens, search for the name of your module.

In this way you will discover all of the imports that involve your module, regardless of whether you have used 'import mymodule' or 'from mymodule import myfunction' or anything else. I'm specifically thinking of how I'd structure a python project, but if you are using another language, you can alter the search in a way that works for the way your language does imports.

Solution 4:[4]

- find unused exports in project:

you can use this extension in vscode to find all unused exports

+ find name references (e.g. used exports) in project:

click on name then press shift+alt+F12

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Interface
Solution 2 Vasil Enchev
Solution 3 Nesha25
Solution 4