-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[java] Similar/duplicated implementations for determining FQCN #864
Comments
Unifying the implementations looks like the right thing to do. Where possible, we should probably try as well to make it match the JLS about binary names you linked in the linked comment |
Actually, the method should be on Avoiding duplicate code may need some refactoring of |
@jsotuyod That's a great idea. The method |
Remove getQualifiedName's copypasta. Refs pmd#864
Remove getQualifiedName's copypasta. Refs pmd#864
It seems to me, like a big part of the work in ClassTypeResolver is about resolving the qualified name of some things (eg class declaration, imports) and then loading the class. I think we could use the implementation that's in JavaQualifiedName to do just that, thus relieving ClassTypeResolver from that work. There are however some issues with how qualified names are computed for the metrics framework.
We could, in place of on-demand evaluation, use a visitor to populate all declaration nodes with their qualified name. Once we have the qualified name, we normally can have the type quite simply (ask a ClassLoader), which means we could have the visitor populate these types too (or compute them lazily). We could perhaps enable that visitor to populate method declarations nodes with the associated j.lang.reflect.Method, which could allow us to finally write a rule to check for missing Override annotations. We could also leave that to the remaining type resolution step. |
@oowekyala I may be wrong, but I believe the implementation in AFAIK, On the other hand, I think |
@jsotuyod That's true, but I don't think it's limiting. We could limit the visitor's actions to just resolve the qualified names (and types) it can resolve, ie class declarations mostly, including anonymous ones. It would be like a "preprocessing phase" for type resolution, resolving what it can, ie the low hanging fruits of type resolution.
That's also true, but the ability to discern between those would only be relevant to find the Method instance of the method declaration (we'd need it for formal parameters). Class declarations can be resolved anyway. We could also make that preprocessing step resolve the type of things like imports, and explicit things like There are two approaches I think, which differ in the responsibilities of each visitor:
|
As mentioned in this comment we have similar implementations for determining the fully qualified names of classes, especially for anonymous classes and local classes.
We should try to unify the implementations. On first sight, it looks like it should be part of the node (e.g. ClassOrInterfaceDeclaration). Given, that we - thanks to the metrics efforts - have a
getQualifiedName()
method, we probably should reuse this in the SymbolTable and TypeResolution, too.The text was updated successfully, but these errors were encountered: