Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Couldn't resolve reference to *** problem
Couldn't resolve reference to *** problem [message #1771348] Thu, 24 August 2017 10:08 Go to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
Hi

When I create a model using xtext(the DSL grammar is generated by default.)
It always alert the error about "Couldn't resolve reference to *** problem"


The Reference name as "sample.cps.host.FirstHostClass0".

index.php/fa/30485/0/

I only change the NameProvider in Xtext, because I want us the name as the ID. But if do not have this kind of change, the model part also alert this problem.

Dose anyone can help me to fix it?
I update the meta-model and model under the attachment.

Thanks Very Much

[Updated on: Thu, 24 August 2017 11:37]

Report message to a moderator

Re: Couldn't resolve reference to *** problem [message #1771351 is a reply to message #1771348] Thu, 24 August 2017 10:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
you may not call QualifiedName.create(ide.identifier)
if identifier contains a .

=>

use an Injected IQualifiedNameConverter instead


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to *** problem [message #1771365 is a reply to message #1771351] Thu, 24 August 2017 11:40 Go to previous messageGo to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
Great~! It works! Thanks for you quick replay. Christian.

And I think I need deeply study Xtext help document.

Thanks again.
Re: Couldn't resolve reference to *** problem [message #1771375 is a reply to message #1771351] Thu, 24 August 2017 12:29 Go to previous messageGo to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
Hi Christian,

I also have a question. If I open a big size of textual model (3-4MB), Open the Xtext editor is very slow.

But in XMIResource, the have a option ,'OPTION_DEFER_IDREF_RESOLUTION ', to 'Defer resolution of same document references until the end of the document is reached'.

How the Xtext to handle the big size model?
Re: Couldn't resolve reference to *** problem [message #1771376 is a reply to message #1771375] Thu, 24 August 2017 12:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
id rather use a profiler to see "what" is actually so slow

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to *** problem [message #1771420 is a reply to message #1771376] Fri, 25 August 2017 02:17 Go to previous messageGo to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
Yes, I will.

After I use Java VisualVM to monitor the Eclipse platform, when open a big size xtext file using xtext editor.

I find that the org.eclipse.emf.ecore.util.EcoreUtil$ProperContentIterator.hasNext() take a long time. And it is called by xtext.validate .

index.php/fa/30504/0/

index.php/fa/30505/0/

So how we can handle this problem?
Do we have a way, only trigger the Xtext validation at the saving time.
Re: Couldn't resolve reference to *** problem [message #1771423 is a reply to message #1771420] Fri, 25 August 2017 04:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
do your objects have ids? this is unusual

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to *** problem [message #1771426 is a reply to message #1771423] Fri, 25 August 2017 05:30 Go to previous messageGo to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
Yes, each of the element has a name, use it as ID to identity each other.
I attach the newest meta-model & model instance.

[Updated on: Fri, 25 August 2017 06:06]

Report message to a moderator

Re: Couldn't resolve reference to *** problem [message #1771427 is a reply to message #1771426] Fri, 25 August 2017 05:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Can you rename this to something else . Xtext ususallly uses name

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 25 August 2017 05:37]

Report message to a moderator

Re: Couldn't resolve reference to *** problem [message #1771432 is a reply to message #1771427] Fri, 25 August 2017 05:52 Go to previous messageGo to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
Sorry for my unclear description.

In this meta-model, it use the attribute 'identifier=EString' as the ID. Not the 'name'.

Like:
CyberPhysicalSystem returns CyberPhysicalSystem:
{CyberPhysicalSystem}
'CyberPhysicalSystem'
identifier=EString
'{'
('dbUrl' dbUrl=EString)?
('appTypes' '{' appTypes+=ApplicationType ( "," appTypes+=ApplicationType)* '}' )?
('requests' '{' requests+=Request ( "," requests+=Request)* '}' )?
('hostTypes' '{' hostTypes+=HostType ( "," hostTypes+=HostType)* '}' )?
'}';
Re: Couldn't resolve reference to *** problem [message #1771433 is a reply to message #1771432] Fri, 25 August 2017 05:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
argggg we are talking not about the same thing.
ususally validate_UniqueID
does nothing since EcoreUtil.getID(eObject); returns null.
why does it find an id in your case.
please debug.
that validate method is a default emf method and its impl might have a bad o(n2) implementation


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to *** problem [message #1771436 is a reply to message #1771433] Fri, 25 August 2017 06:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
otherwise you might have to bind a custom validator that overrides the bevaviour and does not do this validation

public class CompositeEValidator2 extends CompositeEValidator {
	@Override
	protected void initDefaults() {
		if (isUseEObjectValidator()) {
			this.addValidator(new EObjectValidator() {
				@Override
				public boolean validate_UniqueID(EObject eObject, DiagnosticChain diagnostics,
						Map<Object, Object> context) {
					// don't check
					return true;
				}
				@Override
				public boolean validate_EveryProxyResolves(EObject eObject, DiagnosticChain diagnostics,
						Map<Object, Object> context) {
					// don't check, we have our own implementation, which creates nicer messages
					return true;
				}
				
				@Override
				public boolean validate_NoCircularContainment(EObject eObject, DiagnosticChain diagnostics,
						Map<Object, Object> context) {
					// don't check
					return true;
				}
			});
		}
	}
}


class MyDslRuntimeModule extends AbstractMyDslRuntimeModule {

	def Class<? extends CompositeEValidator> bindCompositeEValidator() {
		return CompositeEValidator2
	}
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to *** problem [message #1771438 is a reply to message #1771436] Fri, 25 August 2017 06:03 Go to previous message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
OK, Thanks for your quick reply.
I will debug and try it.

Thanks very much.

Christian
Previous Topic:"Xtext validation" task causing Eclipse to collapse
Next Topic:[SOLVED] Simple "assert" support
Goto Forum:
  


Current Time: Tue Mar 19 08:18:16 GMT 2024

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

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

Back to the top