How to include specific PsiFile (c++)

I have two PsiFiles `a`, `b` and now their full paths(or paths from root of a project).
I want to add #include directive to `a`, so that it'll include file `b`. Surely, I can add it as text with full path but It is ugly and may not work on different machine. I wonder if it is way to automatically make them relative?
For example, if they are in same directory it will be `#include "fileB.h"`, if file `b` is in parent folder it could be "../fileB.h", if it's in some includes directory it could be `#include <fileB.h>` etc.

I think it should have been solved for auto-import feature that is available since CLion Public EAP.

How can I do that?

1 comment
Comment actions Permalink

Have you tried com.intellij.openapi.vfs.VfsUtilCore#getRelativePath(com.intellij.openapi.vfs.VirtualFile, com.intellij.openapi.vfs.VirtualFile)?


Please sign in to leave a comment.