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

Bug 369179

Summary: Improved support for Diagnostic to Issue conversion for code
Product: [Modeling] TMF Reporter: Ed Merks <Ed.Merks>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: jan, sebastian.zarnekow, sven.efftinge
Version: 2.3.0Flags: sebastian.zarnekow: juno+
Target Milestone: M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Ed Merks CLA 2012-01-20 02:33:54 EST
I subclassed the entire DiagnosticConverterImpl.convertValidatorDiagnostic method just to be able to set the Issue's code.  I set it like this:

        issue.setCode(diagnostic.getSource() + "." + diagnostic.getCode());

The combination of diagnostic source and the integer code nicely identifies the issue.  It's nice because then I can define quick fixes like this:

public class XcoreQuickfixProvider extends DefaultQuickfixProvider
{

  @Fix(EcoreValidator.DIAGNOSTIC_SOURCE + '.' + EcoreValidator.CONSISTENT_TYPE_CLASS_NOT_PERMITTED)
  public void convertToReference(final Issue issue, final IssueResolutionAcceptor acceptor) 
  {

See how it's still nicely symbolic and human readable?

It seems there'd be no harm in using this same approach in the base Xtext framework...
Comment 1 Sebastian Zarnekow CLA 2012-04-03 18:23:58 EDT
I don't that we can impose users to define their fixes like this in a backwards compatible manner without querying twice for the pure issue code and for the qualified issue code.

Thus I'm inclined to close this as won't fix. Any opinions?
Comment 2 Ed Merks CLA 2012-04-03 18:40:35 EDT
Can you refactor the code so I can avoid copying the entire convertValidatorDiagnostic method?  

Also, right now you don't set the code at all 

		if (diagnostic instanceof AbstractValidationDiagnostic) {
			AbstractValidationDiagnostic diagnosticImpl = (AbstractValidationDiagnostic) diagnostic;
			issue.setType(diagnosticImpl.getCheckType());
			issue.setCode(diagnosticImpl.getIssueCode());
			issue.setData(diagnosticImpl.getIssueData());
		} else {
			// default to FAST
			issue.setType(CheckType.FAST);
		}

so I'm not sure how setting it in the else case will break clients.  Isn't it the case that without a code you can't even use it?  And if clients have figured out how to use it, they must be setting the code some other way and will be able to continue doing that...
Comment 3 Sven Efftinge CLA 2012-04-04 02:12:23 EDT
Setting the code for non AbstractValidationDiagnostic seems to be ok.
Comment 4 Sebastian Zarnekow CLA 2012-04-04 03:27:24 EDT
(In reply to comment #3)
> Setting the code for non AbstractValidationDiagnostic seems to be ok.

+1

I misunderstood Ed's initial problem description.

Ed, could you please provide a patch?
Comment 5 Ed Merks CLA 2012-04-04 07:34:32 EDT
I ran into problems creating a patch.  I just want to add this one line here:

		} else {
			// default to FAST
			issue.setType(CheckType.FAST);
			issue.setCode(diagnostic.getSource() + "." + diagnostic.getCode());
		}
Comment 6 Jan Koehnlein CLA 2012-04-19 05:48:29 EDT
I pushed the missing line. 

Should we close this ticket now?
Comment 7 Sven Efftinge CLA 2012-04-19 05:51:42 EDT
yes :-)
Comment 8 Eclipse Webmaster CLA 2017-10-31 11:25:48 EDT
Requested via bug 522520.

-M.