Could I create jdt projects in the workspace as result of a xtext generator ? [message #951682] |
Sat, 20 October 2012 19:36  |
Eclipse User |
|
|
|
Hi,
I'm researching for a new dsl, to see if is possible and would like some tips from the list.
I'm thinking in a grammar like this:
Model:
'baseDir' basedir = STRING
components+=Component*;
Component:
'component' name=ID
'{'
'Bundle-SymbolicName' symb=STRING
'}'
;
component comp1{
Bundle-SymbolicName "my.bundle.project"
}
The idea is to create one project in the workspace for each Component in model, maybe using JDT.
Could someone tell me if this would be possible and what route to follow?
regards
|
|
|
|
Re: Could I create jdt projects in the workspace as result of a xtext generator ? [message #961547 is a reply to message #951682] |
Sun, 28 October 2012 07:11  |
Eclipse User |
|
|
|
So you would like to create, from the generator, other projects right?
You can create projects programmatically with eclipse APIs; xtext.junit*
plugins offer some utility methods to create projects programmatically
even more easily.
I'm using these utility methods in some UI tests
(http://sourceforge.net/p/xsemantics/code/ci/68395a1c0bed6fa2f3cdf7a0220a49d4f27c98ae/tree/examples/it.xsemantics.example.lambda.tests/src/it/xsemantics/example/lambda/tests/ui/LambdaIntegrationTest.java)
here's a snippet
import static org.eclipse.xtext.ui.junit.util.IResourcesSetupUtil.addNature;
import static
org.eclipse.xtext.ui.junit.util.IResourcesSetupUtil.cleanWorkspace;
import static
org.eclipse.xtext.ui.junit.util.IResourcesSetupUtil.createFile;
import static
org.eclipse.xtext.ui.junit.util.IResourcesSetupUtil.waitForAutoBuild;
import static
org.eclipse.xtext.ui.junit.util.JavaProjectSetupUtil.addSourceFolder;
import static
org.eclipse.xtext.ui.junit.util.JavaProjectSetupUtil.createJavaProject;
....
@Test
public void testValidSimpleLambdaProgram() throws Exception {
createJavaProjectWithRootSrc("foo");
IFile file = createFile("foo/src/foo.lambda", "lambda x. x");
waitForAutoBuild();
assertNoErrorMarkers(file);
}
....
private IJavaProject createJavaProjectWithRootSrc(String string)
throws CoreException {
IJavaProject project = createJavaProject(string);
addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
addSourceFolder(project, "src");
return project;
}
hope this helps
Lorenzo
On 10/21/2012 01:36 AM, Cristiano Gaviao wrote:
> Hi,
>
> I'm researching for a new dsl, to see if is possible and would like some
> tips from the list.
>
> I'm thinking in a grammar like this:
>
> Model:
> 'baseDir' basedir = STRING
> components+=Component*;
>
> Component:
> 'component' name=ID
> '{'
> 'Bundle-SymbolicName' symb=STRING '}'
> ;
>
>
>
>
> component comp1{
> Bundle-SymbolicName "my.bundle.project"
> }
>
>
>
>
> The idea is to create one project in the workspace for each Component in
> model, maybe using JDT.
>
> Could someone tell me if this would be possible and what route to follow?
> regards
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
|
|
|
Powered by
FUDForum. Page generated in 0.03791 seconds