Bug 218603 - [api] provide a mapping from problem id to preference key
Summary: [api] provide a mapping from problem id to preference key
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 147029 (view as bug list)
Depends on:
Blocks: 96685
  Show dependency tree
 
Reported: 2008-02-12 04:06 EST by Martin Aeschlimann CLA
Modified: 2011-02-08 09:54 EST (History)
7 users (show)

See Also:
maxime_daniel: review?


Attachments
Draft fix + test case (15.64 KB, patch)
2008-03-11 04:30 EDT, Maxime Daniel CLA
no flags Details | Diff
Complete patch for draft fix plus test case (99.73 KB, patch)
2008-03-11 11:47 EDT, Maxime Daniel CLA
no flags Details | Diff
Patch with new name (102.33 KB, patch)
2008-03-14 05:31 EDT, Maxime Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2008-02-12 04:06:50 EST
20080212

For bug 96685 we would like offer a link from compiler warnings to the corresponding preference setting.

It would be good if jdt.core can offer this option.
But we can also place this mapping in JDT.UI. But I assume some compiler knowledge is required to do it right.

For settings with sub options, this could return multiple settings.
Comment 1 Maxime Daniel CLA 2008-03-11 04:30:27 EDT
Created attachment 92134 [details]
Draft fix + test case

This is a first crack at it. Since the bug only asked for compiler problems, this should be good enough, if only problems which can be flagged as error, warning, or ignore are targeted. Martin, would you please let me know what you think?
Comment 2 Martin Aeschlimann CLA 2008-03-11 05:18:07 EDT
Functionality is good, maybe a better name?

getCorrespondingCompilerOption(int problemId)
Comment 3 Maxime Daniel CLA 2008-03-11 05:44:09 EDT
Well, originally proposed name: getCompilerProblemSeverityTuningOption(int problemID) is admittedly as detailed as it could be, which you may find too much indeed, but I would contend that your proposal is too general, since several options may have a bearing on an error being reported or not (even source level indeed). Hence I'd like the name to be specific.
I'll ask Kent review, which will be an occasion to collect his advice on the name as well, and we'll make a decision when he's shared his thoughts if this is OK with you?
Comment 4 Maxime Daniel CLA 2008-03-11 05:45:08 EDT
Kent, would you please let me know what you think about the patch in general, and the name choice as well?
Comment 5 Benno Baumgartner CLA 2008-03-11 07:56:39 EDT
(In reply to comment #2)
> Functionality is good, maybe a better name?
> 
> getCorrespondingCompilerOption(int problemId)
> 

I like that muuuuuch better.

(In reply to comment #3)
> Well, originally proposed name: getCompilerProblemSeverityTuningOption(int
> problemID) is admittedly as detailed as it could be, which you may find too
> much indeed, but I would contend that your proposal is too general, since
> several options may have a bearing on an error being reported or not (even
> source level indeed). 

Which compiler option id do you return in such a case?
Comment 6 Maxime Daniel CLA 2008-03-11 08:39:18 EDT
It depends. Either there is an option that explicitly manages the severity for the given problem and I return this, or else there is none and I return null.

Some options may eliminate the emission of a warning even if this is not their own purpose. Consider:
  /**
   * @param x
   */
  void foo(X x) {
	
  }
If javadoc is processed (COMPILER_DOC_COMMENT_SUPPORT enabled), then you will get no warning or error about x not being used in method, regardless of the value of COMPILER_PB_UNUSED_PARAMETER, because the @param clause is considered to reference x. But if javadoc is not processed, then option COMPILER_PB_UNUSED_PARAMETER will set the level of the reported warning or error, if any. This is not good enough a reason to return COMPILER_DOC_COMMENT_SUPPORT as an option that you may want to consider when attempting to get rid of the warning, the relationship being somewhat remote.

Another case of interest is that some options refine the behavior, while still depending on the severity setting option (for example, COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE). It might be that the warning at hand could be disposed by tuning COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE only (that is, not changing COMPILER_PB_DEPRECATION at all), but to guess that would need more than the problem ID (the same problem ID is used regardless of the offending code being within deprecated code or not; what the option conditions is the fact that the warning is emitted, or not), it would need some context about the error that we may not have at hand when calling the method added here.

So, for now, my proposition is to focus on the primary options that were explicitly designed to handle the severity of compiler errors.
Comment 7 Kent Johnson CLA 2008-03-11 11:34:59 EDT
How about getConfigurableOptionForProblemSeverity() ?

The patch was cut off & is incomplete.
Comment 8 Maxime Daniel CLA 2008-03-11 11:42:19 EDT
(In reply to comment #7)
> How about getConfigurableOptionForProblemSeverity() ?
My votes would go to this one or to my original proposal. Pls others cast yours.

> The patch was cut off & is incomplete.
Damn GSA! I will attach a complete one asap. This will be the occasion to remove the extraneous 'ONLY_'. 

Comment 9 Maxime Daniel CLA 2008-03-11 11:47:02 EDT
Created attachment 92180 [details]
Complete patch for draft fix plus test case
Comment 10 Martin Aeschlimann CLA 2008-03-12 07:58:50 EDT
Both getCompilerProblemSeverityTuningOption and getConfigurableOptionForProblemSeverity sound complicated and use new terminology ('TuningOption', 'ConfigurableOption')

The existing API for options is getOption(String optionName).
so what about
getOptionName(int problemID)
I would also agree to
getOptionForProblemSeverity(int problemID) 
Comment 11 Maxime Daniel CLA 2008-03-12 09:47:58 EDT
(In reply to comment #10)
> Both getCompilerProblemSeverityTuningOption and
> getConfigurableOptionForProblemSeverity sound complicated
I would have preferred 'sound precise' ;-) Would still be my first and second
choices.
The expected behavior *is* very specific, no wonder it reflects in the name?
> and use new
> terminology ('TuningOption', 'ConfigurableOption')
The terminology is severity tuning or configurable severity indeed. And new terminology is not that surprising when adding new function, is it?
> 
> The existing API for options is getOption(String optionName).
> so what about
> getOptionName(int problemID)
Too general. Introduces the idea that maybe we missed 'Name' in previous propositions... especially since getOption is a shorthand for getOptionValue indeed. Would be my fourth choice.
> I would also agree to
> getOptionForProblemSeverity(int problemID) 
Would be my third choice, kind of way behind the second.

Comment 12 Kent Johnson CLA 2008-03-13 10:40:35 EDT
How about getOptionForConfigurableSeverity(int problemId) ?

We do not want to lose the notion that only problems with a configurable severity are returned.

Please vote on your choice, if you have one.
Comment 13 Maxime Daniel CLA 2008-03-13 10:41:35 EDT
(In reply to comment #12)
> How about getOptionForConfigurableSeverity(int problemId) ?
+1

Comment 14 Martin Aeschlimann CLA 2008-03-13 11:17:57 EDT
> getOptionForConfigurableSeverity(int problemId)
+1
Comment 15 Dani Megert CLA 2008-03-13 11:38:12 EDT
> getOptionForConfigurableSeverity(int problemId)
+1
Comment 16 Philipe Mulet CLA 2008-03-13 12:31:35 EDT
Severity means Ignore/Warning/Error...

I'd rather suggest:
  getOptionForConfigurableProblem(int problemId)
Comment 17 Maxime Daniel CLA 2008-03-14 05:00:30 EDT
(In reply to comment #16)
> Severity means Ignore/Warning/Error...
Yes. The current implementation, that fits Martin's needs according to comment #2, only cares about those.
Comment 18 Maxime Daniel CLA 2008-03-14 05:31:57 EDT
Created attachment 92551 [details]
Patch with new name
Comment 19 Maxime Daniel CLA 2008-03-14 05:34:05 EDT
Released for 3.4 M6.
Comment 20 Markus Keller CLA 2008-03-17 07:56:10 EDT
The Javadoc needs some polish:
- references to problemID and null should be in <code>

-   ... the constants defined by this class which names start with ...
                                           ^ whose
or: ... this class' constants whose names start with ...            (preferred)
or: ... this class' constants the names of which start with ...

- ... a problem which severity ...
                ^ whose severity ...                                (preferred)
            or: ^ the severity of which ...
Comment 21 Maxime Daniel CLA 2008-03-17 10:15:22 EDT
Released polished javadoc (taking option 1 in all cases).
Comment 22 Kent Johnson CLA 2008-03-25 13:08:39 EDT
Verified for 3.4M6 using build I20080324-1300
Comment 23 Markus Keller CLA 2011-02-08 09:54:22 EST
*** Bug 147029 has been marked as a duplicate of this bug. ***