Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext generated Java Main(No running)
Xtext generated Java Main [message #986987] Thu, 22 November 2012 12:22 Go to next message
Andrea Margheri is currently offline Andrea Margheri
Messages: 20
Registered: July 2012
Junior Member
Hi,

I've generated the Java Main for parsing and generating code of my DSL. When I try to use it I have an error that seems it cannot load resources. I try yet with absolute path but it doesn't run. I don't make any changes in Xtext configuration file, so why have I this problem?

All exceptions are as follows:

Quote:

Exception in thread "main" java.lang.RuntimeException: Cannot create a resource for 'Input\mydslfile.dsl'; a registered resource factory is needed
at org.eclipse.xtext.resource.XtextResourceSet.getResource(XtextResourceSet.java:156)
at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23)
at it.xtext.mydsl.generator.Main.runGenerator(Main.java:51)
at it.xtext.mydsl.generator.Main.main(Main.java:32)


Thanks

Andrea
Re: Xtext generated Java Main [message #986998 is a reply to message #986987] Thu, 22 November 2012 13:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6229
Registered: July 2009
Senior Member
Hi,

can you please post the workflow too?

~Christian
Re: Xtext generated Java Main [message #987003 is a reply to message #986998] Thu, 22 November 2012 13:42 Go to previous messageGo to next message
Andrea Margheri is currently offline Andrea Margheri
Messages: 20
Registered: July 2012
Junior Member
That's it

Quote:

module it.xtext.facpl.GenerateFacpl

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

var grammarURI = "classpath:/it/xtext/facpl/Facpl.xtext"
var file.extensions = "fpl"
var projectName = "it.xtext.facpl"
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 {
}

// Serializer 2.0
fragment = serializer.SerializerFragment {
generateStub = false
}

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

// The antlr parser generator fragment.
fragment = parser.antlr.XtextAntlrGeneratorFragment {
}

// java-based API for validation
fragment = validation.JavaValidatorFragment {
}

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

// generator API
fragment = generator.GeneratorFragment {
generateMwe = false
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 {}

// rename refactoring
fragment = refactoring.RefactorElementNameFragment {}

// 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 {}

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


Re: Xtext generated Java Main [message #987005 is a reply to message #987003] Thu, 22 November 2012 14:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6229
Registered: July 2009
Senior Member
your file extension is fpl and not dsl
Re: Xtext generated Java Main [message #987006 is a reply to message #987005] Thu, 22 November 2012 15:01 Go to previous messageGo to next message
Andrea Margheri is currently offline Andrea Margheri
Messages: 20
Registered: July 2012
Junior Member
I've modified for posting exception statement. Obviously I use fpl!
Re: Xtext generated Java Main [message #987007 is a reply to message #987006] Thu, 22 November 2012 15:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6229
Registered: July 2009
Senior Member
Then it should work. did you try it with a new mydsl hello world project?
Re: Xtext generated Java Main [message #987008 is a reply to message #987007] Thu, 22 November 2012 15:17 Go to previous message
Andrea Margheri is currently offline Andrea Margheri
Messages: 20
Registered: July 2012
Junior Member
I try the fowlerdsl example and firstly doesn't run.
I use path made by finder, which use this slash "\" instead of "/" and this cause exception, changing it all run.
Maybe exception can be managed better or can be changed deprecated method "createURIWithCache" use in org.eclipse.emf.common.util.URI.
Thus, we can really understand error and don't be aimlessy.

Andrea
Previous Topic:import resolution during editing
Next Topic:expressing inheritance in xtext
Goto Forum:
  


Current Time: Thu Aug 28 07:17:06 EDT 2014

Powered by FUDForum. Page generated in 0.11170 seconds