Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351028 - [Validation] Marker/Annotation creation does not take URI of error source into account
Summary: [Validation] Marker/Annotation creation does not take URI of error source int...
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: M4   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-03 13:46 EDT by Alexander Nittka CLA
Modified: 2017-10-31 11:30 EDT (History)
1 user (show)

See Also:
sven.efftinge: kepler+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.