Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext 2.0] Model editor problem after migrating to 2.0 with imports(After migrating to Xtext 2.0 the model editor is not able to handle imports)
[Xtext 2.0] Model editor problem after migrating to 2.0 with imports [message #693956] Thu, 07 July 2011 14:33 Go to next message
Martin Kuhn is currently offline Martin Kuhn
Messages: 49
Registered: July 2009
Member
Hi,

I have a model editor problem after converting an existing project from Xtext 1.0.x to 2.0.

The migration process was to define completley new Xtext 2.0 projects (with exactly same naming as the "old" ones). Then I copied my DSL def (xtext file) and so on to the new projects.

At first I thought everything is o.k. -> I was able to generate as before.

But then I realized that UI functionality is not o.k. -> In my model editor I get errors in importing models from other files (Couldn't resolve reference to...)

Can anybody of you give me a hint whats wrong???

TIA

Martin

Here is part of my grammar def:


	

grammar at.abc.ea.eadsl.EaDsl with org.eclipse.xtext.common.Terminals

generate eaDsl "http://www.abc.at/ea/eadsl/EaDsl"

Model returns Namespace:
	(imports+=Import)*
	(elements+=ModelElement)*;

ModelElement:
	Namespace | Type;

Namespace:
	'namespace' name=FQN '{'
		(imports+=Import)*
		(elements+=ModelElement)*
	'}';

FQN:
	ID ('.' ID)*;

Import:
	'import' importedNamespace=ImportedFQN;

ImportedFQN:
	FQN ('.' '*')?;

DataType :
  'type' name=ID;

DataTypeRef: referenced=[DataType];

Type:
	DataType | Entity | Dto | Service | Presenter;

Entity:
	'entity' name=ID (needsProcessor?='needsProcessor')?   ('ref' ':' masterReference=[Entity])?  '{'
		(features+=EntityFeature)*
	'}';

...


Here are sample model files:

datatype.eadsl:
---------------
type string
type boolean
type date

Daten.eadsl:
-----------
import datatype.eadsl
namespace Daten {
	entity Person {
		attr name:string
	}
}


SpecialDaten.eadsl:
------------------
import datatype.eadsl

import Daten.*

namespace SDaten {
	entity SPerson ref: Person {
		attr berechtigung:string
		...
	}
}




Re: [Xtext 2.0] Model editor problem after migrating to 2.0 with imports [message #693959 is a reply to message #693956] Thu, 07 July 2011 14:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6385
Registered: July 2009
Senior Member
Hi,

how does your workflow look like? please make sure that you deactivate e.g. the types.TypesGeneratorFragment {}

~Christian
Re: [Xtext 2.0] Model editor problem after migrating to 2.0 with imports [message #694200 is a reply to message #693959] Fri, 08 July 2011 05:19 Go to previous messageGo to next message
Martin Kuhn is currently offline Martin Kuhn
Messages: 49
Registered: July 2009
Member
Christian Dietrich wrote on Thu, 07 July 2011 16:38
Hi,

how does your workflow look like? please make sure that you deactivate e.g. the types.TypesGeneratorFragment {}

~Christian


Hi,

thanks for answering.

I created a completley new XText project and moved only some files from the old project (without the workflow).

Do I have to manipulate the workflow file???

BTW, I did the new 15 Minutes Tutorial where imports are also used -> this project (the model editor) works with no problems (the workflow looks pretty identical to mine and also the dsl definition)


TIA
Martin

Here is my (generated) workflow file. I did no changes after project initialization:

module at.abc.ea.eadsl.GenerateEaDsl

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/at/abc/ea/eadsl/EaDsl.xtext"
var file.extensions = "eadsl"
var projectName = "at.abc.ea.eadsl"
var runtimeProject = "../${projectName}"

Workflow {
    bean = StandaloneSetup {
        scanClassPath = true
        platformUri = "${runtimeProject}/.."
    }

    component = DirectoryCleaner {
        directory = "${runtimeProject}/src-gen"
    }

    component = DirectoryCleaner {
        directory = "${runtimeProject}.ui/src-gen"
    }

    component = Generator {
        pathRtProject = runtimeProject
        pathUiProject = "${runtimeProject}.ui"
        pathTestProject = "${runtimeProject}.tests"
        projectNameRt = projectName
        projectNameUi = "${projectName}.ui"
        language = {
            uri = grammarURI
            fileExtensions = file.extensions

            // Java API to access grammar elements (required by several other fragments)
            fragment = grammarAccess.GrammarAccessFragment {}

            // generates Java API for the generated EPackages
            fragment = ecore.EcoreGeneratorFragment {
            // referencedGenModels = "
            //  platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel,
            //  platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel
            // "
            }

            // Serializer 2.0
            fragment = serializer.SerializerFragment {}
            
            // the serialization component (1.0)
            // fragment = parseTreeConstructor.ParseTreeConstructorFragment {}

            // a custom ResourceFactory for use with EMF
            fragment = resourceFactory.ResourceFactoryFragment {
                fileExtensions = file.extensions
            }

            // The antlr parser generator fragment.
            fragment = parser.antlr.XtextAntlrGeneratorFragment {
            //  options = {
            //      backtrack = true
            //  }
            }

            // java-based API for validation
            fragment = validation.JavaValidatorFragment {
                composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
                composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
            }

            // scoping and exporting API
            // fragment = scoping.ImportURIScopingFragment {}
            // fragment = exporting.SimpleNamesFragment {}

            // scoping and exporting API
            fragment = scoping.ImportNamespacesScopingFragment {}
            fragment = exporting.QualifiedNamesFragment {}
            fragment = builder.BuilderIntegrationFragment {}

            // generator API
            fragment = generator.GeneratorFragment {
                generateMwe = true
                generateJavaMain = true
            }

            // formatter API
            fragment = formatting.FormatterFragment {}

            // labeling API
            fragment = labeling.LabelProviderFragment {}

            // outline API
            fragment = outline.OutlineTreeProviderFragment {}
            fragment = outline.QuickOutlineFragment {}

            // quickfix API
            fragment = quickfix.QuickfixProviderFragment {}

            // content assist API
            fragment = contentAssist.JavaBasedContentAssistFragment {}

            // generates a more lightweight Antlr parser and lexer tailored for content assist
            fragment = parser.antlr.XtextAntlrUiGeneratorFragment {}

            // generates junit test support classes into Generator#pathTestProject
            fragment = junit.Junit4Fragment {}

            // project wizard (optional)
            fragment = projectWizard.SimpleProjectWizardFragment {
                generatorProjectName = "${projectName}"
                modelFileExtension = file.extensions
            }

            // provides the necessary bindings for java types integration
            //fragment = types.TypesGeneratorFragment {}

            // generates the required bindings only if the grammar inherits from Xbase
            fragment = xbase.XbaseGeneratorFragment {}

            // provides a preference page for template proposals
            fragment = templates.CodetemplatesGeneratorFragment {}

            // rename refactoring
            fragment = refactoring.RefactorElementNameFragment {}

            // provides a compare view
            fragment = compare.CompareFragment {
                 fileExtensions = file.extensions
            }

        }
    }
}

Re: [Xtext 2.0] Model editor problem after migrating to 2.0 with imports [message #694218 is a reply to message #694200] Fri, 08 July 2011 06:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6385
Registered: July 2009
Senior Member
Hi,

i just saw that you use importedNamespaces in your grammar. but with import datatype.eadsl importURIs in the model file. Never the less it is working if i create a new xtext project with your grammar out of the box. what is the problem you actually get? did you made any further customnizations?

~Christian
Re: [Xtext 2.0] Model editor problem after migrating to 2.0 with imports [message #694275 is a reply to message #694218] Fri, 08 July 2011 08:58 Go to previous messageGo to next message
Martin Kuhn is currently offline Martin Kuhn
Messages: 49
Registered: July 2009
Member
Hi

the only namable customization is in providing some DslScopeProvider enhancements and checks. I did NO changes in the UI project.

The problem I actually have is, that I'm NOT able to edit my models with the generated UI (I have to use simple text file editing) -> The editor is not able to resolve types (references) defined in other models.

BUT I'm able to execute my own generation process without problems!!! It is only a UI thing...

As I mentioned the same worked in Xtext 1.0.x


TIA
Martin
Re: [Xtext 2.0] Model editor problem after migrating to 2.0 with imports [message #694284 is a reply to message #694275] Fri, 08 July 2011 09:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6385
Registered: July 2009
Senior Member
Hi,

as i said before: with a plain project it works so maybe you scopeprovider customizations may be the problem.

~Christian
Re: [Xtext 2.0] Model editor problem after migrating to 2.0 with imports [message #694318 is a reply to message #694284] Fri, 08 July 2011 10:28 Go to previous message
Martin Kuhn is currently offline Martin Kuhn
Messages: 49
Registered: July 2009
Member
HI,

I did the whole process once more (creating a plain project and copying from the 1.0.x). And (of course) you are right. The model editor works...

Maybe my problem was the merging process with SVN (version 1.0x -> 2.0) which influenced something. Now I deleted the old SVN projects to have no problems in this context...

Thank you very much for supporting.

Regards,
Martin
Previous Topic:[Xtext 2] Replacement for Check?
Next Topic:error detector
Goto Forum:
  


Current Time: Fri Oct 24 08:04:32 GMT 2014

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

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