ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1343693 [4/4] - in /ant/sandbox/antdsl: ./ doc/ org.apache.ant.antdsl.tests/ org.apache.ant.antdsl.tests/META-INF/ org.apache.ant.antdsl.tests/src-gen/ org.apache.ant.antdsl.tests/src/ org.apache.ant.antdsl.ui/ org.apache.ant.antdsl.ui/MET...
Date Tue, 29 May 2012 12:19:50 GMT
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java?rev=1343693&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java
(added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java
Tue May 29 12:19:47 2012
@@ -0,0 +1,219 @@
+package org.apache.ant.antdsl.xtext;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import org.apache.ant.antdsl.AbstractAntDslProjectHelper;
+import org.apache.ant.antdsl.AntDslContext;
+import org.apache.ant.antdsl.IfTask;
+import org.apache.ant.antdsl.IfTask.ConditionnalSequential;
+import org.apache.ant.antdsl.xtext.antdsl.EArgument;
+import org.apache.ant.antdsl.xtext.antdsl.EArguments;
+import org.apache.ant.antdsl.xtext.antdsl.EBranch;
+import org.apache.ant.antdsl.xtext.antdsl.EConditionedTasks;
+import org.apache.ant.antdsl.xtext.antdsl.EExtensionPoint;
+import org.apache.ant.antdsl.xtext.antdsl.EInnerElement;
+import org.apache.ant.antdsl.xtext.antdsl.EInnerElements;
+import org.apache.ant.antdsl.xtext.antdsl.EMacrodef;
+import org.apache.ant.antdsl.xtext.antdsl.ENamespace;
+import org.apache.ant.antdsl.xtext.antdsl.EProject;
+import org.apache.ant.antdsl.xtext.antdsl.EPropertyAssignment;
+import org.apache.ant.antdsl.xtext.antdsl.ETarget;
+import org.apache.ant.antdsl.xtext.antdsl.ETargetList;
+import org.apache.ant.antdsl.xtext.antdsl.ETask;
+import org.apache.ant.antdsl.xtext.antdsl.ETaskLists;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.ExtensionPoint;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Property;
+import org.apache.tools.ant.taskdefs.Sequential;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.xtext.nodemodel.INode;
+import org.eclipse.xtext.parser.IParseResult;
+import org.eclipse.xtext.parser.IParser;
+
+public class AntDslXTextProjectHelper extends AbstractAntDslProjectHelper {
+
+    private IParser parser;
+
+    public AntDslXTextProjectHelper() {
+        parser = ParserCreator.createWithGuice();
+    }
+
+    @Override
+    protected void doParse(InputStream in, String buildFileName, Project project, AntDslContext
context) {
+        IParseResult result;
+        try {
+            result = parser.parse(new InputStreamReader(in));
+        } finally {
+            try {
+                in.close();
+            } catch (IOException e) {
+                // don't care
+            }
+        }
+        if (result.hasSyntaxErrors()) {
+            project.log("Syntax error while parsing the build file " + buildFileName, Project.MSG_ERR);
+            for (INode error : result.getSyntaxErrors()) {
+                project.log(error.getText(), Project.MSG_ERR);
+                project.log(error.getSyntaxErrorMessage().getMessage(), Project.MSG_ERR);
+            }
+            throw new BuildException("Syntax error while parsing the build file " + buildFileName);
+        }
+        EProject eProject = (EProject) result.getRootASTElement();
+        mapProject(project, context, eProject);
+    }
+
+    private void mapProject(Project project, AntDslContext context, EProject eProject) {
+        String name = eProject.getName();
+        String basedir = eProject.getBasedir();
+        String def = eProject.getDefault();
+
+        setupProject(project, context, name, basedir, def);
+
+        EList<ENamespace> namespaces = eProject.getNamespaces();
+        if (namespaces != null) {
+            for (ENamespace namespace : namespaces) {
+                context.addNamespace(namespace.getName(), namespace.getUri());
+            }
+        }
+
+        EList<EMacrodef> macros = eProject.getMacrodDefs();
+        if (macros != null) {
+            for (EMacrodef macro : macros) {
+                mapMacro(project, context, macro);
+            }
+        }
+        ETaskLists tasks = eProject.getTasks();
+        if (tasks != null) {
+            for (ETask eTask : tasks.getTasks()) {
+                context.getImplicitTarget().addTask(mapTask(project, context, eTask));
+            }
+        }
+        for (ETarget eTarget : eProject.getTargets()) {
+            mapTarget(project, context, eTarget);
+        }
+        for (EExtensionPoint eExtensionPoint : eProject.getExtensionPoints()) {
+            mapExtensionPoint(project, context, eExtensionPoint);
+        }
+    }
+
+    private void mapMacro(Project project, AntDslContext context, EMacrodef macro) {
+        // TODO
+    }
+
+    private Target mapTarget(Project project, AntDslContext context, ETarget eTarget) {
+        Target target = new Target();
+        context.setCurrentTarget(target);
+        mapCommonTarget(target, project, context, eTarget.getName(), eTarget.getDescription(),
mapTargetList(eTarget.getDepends()),
+                mapTargetList(eTarget.getExtensionsOf()));
+        ETaskLists tasks = eTarget.getTasks();
+        if (tasks != null && tasks.getTasks() != null) {
+            for (ETask eTask : tasks.getTasks()) {
+                target.addTask(mapTask(project, context, eTask));
+            }
+        }
+        context.setCurrentTarget(context.getImplicitTarget());
+        return target;
+    }
+
+    private List<String> mapTargetList(ETargetList targetList) {
+        if (targetList == null) {
+            return null;
+        }
+        return targetList.getNames();
+    }
+
+    private ExtensionPoint mapExtensionPoint(Project project, AntDslContext context, EExtensionPoint
eExtensionPoint) {
+        ExtensionPoint extensionPoint = new ExtensionPoint();
+        mapCommonTarget(extensionPoint, project, context, eExtensionPoint.getName(), eExtensionPoint.getDescription(),
+                mapTargetList(eExtensionPoint.getDepends()), mapTargetList(eExtensionPoint.getExtensionsOf()));
+        context.setCurrentTarget(context.getImplicitTarget());
+        return extensionPoint;
+    }
+
+    private Task mapTask(Project project, AntDslContext context, ETask eTask) {
+        if (eTask instanceof EPropertyAssignment) {
+            EPropertyAssignment ePropertyAssignment = (EPropertyAssignment) eTask;
+            Property property = new Property();
+            mapCommonTask(project, context, property);
+            property.setName(ePropertyAssignment.getName());
+            property.setValue(ePropertyAssignment.getValue());
+            return property;
+        }
+        if (eTask instanceof EInnerElement) {
+            EInnerElement eInnerElement = (EInnerElement) eTask;
+            return mapUnknown(project, context, mapInnerElement(eInnerElement), false);
+        }
+        if (eTask instanceof EBranch) {
+            EBranch eBranch = (EBranch) eTask;
+            IfTask ifTask = new IfTask();
+            mapCommonTask(project, context, ifTask);
+            EConditionedTasks if_ = eBranch.getIf();
+            if (if_ != null) {
+                ConditionnalSequential main = new ConditionnalSequential();
+                mapCommonTask(project, context, main);
+                main.setCondition(mapExpectedUnknown(project, context, mapInnerElement(if_.getCondition()),
Condition.class));
+                for (ETask t : if_.getTasks().getTasks()) {
+                    main.addTask(mapTask(project, context, t));
+                }
+            }
+            EList<EConditionedTasks> elseifs = eBranch.getElseif();
+            if (elseifs != null) {
+                for (EConditionedTasks elseif : elseifs) {
+                    ConditionnalSequential ei = new ConditionnalSequential();
+                    mapCommonTask(project, context, ei);
+                    ei.setCondition(mapExpectedUnknown(project, context, mapInnerElement(elseif.getCondition()),
Condition.class));
+                    for (ETask t : elseif.getTasks().getTasks()) {
+                        ei.addTask(mapTask(project, context, t));
+                    }
+                }
+            }
+            ETaskLists else_ = eBranch.getElse();
+            if (else_ != null) {
+                Sequential e = new Sequential();
+                mapCommonTask(project, context, e);
+                for (ETask t : else_.getTasks()) {
+                    e.addTask(mapTask(project, context, t));
+                }
+                ifTask.setElse(e);
+            }
+            return ifTask;
+        }
+        throw new IllegalStateException("Unknown task type " + eTask.getClass().getName());
+    }
+
+    private InnerElement mapInnerElement(EInnerElement eInnerElement) {
+        if (eInnerElement == null) {
+            return null;
+        }
+        InnerElement innerElement = new InnerElement();
+        innerElement.ns = eInnerElement.getName().getName();
+        innerElement.name = eInnerElement.getName().getName();
+
+        EArguments arguments = eInnerElement.getArguments();
+        if (arguments != null) {
+            innerElement.attributes = new LinkedHashMap<String, String>();
+            for (EArgument argument : arguments.getArguments()) {
+                innerElement.attributes.put(argument.getName(), argument.getValue());
+            }
+        }
+
+        EInnerElements inners = eInnerElement.getInners();
+        if (inners != null) {
+            innerElement.children = new ArrayList<InnerElement>();
+            for (EInnerElement inner : inners.getElements()) {
+                innerElement.children.add(mapInnerElement(inner));
+            }
+        }
+
+        return innerElement;
+    }
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/GenerateAntDSL.mwe2
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/GenerateAntDSL.mwe2?rev=1343693&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/GenerateAntDSL.mwe2
(added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/GenerateAntDSL.mwe2
Tue May 29 12:19:47 2012
@@ -0,0 +1,138 @@
+module org.apache.ant.antdsl.xtext.GenerateAntDSL
+
+import org.eclipse.emf.mwe.utils.*
+import org.eclipse.xtext.generator.*
+import org.eclipse.xtext.ui.generator.*
+
+var grammarURI = "classpath:/org/apache/ant/antdsl/xtext/AntDSL.xtext"
+var file.extensions = "ant"
+var projectName = "org.apache.ant.antdsl"
+var runtimeProject = "../${projectName}"
+
+Workflow {
+    bean = StandaloneSetup {
+        scanClassPath = true
+        platformUri = "${runtimeProject}/.."
+        // The following two lines can be removed, if Xbase is not used.
+        registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
+        registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
+    }
+
+    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 {
+            	generateStub = false
+            }
+            
+            // 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 = false
+                generateJavaMain = false
+            }
+
+            // 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
+            // }
+
+            // 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
+            }
+
+        }
+    }
+}

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java?rev=1343693&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java
(added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java
Tue May 29 12:19:47 2012
@@ -0,0 +1,201 @@
+package org.apache.ant.antdsl.xtext;
+
+import java.io.FileNotFoundException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+
+import org.apache.ant.antdsl.xtext.parser.antlr.AntDSLAntlrTokenFileProvider;
+import org.apache.ant.antdsl.xtext.parser.antlr.AntDSLParser;
+import org.apache.ant.antdsl.xtext.parser.antlr.internal.InternalAntDSLLexer;
+import org.apache.ant.antdsl.xtext.services.AntDSLGrammarAccess;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xtext.common.services.DefaultTerminalConverters;
+import org.eclipse.xtext.common.services.TerminalsGrammarAccess;
+import org.eclipse.xtext.conversion.impl.DefaultTerminalConverter;
+import org.eclipse.xtext.conversion.impl.DefaultTerminalConverter.Factory;
+import org.eclipse.xtext.conversion.impl.IDValueConverter;
+import org.eclipse.xtext.conversion.impl.INTValueConverter;
+import org.eclipse.xtext.conversion.impl.STRINGValueConverter;
+import org.eclipse.xtext.nodemodel.impl.NodeModelBuilder;
+import org.eclipse.xtext.parser.DefaultEcoreElementFactory;
+import org.eclipse.xtext.parser.IParser;
+import org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider;
+import org.eclipse.xtext.parser.antlr.AntlrTokenToStringConverter;
+import org.eclipse.xtext.parser.antlr.IReferableElementsUnloader;
+import org.eclipse.xtext.parser.antlr.IReferableElementsUnloader.NullUnloader;
+import org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper;
+import org.eclipse.xtext.parser.antlr.Lexer;
+import org.eclipse.xtext.parser.antlr.SyntaxErrorMessageProvider;
+import org.eclipse.xtext.parser.antlr.UnorderedGroupHelper;
+import org.eclipse.xtext.parser.impl.PartialParsingHelper;
+import org.eclipse.xtext.resource.IResourceFactory;
+import org.eclipse.xtext.resource.IResourceServiceProvider;
+import org.eclipse.xtext.resource.SynchronizedXtextResourceSet;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.resource.XtextResourceFactory;
+import org.eclipse.xtext.resource.XtextResourceSet;
+import org.eclipse.xtext.resource.impl.DefaultResourceServiceProvider;
+import org.eclipse.xtext.service.GrammarProvider;
+
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+
+public class ParserCreator {
+
+    public static IParser createWithGuice() {
+        Injector guiceInjector = new AntDSLStandaloneSetup().createInjectorAndDoEMFRegistration();
+        IParser parser = guiceInjector.getInstance(IParser.class);
+        return parser;
+    }
+
+    /**
+     * Expermimental parser creator which mimic the guice boostrap, to try to avoid the guice
cpu overhead  
+     */
+    public static IParser createWithNew() {
+
+        // register default ePackages
+        if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
{
+            Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new
org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
+        }
+        if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
{
+            Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new
org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl());
+        }
+        if (!EPackage.Registry.INSTANCE.containsKey(org.eclipse.xtext.XtextPackage.eNS_URI))
{
+            EPackage.Registry.INSTANCE.put(org.eclipse.xtext.XtextPackage.eNS_URI, org.eclipse.xtext.XtextPackage.eINSTANCE);
+        }
+        if (!EPackage.Registry.INSTANCE.containsKey("http://www.apache.org/ant/AntDSL"))
{
+            EPackage.Registry.INSTANCE.put("http://www.apache.org/ant/AntDSL", org.apache.ant.antdsl.xtext.antdsl.AntdslPackage.eINSTANCE);
+        }
+
+        IResourceFactory resourceFactory = new XtextResourceFactory(makeProvider(new XtextResource()));
+        IResourceServiceProvider serviceProvider = new DefaultResourceServiceProvider();
+        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ant", resourceFactory);
+        IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("ant",
serviceProvider);
+
+        SynchronizedXtextResourceSet xtextResourceSet = new SynchronizedXtextResourceSet();
+        Provider<XtextResourceSet> resourceSetProvider = makeProvider((XtextResourceSet)
xtextResourceSet);
+
+        GrammarProvider grammarProvider = new GrammarProvider("org.apache.ant.antdsl.AntDSL",
resourceSetProvider);
+
+        TerminalsGrammarAccess terminalsGrammarAccess = new TerminalsGrammarAccess(grammarProvider);
+
+        AntDSLGrammarAccess antDSLGrammarAccess = new AntDSLGrammarAccess(grammarProvider,
terminalsGrammarAccess);
+
+        SyntaxErrorMessageProvider syntaxErrorProvider = new SyntaxErrorMessageProvider();
+
+        NullUnloader unloader = new IReferableElementsUnloader.NullUnloader();
+
+        PartialParsingHelper partialParser = new PartialParsingHelper();
+        partialParser.setUnloader(unloader);
+
+        InternalAntDSLLexer lexer = new InternalAntDSLLexer();
+        Provider<Lexer> lexerProvider = makeProvider((Lexer) lexer);
+
+        AntDSLAntlrTokenFileProvider antlrTokenFileProvider = new AntDSLAntlrTokenFileProvider();
+
+        AntlrTokenDefProvider tokenDefProvider = new AntlrTokenDefProvider();
+        tokenDefProvider.setAntlrTokenFileProvider(antlrTokenFileProvider);
+
+        AntlrTokenToStringConverter tokenConverter = new AntlrTokenToStringConverter();
+
+        IDValueConverter idValueConverter = new IDValueConverter();
+        idValueConverter.setGrammarAccess(antDSLGrammarAccess);
+        idValueConverter.setTokenDefProvider(tokenDefProvider);
+        idValueConverter.setLexerProvider(lexerProvider);
+
+        INTValueConverter intValueConverter = new INTValueConverter();
+        intValueConverter.setTokenDefProvider(tokenDefProvider);
+        intValueConverter.setLexerProvider(lexerProvider);
+
+        STRINGValueConverter stringValueConverter = new STRINGValueConverter();
+        stringValueConverter.setTokenDefProvider(tokenDefProvider);
+        stringValueConverter.setLexerProvider(lexerProvider);
+
+        DefaultTerminalConverter defaultTerminalConverter = createPrivate(DefaultTerminalConverter.class);
+        defaultTerminalConverter.setLexerProvider(lexerProvider);
+        defaultTerminalConverter.setTokenDefProvider(tokenDefProvider);
+        Provider<DefaultTerminalConverter> defaultTerminalConverterProvider = makeProvider(defaultTerminalConverter);
+        Factory defaultTerminalConverterFactory = new DefaultTerminalConverter.Factory();
+        setPrivate(defaultTerminalConverterFactory, "provider", defaultTerminalConverterProvider);
+
+        DefaultTerminalConverters converterService = new DefaultTerminalConverters();
+        setPrivate(converterService, "idValueConverter", idValueConverter);
+        setPrivate(converterService, "intValueConverter", intValueConverter);
+        setPrivate(converterService, "stringValueConverter", stringValueConverter);
+        converterService.setGrammar(antDSLGrammarAccess);
+        converterService.setDefaultTerminalConverterFactory(defaultTerminalConverterFactory);
+
+        DefaultEcoreElementFactory elementFactory = new DefaultEcoreElementFactory();
+        setPrivate(elementFactory, "tokenConverter", tokenConverter);
+        elementFactory.setConverterService(converterService);
+
+        NodeModelBuilder nodeModelBuilder = new NodeModelBuilder();
+        Provider<NodeModelBuilder> nodeModelBuilderProvider = makeProvider(nodeModelBuilder);
+
+        UnorderedGroupHelper unorderedGroupHelper = new UnorderedGroupHelper(new UnorderedGroupHelper.Collector(antDSLGrammarAccess));
+        Provider<IUnorderedGroupHelper> unorderedGroupHelperProvider = makeProvider((IUnorderedGroupHelper)
unorderedGroupHelper);
+
+        AntDSLParser parser = new AntDSLParser();
+        parser.setGrammarAccess(antDSLGrammarAccess);
+        parser.setSyntaxErrorProvider(syntaxErrorProvider);
+        parser.setPartialParser(partialParser);
+        parser.setTokenDefProvider(tokenDefProvider);
+        parser.setLexerProvider(lexerProvider);
+        setPrivate(parser, "nodeModelBuilder", nodeModelBuilderProvider);
+        parser.setUnorderedGroupHelper(unorderedGroupHelperProvider);
+        parser.setElementFactory(elementFactory);
+
+        return parser;
+    }
+
+    private static <T> Provider<T> makeProvider(final T provided) {
+        return new Provider<T>() {
+            @Override
+            public T get() {
+                return provided;
+            }
+        };
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <T> T createPrivate(Class<T> cl) {
+        try {
+            Constructor< ? >[] constructors = cl.getDeclaredConstructors();
+            for (Constructor< ? > c : constructors) {
+                if (c.getParameterTypes().length == 0) {
+                    c.setAccessible(true);
+                    return (T) c.newInstance();
+                }
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        throw new RuntimeException("Missing default constructor");
+    }
+
+    private static void setPrivate(Object object, String field, Object fieldObject) {
+        try {
+            Field f = null;
+            Class< ? > cl = object.getClass();
+            while (f == null && cl != null) {
+                try {
+                    f = cl.getDeclaredField(field);
+                } catch (NoSuchFieldException e) {
+                    cl = cl.getSuperclass();
+                }
+            }
+            f.setAccessible(true);
+            f.set(object, fieldObject);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static void main(String[] args) throws FileNotFoundException {
+        long t;
+        t = System.currentTimeMillis();
+        IParser parser1 = createWithNew();
+        System.out.println(System.currentTimeMillis() - t);
+    }
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/ParserCreator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/formatting/AntDSLFormatter.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/formatting/AntDSLFormatter.java?rev=1343693&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/formatting/AntDSLFormatter.java
(added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/formatting/AntDSLFormatter.java
Tue May 29 12:19:47 2012
@@ -0,0 +1,27 @@
+/*
+ * generated by Xtext
+ */
+package org.apache.ant.antdsl.xtext.formatting;
+
+import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter;
+import org.eclipse.xtext.formatting.impl.FormattingConfig;
+
+/**
+ * This class contains custom formatting description.
+ * 
+ * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#formatting
+ * on how and when to use it 
+ * 
+ * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
+ */
+public class AntDSLFormatter extends AbstractDeclarativeFormatter {
+	
+	@Override
+	protected void configureFormatting(FormattingConfig c) {
+// It's usually a good idea to activate the following three statements.
+// They will add and preserve newlines around comments
+//		c.setLinewrap(0, 1, 2).before(getGrammarAccess().getSL_COMMENTRule());
+//		c.setLinewrap(0, 1, 2).before(getGrammarAccess().getML_COMMENTRule());
+//		c.setLinewrap(0, 1, 1).after(getGrammarAccess().getML_COMMENTRule());
+	}
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/formatting/AntDSLFormatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/formatting/AntDSLFormatter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/formatting/AntDSLFormatter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.xtend
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.xtend?rev=1343693&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.xtend
(added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.xtend
Tue May 29 12:19:47 2012
@@ -0,0 +1,15 @@
+/*
+ * generated by Xtext
+ */
+package org.apache.ant.antdsl.xtext.generator
+
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.xtext.generator.IGenerator
+import org.eclipse.xtext.generator.IFileSystemAccess
+
+class AntDSLGenerator implements IGenerator {
+	
+	override void doGenerate(Resource resource, IFileSystemAccess fsa) {
+		//TODO implement me
+	}
+}

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/scoping/AntDSLScopeProvider.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/scoping/AntDSLScopeProvider.java?rev=1343693&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/scoping/AntDSLScopeProvider.java
(added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/scoping/AntDSLScopeProvider.java
Tue May 29 12:19:47 2012
@@ -0,0 +1,17 @@
+/*
+ * generated by Xtext
+ */
+package org.apache.ant.antdsl.xtext.scoping;
+
+import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
+
+/**
+ * This class contains custom scoping description.
+ * 
+ * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping
+ * on how and when to use it 
+ *
+ */
+public class AntDSLScopeProvider extends AbstractDeclarativeScopeProvider {
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/scoping/AntDSLScopeProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/scoping/AntDSLScopeProvider.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/scoping/AntDSLScopeProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/validation/AntDSLJavaValidator.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/validation/AntDSLJavaValidator.java?rev=1343693&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/validation/AntDSLJavaValidator.java
(added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/validation/AntDSLJavaValidator.java
Tue May 29 12:19:47 2012
@@ -0,0 +1,13 @@
+package org.apache.ant.antdsl.xtext.validation;
+ 
+
+public class AntDSLJavaValidator extends AbstractAntDSLJavaValidator {
+
+//	@Check
+//	public void checkGreetingStartsWithCapital(Greeting greeting) {
+//		if (!Character.isUpperCase(greeting.getName().charAt(0))) {
+//			warning("Name should start with a capital", MyDslPackage.Literals.GREETING__NAME);
+//		}
+//	}
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/validation/AntDSLJavaValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/validation/AntDSLJavaValidator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/validation/AntDSLJavaValidator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/xtend-gen/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/xtend-gen/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.java?rev=1343693&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/xtend-gen/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.java
(added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/xtend-gen/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.java
Tue May 29 12:19:47 2012
@@ -0,0 +1,11 @@
+package org.apache.ant.antdsl.xtext.generator;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.IGenerator;
+
+@SuppressWarnings("all")
+public class AntDSLGenerator implements IGenerator {
+  public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
+  }
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/xtend-gen/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/xtend-gen/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/xtend-gen/org/apache/ant/antdsl/xtext/generator/AntDSLGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/test/build.ant
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/test/build.ant?rev=1343693&view=auto
==============================================================================
--- ant/sandbox/antdsl/test/build.ant (added)
+++ ant/sandbox/antdsl/test/build.ant Tue May 29 12:19:47 2012
@@ -0,0 +1,36 @@
+name : myproject
+default : build
+
+{
+	foo = "hello world!"
+	echo(message="${foo}")
+}
+
+macrodef mymacro(dest, arg2 = "defaultvalue", element source) {
+	copy(todir = "@{dest}") {
+		source()
+	}
+}
+
+% description of the target
+target build {
+	copy(file = "${basedir}/test/build.ant", tofile = "${basedir}/build/test/build.ant.copy")
+	// some comment
+	jar(file = "${basedir}/build/test/my.jar") {
+		fileset(dir="${basedir}/test", includes="*.ant")
+	}
+	/*
+	 * Some multiline comment 
+	 */
+	if (available(file = "${basedir}/test/build.ant")) {
+		/* NOT WORKING YET
+		mymacro(dest = "${basedir}/build/test/dest") {
+			fileset(dir = "${basedir}", includes="build.*")
+		}
+		*/
+		echo(message = "mymacro call")
+	} else {
+		fail(message = "fail !")
+	}
+}
+

Propchange: ant/sandbox/antdsl/test/build.ant
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/test/build.ant
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/test/build.ant
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message