Extending Properties language


I'm making plugin for our internal framework.
In our framework we use extended properties files - they have a hierarchy(child can have many parents). Of course child inherit all properties from parents.
I need replace meaning(PSI) of some(not all - only in certain scope) ".properties" files - similar like Maven or Ant or Spring plugins doing for their xml configs.
I looked at Maven and Ant plugins, but they use DOM "sugar" extension points provided by the platform.
I make my FileType and Language, but I don't konow how to register language and annotate .properties files with this language only in certain scope.
Standard FileTypeFactory extension point does not suits me, because FileTypeConsumer provides only name of a file, without file path(which I need to distinguish nls files - our custom properties).
I also tried to use LanguageSubstitutor and LanguageProvider extension points - my implementation of first one is not called, and second interface is not used anywhere in IDEA sources.

The best variant for me is to extend Properties language so that nls-files will act as normal properties files, but if I need I'll be able to get
extended PSI(for example to make custom completion contributor). But I don't want to modify Properties plugin sources - I want make plugin on top of Properties plugin.
Can you suggest starting points or examples for this?

Thanks in advance.

Comment actions Permalink

LanguageSubstitutor is the correct API to use for this scenario. How did you register your implementation?

Comment actions Permalink

<extensions defaultExtensionNs="com.intellij">
     <lang.substitutor language="Properties"            implementationClass="ru.crazyproger.plugins.webtoper.nls.PropertiesToNlsSubstitutor"/>

Comment actions Permalink

Thanks Dmitry, but it's really strange - method com.intellij.psi.LanguageSubstitutors#substituteLanguage is called for Properties language,  but my extension not loaded, don't know why.

Comment actions Permalink

I'm really sorry - I found cause of my problems:

2012-11-10 21:05:17,959 [    900]   INFO - llij.ide.plugins.PluginManager - Disabled plugins: Webtoper (0.1)

Plugin was disabled :) - stupid bug.

Comment actions Permalink

Answered, thanks.


Please sign in to leave a comment.