diff --git a/dsl/org.eclipse.emf.parsley.dsl.ui.tests/.classpath b/dsl/org.eclipse.emf.parsley.dsl.ui.tests/.classpath index 8bf64762d..6ea81b1e6 100644 --- a/dsl/org.eclipse.emf.parsley.dsl.ui.tests/.classpath +++ b/dsl/org.eclipse.emf.parsley.dsl.ui.tests/.classpath @@ -3,7 +3,6 @@ - diff --git a/dsl/org.eclipse.emf.parsley.dsl.ui.tests/additional/org/eclipse/xtext/ui/tests/editor/outline/AbstractOutlineWorkbenchTest.java b/dsl/org.eclipse.emf.parsley.dsl.ui.tests/additional/org/eclipse/xtext/ui/tests/editor/outline/AbstractOutlineWorkbenchTest.java deleted file mode 100644 index 768ade35f..000000000 --- a/dsl/org.eclipse.emf.parsley.dsl.ui.tests/additional/org/eclipse/xtext/ui/tests/editor/outline/AbstractOutlineWorkbenchTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 itemis AG (http://www.itemis.eu) 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 - *******************************************************************************/ -package org.eclipse.xtext.ui.tests.editor.outline; - -import static org.eclipse.xtext.junit4.ui.util.IResourcesSetupUtil.addNature; -import static org.eclipse.xtext.junit4.ui.util.JavaProjectSetupUtil.createJavaProject; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.xtext.junit4.ui.AbstractEditorTest; -import org.eclipse.xtext.junit4.ui.util.IResourcesSetupUtil; -import org.eclipse.xtext.resource.FileExtensionProvider; -import org.eclipse.xtext.ui.XtextProjectHelper; -import org.eclipse.xtext.ui.editor.XtextEditor; -import org.eclipse.xtext.ui.editor.model.IXtextDocument; -import org.eclipse.xtext.ui.editor.outline.IOutlineNode; -import org.eclipse.xtext.ui.editor.outline.IOutlineTreeProvider; - -import com.google.inject.Inject; - -/** - * @author Jan Koehnlein - Initial contribution and API - * @author Lorenzo Bettini - Adapted to be used for any DSL - */ -public abstract class AbstractOutlineWorkbenchTest extends AbstractEditorTest { - - protected static int TAB_INDENT = 2; - - protected static String TEST_PROJECT = "test"; - - protected IFile file; - protected XtextEditor editor; - protected IXtextDocument document; - - public String fileExtension; - - @Inject - protected IOutlineTreeProvider treeProvider; - - @Inject - public void setFileExtensionProvider(FileExtensionProvider extensionProvider) { - fileExtension = extensionProvider.getPrimaryFileExtension(); - } - - @Override - public void setUp() throws Exception { - super.setUp(); - createjavaProject(TEST_PROJECT); - } - - protected IJavaProject createjavaProject(String projectName) throws CoreException { - IJavaProject javaProject = createJavaProject(projectName); - addNature(javaProject.getProject(), XtextProjectHelper.NATURE_ID); - return javaProject; - } - - @Override - public void tearDown() throws Exception { - super.tearDown(); - editor.close(false); - } - - protected IOutlineNode getOutlineTree(CharSequence modelAsText) - throws Exception { - file = IResourcesSetupUtil.createFile(TEST_PROJECT + "/test." - + fileExtension, modelAsText.toString()); - editor = openEditor(file); - document = editor.getDocument(); - return treeProvider.createRoot(document); - } - - /** - * The root node of the outline of the passed program - * is expanded and a string representation of the tree is - * built where children are indented of TAB_INDENT number of tabs; this - * string representation is then compared with the expected representation. - * - * @param modelAsText - * @param expected - * @throws Exception - */ - protected void assertAllLabels(CharSequence modelAsText, CharSequence expected) throws Exception { - assertAllLabels(getOutlineTree(modelAsText), expected); - } - - /** - * The outline node is expanded and a string representation of the tree is - * built where children are indented of TAB_INDENT number of tabs; this - * string representation is then compared with the expected representation. - * - * @param rootNode - * @param expected - */ - protected void assertAllLabels(IOutlineNode rootNode, CharSequence expected) { - assertEquals(expected.toString().trim().replaceAll("\r", ""), - outlineStringRepresentation(rootNode).trim()); - } - - protected String outlineStringRepresentation(IOutlineNode node) { - StringBuffer buffer = new StringBuffer(); - outlineStringRepresentation(node, buffer, 0); - return buffer.toString(); - } - - protected void outlineStringRepresentation(IOutlineNode node, - StringBuffer buffer, int tabs) { - if (getNodeText(node) != "") { - addToStringRepresentation(node, buffer, tabs); - tabs += TAB_INDENT; - } - for (IOutlineNode child : node.getChildren()) { - addToStringRepresentation(child, buffer, tabs); - if (child.hasChildren()) { - for (IOutlineNode child2 : child.getChildren()) { - outlineStringRepresentation(child2, buffer, tabs + TAB_INDENT); - } - } - } - } - - protected void addToStringRepresentation(IOutlineNode node, - StringBuffer buffer, int tabs) { - indent(buffer, tabs); - buffer.append(getNodeText(node) + "\n"); - } - - protected String getNodeText(IOutlineNode node) { - return node.getText().toString(); - } - - protected void indent(StringBuffer buffer, int tabs) { - for (int i = 0; i < tabs; ++i) { - buffer.append(" "); - } - } - -} diff --git a/dsl/org.eclipse.emf.parsley.dsl.ui.tests/build.properties b/dsl/org.eclipse.emf.parsley.dsl.ui.tests/build.properties index 76c3f72de..c9446bbb8 100644 --- a/dsl/org.eclipse.emf.parsley.dsl.ui.tests/build.properties +++ b/dsl/org.eclipse.emf.parsley.dsl.ui.tests/build.properties @@ -1,6 +1,5 @@ source.. = src/,\ src-gen/,\ - xtend-gen/,\ - additional/ + xtend-gen/ bin.includes = .,\ META-INF/ diff --git a/dsl/org.eclipse.emf.parsley.dsl.ui.tests/src/org/eclipse/emf/parsley/dsl/ui/tests/EmfParsleyDslOutlineTest.xtend b/dsl/org.eclipse.emf.parsley.dsl.ui.tests/src/org/eclipse/emf/parsley/dsl/ui/tests/EmfParsleyDslOutlineTest.xtend index 19bab9ef7..71d728651 100644 --- a/dsl/org.eclipse.emf.parsley.dsl.ui.tests/src/org/eclipse/emf/parsley/dsl/ui/tests/EmfParsleyDslOutlineTest.xtend +++ b/dsl/org.eclipse.emf.parsley.dsl.ui.tests/src/org/eclipse/emf/parsley/dsl/ui/tests/EmfParsleyDslOutlineTest.xtend @@ -13,7 +13,7 @@ package org.eclipse.emf.parsley.dsl.ui.tests import org.eclipse.emf.parsley.dsl.ui.internal.DslActivator import org.eclipse.xtext.junit4.InjectWith import org.eclipse.xtext.junit4.XtextRunner -import org.eclipse.xtext.ui.tests.editor.outline.AbstractOutlineWorkbenchTest +import org.eclipse.xtext.junit4.ui.AbstractOutlineTest import org.junit.Test import org.junit.runner.RunWith @@ -22,7 +22,7 @@ import org.junit.runner.RunWith */ @RunWith(typeof(XtextRunner)) @InjectWith(typeof(EmfParsleyDslUiInjectorProvider)) -class EmfParsleyDslOutlineTest extends AbstractOutlineWorkbenchTest { +class EmfParsleyDslOutlineTest extends AbstractOutlineTest { override protected getEditorId() { DslActivator.ORG_ECLIPSE_EMF_PARSLEY_DSL_EMFPARSLEYDSL