How can I get the PSI or Virtual File of all go files in my project?

已回答

I'm trying to make a plug-in for goland, which is used to directly search for the corresponding API implementation through the url address. In order to achieve this, I want to get all the PSI files or Virtual File in the project when the project is opened for the first time? Then make the corresponding index for searching? I tried the following FileTypeIndex, but it not only searches the go files in the project directory itself, but also searches the files in the libraries. Is there any way not to search the files in the libraries? I searched as shown below(For the convenience of testing, I did this operation in the action, and the project is obtained from the actionEvent. I think this is not the cause of this problem?):

评论操作 固定链接

Hi,

I think that FileTypeIndex is the right approach. You can narrow the scope by using, e.g., com.intellij.psi.search.GlobalSearchScopes#projectProductionScope() if it matches your use case. If there is no scope you need, you can implement your own or filter the result files after getting them from the FileTypeIndex.

0
评论操作 固定链接

Thanks for your answer, I use projectScope to solve my problem.

0

请先登录再写评论。