Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cannot reference elements in other files using xtext editor in papyrus
Cannot reference elements in other files using xtext editor in papyrus [message #1037432] Tue, 09 April 2013 10:55 Go to next message
Dennis D. is currently offline Dennis D.
Messages: 23
Registered: April 2013
Junior Member
Hi,

I am working on a proof of concept that integrates several dsls with several modes of editing with/in UML.

I have a very basic DSL where I want to reference elements declared in external files:

Test:
	'ComplexTest' name=ID
;

TestRef:
	'Testref' name=ID 'references' ref=[Test]
;



declarations.mydsl:
ComplexTest basicParamTest


In a second file I reference basicParamTest from the first file.

use.mydsl: (same project/folder as declarations.mydsl)
Testref myref references basicParamTest



This simple example works fine out of the box. Since we are integrating this DSL with papyrus UML modeling, I created a PopupEditor for papyrus that uses the Editor of mydsl:

public class MyEditorConfiguration extends org.eclipse.xtext.gmf.glue.PopupEditorConfiguration implements IPopupEditorConfiguration {
	
	// standard stuff skipped

	@Override
	public IPopupEditorHelper createPopupEditorHelper(Object editPart) {
		System.out.println("createPopupEditorHelper!!!!!");

		IGraphicalEditPart graphicalEditPart = null;
		if(!(editPart instanceof IGraphicalEditPart)) {
			return null;
		}
		graphicalEditPart = (IGraphicalEditPart)editPart;
		if(!(graphicalEditPart.getTopGraphicEditPart().resolveSemanticElement() instanceof Comment)) {
			return null;
		}
		
		content = (Content)graphicalEditPart.getTopGraphicEditPart().resolveSemanticElement();

		Injector injector = org.example.ParameterActivator.getInstance().getInjector("org.example.Parameter"); 

		String textToEdit = "" + this.getTextToEdit(content);
		String fileExtension = "" + ".mydsl";
				
		IXtextEMFReconciler reconciler = new IXtextEMFReconciler() {
			@Override
			public void reconcile(EObject modelObject, EObject xtextObject) {
				// ... apply changes from popup editor ...
			}
			
		};		
		return super.createPopupEditorHelper(graphicalEditPart, injector, reconciler, textToEdit, fileExtension, new DefaultXtextSemanticValidator());
	}

}


It all works fine so far: I can use the popup editor of a uml model (say, 'use.uml') to write stuff in my DSL, embed it in the uml model, and are able to generate code from it. However, as we are following the library idea, we have to reference objects declared in the above mentioned declarations.mydsl from the popup editor when editing use.uml: "Testref myref references basicParamTest". However, the editor cannot resolve the reference to basicParamTest ("Could not resolve reference to basicParamTest"). Using the generated editor of mydsl (opening/editing use.mydsl) it works fine.

I suspect that from within the papyrus editor, the contents of declarations.mydsl are not loaded. I do not have any Idea where to begin in order to track down the problem or direction of solution. Is it about global scoping or resourceServiceProviders or import statements? I read about this but have no Idea how to use that from the papyrus editor.

What am I missing? Any help appreciated.

cheers,
Dennis

Re: Cannot reference elements in other files using xtext editor in papyrus [message #1043075 is a reply to message #1037432] Wed, 17 April 2013 04:33 Go to previous messageGo to next message
Dennis D. is currently offline Dennis D.
Messages: 23
Registered: April 2013
Junior Member
Hi,

I wonder if everyone is using the standard generated editors for xtext. Is my approach wrong to use the popup editor from papyrus? Can anyone confirm my problem with papyrus or other custom editors?

thanks
dennis

Re: Cannot reference elements in other files using xtext editor in papyrus [message #1043078 is a reply to message #1043075] Wed, 17 April 2013 04:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6126
Registered: July 2009
Senior Member
Hi,

how does your IEditedResourceProvider look like?
Re: Cannot reference elements in other files using xtext editor in papyrus [message #1043108 is a reply to message #1043078] Wed, 17 April 2013 05:40 Go to previous messageGo to next message
Dennis D. is currently offline Dennis D.
Messages: 23
Registered: April 2013
Junior Member
Hi Christian,

thanks for your reply. I have not implemented an IEditedResourceProvider. My plugin only consists of the class cited above as it is supposed to integrate in papyrus. Right-clicking on an graphical element, selecting "Edit xy" and my editor, the standard papyrus xtext editor pops up with my dsl. Editing and completion works inside this editor but I cannot use cross references. - see image.

I have no idea where to implement an IEditedResourceProvider or connect it to the papyrus editor.

thanks
dennis

index.php/fa/14395/0/
Re: Cannot reference elements in other files using xtext editor in papyrus [message #1043113 is a reply to message #1043108] Wed, 17 April 2013 05:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6126
Registered: July 2009
Senior Member
Guess you should ask this the papyrus guys

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: Cannot reference elements in other files using xtext editor in papyrus [message #1058998 is a reply to message #1043113] Thu, 16 May 2013 03:39 Go to previous messageGo to next message
Dennis D. is currently offline Dennis D.
Messages: 23
Registered: April 2013
Junior Member
I noticed that when using the importURI statement with e.g. "platform:/resource/tmp/src/somefile.dsl", i can actually reference other models from that imported file. How can I reference files that are in the classpath? I actually do not know in what project somefile.dsl is, but I can assume it is in the classpath.
Re: Cannot reference elements in other files using xtext editor in papyrus [message #1059255 is a reply to message #1058998] Thu, 16 May 2013 12:26 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard Traetteberg
Messages: 594
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 16.05.13 00.39, Dennis D. wrote:
> I noticed that when using the importURI statement with e.g.
> "platform:/resource/tmp/src/somefile.dsl", i can actually reference
> other models from that imported file. How can I reference files that are
> in the classpath? I actually do not know in what project somefile.dsl
> is, but I can assume it is in the classpath.

You either reference the files explicitly, using the importURI
technique, or you use the namespace technique to refer to named (and
exported) objects in (indexed) files that are on the classpath. This
technique relies on:
- Qualified names must be computed for the objects you want to be
visible outside a file.
- You may limit the set of visible objects be explicitly exporting them.
- References must use qualified names, which however may be shortened if
you use imports.

Hallvard
Re: Cannot reference elements in other files using xtext editor in papyrus [message #1384778 is a reply to message #1059255] Sun, 01 June 2014 06:12 Go to previous messageGo to next message
Davincho Huevada is currently offline Davincho Huevada
Messages: 7
Registered: June 2014
Junior Member
Hi,
Although this thread has been inactive for a while, I'll try my luck:
I am currently trying to integrate my Xtext grammar into the Papyrus Popup Editor.
There exists a document (http://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments/How-To/PapyrusDevelopperTutorial_OnXtext_v0%206_d2011-01-10.odt), which explains the necessary steps in detail. Unfortunately it is outdated and I am stuck at the step, where you have to implement your own methods "getTextToEdit" and "createPopupEditorHelper".
Do you have any running examples?
Cheers
Davincho
Re: Cannot reference elements in other files using xtext editor in papyrus [message #1384785 is a reply to message #1384778] Sun, 01 June 2014 12:39 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6126
Registered: July 2009
Senior Member
Hi,

you should ask this there https://www.eclipse.org/forums/index.php/f/121/

Previous Topic:Completion proposal with multiple selected regions
Next Topic:xtext in the web
Goto Forum:
  


Current Time: Wed Jul 23 20:34:19 EDT 2014

Powered by FUDForum. Page generated in 0.01664 seconds