|
|
|
|
|
|
|
Re: quickfix for referenced object not found [message #1733751 is a reply to message #1733742] |
Tue, 31 May 2016 08:13  |
Eclipse User |
|
|
|
Thankx, I solved the issue.
You need to inherit from org.eclipse.xtext.linking.impl.LinkingDiagnosticMessageProvider and check for the parent object in org.eclipse.xtext.linking.impl.LinkingDiagnosticMessageProvider.getUnresolvedProxyMessage() and then check the reference with org.eclipse.xtext.linking.ILinkingDiagnosticMessageProvider.ILinkingDiagnosticContext.getReference()
The result is:
@Override
public DiagnosticMessage getUnresolvedProxyMessage(final ILinkingDiagnosticContext context) {
DiagnosticMessage diagnosticMessage = new YourModelSwitch<DiagnosticMessage>() {
@Override
public DiagnosticMessage caseYourParentObject(YourParentObject parent) {
if (context.getReference().equals(YourModelPackage.Literals.YOUR_PARENT_OBJECT__YOUR_REFERENCE)) {
return new DiagnosticMessage(context.getLinkText() + " cannot be resolved to a YourReferencedObject",
Severity.ERROR, YOUR_QUICK_FIX_CODE) context.getLinkText());
}
return null;
}
}.doSwitch(context.getContext());
return diagnosticMessage != null ? diagnosticMessage : super.getUnresolvedProxyMessage(context);
}
to activate this solution you need to register your ddd in the YourModelRuntimeModule:
public Class<? extends LinkingDiagnosticMessageProvider> bindLinkingDiagnosticMessageProvider() {
return YourModelLinkingDiagnosticMessageProvider.class;
}
The corresponding QuickFix goes to the usual location.
|
|
|
Powered by
FUDForum. Page generated in 0.04960 seconds