I'd like to parse code files (all java for now, but I would not like to restrict it to that) that do not belong to the current project in order to get their PSI tree. I have the file path (or the content of the file if you wish) ready as string, and just want to have it parsed. Motivation: I want to find comments and the code that belongs to them in these files, and would like to use the already existing parser mechanisms to extract the AST and comment strings.
Is there a way to do that? If yes, which classes / APIs do I have to use?