I am implementing custom Macro which needs to figure out name of module file physically belongs to.
I am trying to get it inside com.intellij.ide.macro.Macro#expand(com.intellij.openapi.actionSystem.DataContext)
PlatformCoreDataKeys.MODULE.getData(dataContext)
Does not work. It returns module set in run configurations -cp field
Existing macros like FileNameMacro use the virtual file of the context and AFAIK that’s the file of the current editor, if there’s one.
Only run configurations support macros, if I’m not mistaken.
Each run configuration defines the module to pass to macros, see com.intellij.execution.util.ProgramParametersConfigurator#getModule.
The expansion is handled by com.intellij.execution.util.ProgramParametersConfigurator#configureConfiguration and similar methods.
There are run configurations implementations supporting a module context, and others don’t support it.
I don’t think that you can override the module or the file in the context.
I need file from the run configuration. Be it file containing main method, or file containing junit test being run. It does not necessarily need to be in context. Maybe there is some other way to get that file or module name directly?
Is your macro specific to Java run configurations?
Yes, bare minimum is junit. Everything else would be a plus.
Even with Java, there’s not always a file, e.g. when you run tests for a package.
Well package normally is in some module so I was hoping I could get module from package/directory from context/run_configuration somehow…