Referenced PsiClass stays as "Class 'ClassName' is never used"

I created an XML configuration file and make an attribute value be referencing to a PsiClass. Here is the XML and JAVA file segment

<settings>
<setting name="configurationFactory" value="custom"/>
</settings>

public class Custom {
}

Currently, I can navigate (reference) from the attribute value 'custom' to class 'Custom' based on my custom PsiReference, and I have implemented a QueryExecutorBase (referencesSearch) to find usage for class 'Custom', and it works well if I use 'Find Usages' functionality. But we I open the class 'Custom' directly, it still says 'Class 'Custom' is never used'.

Can anyone help me, please, thanks

14 comments
Comment actions Permalink

Thank you very very much for your help, I have spent a long time to solve this problem :)

1
Avatar
Alexey Kudravtsev
Comment actions Permalink

why do you have "value="custom" in your XML whereas your class is named "Custom"?

0
Comment actions Permalink

Yeah, the attribute value must follow normal Java variable name capitalization, that's why I need a custom QueryExecutorBase to register with referencesSearch extension

0
Avatar
Alexey Kudravtsev
Comment actions Permalink

It's the first time we stumble on a framework which willingly pushes itself into problems,

because classes in Java are case-sensitive but your framework assumes they are not.

E.g.

value="myClass" // aaaa which class to choose from two candidates?

class MyClass {}

class myClass {}

Why not follow the same capitalization rules in both XML attribute values and Java?

0
Comment actions Permalink

I'm building a plugin for a Java framework and the framework works like this :(

0
Comment actions Permalink

The framework will throw a RuntimeException when names conflict

0
Avatar
Alexey Kudravtsev
Comment actions Permalink

What framework is this?

0
Comment actions Permalink

It's MyBatis

0
Avatar
Alexey Kudravtsev
Comment actions Permalink

I see. Could you please point me to the documentation or an example where this case-insensitivity is allowed? Because I can't find any. Thanks.

0
Comment actions Permalink

It's here http://www.mybatis.org/mybatis-3/configuration.html  -> 

"Each bean found in domain.blog , if no annotation is found, will be registered as an alias using uncapitalized non-qualified class name of the bean. That is domain.blog.Author will be registered as author"

0
Avatar
Alexey Kudravtsev
Comment actions Permalink

Thanks. One option to support this terrible abomination is to register your own implementation of 

com.intellij.codeInsight.daemon.ImplicitUsageProvider

 Override method isImplicitUsage() where for a given class check if there are MyBatis XML configuration files with typealiases defined for this class.

0
Comment actions Permalink

how to you solve the problem? help me

0
Comment actions Permalink

Yeah I saw that. but still now i get the same error..

0

Please sign in to leave a comment.