【问题标题】:VS code - search for function reference within specific function- macOSVS 代码 - 在特定函数中搜索函数引用 - macOS
【发布时间】:2020-08-27 15:36:20
【问题描述】:
在vs代码中有什么快速搜索的方法吗
在method2中引用了method1?
我正在尝试查看使用 remote-redux-devtools 是否对我的项目有用,我们正在使用 next js,它通过 getInitialProps 进行服务器端调用,所以我试图在 @ 中找到对 dispatch 的所有引用987654323@
我需要更具体的搜索,而不是通过 command + shift + F 单独搜索任一术语(dispatch 或 getInitialProps)。
在这种情况下,我需要在 getInitialProps 中搜索对 dispatch 的引用
【问题讨论】:
标签:
redux
visual-studio-code
next.js
redux-devtools
【解决方案1】:
如果我们可以假设您的 getInitialProps 函数的形式类似于:
static async getInitialProps(ctx) {
const res = await fetch('https://api.github.com/repos/zeit/next.js')
const json = await res.json()
dispatchEvent(event)
return { stars: json.stargazers_count }
}
特别是关于最后一行的return 语句,然后这个正则表达式可以将那些getInitialProps 函数与该函数中某处的序列dispatch 区分开来。
^.*getInitialProps[\s\S]*?\bdispatch[\s\S]*?(return).*\n.*
如果您只想要dispatch 而不是dispatchEvent,则可以在其周围使用字边界,例如\bdispatch\b,除非它用作dispatch(,然后使用\bdispatch( 或类似名称。
见regex101 demo