Path Macros in Facet Configuration

Hi,

In a facet configuration for a plugin, I can define a path to some jar. Normallly this jar is located in some subdirectory of the project or the module the facet belongs to. When working with PersistentStateComponent to persist settings, IDEA seems to use Path Macros automatically. I don't have to cope with them. When IDEA finds a path for which a path macro is defined it is used - collapsed and expanded - automatically.

For facet configurations I seem to be forced to use the old-style readExternal/writeExternal JDOMExternalizable interface and here path macros aren't used automatically.

Can I somehow use PersistentStateComponent for facet configurations? If that is the case, how? How do I need to parametrize the annotation:
@State(
name = "???",
storages = {
@Storage(
id = "???",
file = "???"
)}
)

I have found the interface PathMacroSubstitutor which contains the two methods collapsePaths(Element) and expandPaths(Element). Problem is: The facet configuration doesn't know the module it belongs to. It doesn't seem possible to get it in FacetType.createDefaultConfiguration(). Setting the module or the PathMacroSubstitutor on the configuration in a later step, will probably be too late.

This is still IDEA 7. If this is a bug of IDEA 7 that is fixed in IDEA 8, I'll probably let it be as it is till we port the plugin to IDEA 8, but any hint how to get it working in IDEA 7 will be welcome.

Cheers,
Robert

2 comments
Comment actions Permalink

In IDEA 8 you are able to use new serialization scheme base on PersistentStateComponent. Just implement PersistentStateComponent methods in your facet
configuration class and IDEA will use these methods instead of readExternal/writeExternal. There is no need for @State annotation because
FacetConfiguration is stored in iml-file anyway.

However path macros should work in JDOMExternaliable components as well. Are you sure that you are using forward slashes in your paths?

Hi,

In a facet configuration for a plugin, I can define a path to some jar. Normallly this jar is located in some subdirectory of the project or the module the facet belongs to. When working with PersistentStateComponent to persist settings, IDEA seems to use Path Macros automatically. I don't have to cope with them. When IDEA finds a path for which a path macro is defined it is used - collapsed and expanded - automatically.

For facet configurations I seem to be forced to use the old-style readExternal/writeExternal JDOMExternalizable interface and here path macros aren't used automatically.

Can I somehow use PersistentStateComponent for facet configurations? If that is the case, how? How do I need to parametrize the annotation:
@State(
name = "???",
storages = {
@Storage(
id = "???",
file = "???"
)}
)

I have found the interface PathMacroSubstitutor which contains the two methods collapsePaths(Element) and expandPaths(Element). Problem is: The facet configuration doesn't know the module it belongs to. It doesn't seem possible to get it in FacetType.createDefaultConfiguration(). Setting the module or the PathMacroSubstitutor on the configuration in a later step, will probably be too late.

This is still IDEA 7. If this is a bug of IDEA 7 that is fixed in IDEA 8, I'll probably let it be as it is till we port the plugin to IDEA 8, but any hint how to get it working in IDEA 7 will be welcome.

Cheers,
Robert



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Thanks for the info concerning IDEA 8.

And also thanks for the hint with the forward slashes. The problem really was that the plugin used backslashes on Windows. Replacing them with forward slashes solved the problem.

Cheers,
Robert

0

Please sign in to leave a comment.