Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Accessing Warnings associated with a DSL element
Accessing Warnings associated with a DSL element [message #762388] Thu, 08 December 2011 01:09
Daniel Tuohy is currently offline Daniel TuohyFriend
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
Previous Topic:reference but in content assist
Next Topic:UML to Ecore
Goto Forum:
  


Current Time: Tue Apr 07 21:21:44 GMT 2020

Powered by FUDForum. Page generated in 0.01779 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top