Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 461999

Summary: Warning option for "Unlikely argument type for collection methods using 'Object'" (bug 410218)
Product: [Eclipse Project] JDT Reporter: Stephan Herrmann <stephan.herrmann>
Component: UIAssignee: Till Brychcy <register.eclipse>
Status: VERIFIED FIXED QA Contact: Stephan Herrmann <stephan.herrmann>
Severity: enhancement    
Priority: P3 CC: daniel_megert, jarthana, markus.kell.r, register.eclipse
Version: 4.5   
Target Milestone: 4.7 M6   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/#/c/43884
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=92a55fb8c61c817a37bdd13d873f8eba50e25d7d
https://git.eclipse.org/r/43973
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=cfca412f57f26eae63a2010e2327c439d2554f16
https://git.eclipse.org/r/91578
https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=3f3a03ae74af438b9ef0dbfb539518bf507ce7cc
Whiteboard:
Bug Depends on: 410218    
Bug Blocks: 516946    

Description Stephan Herrmann CLA 2015-03-12 09:01:56 EDT
The new warning being prepared via bug 410218 needs to be configurable in the UI.

Current proposals look like this:

Unlikely argument type for Map.get() et al [Ignore/Warning/Error]
  [X] Accept arguments that could be cast to the expected type
Comment 1 Stephan Herrmann CLA 2015-03-15 13:00:48 EDT
https://git.eclipse.org/r/#/c/43884/ has the fix, but Hudson fails because a relevant change in JDT/Core is still unavailable as a nightly build :(
Comment 2 Stephan Herrmann CLA 2015-03-15 20:13:41 EDT
Released for 4.5 M6
Comment 3 Stephan Herrmann CLA 2015-03-16 17:56:37 EDT
This feature has been withdrawn from Mars.
See bug 410218 comment 31.
Comment 4 Markus Keller CLA 2015-03-16 18:59:11 EDT
Thanks, Stephan.

The "Map.get() et al" part of the compiler option needs to be polished a bit:
- we should avoid latin ("e.g." is already at the limit)
- should try to give a general problem description, not just a single example. E.g.: "Unlikely argument type for collection methods using 'Object'"

In org.eclipse.jdt.internal.ui.preferences.ProblemSeveritiesConfigurationBlock:
- code style: PREF_15_PB_DISCOURAGED_INVOCATION_UNLIKELY_ARGUMENT_TYPE and PREF_15_PB_DISCOURAGED_INVOCATION_ACCEPT_CASTABLE_ARGUMENT should be defined in the order in which they are shown on the preference page
- #getKeys() missed the PREF_15_PB_DISCOURAGED_INVOCATION_ACCEPT_CASTABLE_ARGUMENT

I've added a test for the latter to the OptionsConfigurationBlockTest (which is not run in the build, since we don't want to create test failures every time jdt.core adds a new option): http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=5ac42d5eb45adc17ab1e8ef893cc7501eb224918
Comment 5 Stephan Herrmann CLA 2015-03-16 19:19:02 EDT
(In reply to Markus Keller from comment #4)
> - #getKeys() missed the
> PREF_15_PB_DISCOURAGED_INVOCATION_ACCEPT_CASTABLE_ARGUMENT

For my education, what is the effect of that omission?
I could see that the other key was needed for the "Configure Problem Severity" link, but I saw now reason to add this key.
Comment 6 Markus Keller CLA 2015-03-16 21:08:30 EDT
We assume that a project has project-specific settings for a preference page if at least one of the options is stored in the project.

Since we always store all project-specific settings (even if their value matches the workspace setting), most of the keys are usually not strictly necessary. But if a user releases a .prefs file with just that one option set, then it becomes necessary.
Comment 7 Stephan Herrmann CLA 2016-03-03 13:22:30 EST
See bug 410218 comment 45
Comment 8 Eclipse Genie CLA 2017-02-21 17:14:11 EST
New Gerrit change created: https://git.eclipse.org/r/91578
Comment 9 Till Brychcy CLA 2017-02-21 17:19:26 EST
(In reply to Eclipse Genie from comment #8)
> New Gerrit change created: https://git.eclipse.org/r/91578

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=410218#c49.

@Stephan, I'm not a jdt.ui committer, so I had to set myself as author to push this to gerrit and I've set you to Also-By. I hope that's ok.

Patch set 1 just is the rebased patch,
Patch set 2 is updated.
Comment 11 Stephan Herrmann CLA 2017-03-06 11:31:29 EST
(In reply to Eclipse Genie from comment #10)
> Gerrit change https://git.eclipse.org/r/91578 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/
> ?id=3f3a03ae74af438b9ef0dbfb539518bf507ce7cc

Released for 4.7 M6
Comment 12 Jay Arthanareeswaran CLA 2017-03-08 03:26:10 EST
Verified for 4.7 M6 with build I20170307-2000.