Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Duplicate declarations with cross reference
Duplicate declarations with cross reference [message #1008481] Tue, 12 February 2013 16:55 Go to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
The language we used for modeling doesn't have a clear scope concept which makes implementation of scoping very hard in Xtext.

For example, the same variable of "A" is defined two locations in a model, but the usage of the variable A (cross references) can be link to one of the two declarations only during run time. During the editing, it is very hard to tell a usage should be cross referenced to which declaration. Generally all the usages and declarations for the same variable are linked together. I can explain with an example if needed.

An easy way I can think of is to link all the cross references with the two declarations all together. When a refactor is conducted, all the cross references and two declarations are all changed together without distinguish which declarations are used or what scope a cross reference belongs to.

The default cross reference mechanism is different from what I expected. The default cross reference will link some of the usages to one declaration and other usages to the other declaration based on calculations from its internal scheme, which generally is not right according to my code or purpose.

Do you think I can group all the usages and all the declaration for the same variable into one set of cross references without distinguishing the scope of each individual declaration?
Re: Duplicate declarations with cross reference [message #1008580 is a reply to message #1008481] Wed, 13 February 2013 07:44 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 656
Registered: July 2009
Senior Member
As an alterantive, you could try to derive the actual declaration on
demand and use cross references in all other places. We are using this
approach in languages that don't provide an explicit declaration for all
model elements.

I.e., if one of your models refers to a variable, it's looked up in the
scope, and if it doesn't exist yet, its definition is inferred (created)
using the IDerivedStateComputer mechanism. The referring element than
points to this declaration. This way you keep a single definition of
each element and an arbitrary number of cross-references to it.

Am 12.02.13 17:55, schrieb Hao Xie:
> The language we used for modeling doesn't have a clear scope concept
> which makes implementation of scoping very hard in Xtext.
> For example, the same variable of "A" is defined two locations in a
> model, but the usage of the variable A (cross references) can be link to
> one of the two declarations only during run time. During the editing, it
> is very hard to tell a usage should be cross referenced to which
> declaration. Generally all the usages and declarations for the same
> variable are linked together. I can explain with an example if needed.
> An easy way I can think of is to link all the cross references with the
> two declarations all together. When a refactor is conducted, all the
> cross references and two declarations are all changed together without
> distinguish which declarations are used or what scope a cross reference
> belongs to.
>
> The default cross reference mechanism is different from what I expected.
> The default cross reference will link some of the usages to one
> declaration and other usages to the other declaration based on
> calculations from its internal scheme, which generally is not right
> according to my code or purpose.
>
> Do you think I can group all the usages and all the declaration for the
> same variable into one set of cross references without distinguishing
> the scope of each individual declaration?


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Duplicate declarations with cross reference [message #1008900 is a reply to message #1008580] Thu, 14 February 2013 05:05 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
My understanding of your method is: make my actual declaration as a reference of an implicit declaration generated by xtext IDerivedStateComputer.

For example: I have two actual declarations in my program.

Svar A {value 3}
...
...
...
Svar A {value 5}


We are going to let xtext to generate an implicit declaration of

Svar A

Then the two actual declarations above become cross references of the implicit declaration.

If my understanding is right, how should I implement this method. Could you point some details of the implementation. It seems the '[ ]' used in cross reference would not be useful in this new alternative.

Re: Duplicate declarations with cross reference [message #1009354 is a reply to message #1008900] Fri, 15 February 2013 00:45 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
Meanwhile, I research the forum and follow the suggestion on the following post:

http://www.eclipse.org/forums/index.php?t=msg&S=2e4a29d7fff0322e71b35e3a3aa63e3f&th=198813&goto=634090#msg_634090

I overrides getLinkedObjects() in DefaultLinkingService class. However, I don't know how to create dummy variable declarations. I implemented based on my limited knowlege. So I got the following errors:


4789 [Worker-1] ERROR org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy - Reference from platform:/resource/CalLite_FAM/callite/Run/System/Reservoir-table.wresl#//@pattern.140 to gov.ca.dwr.wresl.xtext.editor.ui.link.WreslDeclarationImpl@1dce1ab (name: null) cannot be exported as the target is not contained in a resource.

!ENTRY org.apache.log4j 4 0 2013-02-14 16:43:30.274
!MESSAGE org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy - Reference from platform:/resource/CalLite_FAM/callite/Run/System/Reservoir-table.wresl#//@pattern.140 to gov.ca.dwr.wresl.xtext.editor.ui.link.WreslDeclarationImpl@1dce1ab (name: null) cannot be exported as the target is not contained in a resource.
Re: Duplicate declarations with cross reference [message #1009870 is a reply to message #1009354] Fri, 15 February 2013 22:35 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I followed the examples from the following posts to create implicit EObject by overriding getLinkedObjects in DefaultLinkingService class. Now I am able to add implicit variable declaration to my model and all the variables are referred to these implicit declarations. However, if I click find reference button, nothing come out with no error message.

http://www.eclipse.org/forums/index.php/m/986888/?srch=factory+eobjects#msg_986888
http://www.eclipse.org/forums/index.php?t=msg&S=2e4a29d7fff0322e71b35e3a3aa63e3f&th=198813&goto=634090#msg_634090

If I click rename button, I got the following error:

!STACK 0
java.lang.NullPointerException
at org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler.isRefactoringEnabled(DefaultRenameElementHandler.java:122)
at org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler$1.exec(DefaultRenameElementHandler.java:77)
at org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler$1.exec(DefaultRenameElementHandler.java:1)
at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32)
at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:78)
at org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler.execute(DefaultRenameElementHandler.java:69)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:829)
at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:815)
at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:805)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Re: Duplicate declarations with cross reference [message #1010023 is a reply to message #1009870] Sat, 16 February 2013 09:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6327
Registered: July 2009
Senior Member
Hi,

which Xtext Version do you use.
this you add the created eobject to a resource?
did you try to implement a IDerivedStateComputer as jan suggested

~Christian

[Updated on: Sat, 16 February 2013 09:42]

Report message to a moderator

Re: Duplicate declarations with cross reference [message #1010100 is a reply to message #1010023] Sat, 16 February 2013 14:47 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I used XText 2.4.

I didn't implement IDerivedStateComputer as there is no example online.

I also didn't override getScope in DefaultLinkingService (not sure if that is the reason).

The following code are my overriding of getLinkedObjects in DefaultLinkingService.I am not sure if I need generate resource file on hard disk through FileOutputStream as I did in the code. Also I am not sure if URI should match with the resource file name.

After the failure in "find reference", I am wondering if the method everyone used is to generate some temperory files with undeclared variables declared in the temp files. Then the workspace includes those temp files so that reference link works. But I doubt it.

@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node)
		throws IllegalNodeException {
	List<EObject> list = super.getLinkedObjects(context, ref, node);
	if ( list.isEmpty()) {
		final String crossRefString = getCrossRefNodeAsString(node);
	    	
		URI uri = URI.createURI(crossRefString+".dmy");
		Resource resource = context.eResource().getResourceSet().getResource(uri, false);
		if ( resource ==null){
			resource = context.eResource().getResourceSet().createResource(uri);
		       	WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
		    	Declaration declare = 
	    			(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
			declare.setName(crossRefString);
			resource.getContents().add(declare);

			SerializerOptions op = new SerializerOptions(false, true);
			Map map = new HashMap();
			map.put(XtextResource.OPTION_SERIALIZATION_OPTIONS, op);
			IWorkspace workspace = ResourcesPlugin.getWorkspace();   
			String workspaceDirectory = 
				workspace.getRoot().getLocation().toFile().getAbsolutePath();
			String resourceFolderDir = workspaceDirectory+"\\resource";
			File resourceFolder=new File(resourceFolderDir);
			try {
				if (!resourceFolder.exists()) resourceFolder.mkdir();
				String resourceDirectory=
					resourceFolderDir+"\\resource_"+crossRefString+".txt";
				FileOutputStream output = 
					new FileOutputStream(resourceDirectory);
				resource.save(output, map);
			} catch (Exception e) {
				e.printStackTrace();
			}
			list = Collections.singletonList((EObject)declare); 
		}else{
		        EObject o=resource.getContents().get(0);
		        list = Collections.singletonList(o);
		}        
	}
	return list;
}

[Updated on: Sat, 16 February 2013 14:57]

Report message to a moderator

Re: Duplicate declarations with cross reference [message #1010104 is a reply to message #1010100] Sat, 16 February 2013 15:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6327
Registered: July 2009
Senior Member
HI,

why dont you simply use the contexts eresource?
Re: Duplicate declarations with cross reference [message #1010110 is a reply to message #1010104] Sat, 16 February 2013 15:23 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I did use. You will find it in the above code as:

resource = context.eResource().getResourceSet().createResource(uri);


So what you mean is FileOutPutStream to save the resource on hard disk is not necessary, right?

But I don't know why "find reference" doesn't work, but editor display no error on resolve references to declaration.

[Updated on: Sat, 16 February 2013 15:25]

Report message to a moderator

Re: Duplicate declarations with cross reference [message #1010124 is a reply to message #1010110] Sat, 16 February 2013 16:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6327
Registered: July 2009
Senior Member
No e mean

context.eResource().getContents().add(...)
never the less you should try to implement iderivedstatecomputer.
you may have a look at org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator or https://github.com/merks/Xcore/blob/master/org.eclipse.emf.ecore.xcore/src/org/eclipse/emf/ecore/xcore/resource/LateInferrer.java
Re: Duplicate declarations with cross reference [message #1010265 is a reply to message #1010124] Sun, 17 February 2013 02:00 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.

@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
     List<EObject> list = super.getLinkedObjects(context, ref, node);
     if ( list.isEmpty()) {
          final String crossRefString = getCrossRefNodeAsString(node);

          URI uri = URI.createURI(crossRefString+".dmy");
          ResourceSet resourceSet = context.eResource().getResourceSet();
          Resource resource = resourceSet.getResource(uri, false);
          if ( resource ==null){
               resource = resourceSet.createResource(uri);
               WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
               Declaration declare = 
                     (Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
               declare.setName(crossRefString);
               resource.getContents().add(declare);

               IEObjectDescription eObjectDescription = 
                        EObjectDescription.create(crossRefString, declare);
               list =
                   Collections.singletonList(eObjectDescription.getEObjectOrProxy());
          }else{
               EObject o=resource.getContents().get(0);
               IEObjectDescription eObjectDescription = 
                        EObjectDescription.create(crossRefString, o);
               list =
                   Collections.singletonList(eObjectDescription.getEObjectOrProxy());
          }
     }
     return list;
}


[Updated on: Sun, 17 February 2013 05:31]

Report message to a moderator

Re: Duplicate declarations with cross reference [message #1010313 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.

@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
     List<EObject> list = super.getLinkedObjects(context, ref, node);
     if ( list.isEmpty()) {
          final String crossRefString = getCrossRefNodeAsString(node);

          URI uri = URI.createURI(crossRefString+".dmy");
          ResourceSet resourceSet = context.eResource().getResourceSet();
          Resource resource = resourceSet.getResource(uri, false);
          if ( resource ==null){
               resource = resourceSet.createResource(uri);
               WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
               Declaration declare = 
                     (Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
               declare.setName(crossRefString);
               resource.getContents().add(declare);

               IEObjectDescription eObjectDescription = 
                        EObjectDescription.create(crossRefString, declare);
               list =
                   Collections.singletonList(eObjectDescription.getEObjectOrProxy());
          }else{
               EObject o=resource.getContents().get(0);
               IEObjectDescription eObjectDescription = 
                        EObjectDescription.create(crossRefString, o);
               list =
                   Collections.singletonList(eObjectDescription.getEObjectOrProxy());
          }
     }
     return list;
}

Re: Duplicate declarations with cross reference [message #1010314 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.

@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
     List<EObject> list = super.getLinkedObjects(context, ref, node);
     if ( list.isEmpty()) {
          final String crossRefString = getCrossRefNodeAsString(node);

          URI uri = URI.createURI(crossRefString+".dmy");
          ResourceSet resourceSet = context.eResource().getResourceSet();
          Resource resource = resourceSet.getResource(uri, false);
          if ( resource ==null){
               resource = resourceSet.createResource(uri);
               WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
               Declaration declare = 
                     (Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
               declare.setName(crossRefString);
               resource.getContents().add(declare);

               IEObjectDescription eObjectDescription = 
                        EObjectDescription.create(crossRefString, declare);
               list =
                   Collections.singletonList(eObjectDescription.getEObjectOrProxy());
          }else{
               EObject o=resource.getContents().get(0);
               IEObjectDescription eObjectDescription = 
                        EObjectDescription.create(crossRefString, o);
               list =
                   Collections.singletonList(eObjectDescription.getEObjectOrProxy());
          }
     }
     return list;
}

Re: Duplicate declarations with cross reference [message #1010317 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010318 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010321 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010322 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010325 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010326 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010329 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010330 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010333 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010334 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010337 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010338 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010341 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010342 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010345 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010346 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010350 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010351 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010354 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010355 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010359 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010360 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010363 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010364 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010367 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010368 is a reply to message #1010124] Sun, 17 February 2013 05:27 Go to previous messageGo to next message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Re: Duplicate declarations with cross reference [message #1010371 is a reply to message #1010265] Sun, 17 February 2013 05:26 Go to previous messageGo to previous message
Hao Xie is currently offline Hao Xie
Messages: 68
Registered: January 2013
Member
I think I found the problem of my code, but fail to find the solution. I believe I can make it work with my own LinkService class.

When I use resource = resourceSet.createResource(uri) in my code, a XMIResourceImpl resource is created. However, my program file is LazyLinkingResource resource.

I think the two kinds of resources can't reference each other. I need create LazyLinkingResource with the function of resourceSet.createResource(uri). However, I don't have a solution now.


@Override
public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
List<EObject> list = super.getLinkedObjects(context, ref, node);
if ( list.isEmpty()) {
final String crossRefString = getCrossRefNodeAsString(node);

URI uri = URI.createURI(crossRefString+".dmy");
ResourceSet resourceSet = context.eResource().getResourceSet();
Resource resource = resourceSet.getResource(uri, false);
if ( resource ==null){
resource = resourceSet.createResource(uri);
WreslEditorFactory f = WreslEditorFactoryImpl.eINSTANCE;
Declaration declare =
(Declaration) f.create(WreslEditorPackage.Literals.DECLARATION);
declare.setName(crossRefString);
resource.getContents().add(declare);

IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, declare);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}else{
EObject o=resource.getContents().get(0);
IEObjectDescription eObjectDescription =
EObjectDescription.create(crossRefString, o);
list =
Collections.singletonList(eObjectDescription.getEObjectOrProxy());
}
}
return list;
}
Previous Topic:Customizing Outline View
Next Topic:Running mweWorkflow without eclipse project/classpath (headless gradle build)
Goto Forum:
  


Current Time: Wed Oct 01 00:02:49 GMT 2014

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

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