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

Bug 351028

Summary: [Validation] Marker/Annotation creation does not take URI of error source into account
Product: [Modeling] TMF Reporter: Alexander Nittka <alex>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow
Version: 2.0.0Flags: sven.efftinge: kepler+
Target Milestone: M4   
Hardware: All   
OS: All   
Whiteboard:

Description Alexander Nittka CLA 2011-07-03 13:46:22 EDT
If you create an error/warning for an object X (error source) not located in the current resource (of the context object O), the marker is created for the resource of O rather than that of X. The node model information of X is used.

Example Grammar:
Model:
	greetings+=Greeting*
	('ref' ref=[Greeting])?;
	
Greeting:
	'Hello' name=ID '!';

Example Validation:
@Check
	public void checkGreetingStartsWithCapital(Model model) {
		if(model.getRef()!=null){
			if (!Character.isUpperCase(model.getRef().getName().charAt(0))) {
				error("Name must start with a capital", model.getRef(),MyDslPackage.Literals.GREETING__NAME,0);
			}
		}
	}

Sample file1:
Hello sven!
Hello Sebastian!

Sample file2:
/*comment*/
ref sven

In this (stupid) example, the reference (file2) checks whether some property of the referenced object is satisfied and tries to mark the error in the target (file1). However, the marker/annotation is created in file2.
It seems that the URI of the error source object is not taken into account.

This issue exists for Xtext 1.x as well.
Comment 1 Sebastian Zarnekow CLA 2011-07-03 13:50:15 EDT
I think we should throw a runtime exception (IllegalArgument) if one tries to create issues for the wrong resource.
Comment 2 Sven Efftinge CLA 2012-11-21 09:59:09 EST
pushed to master
Comment 3 Eclipse Webmaster CLA 2017-10-31 11:30:50 EDT
Requested via bug 522520.

-M.