Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Importing Ecore Model(Project Organization)
Importing Ecore Model [message #1767410] Wed, 05 July 2017 17:17 Go to next message
Amit Yadav is currently offline Amit YadavFriend
Messages: 28
Registered: June 2017
Junior Member
Hello All,

I am trying to create a DSL using Xbase and Xtext. I am also planning to support IDEA plugin for this DSL. I have some constrain however around organizing the code for this DSL. Specifically

1) I am trying to create one project (this does not mean an 'eclipse project') which contains the DSL file, validation code, model inferring code, generator code, scoping code etc.

2) I need to crate another project which contains all the ui related stuff. e.g content assist, labeling, quick fix etc.

I am able to complete step 1 and have a jar which contains the xtext file, model files etc. But I am struggling with step 2. Can someone please advice on how should I go about implementing 2. (I have tried importing ecore model and tried searching on this forum but getting into one error or the other).

Thank You,
Re: Importing Ecore Model [message #1767539 is a reply to message #1767410] Fri, 07 July 2017 03:06 Go to previous message
Amit Yadav is currently offline Amit YadavFriend
Messages: 28
Registered: June 2017
Junior Member
Here is my MWE2 file
module org.example.my.idea.Mydsl

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*

var grammarURI = "classpath:/org/example/my/Mydsl.xtext"
var file.extensions = "mydsl"
var runtimeProject = "src/main/java/org/example/my"
var rootPath = ".."

Workflow {

  bean = StandaloneSetup {
    logResourceUriMap = true
    projectMapping = {
      projectName = 'org.example.my'
      path = 'src/main/java/org/example/my'
    }

    scanClassPath = true
    platformUri = "${runtimeProject}"
    uriMap = {
         from	= "platform:/resource/org.example.my/model/Mydsl.genmodel"
         to 	= "classpath:/model/generated/Mydsl.genmodel"
     }

    uriMap = {
        from	= "platform:/resource/org.example.my/model/Mydsl.ecore"
        to 		= "classpath:/model/generated/Mydsl.ecore"
    }

    registerGenModelFile = "platform:/resource/org.example.my/model/Mydsl.genmodel"
    registerEcoreFile= "platform:/resource/org.example.my/model/Mydsl.ecore"
    registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
    registerGenModelFile = "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel"
    registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
    registerGeneratedEPackage="org.example.my.dsl.mydsl.MydslPackage"
	}

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

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

  component = XtextGenerator {
    configuration = {
      project = StandardProjectConfig {
        baseName = "my-dsl-ide"
        rootPath = rootPath
        runtime = {
          enabled = false
        }
        runtimeTest = {
          enabled = false
        }
        genericIde = {
          name = "my-dsl-ide"
          enabled = true
        }
        ideaPlugin = {
          name = "my-dsl-ide"
          enabled = true
        }
        mavenLayout = true
      }
      code = {
        preferXtendStubs = false
        encoding = "UTF-8"
        fileHeader = "/*\n * generated by Xtext \${version}\n */"
      }
    }

    language = XtextGeneratorLanguage {
      grammarUri = grammarURI
      fileExtensions = "mydsl"

      fragment = grammarAccess.GrammarAccessFragment2 {}

       // generates Java API for the generated EPackages
      fragment = ecore.EMFGeneratorFragment2 {
          genModel = "platform:/resource/org.example.my/model/Mydsl.genmodel"
      }

      fragment = ui.labeling.LabelProviderFragment2 {}
      fragment = ui.outline.QuickOutlineFragment2 {}
      fragment = ui.outline.OutlineTreeProviderFragment2 {}
      fragment = ui.quickfix.QuickfixProviderFragment2 {}
      fragment = ui.contentAssist.ContentAssistFragment2 {}
      fragment = ui.templates.CodetemplatesGeneratorFragment2 {}
      fragment = ui.compare.CompareFragment2 {}
      fragment = idea.parser.antlr.XtextAntlrIDEAGeneratorFragment {}
      fragment = idea.IdeaPluginGenerator {}
    }
  }
}


Here is the error I am getting:
Caused by: java.net.MalformedURLException: unknown protocol: classpath
at java.net.URL.<init>(URL.java:593)
at java.net.URL.<init>(URL.java:483)
at java.net.URL.<init>(URL.java:432)
at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URIHandlerImpl.java:199)
at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1269)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)


I have added the jar from project 1 to class path of porject 2.
Previous Topic:QualifiedNameProvider not working with custom Scopes
Next Topic:Using File Name in DSL
Goto Forum:
  


Current Time: Tue Sep 21 19:58:05 GMT 2021

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

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

Back to the top