I dev a plugin that imported same class of properties, but it throw ClassCastException

I dev a plugin, and import plugin properties's lib (properties.jar) as a dependency. In my codes where used properties.jar's class listed belowe:

codes

            PsiFile[] psiFiles = PsiShortNamesCache.getInstance(myPsiManager.getProject()).getFilesByName("messages_zh_CN.properties");
            if (psiFiles.length > 0) {
                List<IProperty> properties = ((PropertiesFileImpl) psiFiles[0]).getProperties(); // here throw ClassCastException, I debug the line code,the psiFiles[0] is really a PropertiesFileImpl class.
            }


console's errors info:

errors

java.lang.ClassCastException: com.intellij.lang.properties.psi.impl.PropertiesFileImpl
at org.wbase.plugin.i18n.manager.ITipsReferenceManager.findPropertiesFiles(ITipsReferenceManager.java:49)
at org.wbase.plugin.i18n.impl.ITipsReference.getVariants(ITipsReference.java:74)
at com.intellij.codeInsight.completion.CompletionData.completeReference(CompletionData.java:312)




I'm completely lost, can somebody give some hint of why this could be happening?

Thanks in advanced !

2 comments
Comment actions Permalink

Make sure to add dependencies to IDEA plugins to your IDEA JDK, not as "normal" library dependencies of your plugin module

0
Comment actions Permalink

It works by add attr <depends>com.intellij.properties</depends> to pulgin.xml, thx a lot for your post!

0

Please sign in to leave a comment.