xtext

How can I add xText editor to Eclipse (e4) RCP Application?

喜欢而已 提交于 2019-12-07 17:16:56
问题 I've already made a xtext editor (2.5). I try to use this editor in a part in my RCP application. I use this code: Injector injector = MyDslActivator.getInstance().getInjector(MyDslActivator.XTEXT_DSL_MYDSL); EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class); editor = factory.newEditor(resourceProvider).showErrorAndWarningAnnotations().withParent(container); But I got an error java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse

Translate ANTLR grammar into XText grammar: how to remove syntactic predicates

风格不统一 提交于 2019-12-07 16:59:19
问题 I'm new to both Xtext and ANTLR. I need to translate an ANTLR (.g) grammar into an XTEXT (.xtext) grammar. In the ANTLR grammar there are syntactic predicates which are not supported by Xtext. Is there a way to remove/translate these predicates? Thanks EDIT The ANTLR grammar which I'm trying to translate can be found here: /* * Copyright 2009, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that

Accessing Xtext's runtime EMF model

假如想象 提交于 2019-12-07 16:05:29
问题 I created a DSL via Xtext and now I need to transform the models created in the editor into another model(s). I suppose the most straightforward way is to employ some kind of M2M transformation framework, but i need to access the model behind the textual file. Question: how can I get a reference to the model? 回答1: The models created by Xtext have also a resource factory created for them. If you try to load the textual file as an EMF model, EMF will look for resource factories available for

XText: use custom terminals definitions

前提是你 提交于 2019-12-07 15:24:31
问题 I'm totally new to XText. When you define a grammar using XText you could specify a second grammar and use the definitions it declares as it is said here: grammar org.eclipse.xtext.example.Domainmodel with org.eclipse.xtext.common.Terminals In Xtext each grammar has a unique name, which like public Java classes needs to reflect the location of the file within the Java classpath. In our case the grammar file is located in /org/eclipse/xtext/example/Domainmodel.xtext therefore the name of the

Xtext Project: Add Jar Libraries with the Project Wizard Manager into the Classpath/Referenced Libaries of the clients Project

你离开我真会死。 提交于 2019-12-06 13:09:38
I have been searching quite a lot for this problem, however I can't really find a proper solution or a how-to manage this one. I have written a simple DSL for generating some code via Xtext and Xtend. I optionally use the project wizard in the UI project of Xtext to be able to create an individual project for my grammar and plugin. I am able to create the project with ease, however I still need to add some important dependencies into my class path of the clients project. It seems to be a bit more tricky especially if the path of the .jar is not absolute. This is probably pretty obvious to

How to use rename refactoring as part of a quickfix?

一笑奈何 提交于 2019-12-06 12:54:49
I've added a quickfix option to my DSL in which I want to make some modifications to the document text - including renaming some element. I can change text in that element just fine, but I want to also rename all of its references - i.e. rename refactoring. How do I do that? Can I somehow trigger the built-in rename refactoring from inside a quickfix? Or alternatively, how do I go over all of the element's references and change them? So, I found a way to programmatically trigger a rename refactor. I don't know if it's the "proper" way - I guess it isn't, since I had to add @SuppressWarnings(

Xtext cross referencing and scoping

血红的双手。 提交于 2019-12-06 09:34:57
I have some problems with xtext cross referencing Here is a very simple grammer: grammar org.xtext.example.mydsl1.Test with org.eclipse.xtext.common.Terminals generate test "http://www.xtext.org/example/mydsl1/Test" Model: block=Block? cs+=Company* ; Block: '{' g=[Employee] '}'; Company: 'Company' name=ID '{' es+= Employee* '}'; Employee: 'Employee' name=ID ';' ; and it is my dsl : { Pooyan } Company Sony{ Employee Pooyan; Employee John; } It always shown that "Couldn't resolve reference to Employee 'Pooyan'." Could anyone please help me? I have no idea... The fully qualified name of Pooyan is

terminal/datatype/parser rules in xtext

你离开我真会死。 提交于 2019-12-06 07:06:59
问题 I'm using xtext 2.4. What I want to do is a SQL-like syntax. The things confuse me are I'm not sure which things should be treated as terminal/datatype/parser rules. So far my grammar related to MyTerm is: Model: (terms += MyTerm ';')* ; MyTerm: constant=MyConstant | variable?='?'| collection_literal=CollectionLiteral ; MyConstant : string=STRING | number=MyNumber | date=MYDATE | uuid=UUID | boolean=MYBOOLEAN | hex=BLOB ; MyNumber: int=SIGNINT | float=SIGNFLOAT ; SIGNINT returns ecore::EInt:

How to write custom autocompletion in Xtext?

我是研究僧i 提交于 2019-12-06 02:33:51
I just can't find anything about this, only sources about writing a custom autocompletion proposal, which is not what I want (or is it)? Syntax We can use the example syntax for this: Model: greetings+=Greeting*; Greeting: 'Hello' name=ID '!'; Problem Now, when the user creates a new instance of the syntax, he has to Write "Hello" (and could complete it) Has to write a space Can now autocomplete the "Name=ID" But this is not what I want. What I want When the user completes "Hello", I want the rest to be filled with a default example, like: "Hello World" Is this possible? Are there some source

XText: use custom terminals definitions

点点圈 提交于 2019-12-06 00:48:15
I'm totally new to XText. When you define a grammar using XText you could specify a second grammar and use the definitions it declares as it is said here : grammar org.eclipse.xtext.example.Domainmodel with org.eclipse.xtext.common.Terminals In Xtext each grammar has a unique name, which like public Java classes needs to reflect the location of the file within the Java classpath. In our case the grammar file is located in /org/eclipse/xtext/example/Domainmodel.xtext therefore the name of the grammar is org.eclipse.xtext.example.Domainmodel. The second part of that statement ( with org.eclipse