最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - VS code extension for knowing where function is called from - Stack Overflow

programmeradmin3浏览0评论

I want VScode to inform where a defined function is being called from.

file utils.js

function counter(){
 console.log('counter');
}
export default counter;

file index.js:

import counter from './utils';

counter();

I want to know in counter function definition in utils.js that it is being used at index.js

if the function counter is called in different files I want to get the information about where the function is being used | called from.

I want VScode to inform where a defined function is being called from.

file utils.js

function counter(){
 console.log('counter');
}
export default counter;

file index.js:

import counter from './utils';

counter();

I want to know in counter function definition in utils.js that it is being used at index.js

if the function counter is called in different files I want to get the information about where the function is being used | called from.

Share Improve this question edited Oct 4, 2022 at 15:48 Mark 185k30 gold badges542 silver badges552 bronze badges asked Oct 4, 2022 at 5:09 Anish ShresthaAnish Shrestha 632 silver badges8 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

Thanks for the answers. I found that VScode has an inbuilt reference locater. Just right-click the function and select the option find all references, and VScode will locate all the references to that functions Shortcut: Alt + Shift + F12

As stated by @hUwUtao, the callstack has the information about the callers of your counter() function when it is executing. If you want to find references without executing, VS Code can do this by right-clicking the function, then selecting Go to References, as seen in the following screenshot.

Explain: Browser log should show the whole callstack where the error should throw

发布评论

评论列表(0)

  1. 暂无评论