Bug 375802 - Linker doesn't respect ILinkingDiagnosticMessageProvider API
Summary: Linker doesn't respect ILinkingDiagnosticMessageProvider API
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2012-04-01 15:03 EDT by Vlad Dumitrescu CLA
Modified: 2016-09-09 06:00 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vlad Dumitrescu CLA 2012-04-01 15:03:42 EDT
Build Identifier: 2.3.0.v201203201034

ILinkingDiagnosticMessageProvider.getUnresolvedProxyMessage may return null if it is ok to have an unresolved reference.

When using Linker (as opposed to LazyLinker), the returned value is used as 
	producer.addDiagnostic(message);
where the producer expects a non-null message, causing an error further on.

So either Linker should check the value, or the IDiagnosticProducer should accept nulls.


 

Reproducible: Always

Steps to Reproduce:
1. Start with the arithmetics examples

2. Bind these in the guice module:

	@Override
	public Class<? extends ILinker> bindILinker() {
		return DemoLinker.class;
	}

	public Class<? extends ILinkingDiagnosticMessageProvider.Extended> bindILinkingDiagnosticMessageProvider() {
		return DemoLinkingDiagnosticMessageProvider.class;
	}

3. Define

public class DemoLinker extends Linker {
}

and 

public class DemoLinkingDiagnosticMessageProvider extends
		LinkingDiagnosticMessageProvider {
	@Override
	public DiagnosticMessage getUnresolvedProxyMessage(
			ILinkingDiagnosticContext context) {
		return null; 
	}
}

4. Build and run and create a .calc file with an unresolved reference

module v
def x: zzz+3;

5. There will be a NPE causing trouble
Comment 1 Christian Dietrich CLA 2016-08-10 05:49:21 EDT
this is still valid. i guess the preferred way to implement this is 

org.eclipse.xtext.linking.impl.Linker.isNullValidResult(EObject, EReference, INode)

so we should change the javadoc right?
Comment 2 Christian Dietrich CLA 2016-08-30 11:59:22 EDT
seems lazy linker and linker behave differently here