Summary: | Detect/Warn on possible user typos | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Genady Beryozkin <eclipse> | ||||
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | enhancement | ||||||
Priority: | P3 | CC: | sja.eclipse | ||||
Version: | 2.0 | ||||||
Target Milestone: | 2.1 M3 | ||||||
Hardware: | All | ||||||
OS: | All | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Genady Beryozkin
2002-10-19 03:47:38 EDT
This sounds similar to the request to notice no-op assignments, arg = arg this.field = field Similar request is bug 18320. Let's put it on the 2.1 plan. If you want to contribute a fix for it, you should look at the AST node: Assignment in its #resolveType method. A bonus check for detecting this scenario would be necessary (looking at the expression binding if it is a NameReference or a field reference with This as a receiver). Once you have some basic check working, we can talk about having an optional setting for controlling its enabling. Do you have any idea about when you could start working on this ? This feature request should indeed solve the problem of no-op assignement, but is a little more general. What I mean by "where do I start" is - where do you perform such checks ? in what package ? pkg: org.eclipse.jdt.internal.compiler.ast type: Assignment method: resolveType I think I can write the code until M4 release. Although the documentation is missing I think it is possible even for non-OTI employee :) Excellent. We indeed did not put too much comment on internal code. Mostly annotations for us later. Please interact with us to get it in time for M4, i.e. we will need to challenge it, have some tests, etc... Also one thing to keep in mind is that the overhead should be almost zero, we don't want to slow down the compiler for checking some optional warning. I will try to complete it in the next two weeks Created attachment 2348 [details]
First proposed patch
Congrats, your first patch looks good. Will integrate it for M4. We should provide an option (all our warnings have an associated option). Also, we cannot print AST nodes in error messages, this could be problematic. We have to isolate names. I'm sorry, what did you mean by the last comment ? In the code reporting an error, it seems your are using #toString on AST nodes, this isn't an official protocol to use for outputting information to users (only for internal debug purpose). Actually more issues, #getBinding will return the first binding for a qualified name reference: e.g. this.y = y.z would think it is a noop I have integrated your changes, with a few modifications as mentionned in previous comments, and added an option for it. Fixed, thanks much. *** Bug 18320 has been marked as a duplicate of this bug. *** Verified. |