Accessing Warnings associated with a DSL element [message #762388] |
Thu, 08 December 2011 01:09 |
Daniel Tuohy Messages: 41 Registered: July 2009 |
Member |
|
|
Hello again!
We would like our subclass of DefaultEObjectLabelProvider to be able to provide icons which have sub-icons indicating if the element has a build error or warning. To do so, we have to determine for each DSL element if it associated with an error/warning.
For ERRORS, there is a convenient solution. One simply has to do the following:
public static boolean hasError(EObject object) {
String uriFragment = object.eResource().getURIFragment(object);
boolean hasError = false;
for(Diagnostic diagnostic : object.eResource().getErrors())
if(diagnostic instanceof AbstractDiagnostic){
String uriFragToProblem = ((AbstractDiagnostic) diagnostic).getUriToProblem().fragment();
if(uriFragToProblem.startsWith(uriFragment))
hasError = true;
}
return hasError;
}
WARNINGS, on the other hand, don't appear to be accessible. I see build warnings in the XTextEditor, but there is no corresponding Diagnostic in either the getErrors() or getWarnings() lists for the Resource.
I know that all annotations (including warnings and errors) are accessible from the AnnotationModel associated with the XTextEditor but (1) we can't always assume the editor is open and (2) it is not obvious how to access the active editor from a non-UI thread. Any ideas on how to get the Warnings from the label provider?
Thanks,
Daniel
|
|
|
Powered by
FUDForum. Page generated in 0.02548 seconds