Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Couldn't resolve reference to *** problem
Couldn't resolve reference to *** problem [message #1771348] Thu, 24 August 2017 06:08 Go to next message
Eclipse UserFriend
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 07:37] by Moderator

Re: Couldn't resolve reference to *** problem [message #1771351 is a reply to message #1771348] Thu, 24 August 2017 06:12 Go to previous messageGo to next message
Eclipse UserFriend
you may not call QualifiedName.create(ide.identifier)
if identifier contains a .

=>

use an Injected IQualifiedNameConverter instead
Re: Couldn't resolve reference to *** problem [message #1771365 is a reply to message #1771351] Thu, 24 August 2017 07:40 Go to previous messageGo to next message
Eclipse UserFriend
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 08:29 Go to previous messageGo to next message
Eclipse UserFriend
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 08:32 Go to previous messageGo to next message
Eclipse UserFriend
id rather use a profiler to see "what" is actually so slow
Re: Couldn't resolve reference to *** problem [message #1771420 is a reply to message #1771376] Thu, 24 August 2017 22:17 Go to previous messageGo to next message
Eclipse UserFriend
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 00:28 Go to previous messageGo to next message
Eclipse UserFriend
do your objects have ids? this is unusual
Re: Couldn't resolve reference to *** problem [message #1771426 is a reply to message #1771423] Fri, 25 August 2017 01:30 Go to previous messageGo to next message
Eclipse UserFriend
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 02:06] by Moderator

Re: Couldn't resolve reference to *** problem [message #1771427 is a reply to message #1771426] Fri, 25 August 2017 01:36 Go to previous messageGo to next message
Eclipse UserFriend
Can you rename this to something else . Xtext ususallly uses name

[Updated on: Fri, 25 August 2017 01:37] by Moderator

Re: Couldn't resolve reference to *** problem [message #1771432 is a reply to message #1771427] Fri, 25 August 2017 01:52 Go to previous messageGo to next message
Eclipse UserFriend
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 01:55 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Couldn't resolve reference to *** problem [message #1771436 is a reply to message #1771433] Fri, 25 August 2017 02:01 Go to previous messageGo to next message
Eclipse UserFriend
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
	}
}
Re: Couldn't resolve reference to *** problem [message #1771438 is a reply to message #1771436] Fri, 25 August 2017 02:03 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 15:13:58 EDT 2025

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

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

Back to the top