summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmusset2009-03-05 11:32:28 (EST)
committerjmusset2009-03-05 11:32:28 (EST)
commitfebae53978c8975c54de6a55e3e3d1c0bb51434b (patch)
tree022f77ebadaf950b8f2756814785fb14f9c60e54
parentd3d1212cf06e360dff7de0bfc965ed33658ce039 (diff)
downloadorg.eclipse.acceleo-febae53978c8975c54de6a55e3e3d1c0bb51434b.zip
org.eclipse.acceleo-febae53978c8975c54de6a55e3e3d1c0bb51434b.tar.gz
org.eclipse.acceleo-febae53978c8975c54de6a55e3e3d1c0bb51434b.tar.bz2
Project renaming from MTL to Acceleo
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/.classpath7
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/.project28
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/META-INF/MANIFEST.MF23
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/about.html57
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/build.properties20
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessor.mtl27
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessorCommon.emtl94
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessorCommon.mtl4
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/plugin.properties25
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/editors/template/AcceleoCompletionProcessorTests.java209
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/editors/template/rules/FirstVariableRuleTests.java76
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/suite/AllTests.java49
-rw-r--r--tests/org.eclipse.acceleo.ide.ui.tests/test.xml66
14 files changed, 692 insertions, 0 deletions
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/.classpath b/tests/org.eclipse.acceleo.ide.ui.tests/.classpath
new file mode 100644
index 0000000..64c5e31
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/.project b/tests/org.eclipse.acceleo.ide.ui.tests/.project
new file mode 100644
index 0000000..74193b8
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.acceleo.ide.ui.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.acceleo.ide.ui.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..279992b
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Thu May 29 17:53:55 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.acceleo.ide.ui.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..904e57e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.acceleo.ide.ui.tests; singleton:=true
+Bundle-Version: 0.8.0.qualifier
+Bundle-ClassPath: .
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.ocl.ecore,
+ org.junit,
+ org.eclipse.acceleo.common,
+ org.eclipse.acceleo.ide.ui,
+ org.eclipse.jface.text,
+ org.eclipse.acceleo.parser,
+ org.eclipse.emf
+Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.acceleo.ide.ui.tests.editors.template,
+ org.eclipse.acceleo.ide.ui.tests.editors.template.rules
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/about.html b/tests/org.eclipse.acceleo.ide.ui.tests/about.html
new file mode 100644
index 0000000..7e1117e
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/about.html
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+
+
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>About</title>
+</head><body lang="EN-US">
+<h2>About This Content</h2>
+
+<em>July 25, 2008</em></p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+
+ <h3>Third Party Content</h3>
+ <p>The Content includes items that have been sourced from third parties as set out below. If you
+ did not receive this Content directly from the Eclipse Foundation, the following is provided
+ for informational purposes only, and you should look to the Redistributor's license for
+ terms and conditions of use.</p>
+ <p><em>
+ <br><br>
+ <strong>OMG MOF 2.0 Specification (06-01-01)</strong> <br>
+ <ul>
+ <li><a href="http://www.omg.org/technology/documents/formal/mof.htm">MOF 2.0 main page</a></li>
+ <li><a href="http://www.omg.org/docs/formal/06-01-01.pdf">MOF 2.0 specification</a></li>
+ <li><a href="http://www.omg.org/">OMG site</a></li>
+ </ul>
+ <br>
+ <strong>OMG OCL 2.0 specification (06-05-01)</strong> <br>
+ <ul>
+ <li><a href="http://www.omg.org/technology/documents/formal/ocl.htm">OCL 2.0 main page</a></li>
+ <li><a href="http://www.omg.org/docs/formal/06-05-01.pdf">OCL 2.0 specification</a></li>
+ <li><a href="http://www.omg.org/">OMG site</a></li>
+ </ul>
+ <br>
+ <strong>OMG MTL 1.0 specification (08-01-16)</strong> <br>
+ <ul>
+ <li><a href="http://www.omg.org/spec/MOFM2T/1.0/">MTL 1.0 main page</a></li>
+ <li><a href="http://www.omg.org/spec/MOFM2T/1.0/PDF">MTL 1.0 specification</a></li>
+ <li><a href="http://www.omg.org/">OMG site</a></li>
+ </ul>
+ <br>
+ </em></p>
+ <p>A detailed list of fixes and clarifications with respect to those specifications may be found in the plug-in directly realizing them.</p>
+</body></html> \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/build.properties b/tests/org.eclipse.acceleo.ide.ui.tests/build.properties
new file mode 100644
index 0000000..dce8eda
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/build.properties
@@ -0,0 +1,20 @@
+################################################################################
+# Copyright (c) 2008, 2009 Obeo.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Obeo - initial API and implementation
+################################################################################
+bin.includes = .,\
+ META-INF/,\
+ plugin.properties,\
+ test.xml,\
+ data/,\
+ about.html
+jars.compile.order = .
+source.. = src/
+output.. = bin/
+Bundle-ClassPath: .
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessor.mtl b/tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessor.mtl
new file mode 100644
index 0000000..4dc302c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessor.mtl
@@ -0,0 +1,27 @@
+[module mtlCompletionProcessor(http://www.eclipse.org/emf/2002/Ecore) /]
+
+[import mtlCompletionProcessorCommon /]
+
+[template public classToJava(p:EPackage) ]
+
+ [if (true)]
+
+ [else]
+
+ [/if]
+
+ [for (c:EClassifier | p.eClassifiers) {count : Integer = 0; }]
+ [ /]
+ [/for]
+
+ [for (c:EClassifier | p.eClassifiers) separator(',')]
+
+ [/for]
+
+ [p.name.toLowerFi() /]
+
+ [let p:Property][p/]
+
+ [/let]
+
+[/template]
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessorCommon.emtl b/tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessorCommon.emtl
new file mode 100644
index 0000000..9ee4d45
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessorCommon.emtl
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:mtl="http://www.eclipse.org/acceleo/mtl/0.8.0" xmlns:ocl.ecore="http://www.eclipse.org/ocl/1.1.0/Ecore">
+ <mtl:Module name="mtlCompletionProcessorCommon">
+ <input>
+ <takesTypesFrom href="http://www.eclipse.org/emf/2002/Ecore#/"/>
+ </input>
+ <ownedModuleElement xsi:type="mtl:Template" name="toUpperFirst" startPosition="71" endPosition="190" visibility="Public">
+ <body xsi:type="ocl.ecore:StringLiteralExp" startPosition="112" endPosition="115" stringSymbol="&#xD;&#xA;&#x9;"/>
+ <body xsi:type="ocl.ecore:OperationCallExp" startPosition="116" endPosition="175">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String"/>
+ <source xsi:type="ocl.ecore:OperationCallExp" startPosition="116" endPosition="142">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String"/>
+ <source xsi:type="ocl.ecore:OperationCallExp" startPosition="116" endPosition="132">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String"/>
+ <source xsi:type="ocl.ecore:VariableExp" startPosition="116" endPosition="117" referredVariable="/0/toUpperFirst/s">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </source>
+ <argument xsi:type="ocl.ecore:IntegerLiteralExp" startPosition="128" endPosition="129" integerSymbol="1">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/Integer"/>
+ </argument>
+ <argument xsi:type="ocl.ecore:IntegerLiteralExp" startPosition="130" endPosition="131" integerSymbol="1">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/Integer"/>
+ </argument>
+ <referredOperation xsi:type="ecore:EOperation" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String_Class/substring"/>
+ </source>
+ <referredOperation xsi:type="ecore:EOperation" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String_Class/toUpper"/>
+ </source>
+ <argument xsi:type="ocl.ecore:OperationCallExp" startPosition="150" endPosition="174">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String"/>
+ <source xsi:type="ocl.ecore:VariableExp" startPosition="150" endPosition="151" referredVariable="/0/toUpperFirst/s">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </source>
+ <argument xsi:type="ocl.ecore:IntegerLiteralExp" startPosition="162" endPosition="163" integerSymbol="2">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/Integer"/>
+ </argument>
+ <argument xsi:type="ocl.ecore:OperationCallExp" startPosition="165" endPosition="173">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/Integer"/>
+ <source xsi:type="ocl.ecore:VariableExp" startPosition="165" endPosition="166" referredVariable="/0/toUpperFirst/s">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </source>
+ <referredOperation xsi:type="ecore:EOperation" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String_Class/size"/>
+ </argument>
+ <referredOperation xsi:type="ecore:EOperation" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String_Class/substring"/>
+ </argument>
+ <referredOperation xsi:type="ecore:EOperation" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String_Class/concat"/>
+ </body>
+ <body xsi:type="ocl.ecore:StringLiteralExp" startPosition="177" endPosition="179" stringSymbol="&#xD;&#xA;"/>
+ <parameter name="s" startPosition="101" endPosition="110">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </parameter>
+ </ownedModuleElement>
+ </mtl:Module>
+ <ocl.ecore:Variable name="self">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </ocl.ecore:Variable>
+ <ecore:EPackage name="additions">
+ <eClassifiers xsi:type="ecore:EClass" name="EObject_Class">
+ <eAnnotations source="http://www.eclipse.org/ocl/1.1.0/OCL">
+ <references href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </eAnnotations>
+ <eOperations name="toUpperFirst">
+ <eAnnotations source="http://www.eclipse.org/ocl/1.1.0/OCL">
+ <contents xsi:type="ocl.ecore:Constraint"/>
+ </eAnnotations>
+ <eAnnotations source="MTL" references="/0/toUpperFirst"/>
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String"/>
+ <eParameters name="s">
+ <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eParameters>
+ </eOperations>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="EString_Class">
+ <eAnnotations source="http://www.eclipse.org/ocl/1.1.0/OCL">
+ <references href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eAnnotations>
+ <eOperations name="toUpperFirst">
+ <eAnnotations source="http://www.eclipse.org/ocl/1.1.0/OCL">
+ <contents xsi:type="ocl.ecore:Constraint"/>
+ </eAnnotations>
+ <eAnnotations source="MTL" references="/0/toUpperFirst"/>
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String"/>
+ </eOperations>
+ </eClassifiers>
+ </ecore:EPackage>
+ <ocl.ecore:Variable name="self">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String"/>
+ </ocl.ecore:Variable>
+ <ocl.ecore:Variable name="self">
+ <eType xsi:type="ocl.ecore:PrimitiveType" href="http://www.eclipse.org/ocl/1.1.0/oclstdlib.ecore#/0/String"/>
+ </ocl.ecore:Variable>
+ <ocl.ecore:Variable name="self">
+ <eType xsi:type="ecore:EClass" href="http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
+ </ocl.ecore:Variable>
+</xmi:XMI>
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessorCommon.mtl b/tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessorCommon.mtl
new file mode 100644
index 0000000..6fe6df5
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/data/template/mtlCompletionProcessorCommon.mtl
@@ -0,0 +1,4 @@
+[module mtlCompletionProcessorCommon(http://www.eclipse.org/emf/2002/Ecore)/]
+[template public toUpperFirst(s:EString)]
+ [s.substring(1,1).toUpper().concat(s.substring(2, s.size()))/]
+[/template] \ No newline at end of file
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/plugin.properties b/tests/org.eclipse.acceleo.ide.ui.tests/plugin.properties
new file mode 100644
index 0000000..9b155b9
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/plugin.properties
@@ -0,0 +1,25 @@
+#################################################################################
+# Copyright (c) 2008, 2009 Obeo.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Obeo - initial API and implementation
+#################################################################################
+
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# ====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# ====================================================================
+
+pluginName = Acceleo Eclipse User Interface Tests
+providerName = Eclipse Modeling Project
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/editors/template/AcceleoCompletionProcessorTests.java b/tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/editors/template/AcceleoCompletionProcessorTests.java
new file mode 100644
index 0000000..e23f2d9
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/editors/template/AcceleoCompletionProcessorTests.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.ide.ui.tests.editors.template;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.acceleo.internal.ide.ui.editors.template.AcceleoCompletionProcessor;
+import org.eclipse.acceleo.internal.ide.ui.editors.template.AcceleoSourceContent;
+import org.eclipse.acceleo.internal.parser.cst.utils.FileContent;
+import org.osgi.framework.Bundle;
+
+public class AcceleoCompletionProcessorTests extends TestCase {
+
+ private Bundle bundle;
+
+ private StringBuffer text;
+
+ private AcceleoCompletionProcessor processor;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ bundle = Platform.getBundle("org.eclipse.acceleo.ide.ui.tests");
+ assertNotNull(bundle);
+ assertFalse(EPackage.Registry.INSTANCE.isEmpty());
+ File file = createFile("/data/template/mtlCompletionProcessor.mtl");
+ text = FileContent.getFileContent(file);
+ AcceleoSourceContent content = new AcceleoSourceContent() {
+ public List<URI> getAccessibleOutputFiles() {
+ List<URI> dependencies = new ArrayList<URI>();
+ dependencies.add(createFileURI("/data/template/mtlCompletionProcessorCommon.emtl"));
+ return dependencies;
+ }
+ };
+ content.init(text);
+ content.createCST();
+ processor = new AcceleoCompletionProcessor(content);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ bundle = null;
+ }
+
+ private File createFile(String pathName) {
+ try {
+ String fileLocation = FileLocator.resolve(bundle.getEntry(pathName)).getPath();
+ return new File(fileLocation);
+ } catch (IOException e) {
+ throw new AssertionFailedError(e.getMessage());
+ }
+
+ }
+
+ private URI createFileURI(String pathName) {
+ try {
+ String fileLocation = FileLocator.resolve(bundle.getEntry(pathName)).getPath();
+ return URI.createFileURI(fileLocation);
+ } catch (IOException e) {
+ throw new AssertionFailedError(e.getMessage());
+ }
+ }
+
+ public void testModule() {
+ List<String> messages = new ArrayList<String>();
+ checkProposalsAt(messages, 1, 1, "");
+ checkProposalsAt(messages, 1, 69, "http://www.eclipse.org/emf/2002/Ecore");
+ checkProposalsAt(messages, 1, 71, "extends");
+ if (messages.size() > 0) {
+ fail(messages.toString());
+ }
+ }
+
+ public void testImport() {
+ List<String> messages = new ArrayList<String>();
+ checkProposalsAt(messages, 2, 1, "[import]$[template]$[query]$[macro]$[comment]");
+ checkProposalsAt(messages, 3, 9, "mtlCompletionProcessorCommon");
+ checkProposalsAt(messages, 4, 1, "[import]$[template]$[query]$[macro]$[comment]");
+ if (messages.size() > 0) {
+ fail(messages.toString());
+ }
+ }
+
+ public void testTemplate() {
+ List<String> messages = new ArrayList<String>();
+ checkProposalsAt(messages, 5, 41, "overrides$? ()${ }");
+ checkProposalsAt(messages, 5, 42, "overrides$? ()${ }");
+ checkProposalsAt(messages, 6, 5,
+ "[comment]$[ ]$[for]$[if]$[file] - @main$[file]$[let]$[trace]$[protected]$[super]$'['$']'$@main");
+ if (messages.size() > 0) {
+ fail(messages.toString());
+ }
+ }
+
+ public void testIf() {
+ List<String> messages = new ArrayList<String>();
+ checkProposalsAt(messages, 8, 5, "[elseif]$[else]$[comment]");
+ checkProposalsAt(messages, 10, 5, "[comment]$[ ]$[for]$[if]");
+ if (messages.size() > 0) {
+ fail(messages.toString());
+ }
+ }
+
+ public void testFor() {
+ List<String> messages = new ArrayList<String>();
+ checkProposalsAt(messages, 13, 24, "EClassifier");
+ checkProposalsAt(messages, 13, 35, "eClassifiers:EClassifier [0..*]");
+ checkProposalsAt(messages, 13, 43, "before ()$separator ()$after ()$? ()");
+ checkProposalsAt(messages, 13, 59, "Integer");
+ checkProposalsAt(messages, 17, 43, "before ()$after ()$? ()${ }");
+ checkProposalsAt(messages, 17, 57, "p:EPackage$self$classToJava() : String");
+ if (messages.size() > 0) {
+ fail(messages.toString());
+ }
+ }
+
+ public void testTemplateInvocation() {
+ List<String> messages = new ArrayList<String>();
+ checkProposalsAt(messages, 21, 10, "name:EString [0..1]");
+ checkProposalsAt(messages, 21, 22, "toLowerFirst() : String");
+ checkProposalsAt(messages, 21, 25, "before ()$separator ()$after ()");
+ if (messages.size() > 0) {
+ fail(messages.toString());
+ }
+ }
+
+ public void testLet() {
+ List<String> messages = new ArrayList<String>();
+ checkProposalsAt(messages, 23, 23,
+ "[ ]$[for]$[if]$[file] - @main$[file]$[let]$[trace]$[protected]$[super]$'['$p:EPackage");
+ checkProposalsAt(messages, 24, 5, "[elselet]$[else]$[comment]");
+ if (messages.size() > 0) {
+ fail(messages.toString());
+ }
+ }
+
+ private void checkProposalsAt(List<String> messages, int line, int column, String nrText) {
+ int offset = 0;
+ int offsetLine = 1;
+ int offsetColumn = 1;
+ while (offsetLine < line || (offsetLine == line && offsetColumn < column)) {
+ char c = text.charAt(offset);
+ if (c == '\n') {
+ offsetLine++;
+ offsetColumn = 1;
+ } else if (c == '\t') {
+ offsetColumn += 5;
+ } else {
+ offsetColumn++;
+ }
+ offset++;
+ }
+ ICompletionProposal[] proposals = processor.computeCompletionProposals(null, offset);
+ boolean ok;
+ StringTokenizer nrST = new StringTokenizer(nrText, "$");
+ int nrSTCount = nrST.countTokens();
+ if ((nrSTCount == 0 && proposals.length > 0) || (proposals.length < nrSTCount)) {
+ ok = false;
+ } else {
+ ok = true;
+ for (int i = 0; ok && i < nrSTCount; i++) {
+ String s1 = nrST.nextToken().trim();
+ int pos = s1.lastIndexOf(":");
+ if (pos > -1) {
+ s1 = s1.substring(0, pos).trim();
+ }
+ String s2 = proposals[i].getDisplayString().trim();
+ pos = s2.lastIndexOf(":");
+ if (pos > -1) {
+ s2 = s2.substring(0, pos).trim();
+ }
+ ok = s1.equals(s2);
+ }
+ }
+ if (!ok) {
+ StringBuffer text = new StringBuffer();
+ for (int i = 0; i < proposals.length; i++) {
+ text.append(proposals[i].getDisplayString().trim());
+ if (i + 1 < proposals.length) {
+ text.append('$');
+ }
+ }
+ String message = "\n[" + line + "," + column + "] : proposals not valid, NR=" + text.toString();
+ messages.add(message);
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/editors/template/rules/FirstVariableRuleTests.java b/tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/editors/template/rules/FirstVariableRuleTests.java
new file mode 100644
index 0000000..824bf48
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/editors/template/rules/FirstVariableRuleTests.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.ide.ui.tests.editors.template.rules;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.acceleo.internal.ide.ui.editors.template.rules.FirstVariableRule;
+
+public class FirstVariableRuleTests extends TestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testFirstVariableRuleTemplate() {
+ String[] previousWords = {"[", "template", "public", "name", "("};
+ String textBefore = "[template public name(";
+ String textRange = "a:Property";
+ String textAfter = ")]";
+ testFirstVariableRule(previousWords, textBefore, textRange, textAfter, true);
+ }
+
+ public void testFirstVariableRuleTemplateWithSpaces() {
+ String[] previousWords = {"[", "template", "public", "name", "("};
+ String textBefore = "[ template public name ( \t ";
+ String textRange = "a : Property";
+ String textAfter = " ) ] ";
+ testFirstVariableRule(previousWords, textBefore, textRange, textAfter, true);
+ }
+
+ public void testFirstVariableRuleTemplateNotValid() {
+ String[] previousWords = {"[", "template", "public", "name", "("};
+ String textBefore = "[template public BAD_STRING name(";
+ String textRange = "a:Property";
+ String textAfter = ")]";
+ testFirstVariableRule(previousWords, textBefore, textRange, textAfter, false);
+ }
+
+ public void testFirstVariableRuleTemplateWithUnknownParts() {
+ String[] previousWords = {"[", "template", "*", "*", "("};
+ String textBefore = "[template public name(";
+ String textRange = "a:Property";
+ String textAfter = ")]";
+ testFirstVariableRule(previousWords, textBefore, textRange, textAfter, true);
+ }
+
+ private void testFirstVariableRule(String[] previousWords, String textBefore, String textRange,
+ String textAfter, boolean isValid) {
+ RuleBasedScanner scanner = new RuleBasedScanner();
+ Document document = new Document(textBefore + textRange + textAfter);
+ scanner.setRange(document, textBefore.length(), textRange.length());
+ FirstVariableRule rule = new FirstVariableRule(previousWords, null);
+ if (isValid) {
+ assertEquals(rule.read(scanner), textRange.length());
+ } else {
+ assertNotSame(rule.read(scanner), textRange.length());
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/suite/AllTests.java b/tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/suite/AllTests.java
new file mode 100644
index 0000000..06d0d0c
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/src/org/eclipse/acceleo/ide/ui/tests/suite/AllTests.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Obeo.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.acceleo.ide.ui.tests.suite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.eclipse.acceleo.ide.ui.tests.editors.template.AcceleoCompletionProcessorTests;
+import org.eclipse.acceleo.ide.ui.tests.editors.template.rules.FirstVariableRuleTests;
+
+/**
+ * This suite will launch all the tests defined for the Acceleo Eclipse User Interface Tests Plug-in.
+ *
+ * @author <a href="mailto:jonathan.musset@obeo.fr">Jonathan Musset</a>
+ */
+public class AllTests {
+
+ /**
+ * Launches the test with the given arguments.
+ *
+ * @param args
+ * Arguments of the testCase.
+ */
+ public static void main(String[] args) {
+ TestRunner.run(suite());
+ }
+
+ /**
+ * Creates the {@link junit.framework.TestSuite TestSuite} for all the test.
+ *
+ * @return The test suite containing all the tests
+ */
+ public static Test suite() {
+ final TestSuite suite = new TestSuite("Acceleo User Interface test suite");
+ suite.addTestSuite(AcceleoCompletionProcessorTests.class);
+ suite.addTestSuite(FirstVariableRuleTests.class);
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.acceleo.ide.ui.tests/test.xml b/tests/org.eclipse.acceleo.ide.ui.tests/test.xml
new file mode 100644
index 0000000..b163acd
--- /dev/null
+++ b/tests/org.eclipse.acceleo.ide.ui.tests/test.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!--
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2008, 2009 Obeo and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: test.xml,v 1.1 2009/03/05 16:32:28 jmusset Exp $
+ */
+-->
+
+<project name="testsuite" default="run" basedir=".">
+ <!-- The property ${eclipse-home} should be passed into this script -->
+ <!-- Set a meaningful default value for when it is not. -->
+ <property name="eclipse-home" value="${basedir}\..\.."/>
+
+ <!-- sets the properties plugin-name, and library-file -->
+ <property name="plugin-name" value="org.eclipse.acceleo.ide.ui.tests"/>
+ <property name="library-file" value="${eclipse-home}/dropins/eclipse/plugins/org.eclipse.test/library.xml"/>
+
+ <!-- This target holds all initialization code that needs to be done for -->
+ <!-- all tests that are to be run. Initialization for individual tests -->
+ <!-- should be done within the body of the suite target. -->
+ <target name="init">
+ <tstamp/>
+ <delete>
+ <fileset dir="${eclipse-home}" includes="org*.xml"/>
+ </delete>
+ </target>
+
+ <!-- This target defines the tests that need to be run. -->
+ <target name="suite">
+ <property name="m2t-folder" value="${eclipse-home}/emf_folder"/>
+ <delete dir="${m2t-folder}" quiet="true"/>
+ <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="data-dir" value="${m2t-folder}"/>
+ <property name="plugin-name" value="${plugin-name}"/>
+ <property name="classname" value="org.eclipse.acceleo.ide.ui.tests.suite.AllTests"/>
+ </ant>
+ </target>
+
+ <!-- This target holds code to cleanup the testing environment after -->
+ <!-- after all of the tests have been run. You can use this target to -->
+ <!-- delete temporary files that have been created. -->
+ <target name="cleanup">
+ </target>
+
+ <!-- This target runs the test suite. Any actions that need to happen -->
+ <!-- after all the tests have been run should go here. -->
+ <target name="run" depends="init,suite,cleanup">
+ <ant target="collect" antfile="${library-file}" dir="${eclipse-home}">
+ <property name="includes" value="org*.xml"/>
+ <property name="output-file" value="${plugin-name}.xml"/>
+ </ant>
+ </target>
+
+</project>