|
|
|
Re: Check for syntax errors before formatting. [message #832000 is a reply to message #807980] |
Thu, 29 March 2012 16:15 |
kon f Messages: 152 Registered: March 2012 |
Senior Member |
|
|
Hey,
thank you John for the hint. Here is my code I used to override the behaviour of IContentFormatterFactory:
public class MyDQLContentFormatterFactory extends ContentFormatterFactory {
@Inject
private XtextResource resource;
public class MyDSLContentFormatter implements IContentFormatter {
public void format(IDocument document, IRegion region) {
// if formatting is performed with errors, the code will be destroyed
if (!resource.getErrors().isEmpty()) {
return;
}
new ContentFormatter().format(document, region);
}
public IFormattingStrategy getFormattingStrategy(String contentType) {
return null;
}
}
@Override
public IContentFormatter createConfiguredFormatter(SourceViewerConfiguration configuration, ISourceViewer sourceViewer) {
return new MyDSLContentFormatter();
}
}
as well as the method in MyDSLUiModule:
@Override
public Class<? extends IContentFormatterFactory> bindIContentFormatterFactory() {
return MyDQLContentFormatterFactory.class;
}
It is pretty strange since resource.getErrors().isEmpty() always returns true, even the Eclipse Error View says that MyDQL language contains errors.
Why do I always get an empty error list? Am I doing something wrong? Thank you!
Kon
[Updated on: Thu, 19 April 2012 20:59] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03434 seconds