Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem with XtextLinkingDiagnostic
Problem with XtextLinkingDiagnostic [message #882975] Thu, 07 June 2012 15:09 Go to next message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
Hey,

I would like to perform the generation process without need of starting an Eclipse instance. It just takes to much time and I'm currently working only on the generation process. The process works fine if I just use one Resource for generation.

If I have two Resources that contain references to each other, the validation results in the following error :

XtextLinkingDiagnostic: null:51 Couldn't resolve reference to SubProduct 'productNameXYZ'.

Here is the extracted part of my GenerationClass:

@Inject
private Provider<ResourceSet> resourceSetProvider;

@Inject
private IResourceValidator validator;

@Inject
private IGenerator generator;

@Inject
private JavaIoFileSystemAccess fileAccess;

public static void main(String[] args) {
    if (args.length == 0) {
	System.err.println("Aborting: no path to EMF resource provided!");
	return;
    }
    Injector injector = new org.product.ProductStandaloneSetupGenerated()
				.createInjectorAndDoEMFRegistration();
    ProductGeneratorRunner main = injector
				.getInstance(ProductGeneratorRunner.class);
    main.setOutputPath(ProductBuilder.PFODUCT_GEN_DIRECTORY);
    main.runGenerator(args);
}

public List<Issue> runGenerator(String[] paths) {
	// load the resource
	ResourceSet set = resourceSetProvider.get();

	List<Resource> resources = new ArrayList<Resource>();

	for (String path : paths) {
		Resource resource = set.getResource(URI.createURI(path), true);
		resources.add(resource);
	}

	for (Resource resource : resources) {
		List<Issue> issues = validator.validate(resource, CheckMode.ALL,
				CancelIndicator.NullImpl);
		if (!issues.isEmpty()) {
			for (Issue issue : issues) {
				System.err.println(issue);
			}
			return issues;
		}
		fileAccess.setOutputPath(outputPath);
		generator.doGenerate(resource, fileAccess);
	}

	System.out.println("Code generation finished.");

	return null;
}


Somehow is Xtext aware of the referenced file if I execute the generation process with an Eclipse instance. How can I resolve this issue? Thank you.

Kon
Re: Problem with XtextLinkingDiagnostic [message #883000 is a reply to message #882975] Thu, 07 June 2012 16:02 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i cannot reproduce this problem. please note: in standalone mode you have to add all involved resource to the resourceset.
so are you sure you added the file containing productNameXYZ to the resourceset?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Ecore Modell from extisting Grammar
Next Topic:How to support implicit imports?
Goto Forum:
  


Current Time: Thu Apr 25 01:04:59 GMT 2024

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

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

Back to the top