set up performance tests
diff --git a/org.eclipse.core.filebuffers.tests/build.properties b/org.eclipse.core.filebuffers.tests/build.properties
index 8022cfc..065209c 100644
--- a/org.eclipse.core.filebuffers.tests/build.properties
+++ b/org.eclipse.core.filebuffers.tests/build.properties
@@ -11,6 +11,5 @@
bin.includes = plugin.xml,\
test.xml,\
about.html,\
- testResources/,\
*.jar,\
source.javauitests.jar = src/
diff --git a/org.eclipse.core.filebuffers.tests/plugin.xml b/org.eclipse.core.filebuffers.tests/plugin.xml
index e07bcba..19e6715 100644
--- a/org.eclipse.core.filebuffers.tests/plugin.xml
+++ b/org.eclipse.core.filebuffers.tests/plugin.xml
@@ -5,7 +5,7 @@
name="%Plugin.name"
version="3.0.0"
provider-name="%Plugin.providerName"
- class="org.eclipse.core.filebuffers.tests.FilebuffersTestPlugin">
+ class="">
<runtime>
<library name="filebufferstests.jar">
@@ -13,12 +13,8 @@
</library>
</runtime>
<requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.junit"/>
- <import plugin="org.eclipse.core.filebuffers"/>
- <import plugin="org.eclipse.text"/>
</requires>
-
-
+
</plugin>
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferTest1.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferTest1.java
deleted file mode 100644
index b74e5ac..0000000
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBufferTest1.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers.tests;
-
-import java.io.File;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-
-
-public class FileBufferTest1 extends TestCase {
-
- private final static String CONTENT1= "This is the content of the workspace file.";
- private final static String CONTENT2= "This is the content of the link target.";
- private final static String CONTENT3= "This is the content of the external file.";
-
-
- private IProject fProject;
-
-
- public static Test suite() {
- TestSuite suite= new TestSuite();
- suite.addTest(new FileBufferTest1("test1"));
- suite.addTest(new FileBufferTest1("test2"));
- suite.addTest(new FileBufferTest1("test3"));
- suite.addTest(new FileBufferTest1("test4"));
- suite.addTest(new FileBufferTest1("test5"));
- suite.addTest(new FileBufferTest1("test6"));
- return suite;
- }
-
- public FileBufferTest1(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- fProject= TestHelper.createProject("project");
- }
-
- protected void tearDown() throws Exception {
- TestHelper.deleteProject("project");
- }
-
- public void test1() throws Exception {
- IFolder folder= TestHelper.createFolder("project/folderA/folderB/");
- IFile file= TestHelper.createFile(folder, "file", CONTENT1);
- IPath path= file.getFullPath();
- assertNotNull(path);
-
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.connect(path, null);
- ITextFileBuffer buffer= manager.getTextFileBuffer(path);
- assertNotNull(buffer);
-
- IDocument document= buffer.getDocument();
- assertNotNull(document);
- assertEquals(CONTENT1, document.get());
-
- manager.disconnect(path, null);
- assertNull(manager.getTextFileBuffer(path));
- }
-
- public void test2() throws Exception {
-
- IFolder folder= TestHelper.createFolder("project/folderA/folderB/");
- IFile file= TestHelper.createFile(folder, "file", CONTENT1);
- IPath path1= file.getFullPath();
- assertNotNull(path1);
-
- IPath path2= ResourcesPlugin.getWorkspace().getRoot().getLocation();
- path2= path2.append(path1.makeAbsolute());
-
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.connect(path1, null);
- ITextFileBuffer buffer1= manager.getTextFileBuffer(path1);
- assertNotNull(buffer1);
-
- ITextFileBuffer buffer2= manager.getTextFileBuffer(path2);
- assertNotNull(buffer2);
-
- manager.connect(path2, null);
- buffer2= manager.getTextFileBuffer(path2);
- assertNotNull(buffer2);
-
- IDocument document1= buffer1.getDocument();
- assertNotNull(document1);
- assertEquals(CONTENT1, document1.get());
-
- IDocument document2= buffer2.getDocument();
- assertNotNull(document2);
- assertEquals(CONTENT1, document2.get());
-
- try {
- document1.replace(0, document1.getLength(), CONTENT3);
- } catch (BadLocationException x) {
- assertTrue(false);
- }
-
- assertEquals(CONTENT3, document2.get());
-
- manager.disconnect(path1, null);
- assertNotNull(manager.getTextFileBuffer(path1));
- assertNotNull(manager.getTextFileBuffer(path2));
-
- manager.disconnect(path2, null);
- assertNull(manager.getTextFileBuffer(path1));
- assertNull(manager.getTextFileBuffer(path2));
- }
-
- public void test3() throws Exception {
- IPath path= createLinkedFile("file", "testResources/LinkTarget1");
- assertNotNull(path);
-
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.connect(path, null);
- ITextFileBuffer buffer= manager.getTextFileBuffer(path);
- Assert.assertNotNull(buffer);
-
- IDocument document= buffer.getDocument();
- Assert.assertNotNull(document);
- Assert.assertTrue(CONTENT2.equals(document.get()));
-
- manager.disconnect(path, null);
- assertNull(manager.getTextFileBuffer(path));
- }
-
- public void test4() throws Exception {
-
- IPath path1= createLinkedFile("file1", "testResources/LinkTarget1");
- assertNotNull(path1);
- IPath path2= createLinkedFile("file2", "testResources/LinkTarget1");
- assertNotNull(path2);
-
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.connect(path1, null);
- ITextFileBuffer buffer1= manager.getTextFileBuffer(path1);
- assertNotNull(buffer1);
- manager.connect(path2, null);
- ITextFileBuffer buffer2= manager.getTextFileBuffer(path2);
- assertNotNull(buffer2);
-
- IDocument document1= buffer1.getDocument();
- assertNotNull(document1);
- IDocument document2= buffer2.getDocument();
- assertNotNull(document2);
-
- assertEquals(document1.get(), document2.get());
- assertEquals(CONTENT2, document1.get());
-
- try {
- document1.replace(0, document1.getLength(), CONTENT1);
- } catch (BadLocationException x) {
- Assert.assertFalse(false);
- }
-
- assertFalse(document1.get().equals(document2.get()));
-
- manager.disconnect(path1, null);
- assertNull(manager.getTextFileBuffer(path1));
- manager.disconnect(path2, null);
- assertNull(manager.getTextFileBuffer(path2));
- }
-
- public void test5() throws Exception {
- File externalFile= TestHelper.getFileInPlugin(FilebuffersTestPlugin.getDefault(), new Path("testResources/ExternalFile"));
- assertNotNull(externalFile);
- IPath path= new Path(externalFile.getAbsolutePath());
-
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.connect(path, null);
- ITextFileBuffer buffer= manager.getTextFileBuffer(path);
- assertNotNull(buffer);
-
- IDocument document= buffer.getDocument();
- assertNotNull(document);
- assertTrue(CONTENT3.equals(document.get()));
-
- manager.disconnect(path, null);
- assertNull(manager.getTextFileBuffer(path));
- }
-
- public void test6() throws Exception {
-
- IPath path1= createLinkedFile("file1", "testResources/ExternalFile");
- assertNotNull(path1);
-
- File externalFile= TestHelper.getFileInPlugin(FilebuffersTestPlugin.getDefault(), new Path("testResources/ExternalFile"));
- assertNotNull(externalFile);
- IPath path2= new Path(externalFile.getAbsolutePath());
-
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.connect(path1, null);
- ITextFileBuffer buffer1= manager.getTextFileBuffer(path1);
- assertNotNull(buffer1);
- manager.connect(path2, null);
- ITextFileBuffer buffer2= manager.getTextFileBuffer(path2);
- assertNotNull(buffer2);
-
- IDocument document1= buffer1.getDocument();
- assertNotNull(document1);
- IDocument document2= buffer2.getDocument();
- assertNotNull(document2);
-
- assertEquals(document1.get(), document2.get());
- assertEquals(CONTENT3, document1.get());
-
- try {
- document1.replace(0, document1.getLength(), CONTENT1);
- } catch (BadLocationException x) {
- Assert.assertFalse(false);
- }
-
- assertFalse(document1.get().equals(document2.get()));
-
- manager.disconnect(path1, null);
- assertNull(manager.getTextFileBuffer(path1));
- manager.disconnect(path2, null);
- assertNull(manager.getTextFileBuffer(path2));
- }
-
- private IPath createLinkedFile(String fileName, String linkTarget) throws CoreException {
- IFile file= TestHelper.createLinkedFile(fProject, new Path(fileName), FilebuffersTestPlugin.getDefault(), new Path(linkTarget));
- return file != null ? file.getFullPath() : null;
- }
-}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FilebuffersTestPlugin.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FilebuffersTestPlugin.java
deleted file mode 100644
index 3115138..0000000
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FilebuffersTestPlugin.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-
-/**
- * The main plug-in class to be used in the desktop.
- *
- * @since 3.0
- */
-public class FilebuffersTestPlugin extends Plugin {
- //The shared instance.
- private static FilebuffersTestPlugin fPlugin;
-
- /**
- * The constructor.
- */
- public FilebuffersTestPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- fPlugin = this;
- }
-
- /**
- * Returns the shared instance.
- */
- public static FilebuffersTestPlugin getDefault() {
- return fPlugin;
- }
-
- /**
- * Returns the workspace instance.
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- public static File getFileInPlugin(Plugin plugin, IPath path) {
- try {
- URL installURL= new URL(plugin.getDescriptor().getInstallURL(), path.toString());
- URL localURL= Platform.asLocalURL(installURL);
- return new File(localURL.getFile());
- } catch (IOException e) {
- return null;
- }
- }
-}
diff --git a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/TestHelper.java b/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/TestHelper.java
deleted file mode 100644
index b789eed..0000000
--- a/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/TestHelper.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2003 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.core.filebuffers.tests;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringBufferInputStream;
-import java.net.URL;
-
-import org.eclipse.core.internal.filebuffers.ContainerGenerator;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-
-/**
- * @since 3.0
- */
-public class TestHelper {
-
- private final static IProgressMonitor NULL_MONITOR= new NullProgressMonitor();
- private static final int MAX_RETRY= 5;
-
- public static File getFileInPlugin(Plugin plugin, IPath path) {
- try {
- URL installURL= new URL(plugin.getDescriptor().getInstallURL(), path.toString());
- URL localURL= Platform.asLocalURL(installURL);
- return new File(localURL.getFile());
- } catch (IOException e) {
- return null;
- }
- }
-
- public static IProject createProject(String projectName) throws CoreException {
-
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- IProject project= root.getProject(projectName);
- if (!project.exists())
- project.create(NULL_MONITOR);
- else
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- if (!project.isOpen())
- project.open(NULL_MONITOR);
-
- return project;
- }
-
- public static void deleteProject(String projectName) throws CoreException {
- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
- IProject project= root.getProject(projectName);
- if (project.exists())
- delete(project);
- }
-
- public static void delete(final IProject project) throws CoreException {
- for (int i= 0; i < MAX_RETRY; i++) {
- try {
- project.delete(true, true, NULL_MONITOR);
- i= MAX_RETRY;
- } catch (CoreException x) {
- if (i == MAX_RETRY - 1) {
- FilebuffersTestPlugin.getDefault().getLog().log(x.getStatus());
- throw x;
- }
- try {
- Thread.sleep(1000); // sleep a second
- } catch (InterruptedException e) {
- }
- }
- }
- }
-
- public static IFolder createFolder(String folderPath) throws CoreException {
- ContainerGenerator generator= new ContainerGenerator(ResourcesPlugin.getWorkspace(), new Path(folderPath));
- IContainer container= generator.generateContainer(NULL_MONITOR);
- if (container instanceof IFolder)
- return (IFolder) container;
- return null;
- }
-
- public static IFile createFile(IFolder folder, String name, String contents) throws CoreException {
- IFile file= folder.getFile(name);
- if (contents == null)
- contents= "";
- InputStream inputStream= new StringBufferInputStream(contents);
- file.create(inputStream, true, NULL_MONITOR);
- return file;
- }
-
- public static IFile createLinkedFile(IContainer container, IPath filePath, Plugin plugin, IPath linkPath) throws CoreException {
- IFile iFile= container.getFile(filePath);
- File file= getFileInPlugin(plugin, linkPath);
- iFile.createLink(new Path(file.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR);
- return iFile;
- }
-
- public static IFolder createLinkedFolder(IContainer container, IPath folderPath, Plugin plugin, IPath linkPath) throws CoreException {
- IFolder iFolder= container.getFolder(folderPath);
- File file= getFileInPlugin(plugin, linkPath);
- iFolder.createLink(new Path(file.getAbsolutePath()), IResource.ALLOW_MISSING_LOCAL, NULL_MONITOR);
- return iFolder;
- }
-
- public static IProject createLinkedProject(String projectName, Plugin plugin, IPath linkPath) throws CoreException {
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IProject project= workspace.getRoot().getProject(projectName);
-
- IProjectDescription desc= workspace.newProjectDescription(projectName);
- File file= getFileInPlugin(plugin, linkPath);
- IPath projectLocation= new Path(file.getAbsolutePath());
- if (Platform.getLocation().equals(projectLocation))
- projectLocation= null;
- desc.setLocation(projectLocation);
-
- project.create(desc, NULL_MONITOR);
- if (!project.isOpen())
- project.open(NULL_MONITOR);
-
- return project;
- }
-}
diff --git a/org.eclipse.core.filebuffers.tests/test.xml b/org.eclipse.core.filebuffers.tests/test.xml
index d6b8b99..9ddfe13 100644
--- a/org.eclipse.core.filebuffers.tests/test.xml
+++ b/org.eclipse.core.filebuffers.tests/test.xml
@@ -20,19 +20,6 @@
</delete>
</target>
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="core-filebuffers-folder"
- value="${eclipse-home}/core_filebuffers_folder"/>
- <delete dir="${core-filebuffers-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${core-filebuffers-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.core.filebuffers.tests.FileBuffersTestSuite"/>
- </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. -->
@@ -41,13 +28,11 @@
<!-- 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 name="run">
</target>
+ <!-- This target runs the performance test suites. -->
<target name="performance">
</target>
+
</project>
diff --git a/org.eclipse.core.filebuffers.tests/testResources/ExternalFile b/org.eclipse.core.filebuffers.tests/testResources/ExternalFile
deleted file mode 100644
index 165dae0..0000000
--- a/org.eclipse.core.filebuffers.tests/testResources/ExternalFile
+++ /dev/null
@@ -1 +0,0 @@
-This is the content of the external file.
\ No newline at end of file
diff --git a/org.eclipse.core.filebuffers.tests/testResources/LinkTarget1 b/org.eclipse.core.filebuffers.tests/testResources/LinkTarget1
deleted file mode 100644
index d80dbfd..0000000
--- a/org.eclipse.core.filebuffers.tests/testResources/LinkTarget1
+++ /dev/null
@@ -1 +0,0 @@
-This is the content of the link target.
\ No newline at end of file
diff --git a/org.eclipse.jface.text.tests/JFaceTextSuite.launch b/org.eclipse.jface.text.tests/JFaceTextSuite.launch
deleted file mode 100644
index 1908eb8..0000000
--- a/org.eclipse.jface.text.tests/JFaceTextSuite.launch
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.jface.text.tests.JFaceTextSuite"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.jface.text.tests"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Djava.library.path=${workspace_loc}\org.eclipse.swt.win32\os\win32\x86"/>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
-<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.debug.ui.javaSourceLocator"/>
-</launchConfiguration>
diff --git a/org.eclipse.jface.text.tests/plugin.xml b/org.eclipse.jface.text.tests/plugin.xml
index 47e2386..a1fbff2 100644
--- a/org.eclipse.jface.text.tests/plugin.xml
+++ b/org.eclipse.jface.text.tests/plugin.xml
@@ -13,12 +13,9 @@
</library>
</runtime>
<requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.text"/>
<import plugin="org.eclipse.jface.text"/>
<import plugin="org.eclipse.jface"/>
<import plugin="org.junit"/>
</requires>
-
-
+
</plugin>
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/JFaceTextSuite.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/JFaceTextSuite.java
deleted file mode 100644
index 3afee0c..0000000
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/JFaceTextSuite.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Test JFace/Text.
- */
-public class JFaceTextSuite extends TestSuite {
-
- /**
- * Returns the suite. This is required to use the JUnit Launcher.
- */
- public static Test suite() {
- return new JFaceTextSuite();
- }
-
- /**
- * Construct the test suite.
- */
- public JFaceTextSuite() {
- addTest(TextHoverPopupTest.suite());
- addTest(TextPresentationTest.suite());
- addTest(TextUtilitiesTest.suite());
- addTest(UndoManagerTest.suite());
- }
-}
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextEvent.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextEvent.java
deleted file mode 100644
index 9b0f7b6..0000000
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextEvent.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.tests;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.TextEvent;
-
-
-public class TestTextEvent extends TextEvent {
-
- TestTextEvent(DocumentEvent event, String replacedText) {
- super(event.getOffset(), event.getLength(), event.getText(), replacedText, event, true);
- }
-
- TestTextEvent(String text) {
- super(0, 0, text, (String) null, (DocumentEvent) null, true);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java
deleted file mode 100644
index e74f814..0000000
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TestTextViewer.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.tests;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IAutoIndentStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IEventConsumer;
-import org.eclipse.jface.text.IFindReplaceTarget;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.IUndoManager;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.viewers.ISelectionProvider;
-
-
-
-
-public class TestTextViewer implements ISourceViewer, IDocumentListener {
-
-
- protected IDocument fDocument;
- protected List fInputListeners= new ArrayList();
- protected List fTextListeners= new ArrayList();
- protected TextPresentation fTextPresentation;
- protected Point fSelection= new Point(-1, -1);
- protected String fDeletion;
-
- /**
- * @see ITextViewer#setDocument(IDocument, int, int)
- */
- public void setDocument(IDocument document, int p1, int p2) {
- setDocument(document);
- }
-
- /**
- * @see ITextViewer#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * @see ITextViewer#setDocument(IDocument)
- */
- public void setDocument(IDocument document) {
- IDocument oldDoc= fDocument;
- fireTextInputChanged(oldDoc, document, true);
-
- if (oldDoc != null)
- oldDoc.removeDocumentListener(this);
-
- fDocument= document;
-
- if (fDocument != null) {
- fireTextChanged(new TestTextEvent(fDocument.get()));
- fDocument.addDocumentListener(this);
- }
-
- fireTextInputChanged(oldDoc, document, false);
- }
-
- /**
- * @see ITextViewer#removeTextInputListener(ITextInputListener)
- */
- public void removeTextInputListener(ITextInputListener listener) {
- fInputListeners.remove(listener);
- }
-
- /**
- * @see ITextViewer#addTextInputListener(ITextInputListener)
- */
- public void addTextInputListener(ITextInputListener listener) {
- if (!fInputListeners.contains(listener))
- fInputListeners.add(listener);
- }
-
- protected void fireTextInputChanged(IDocument oldDoc, IDocument newDoc, boolean about) {
- Iterator e= new ArrayList(fInputListeners).iterator();
- while (e.hasNext()) {
- ITextInputListener l= (ITextInputListener) e.next();
- if (about)
- l.inputDocumentAboutToBeChanged(oldDoc, newDoc);
- else
- l.inputDocumentChanged(oldDoc, newDoc);
- }
- }
-
- /**
- * @see ITextViewer#changeTextPresentation(TextPresentation, boolean)
- */
- public void changeTextPresentation(TextPresentation presentation, boolean p1) {
- fTextPresentation= presentation;
- }
-
- /**
- * @see ITextViewer#invalidateTextPresentation()
- */
- public void invalidateTextPresentation() {
- }
-
- public TextPresentation getTextPresentation() {
- return fTextPresentation;
- }
-
- public void documentAboutToBeChanged(DocumentEvent event) {
- try {
- fDeletion= fDocument.get(event.getOffset(), event.getLength());
- } catch (BadLocationException x) {
- }
- }
-
- public void documentChanged(DocumentEvent event) {
- fireTextChanged(new TestTextEvent(event, fDeletion));
- }
-
- /**
- * @see ITextViewer#getFindReplaceTarget()
- */
- public IFindReplaceTarget getFindReplaceTarget() {
- return null;
- }
-
- /**
- * @see ITextViewer#getTextOperationTarget()
- */
- public ITextOperationTarget getTextOperationTarget() {
- return null;
- }
-
- /**
- * @see ITextViewer#setTextColor(Color, int, int, boolean)
- */
- public void setTextColor(Color p0, int p1, int p2, boolean p3) {
- }
-
- /**
- * @see ITextViewer#setTextColor(Color)
- */
- public void setTextColor(Color p0) {
- }
-
- /**
- * @see ITextViewer#adjustVisibleRegion(int, int)
- */
- public void adjustVisibleRegion(int p0, int p1) {
- }
-
- /**
- * @see ITextViewer#overlapsWithVisibleRegion(int, int)
- */
- public boolean overlapsWithVisibleRegion(int p0, int p1) {
- return false;
- }
-
- /**
- * @see ITextViewer#getVisibleRegion()
- */
- public IRegion getVisibleRegion() {
- return null;
- }
-
- /**
- * @see ITextViewer#resetVisibleRegion()
- */
- public void resetVisibleRegion() {
- }
-
- /**
- * @see ITextViewer#setVisibleRegion(int, int)
- */
- public void setVisibleRegion(int p0, int p1) {
- }
-
- /**
- * @see ITextViewer#setIndentPrefixes(String[], String)
- */
- public void setIndentPrefixes(String[] p0, String p1) {
- }
-
- /**
- * @see ITextViewer#setDefaultPrefixes(String, String)
- */
- public void setDefaultPrefixes(String[] p0, String p1) {
- }
-
- /**
- * @see ITextViewer#setAutoIndentStrategy(IAutoIndentStrategy, String)
- */
- public void setAutoIndentStrategy(IAutoIndentStrategy p0, String p1) {
- }
-
- /**
- * @see ITextViewer#setTextDoubleClickStrategy(ITextDoubleClickStrategy, String)
- */
- public void setTextDoubleClickStrategy(ITextDoubleClickStrategy p0, String p1) {
- }
-
- /**
- * @see ITextViewer#setUndoManager(IUndoManager)
- */
- public void setUndoManager(IUndoManager p0) {
- }
-
- /**
- * @see ITextViewer#getTextWidget()
- */
- public StyledText getTextWidget() {
- return null;
- }
-
- public void setTextHover(ITextHover p0, String p1) {
- }
-
- /**
- * @see ITextViewer#activatePlugins()
- */
- public void activatePlugins() {
- }
-
- /**
- * @see ITextViewer#resetPlugins()
- */
- public void resetPlugins() {
- }
-
- /**
- * @see ITextViewer#getTopInset()
- */
- public int getTopInset() {
- return 0;
- }
-
- /**
- * @see ITextViewer#getBottomIndexEndOffset()
- */
- public int getBottomIndexEndOffset() {
- return 0;
- }
-
- /**
- * @see ITextViewer#getBottomIndex()
- */
- public int getBottomIndex() {
- return 0;
- }
-
- /**
- * @see ITextViewer#getTopIndexStartOffset()
- */
- public int getTopIndexStartOffset() {
- return 0;
- }
-
- /**
- * @see ITextViewer#getTopIndex()
- */
- public int getTopIndex() {
- return 0;
- }
-
- /**
- * @see ITextViewer#setTopIndex(int)
- */
- public void setTopIndex(int p0) {
- }
-
- /**
- * @see ITextViewer#revealRange(int, int)
- */
- public void revealRange(int p0, int p1) {
- }
-
- /**
- * @see ITextViewer#getSelectedRange()
- */
- public Point getSelectedRange() {
- return fSelection;
- }
-
- /**
- * @see ITextViewer#setSelectedRange(int, int)
- */
- public void setSelectedRange(int offset, int length) {
- fSelection.x= offset;
- fSelection.y= length;
- }
-
- /**
- * @see ITextViewer#isEditable()
- */
- public boolean isEditable() {
- return true;
- }
-
- /**
- * @see ITextViewer#setEditable(boolean)
- */
- public void setEditable(boolean p0) {
- }
-
- /**
- * @see ITextViewer#setEventConsumer(IEventConsumer)
- */
- public void setEventConsumer(IEventConsumer p0) {
- }
-
- /**
- * @see ITextViewer#removeTextListener(ITextListener)
- */
- public void removeTextListener(ITextListener listener) {
- fTextListeners.remove(listener);
- }
-
- protected void fireTextChanged(TextEvent event) {
- Iterator e= new ArrayList(fTextListeners).iterator();
- while (e.hasNext()) {
- ITextListener l= (ITextListener) e.next();
- l.textChanged(event);
- }
- }
-
- /**
- * @see ITextViewer#addTextListener(ITextListener)
- */
- public void addTextListener(ITextListener listener) {
- if (!fTextListeners.contains(listener))
- fTextListeners.add(listener);
- }
-
- /**
- * @see ITextViewer#removeViewportListener(IViewportListener)
- */
- public void removeViewportListener(IViewportListener p0) {
- }
-
- /**
- * @see ITextViewer#addViewportListener(IViewportListener)
- */
- public void addViewportListener(IViewportListener p0) {
- }
-
- /**
- * @see ISourceViewer#getSelectionProvider()
- */
- public ISelectionProvider getSelectionProvider() {
- return null;
- }
-
- /**
- * @see ISourceViewer#showAnnotations(boolean)
- */
- public void showAnnotations(boolean p0) {
- }
-
- /**
- * @see ISourceViewer#removeRangeIndication()
- */
- public void removeRangeIndication() {
- }
-
- /**
- * @see ISourceViewer#getRangeIndication()
- */
- public IRegion getRangeIndication() {
- return null;
- }
-
- /**
- * @see ISourceViewer#setRangeIndication(int, int, boolean)
- */
- public void setRangeIndication(int p0, int p1, boolean p2) {
- }
-
- /**
- * @see ISourceViewer#setRangeIndicator(Annotation)
- */
- public void setRangeIndicator(Annotation p0) {
- }
-
- /**
- * @see ISourceViewer#getAnnotationModel()
- */
- public IAnnotationModel getAnnotationModel() {
- return null;
- }
-
- /**
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
- */
- public void setDocument(IDocument p0, IAnnotationModel p1, int p2, int p3) {
- }
-
- /**
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel)
- */
- public void setDocument(IDocument p0, IAnnotationModel p1) {
- }
-
- /**
- * @see ISourceViewer#setAnnotationHover(IAnnotationHover)
- */
- public void setAnnotationHover(IAnnotationHover p0) {
- }
-
- /**
- * @see ISourceViewer#configure(SourceViewerConfiguration)
- */
- public void configure(SourceViewerConfiguration p0) {
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextHoverPopupTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextHoverPopupTest.java
deleted file mode 100644
index ecb93b1..0000000
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextHoverPopupTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.tests;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-public class TextHoverPopupTest extends TestCase {
-
-
- public TextHoverPopupTest(String name) {
- super(name);
- }
-
- public static void main(String args[]) {
- String a[] = { "org.eclipse.jface.text.tests.TextHoverPopupTest" };
- TestRunner.main(a);
- }
-
- protected void setUp() {
- }
-
- public static Test suite() {
- return new TestSuite(TextHoverPopupTest.class);
- }
-
- protected void tearDown() {
- }
-
-
- protected int search(int[] array, int x) {
- int low= 0;
- int high= array.length -1;
-
- while (high > low) {
- int offset= (low + high) / 2;
- int lookup= array[offset];
- if (lookup > x)
- high= offset - 1;
- else if (lookup < x)
- low= offset + 1;
- else
- low= high= offset;
- }
-
- return high;
- }
-
- public void testSearch() {
- int[] values= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- for (int i= 0; i < 10; i++) {
- int result= search(values, i);
- assertTrue(i == result);
- }
-
- int[] values2= { 0, 3, 6, 9, 12, 15, 18, 21, 24, 27 };
- for (int i= 0; i < 10; i++) {
- int result= search(values2, i * 3);
- assertTrue(i == result);
- }
- }
-}
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
deleted file mode 100644
index 0b8348b..0000000
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextPresentationTest.java
+++ /dev/null
@@ -1,572 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.tests;
-
-import java.util.Iterator;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextPresentation;
-
-public class TextPresentationTest extends TestCase {
-
- private static final int NORMAL= SWT.NORMAL;
- private static final int BOLD= SWT.BOLD;
-// private static final int ITALIC= SWT.ITALIC;
-
- private TextPresentation fTextPresentation;
- private StyleRange[] fAllRanges;
- private StyleRange[] fNonDefaultRanges;
-
- public static Test suite() {
- return new TestSuite(TextPresentationTest.class);
- }
-
- protected void setUp() {
- setUpStyleRanges();
- setUpTextPresentation();
- }
-
- private void setUpStyleRanges() {
- fAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 47, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL)
- };
-
- fNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 96, 102, BOLD)
- };
- }
-
- private void setUpTextPresentation() {
- fTextPresentation= new TextPresentation();
- fTextPresentation.setDefaultStyleRange(createStyleRange(0, 140, NORMAL));
- for (int i= 0; i < fAllRanges.length; i++)
- fTextPresentation.addStyleRange(fAllRanges[i]);
- }
-
- /**
- * @param end is exclusive
- */
- private StyleRange createStyleRange(int start, int end, int style) {
- return createStyleRange(start, end, null, null, style);
- }
-
- /**
- * @param end is exclusive
- */
- private StyleRange createStyleRange(int start, int end, Color foreground, Color background, int style) {
- return new StyleRange(start, end - start, foreground, background, style);
- }
-
- /**
- * @param end is exclusive
- */
- private StyleRange createStyleRange(int start, int end, int foreground, int background, int style) {
- return createStyleRange(start, end, createColor(foreground, foreground, foreground), createColor(background, background, background), style);
- }
-
- private static Display fDisplay= new Display();
-
- /**
- * @return <code>null</code> if any of the parameters is smaller than 0 or greater than 255
- */
- private Color createColor(int red, int green, int blue) {
- if (red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255)
- return null;
- return new Color(fDisplay, red, green, blue);
- }
-
- private void checkRegions(StyleRange[] expectedAllRanges, StyleRange[] expectedNonDefaultRanges) {
- Iterator e= fTextPresentation.getAllStyleRangeIterator();
- for (int i= 0; i < expectedAllRanges.length; i++) {
- assertTrue(e.hasNext());
- assertEquals(expectedAllRanges[i], e.next());
- }
- assertTrue(!e.hasNext());
-
- e= fTextPresentation.getNonDefaultStyleRangeIterator();
- for (int i= 0; i < expectedNonDefaultRanges.length; i++) {
- assertTrue(e.hasNext());
- assertEquals(expectedNonDefaultRanges[i], e.next());
- }
- assertTrue(!e.hasNext());
- }
-
- public void testUnclippedRegions() {
- checkRegions(fAllRanges, fNonDefaultRanges);
- }
-
- public void testClippedRegions1() {
- fTextPresentation.setResultWindow(new Region(0, 140));
- checkRegions(fAllRanges, fNonDefaultRanges);
- }
-
- public void testClippedRegions2() {
-
- fTextPresentation.setResultWindow(new Region(30, 70));
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 17, NORMAL),
- createStyleRange( 17, 24, BOLD),
- createStyleRange( 24, 66, NORMAL),
- createStyleRange( 66, 70, BOLD)
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 17, 24, BOLD),
- createStyleRange( 66, 70, BOLD)
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range at start of first existing range.
- */
- public void testMergeStyleRange1() {
- StyleRange range= createStyleRange(0, 2, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange(0, 2, 1, -1, NORMAL),
- createStyleRange( 2, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 47, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange(0, 2, 1, -1, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range at end of last existing range.
- */
- public void testMergeStyleRange2() {
- StyleRange range= createStyleRange(138, 140, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 47, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 138, NORMAL),
- createStyleRange(138, 140, 1, -1, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(138, 140, 1, -1, NORMAL),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range at start of existing default range.
- */
- public void testMergeStyleRange3() {
- StyleRange range= createStyleRange(20, 22, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange(20, 22, 1, -1, NORMAL),
- createStyleRange( 22, 47, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange(20, 22, 1, -1, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range within existing default range.
- */
- public void testMergeStyleRange4() {
- StyleRange range= createStyleRange(22, 24, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 22, NORMAL),
- createStyleRange(22, 24, 1, -1, NORMAL),
- createStyleRange( 24, 47, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange(22, 24, 1, -1, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range at end of existing default range.
- */
- public void testMergeStyleRange5() {
- StyleRange range= createStyleRange(45, 47, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 45, NORMAL),
- createStyleRange(45, 47, 1, -1, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange(45, 47, 1, -1, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range at start of existing non-default range.
- */
- public void testMergeStyleRange6() {
- StyleRange range= createStyleRange(47, 49, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 47, NORMAL),
- createStyleRange(47, 49, 1, -1, BOLD),
- createStyleRange( 49, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange(47, 49, 1, -1, BOLD),
- createStyleRange( 49, 54, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range within existing non-default range.
- */
- public void testMergeStyleRange7() {
- StyleRange range= createStyleRange(49, 51, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 47, NORMAL),
- createStyleRange( 47, 49, BOLD),
- createStyleRange(49, 51, 1, -1, BOLD),
- createStyleRange( 51, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 47, 49, BOLD),
- createStyleRange(49, 51, 1, -1, BOLD),
- createStyleRange( 51, 54, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range at end of existing non-default range.
- */
- public void testMergeStyleRange8() {
- StyleRange range= createStyleRange(52, 54, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 47, NORMAL),
- createStyleRange( 47, 52, BOLD),
- createStyleRange(52, 54, 1, -1, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 47, 52, BOLD),
- createStyleRange(52, 54, 1, -1, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range from existing default to non-default range.
- */
- public void testMergeStyleRange9() {
- StyleRange range= createStyleRange(45, 49, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 45, NORMAL),
- createStyleRange(45, 47, 1, -1, NORMAL),
- createStyleRange(47, 49, 1, -1, BOLD),
- createStyleRange( 49, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange(45, 47, 1, -1, NORMAL),
- createStyleRange(47, 49, 1, -1, BOLD),
- createStyleRange( 49, 54, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range from existing non-default to default range.
- */
- public void testMergeStyleRange10() {
- StyleRange range= createStyleRange(52, 56, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 47, NORMAL),
- createStyleRange( 47, 52, BOLD),
- createStyleRange(52, 54, 1, -1, BOLD),
- createStyleRange(54, 56, 1, -1, NORMAL),
- createStyleRange( 56, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 47, 52, BOLD),
- createStyleRange(52, 54, 1, -1, BOLD),
- createStyleRange(54, 56, 1, -1, NORMAL),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range from existing default over non-default to default range.
- */
- public void testMergeStyleRange11() {
- StyleRange range= createStyleRange(45, 56, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 45, NORMAL),
- createStyleRange(45, 47, 1, -1, NORMAL),
- createStyleRange(47, 54, 1, -1, BOLD),
- createStyleRange(54, 56, 1, -1, NORMAL),
- createStyleRange( 56, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange(45, 47, 1, -1, NORMAL),
- createStyleRange(47, 54, 1, -1, BOLD),
- createStyleRange(54, 56, 1, -1, NORMAL),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range from existing non-default over default to non-default range.
- */
- public void testMergeStyleRange12() {
- StyleRange range= createStyleRange(52, 98, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 47, NORMAL),
- createStyleRange( 47, 52, BOLD),
- createStyleRange(52, 54, 1, -1, BOLD),
- createStyleRange(54, 96, 1, -1, NORMAL),
- createStyleRange(96, 98, 1, -1, BOLD),
- createStyleRange( 98, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 47, 52, BOLD),
- createStyleRange(52, 54, 1, -1, BOLD),
- createStyleRange(54, 96, 1, -1, NORMAL),
- createStyleRange(96, 98, 1, -1, BOLD),
- createStyleRange( 98, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range over existing default range.
- */
- public void testMergeStyleRange13() {
- StyleRange range= createStyleRange(20, 47, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange(20, 47, 1, -1, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange(20, 47, 1, -1, NORMAL),
- createStyleRange( 47, 54, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
- /**
- * Merge range over existing non-default range.
- */
- public void testMergeStyleRange14() {
- StyleRange range= createStyleRange(47, 54, 1, -1, NORMAL);
- fTextPresentation.mergeStyleRange(range);
-
- StyleRange[] expectedAllRanges= new StyleRange[] {
- createStyleRange( 0, 4, NORMAL),
- createStyleRange( 4, 20, BOLD),
- createStyleRange( 20, 47, NORMAL),
- createStyleRange(47, 54, 1, -1, BOLD),
- createStyleRange( 54, 96, NORMAL),
- createStyleRange( 96, 102, BOLD),
- createStyleRange(102, 140, NORMAL),
- };
-
- StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
- createStyleRange( 4, 20, BOLD),
- createStyleRange(47, 54, 1, -1, BOLD),
- createStyleRange( 96, 102, BOLD),
- };
-
- checkRegions(expectedAllRanges, expectedNonDefaultRanges);
- }
-
-// Template
-//
-// public void testMergeStyleRange0() {
-//// StyleRange range= createStyleRange(0, 2, 1, -1, NORMAL);
-//// fTextPresentation.mergeStyleRange(range);
-//
-// StyleRange[] expectedAllRanges= new StyleRange[] {
-// createStyleRange( 0, 4, NORMAL),
-// createStyleRange( 4, 20, BOLD),
-// createStyleRange( 20, 47, NORMAL),
-// createStyleRange( 47, 54, BOLD),
-// createStyleRange( 54, 96, NORMAL),
-// createStyleRange( 96, 102, BOLD),
-// createStyleRange(102, 140, NORMAL),
-// };
-//
-// StyleRange[] expectedNonDefaultRanges= new StyleRange[] {
-// createStyleRange( 4, 20, BOLD),
-// createStyleRange( 47, 54, BOLD),
-// createStyleRange( 96, 102, BOLD),
-// };
-//
-// checkRegions(expectedAllRanges, expectedNonDefaultRanges);
-// }
-}
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextUtilitiesTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextUtilitiesTest.java
deleted file mode 100644
index 3715440..0000000
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextUtilitiesTest.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.tests;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.TextUtilities;
-
-
-/**
- * A test case for text utilities.
- */
-public class TextUtilitiesTest extends TestCase {
-
- public static Test suite() {
- return new TestSuite(TextUtilitiesTest.class);
- }
-
- /**
- * A document which is a copy of another document.
- * Implementation uses old document state.
- */
- private static class LazilyMirroredDocument extends Document {
-
- private final class DocumentListener implements IDocumentListener {
- public void documentAboutToBeChanged(DocumentEvent event) {}
- public void documentChanged(DocumentEvent event) {
- fEvents.add(event);
- }
- }
-
- /** The document listener. */
- private final DocumentListener fDocumentListener= new DocumentListener();
-
- /** The buffered events. */
- private final List fEvents= new ArrayList();
-
- public LazilyMirroredDocument(IDocument document) {
- document.addDocumentListener(fDocumentListener);
- }
-
- private void flush() throws BadLocationException {
- DocumentEvent event= TextUtilities.mergeUnprocessedDocumentEvents(this, fEvents);
- if (event == null)
- return;
-
- replace(event.getOffset(), event.getLength(), event.getText());
- fEvents.clear();
- }
-
- /*
- * Should override all other getXXX() methods as well, but it's sufficient for the test.
- *
- * @see org.eclipse.jface.text.IDocument#get()
- */
- public String get() {
- try {
- flush();
- } catch (BadLocationException e) {
- assertFalse(true);
- }
- return super.get();
- }
- }
-
- /**
- * A document which is a copy of another document.
- * Implementation uses new document state.
- */
- private static class LazilyMirroredDocument2 extends Document {
-
- private final class DocumentListener implements IDocumentListener {
- public void documentAboutToBeChanged(DocumentEvent event) {}
- public void documentChanged(DocumentEvent event) {
- event= new DocumentEvent(event.getDocument(), event.getOffset(), event.getLength(), event.getText());
- fEvents.add(event);
- }
- }
-
- /** The document listener. */
- private final DocumentListener fDocumentListener= new DocumentListener();
-
- /** The buffered events. */
- private final List fEvents= new ArrayList();
-
- public LazilyMirroredDocument2(IDocument document) {
- document.addDocumentListener(fDocumentListener);
- }
-
- private void flush() throws BadLocationException {
- DocumentEvent event= TextUtilities.mergeProcessedDocumentEvents(fEvents);
- if (event == null)
- return;
-
- replace(event.getOffset(), event.getLength(), event.getText());
- fEvents.clear();
- }
-
- /*
- * Should override all other getXXX() methods as well, but it's sufficient for the test.
- *
- * @see org.eclipse.jface.text.IDocument#get()
- */
- public String get() {
- try {
- flush();
- } catch (BadLocationException e) {
- Assert.fail("bad implementation");
- }
- return super.get();
- }
- }
-
-
- /**
- * Constructor for UtilitiesTest.
- * @param name
- */
- public TextUtilitiesTest(String name) {
- super(name);
- }
-
- private static DocumentEvent createRandomEvent(IDocument document, int maxLength, char character) {
-
- int index0= (int) (Math.random() * (maxLength + 1));
- int index1= (int) (Math.random() * (maxLength + 1));
-
- int offset= Math.min(index0, index1);
- int length= Math.max(index0, index1) - offset;
-
- int stringLength= (int) (Math.random() * 10);
- StringBuffer buffer= new StringBuffer(stringLength);
- for (int i= 0; i < stringLength; ++i)
- buffer.append(character);
-
- return new DocumentEvent(document, offset, length, buffer.toString());
- }
-
- public void testMergeEvents1() {
- IDocument reference= new Document();
- LazilyMirroredDocument testee= new LazilyMirroredDocument(reference);
-
- try {
- reference.replace(0, 0, "01234567890123");
- check(reference, testee);
-
- reference.replace(4, 3, "moo ");
- reference.replace(9, 2, "asd");
- check(reference, testee);
-
- } catch (BadLocationException e) {
- Assert.fail("bad location exception");
- }
- }
-
- public void testMergeEvents() {
- IDocument reference= new Document();
- LazilyMirroredDocument testee= new LazilyMirroredDocument(reference);
-
- try {
-
- List events= new ArrayList();
- int currentLength= 0;
-
- events.add(new DocumentEvent(reference, 0, 0, "foo bar goo haa"));
- events.add(new DocumentEvent(reference, 0, "foo bar goo haa".length(), "foo bar goo haa"));
- events.add(new DocumentEvent(reference, 4, 4, "xxxx"));
- events.add(new DocumentEvent(reference, 4, 4, "yyy"));
- events.add(new DocumentEvent(reference, 4, 3, "moo "));
- events.add(new DocumentEvent(reference, 9, 2, "asd"));
- events.add(new DocumentEvent(reference, 0, 2, "asd"));
-
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
- currentLength += event.getText().length() - event.getLength();
- }
-
- for (int i= 0; i < 500; i++) {
- char character= (char) (32 + i % 95);
- DocumentEvent event= createRandomEvent(reference, currentLength, character);
- currentLength += event.getText().length() - event.getLength();
- events.add(event);
- }
-
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
-
-// System.err.println(event.getOffset() + ", " + event.getLength() + ", [" + event.getText() + "]") ;
-
- reference.replace(event.getOffset(), event.getLength(), event.getText());
- if (Math.random() < 0.3) {
-// System.err.println("check");
- check(reference, testee);
-// System.err.println("length = " + reference.getLength());
- }
- }
-
- check(reference, testee);
-
-// System.out.println("[" + reference.get() + "]");
-// System.out.println("[" + testee.get() + "]");
-
- } catch (BadLocationException e) {
- Assert.fail("bad location exception");
- }
- }
-
- public void testMergeEvents2() {
- IDocument reference= new Document();
- LazilyMirroredDocument2 testee= new LazilyMirroredDocument2(reference);
-
- try {
-
- List events= new ArrayList();
- int currentLength= 0;
-
- events.add(new DocumentEvent(reference, 0, 0, "foo bar goo haa"));
- events.add(new DocumentEvent(reference, 0, "foo bar goo haa".length(), "foo bar goo haa"));
- events.add(new DocumentEvent(reference, 4, 4, "xxxx"));
- events.add(new DocumentEvent(reference, 4, 4, "yyy"));
- events.add(new DocumentEvent(reference, 4, 3, "moo "));
- events.add(new DocumentEvent(reference, 9, 2, "asd"));
- events.add(new DocumentEvent(reference, 0, 2, "asd"));
-
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
- currentLength += event.getText().length() - event.getLength();
- }
-
- for (int i= 0; i < 500; i++) {
- char character= (char) (32 + i % 95);
- DocumentEvent event= createRandomEvent(reference, currentLength, character);
- currentLength += event.getText().length() - event.getLength();
- events.add(event);
- }
-
- for (Iterator iterator= events.iterator(); iterator.hasNext();) {
- DocumentEvent event= (DocumentEvent) iterator.next();
-
- reference.replace(event.getOffset(), event.getLength(), event.getText());
- if (Math.random() < 0.3) {
- check(reference, testee);
- }
- }
-
- check(reference, testee);
-
- } catch (BadLocationException e) {
- Assert.fail("bad location exception");
- }
- }
-
- private static void check(IDocument reference, IDocument testee) throws BadLocationException {
- Assert.assertEquals(reference.get(), testee.get());
- }
-
-}
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/UndoManagerTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/UndoManagerTest.java
deleted file mode 100644
index 17959a2..0000000
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/UndoManagerTest.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.tests;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultUndoManager;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.IUndoManager;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextViewer;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test for DefaultUndoManager
- */
-public class UndoManagerTest extends TestCase {
-
- /** The maximum undo level. */
- private static final int MAX_UNDO_LEVEL = 256;
-
- /** The shell. */
- private Shell fShell;
- /** The text viewer. */
- private ITextViewer fTextViewer;
- /** The undo manager. */
- private IUndoManager fUndoManager;
-
- public static Test suite() {
- return new TestSuite(UndoManagerTest.class);
- }
-
- /*
- * @see TestCase#TestCase(String)
- */
- public UndoManagerTest(final String name) {
- super(name);
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() {
- fShell = new Shell();
- fUndoManager = new DefaultUndoManager(MAX_UNDO_LEVEL);
- fTextViewer = new TextViewer(fShell, SWT.NONE);
- fTextViewer.setUndoManager(fUndoManager);
- fUndoManager.connect(fTextViewer);
- }
-
- /**
- * Test for line delimiter conversion.
- */
- public void testConvertLineDelimiters() {
- final String original= "a\r\nb\r\n";
- final IDocument document= new Document(original);
- fTextViewer.setDocument(document);
-
- try {
- document.replace(1, 2, "\n");
- document.replace(3, 2, "\n");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertTrue(fUndoManager.undoable());
- fUndoManager.undo();
- assertTrue(fUndoManager.undoable());
- fUndoManager.undo();
-
- final String reverted= document.get();
-
- assertEquals(original, reverted);
- }
-
- /**
- * Randomly applies document changes.
- */
- public void testRandomAccess() {
- final int RANDOM_STRING_LENGTH= 50;
- final int RANDOM_REPLACE_COUNT= 100;
-
- assertTrue(RANDOM_REPLACE_COUNT >= 1);
- assertTrue(RANDOM_REPLACE_COUNT <= MAX_UNDO_LEVEL);
-
- String original= createRandomString(RANDOM_STRING_LENGTH);
- final IDocument document= new Document(original);
- fTextViewer.setDocument(document);
-
- doChange(document, RANDOM_REPLACE_COUNT);
-
- assertTrue(fUndoManager.undoable());
- while (fUndoManager.undoable())
- fUndoManager.undo();
-
- final String reverted= document.get();
-
- assertEquals(original, reverted);
- }
-
- private void doChange(IDocument document, int count) {
- try {
- for (int i= 0; i < count; i++) {
- final Position position= createRandomPositionPoisson(document.getLength());
- final String string= createRandomStringPoisson(4);
- document.replace(position.getOffset(), position.getLength(), string);
-// System.out.println("replace length = " + position.getLength());
-// System.out.println("string length = " + string.length());
- }
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void testRandomAccessAsCompound() {
- final int RANDOM_STRING_LENGTH= 50;
- final int RANDOM_REPLACE_COUNT= 100;
-
- assertTrue(RANDOM_REPLACE_COUNT >= 1);
- assertTrue(RANDOM_REPLACE_COUNT <= MAX_UNDO_LEVEL);
-
- String original= createRandomString(RANDOM_STRING_LENGTH);
- final IDocument document= new Document(original);
- fTextViewer.setDocument(document);
-
- fUndoManager.beginCompoundChange();
- doChange(document, RANDOM_REPLACE_COUNT);
- fUndoManager.endCompoundChange();
-
- assertTrue(fUndoManager.undoable());
- while (fUndoManager.undoable())
- fUndoManager.undo();
- assertTrue(!fUndoManager.undoable());
-
- final String reverted= document.get();
-
- assertEquals(original, reverted);
- }
-
- private static String createRandomString(int length) {
- final StringBuffer buffer= new StringBuffer();
-
- for (int i= 0; i < length; i++)
- buffer.append(getRandomCharacter());
-
- return buffer.toString();
- }
-
- private static final char getRandomCharacter() {
-// return Math.random() < 0.5
-// ? '\r'
-// : '\n';
-
- // XXX must include \r, \n, \t
- return (char) (32 + 95 * Math.random());
- }
-
- private static String createRandomStringPoisson(int mean) {
- final int length= getRandomPoissonValue(2);
- return createRandomString(length);
- }
-
- private static Position createRandomPositionPoisson(int documentLength) {
-
- final float random= (float) Math.random();
- final int offset= (int) (random * (documentLength + 1));
-
- int length= getRandomPoissonValue(2);
- if (offset + length > documentLength)
- length= documentLength - offset;
-
- return new Position(offset, length);
- }
-
- private static int getRandomPoissonValue(int mean) {
- final int MAX_VALUE= 10;
-
- final float random= (float) Math.random();
- float probability= 0;
- int i= 0;
- while (probability < 1 && i < MAX_VALUE) {
- probability += getPoissonDistribution(mean, i);
- if (random <= probability)
- break;
- i++;
- }
- return i;
- }
-
- private static float getPoissonDistribution(float lambda, int k) {
- return (float) (Math.exp(-lambda) * Math.pow(lambda, k) / faculty(k));
- }
-
- /**
- * Returns the faculty of k.
- */
- private static final int faculty(int k) {
- return k == 0
- ? 1
- : k * faculty(k - 1);
- }
-
-}
diff --git a/org.eclipse.text.tests/.classpath b/org.eclipse.text.tests/.classpath
index 0a6e981..21d37ba 100644
--- a/org.eclipse.text.tests/.classpath
+++ b/org.eclipse.text.tests/.classpath
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="projection"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/org.junit"/>
- <classpathentry kind="src" path="/org.eclipse.text"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.text.tests/build.properties b/org.eclipse.text.tests/build.properties
index 276018e..6602357 100644
--- a/org.eclipse.text.tests/build.properties
+++ b/org.eclipse.text.tests/build.properties
@@ -12,5 +12,4 @@
test.xml,\
about.html,\
*.jar,\
-source.texttests.jar = projection/,\
- src/
+source.texttests.jar = src/
diff --git a/org.eclipse.text.tests/plugin.xml b/org.eclipse.text.tests/plugin.xml
index f80eb14..45f9c78 100644
--- a/org.eclipse.text.tests/plugin.xml
+++ b/org.eclipse.text.tests/plugin.xml
@@ -13,8 +13,7 @@
</runtime>
<requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
<import plugin="org.junit"/>
</requires>
-
+
</plugin>
diff --git a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java b/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
deleted file mode 100644
index b6fda40..0000000
--- a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
+++ /dev/null
@@ -1,1763 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ISlaveDocumentManager;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.projection.Fragment;
-import org.eclipse.jface.text.projection.Segment;
-
-public class ProjectionDocumentTest extends TestCase {
-
- static private class ProjectionDocument extends org.eclipse.jface.text.projection.ProjectionDocument {
-
- public boolean isUpdating= false;
-
- public ProjectionDocument(IDocument masterDocument) {
- super(masterDocument);
- }
-
- /*
- * @see org.eclipse.jface.text.projection.ProjectionDocument#getSegments()
- */
- public Position[] getSegments2() {
- return super.getSegments();
- }
-
- /*
- * @see org.eclipse.jface.text.projection.ProjectionDocument#adaptProjectionToMasterChange(org.eclipse.jface.text.DocumentEvent)
- */
- public boolean adaptProjectionToMasterChange2(DocumentEvent masterEvent) throws BadLocationException {
- return super.adaptProjectionToMasterChange(masterEvent);
- }
-
- /*
- * @see org.eclipse.jface.text.projection.ProjectionDocument#isUpdating()
- */
- protected boolean isUpdating() {
- return super.isUpdating() || isUpdating;
- }
- }
-
- static private class ProjectionDocumentManager extends org.eclipse.jface.text.projection.ProjectionDocumentManager {
- /*
- * @see org.eclipse.jface.text.projection.ProjectionDocumentManager#createProjectionDocument(org.eclipse.jface.text.IDocument)
- */
- protected org.eclipse.jface.text.projection.ProjectionDocument createProjectionDocument(IDocument master) {
- return new ProjectionDocument(master);
- }
- }
-
- static private boolean LINES= true;
-
-
- private ProjectionDocument fSlaveDocument;
- private IDocument fMasterDocument;
- private ISlaveDocumentManager fSlaveDocumentManager;
-
-
- public ProjectionDocumentTest(String name) {
- super(name);
- }
-
- private String getOriginalMasterContents() {
- return LINES ?
- "1111111111111111111\n" +
- "2222222222222222222\n" +
- "3333333333333333333\n" +
- "4444444444444444444\n" +
- "5555555555555555555\n" +
- "6666666666666666666\n" +
- "7777777777777777777\n" +
- "8888888888888888888\n" +
- "9999999999999999999\n"
- :
- "11111111111111111111" +
- "22222222222222222222" +
- "33333333333333333333" +
- "44444444444444444444" +
- "55555555555555555555" +
- "66666666666666666666" +
- "77777777777777777777" +
- "88888888888888888888" +
- "99999999999999999999";
- }
-
- protected void setUp() {
- fMasterDocument= new Document();
- fMasterDocument.set(getOriginalMasterContents());
- fSlaveDocumentManager= new ProjectionDocumentManager();
- fSlaveDocument= (ProjectionDocument) fSlaveDocumentManager.createSlaveDocument(fMasterDocument);
- }
-
- protected void tearDown () {
- fSlaveDocumentManager.freeSlaveDocument(fSlaveDocument);
- fSlaveDocument= null;
- fSlaveDocumentManager= null;
- }
-
- private void createIdenticalProjection() {
- int offset= 0;
- int length= fMasterDocument.getLength();
- try {
- fSlaveDocument.addMasterDocumentRange(offset, length);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- private void createProjectionA() {
- createProjectionA(fSlaveDocument);
- }
-
- private void createProjectionA(ProjectionDocument projection) {
- try {
- projection.addMasterDocumentRange(0, 20);
- projection.addMasterDocumentRange(40, 20);
- projection.addMasterDocumentRange(80, 20);
- projection.addMasterDocumentRange(120, 20);
- projection.addMasterDocumentRange(160, 20);
- } catch (BadLocationException x) {
- assertTrue(false);
- }
- }
-
- private String getProjectionASlaveContents() {
- return LINES ?
- "1111111111111111111\n" +
- "3333333333333333333\n" +
- "5555555555555555555\n" +
- "7777777777777777777\n" +
- "9999999999999999999\n"
- :
- "11111111111111111111" +
- "33333333333333333333" +
- "55555555555555555555" +
- "77777777777777777777" +
- "99999999999999999999";
- }
-
- private void createProjectionB() {
- createProjectionB(fSlaveDocument);
- }
-
- private void createProjectionB(ProjectionDocument projection) {
- try {
- projection.addMasterDocumentRange(20, 20);
- projection.addMasterDocumentRange(60, 20);
- projection.addMasterDocumentRange(100, 20);
- projection.addMasterDocumentRange(140, 20);
- } catch (BadLocationException x) {
- assertTrue(false);
- }
- }
-
- private String getProjectionBSlaveContents() {
- return LINES ?
- "2222222222222222222\n" +
- "4444444444444444444\n" +
- "6666666666666666666\n" +
- "8888888888888888888\n"
- :
- "22222222222222222222" +
- "44444444444444444444" +
- "66666666666666666666" +
- "88888888888888888888";
- }
-
- private String print(Position p) {
- return "[" + p.getOffset() + "," + p.getLength() + "]";
- }
-
- private void assertWellFormedSegmentation() {
- Position[] segmentation= fSlaveDocument.getSegments2();
- assertNotNull(segmentation);
-
- for (int i= 0; i < segmentation.length; i++)
- assertFalse(segmentation[i].getLength() == 0);
- }
-
- private void assertWellFormedFragmentation() {
- Position[] segmentation= fSlaveDocument.getSegments2();
-
- Position previous= null;
- for (int i= 0; i < segmentation.length; i++) {
- Segment segment= (Segment) segmentation[i];
- Fragment fragment= segment.fragment;
- assertFalse(fragment.getLength() == 0);
- assertTrue(fragment.length == segment.length);
- if (previous != null)
- assertFalse(previous.getOffset() + previous.getLength() == fragment.getOffset());
- previous= fragment;
- }
- }
-
- private void assertFragmentation(Position[] expected) {
- assertFragmentation(expected, true);
- }
-
- private void assertFragmentation(Position[] expected, boolean checkWellFormedness) {
- if (checkWellFormedness) {
- assertWellFormedSegmentation();
- assertWellFormedFragmentation();
- }
-
- Position[] segmentation= fSlaveDocument.getSegments2();
- assertTrue("invalid number of segments", expected.length == segmentation.length);
-
- for (int i= 0; i < expected.length; i++) {
- Segment segment= (Segment) segmentation[i];
- Fragment actual= segment.fragment;
- assertEquals(print(actual) + " != " + print(expected[i]), expected[i], actual);
- }
-
- }
-
- private void assertLineInformationConsistency(IDocument document) {
- DefaultLineTracker textTracker= new DefaultLineTracker();
- textTracker.set(document.get());
-
- int textLines= textTracker.getNumberOfLines();
- int trackerLines= document.getNumberOfLines();
- assertEquals(trackerLines, textLines);
-
- for (int i= 0; i < trackerLines; i++) {
- try {
- IRegion trackerLine= document.getLineInformation(i);
- IRegion textLine= textTracker.getLineInformation(i);
-
- assertEquals(trackerLine.getOffset(), textLine.getOffset());
- assertEquals(trackerLine.getLength(), textLine.getLength());
-
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
- }
-
- private void assertContents(String expected, IDocument document) {
- assertWellFormedSegmentation();
- assertWellFormedFragmentation();
- assertEquals(expected, document.get());
- assertLineInformationConsistency(document);
- }
-
- private void assertSlaveContents(String expected) {
- assertContents(expected, fSlaveDocument);
- }
-
- private void assertMasterContents(String expected) {
- assertContents(expected, fMasterDocument);
- }
-
- public void test1() {
- // test identical projection
- createIdenticalProjection();
- assertSlaveContents(fMasterDocument.get());
- }
-
- public void test2() {
- // test complete replace the master document in case of identical projection
- createIdenticalProjection();
- try {
- fMasterDocument.replace(0,fMasterDocument.getLength(), "nothing");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- assertSlaveContents(fMasterDocument.get());
- }
-
- public void test3() {
- // test standard projection, i.e. all odd digits
- createProjectionA();
- assertSlaveContents(getProjectionASlaveContents());
- }
-
- public void test4() {
- // test modifying the unprojected regions of the master document
- createProjectionA();
- try {
- fMasterDocument.replace(145, 5, "~");
- fMasterDocument.replace(105, 5, "~");
- fMasterDocument.replace(65, 5, "~");
- fMasterDocument.replace(25, 5, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- assertSlaveContents(getProjectionASlaveContents());
- }
-
- public void test5() {
- // test modifying the projected regions of the master document
- createProjectionA();
- try {
- fMasterDocument.replace(165, 5, "~");
- fMasterDocument.replace(125, 5, "~");
- fMasterDocument.replace(85, 5, "~");
- fMasterDocument.replace(45, 5, "~");
- fMasterDocument.replace(5, 5, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.replace(85, 90, "~");
- buffer.replace(65, 70, "~");
- buffer.replace(45, 50, "~");
- buffer.replace(25, 30, "~");
- buffer.replace(5, 10, "~");
- assertSlaveContents(buffer.toString());
- }
-
- public void test6() {
- // test replacing the contents of the projected regions of the master document
- createProjectionA();
- try {
- fMasterDocument.replace(160, 20, "~");
- fMasterDocument.replace(120, 20, "~");
- fMasterDocument.replace(80, 20, "~");
- fMasterDocument.replace(40, 20, "~");
- fMasterDocument.replace(0, 20, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents("~~~~~");
- }
-
- public void test7() {
- // test replacing the contents of the master document
- createProjectionA();
- try {
- fMasterDocument.replace(0, fMasterDocument.getLength(), "~~~~~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents("~~~~~");
-
- Position[] expected= new Position[] { new Position(0, 5) };
- assertFragmentation(expected);
- }
-
- public void test8_a() {
- // test corner case manipulation of the projected regions of the master document
- // insert at the beginning of the document
-
- createProjectionA();
- try {
- fMasterDocument.replace(0, 0, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents("~" + getProjectionASlaveContents());
- }
-
- public void test8_b() {
- // test corner case manipulation of the projected regions of the master document
- // delete at the beginning of the document
-
- createProjectionA();
- try {
- fMasterDocument.replace(0, 1, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents(getProjectionASlaveContents().substring(1));
- }
-
- public void test8_c() {
- // test corner case manipulation of the projected regions of the master document
- // replace at the beginning of the document
-
- createProjectionA();
- try {
- fMasterDocument.replace(0, 1, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents("~" + getProjectionASlaveContents().substring(1));
- }
-
- public void test8_d() {
- // test corner case manipulation of the projected regions of the master document
- // insert at the end of the document
-
- createProjectionA();
- try {
- fMasterDocument.replace(fMasterDocument.getLength(), 0, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents(getProjectionASlaveContents() + "~");
- }
-
- public void test8_e() {
- // test corner case manipulation of the projected regions of the master document
- // delete at the end of the document
-
- createProjectionA();
- try {
- fMasterDocument.replace(fMasterDocument.getLength()-1, 1, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- String text= getProjectionASlaveContents();
- assertSlaveContents(text.substring(0, text.length()-1));
- }
-
- public void test8_f() {
- // test corner case manipulation of the projected regions of the master document
- // replace at the end of the document
-
- createProjectionA();
- try {
- fMasterDocument.replace(fMasterDocument.getLength()-1, 1, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- String text= getProjectionASlaveContents();
- assertSlaveContents(text.substring(0, text.length()-1) + "~");
- }
-
- public void test8_g() {
- // test corner case manipulation of the projected regions of the master document
- // insert at the beginning of a projected region of the master document
-
- createProjectionA();
- try {
- fMasterDocument.replace(80, 0, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.insert(40, '~');
- assertSlaveContents(buffer.toString());
- }
-
- public void test8_h() {
- // test corner case manipulation of the projected regions of the master document
- // delete at the beginning of a projected region of the master document
-
- createProjectionA();
- try {
- fMasterDocument.replace(80, 1, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.deleteCharAt(40);
- assertSlaveContents(buffer.toString());
- }
-
- public void test8_i() {
- // test corner case manipulation of the projected regions of the master document
- // replace at the beginning of a projected region of the master document
-
- createProjectionA();
- try {
- fMasterDocument.replace(80, 1, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.replace(40, 41, "~");
- assertSlaveContents(buffer.toString());
- }
-
- public void test8_j() {
- // test corner case manipulation of the projected regions of the master document
- // insert at the end of a projected region of the master document
- // -> slave document unchanged as this is interpreted as "beginning of an unprojected region"
-
- test9_a();
- }
-
- public void test8_k() {
- // test corner case manipulation of the projected regions of the master document
- // delete at the end of a projected region of the master document
- // -> slave document changed
-
- createProjectionA();
- try {
- fMasterDocument.replace(99, 1, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.deleteCharAt(59);
- assertSlaveContents(buffer.toString());
- }
-
- public void test8_l() {
- // test corner case manipulation of the projected regions of the master document
- // replace at the end of a projected region of the master document
- // -> slave document changed
-
- createProjectionA();
- try {
- fMasterDocument.replace(99, 1, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.replace(59, 60, "~");
- assertSlaveContents(buffer.toString());
- }
-
- public void test9_a() {
- // test corner case manipulation of the unprojected regions of the master document
- // insert at the beginning of an unprojected region
- // -> slave document unchanged
-
- createProjectionA();
- try {
- fMasterDocument.replace(100, 0, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents(getProjectionASlaveContents());
- }
-
- public void test9_b() {
- // test corner case manipulation of the unprojected regions of the master document
- // delete at the beginning of an unprojected region
- // -> slave document unchanged
-
- createProjectionA();
- try {
- fMasterDocument.replace(100, 1, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents(getProjectionASlaveContents());
- }
-
- public void test9_c() {
- // test corner case manipulation of the unprojected regions of the master document
- // replace at the beginning of an unprojected region
- // -> slave document unchanged
-
- createProjectionA();
- try {
- fMasterDocument.replace(100, 1, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents(getProjectionASlaveContents());
- }
-
- public void test9_d() {
- // test corner case manipulation of the unprojected regions of the master document
- // insert at the end of an unprojected region
- // -> slave document changed, as this is interpreted as "beginning of a projected region"
-
- test8_g();
- }
-
- public void test9_e() {
- // test corner case manipulation of the unprojected regions of the master document
- // delete at the end of an unprojected region
- // -> slave document unchanged
-
- createProjectionA();
- try {
- fMasterDocument.replace(79, 1, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents(getProjectionASlaveContents());
- }
-
- public void test9_f() {
- // test corner case manipulation of the unprojected regions of the master document
- // replace at the end of an unprojected region
- // -> slave document unchanged
-
- createProjectionA();
- try {
- fMasterDocument.replace(79, 1, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents(getProjectionASlaveContents());
- }
-
- /*
- * Replace in the master document at the end offset of the slave document
- *
- * [formatting] IllegalArgumentException when formatting comment code snippet in segmented mode
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51594
- */
- public void test9_g() {
- if (!LINES)
- return;
-
- try {
- int startOffset= fMasterDocument.getLineOffset(4);
- assertEquals(80, startOffset);
- int endOffset= fMasterDocument.getLineOffset(7);
- assertEquals(140, endOffset);
- fSlaveDocument.addMasterDocumentRange(startOffset, endOffset - startOffset);
-
- assertSlaveContents(getOriginalMasterContents().substring(80, 140));
-
- fMasterDocument.replace(endOffset, 1, "x");
- assertLineInformationConsistency(fSlaveDocument);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test10_a() {
- // test manipulations overlapping projected and unprojected regions of the master document
- // delete range overlapping from a projected into an unprojected region
-
- createProjectionA();
- try {
- fMasterDocument.replace(50, 20, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(30, 40);
- assertSlaveContents(buffer.toString());
- }
-
- public void test10_b() {
- // test manipulations overlapping projected and unprojected regions of the master document
- // replace range overlapping from a projected into an unprojected region
- // => replaced range will appear in slave document because of auto expansion of slave document in case of overlapping events
-
- createProjectionA();
- try {
- fMasterDocument.replace(50, 20, "~~~~~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 15),
- new Position(65, 20),
- new Position(105, 20),
- new Position(145, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.replace(30, 40, "~~~~~");
- assertSlaveContents(buffer.toString());
- }
-
- public void test10_c() {
- // test manipulations overlapping projected and unprojected regions of the master document
- // delete range overlapping from an unprojected into a projected region
-
- createProjectionA();
- try {
- fMasterDocument.replace(70, 20, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(40, 50);
- assertSlaveContents(buffer.toString());
- }
-
- public void test10_d() {
- // test manipulations overlapping projected and unprojected regions of the master document
- // replace range overlapping from an unprojected into a projected region
- // -> replaced range will appear in slave document because of auto expansion of slave document in case of overlapping events
-
- createProjectionA();
- try {
- fMasterDocument.replace(70, 20, "~~~~~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(70, 15),
- new Position(105, 20),
- new Position(145, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.replace(40, 50, "~~~~~");
- assertSlaveContents(buffer.toString());
- }
-
- public void test11() {
- // test deleting an unprojected region of the master document
-
- createProjectionA();
- try {
- fMasterDocument.replace(60, 20, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 40),
- new Position(100, 20),
- new Position(140, 20)
- };
- assertFragmentation(expected);
-
- assertSlaveContents(getProjectionASlaveContents());
- }
-
- public void test12() {
- // test deleting a projected region of the master document
-
- createProjectionA();
- try {
- fMasterDocument.replace(80, 20, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(100, 20),
- new Position(140, 20)
- };
- assertFragmentation(expected);
- }
-
- public void test13() {
- // test complete replace of the contents of the slave document in identical projection
-
- createIdenticalProjection();
-
- try {
- fSlaveDocument.replace(0, fSlaveDocument.getLength(), "~~~~~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents("~~~~~");
- assertMasterContents("~~~~~");
- }
-
- public void test14_a() {
- // test complete replace of the contents of the slave document in standard projection A
-
- createProjectionA();
- try {
- fSlaveDocument.replace(0, fSlaveDocument.getLength(), "~~~~~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- assertSlaveContents("~~~~~");
- assertMasterContents("~~~~~");
- }
-
- public void test14_b() {
- // test complete replace of the contents of the slave document in standard projection B
-
- createProjectionB();
- try {
- fSlaveDocument.replace(0, fSlaveDocument.getLength(), "~~~~~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- assertSlaveContents("~~~~~");
- StringBuffer buffer= new StringBuffer(getOriginalMasterContents());
- buffer.replace(20, 160, "~~~~~");
- assertMasterContents(buffer.toString());
- }
-
- public void test15() {
- // test modifying the segments of the slave document
-
- createProjectionA();
- try {
- fSlaveDocument.replace(90, 5, "~");
- fSlaveDocument.replace(70, 5, "~");
- fSlaveDocument.replace(50, 5, "~");
- fSlaveDocument.replace(30, 5, "~");
- fSlaveDocument.replace(10, 5, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.replace(90, 95, "~");
- buffer.replace(70, 75, "~");
- buffer.replace(50, 55, "~");
- buffer.replace(30, 35, "~");
- buffer.replace(10, 15, "~");
- assertSlaveContents(buffer.toString());
-
- buffer= new StringBuffer(getOriginalMasterContents());
- buffer.replace(170, 175, "~");
- buffer.replace(130, 135, "~");
- buffer.replace(90, 95, "~");
- buffer.replace(50, 55, "~");
- buffer.replace(10, 15, "~");
- assertMasterContents(buffer.toString());
- }
-
- public void test16() {
- // test replacing the contents of the segments of the slave document
-
- createProjectionA();
- try {
- fSlaveDocument.replace(80, 20, "~");
- fSlaveDocument.replace(60, 20, "~");
- fSlaveDocument.replace(40, 20, "~");
- fSlaveDocument.replace(20, 20, "~");
- fSlaveDocument.replace(0, 20, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- assertSlaveContents("~~~~~");
- StringBuffer buffer= new StringBuffer(getOriginalMasterContents());
- buffer.replace(160, 180, "~");
- buffer.replace(120, 140, "~");
- buffer.replace(80, 100, "~");
- buffer.replace(40, 60, "~");
- buffer.replace(0, 20, "~");
- assertMasterContents(buffer.toString());
- }
-
- public void test17_a() {
- // test corner case manipulation of the segments of the slave document
- // insert at the beginning of a segment of the slave document
-
- createProjectionA();
- try {
- fSlaveDocument.replace(20, 0, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.insert(20, '~');
- assertSlaveContents(buffer.toString());
-
- buffer= new StringBuffer(getOriginalMasterContents());
- buffer.insert(40, '~');
- assertMasterContents(buffer.toString());
- }
-
- public void test17_b() {
- // test corner case manipulation of the segments of the slave document
- // delete at the beginning of a segment of the slave document
-
- createProjectionA();
- try {
- fSlaveDocument.replace(20, 1, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.deleteCharAt(20);
- assertSlaveContents(buffer.toString());
-
- buffer= new StringBuffer(getOriginalMasterContents());
- buffer.deleteCharAt(40);
- assertMasterContents(buffer.toString());
- }
-
- public void test17_c() {
- // test corner case manipulation of the segments of the slave document
- // replace at the beginning of a segment of the slave document
-
- createProjectionA();
- try {
- fSlaveDocument.replace(20, 1, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.replace(20, 21, "~");
- assertSlaveContents(buffer.toString());
-
- buffer= new StringBuffer(getOriginalMasterContents());
- buffer.replace(40, 41, "~");
- assertMasterContents(buffer.toString());
- }
-
- public void test17_d() {
- // test corner case manipulation of the segments of the slave document
- // insert at the end of a segment of the slave document
- // interpreted as "insert at the beginning of the next segment"
-
- test17_a();
- }
-
- public void test17_e() {
- // test corner case manipulation of the segments of the slave document
- // delete at the end of a segment of the slave document
-
- createProjectionA();
- try {
- fSlaveDocument.replace(39, 1, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.deleteCharAt(39);
- assertSlaveContents(buffer.toString());
-
- buffer= new StringBuffer(getOriginalMasterContents());
- buffer.deleteCharAt(59);
- assertMasterContents(buffer.toString());
- }
-
- public void test17_f() {
- // test corner case manipulation of the segments of the slave document
- // replace at the end of a segment of the slave document
-
- createProjectionA();
- try {
- fSlaveDocument.replace(39, 1, "~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.replace(39, 40, "~");
- assertSlaveContents(buffer.toString());
-
- buffer= new StringBuffer(getOriginalMasterContents());
- buffer.replace(59, 60, "~");
- assertMasterContents(buffer.toString());
- }
-
- public void test18_a() {
- // test manipulations overlapping multiple segments of the slave document
- // delete range overlapping two neighboring segments
-
- createProjectionA();
-
- try {
- fSlaveDocument.replace(30, 20, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(80, 20),
- new Position(120, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(30, 50);
- assertSlaveContents(buffer.toString());
-
- buffer= new StringBuffer(getOriginalMasterContents());
- buffer.delete(50, 90);
- assertMasterContents(buffer.toString());
- }
-
- public void test18_b() {
- // test manipulations overlapping multiple segments of the slave document
- // replace range overlapping two neighboring segments
-
- createProjectionA();
-
- try {
- fSlaveDocument.replace(30, 20, "~~~~~");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 25),
- new Position(85, 20),
- new Position(125, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.replace(30, 50, "~~~~~");
- assertSlaveContents(buffer.toString());
-
- buffer= new StringBuffer(getOriginalMasterContents());
- buffer.replace(50, 90, "~~~~~");
- assertMasterContents(buffer.toString());
- }
-
- public void test19() {
- // test deleting the contents of a segment of the slave document
-
- createProjectionA();
-
- try {
- fSlaveDocument.replace(20, 20, "");
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(20, 40);
- assertSlaveContents(buffer.toString());
-
- buffer= new StringBuffer(getOriginalMasterContents());
- buffer.delete(40, 60);
- assertMasterContents(buffer.toString());
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(60, 20),
- new Position(100, 20),
- new Position(140, 20)
- };
- assertFragmentation(expected);
- }
-
- public void test20_a() {
- // test adding a range to the slave document at the beginning of a segment gap
-
- createProjectionA();
-
- try {
- fSlaveDocument.addMasterDocumentRange(60, 10);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 30),
- new Position(80, 20),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- String addition= getOriginalMasterContents().substring(60, 70);
- buffer.insert(40, addition);
- assertSlaveContents(buffer.toString());
- }
-
- public void test20_b() {
- // test adding a range to the slave document at the end of a segment gap
-
- createProjectionA();
-
- try {
- fSlaveDocument.addMasterDocumentRange(70, 10);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(70, 30),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- String addition= getOriginalMasterContents().substring(70, 80);
- buffer.insert(40, addition);
- assertSlaveContents(buffer.toString());
- }
-
- public void test20_c() {
- // test adding a range to the slave document that is in the middle of a segment gap
-
- createProjectionA();
-
- try {
- fSlaveDocument.addMasterDocumentRange(65, 10);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(65, 10),
- new Position(80, 20),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- String addition= getOriginalMasterContents().substring(65, 75);
- buffer.insert(40, addition);
- assertSlaveContents(buffer.toString());
- }
-
- public void test20_d() {
- // test adding a range to the slave document that is a segment gap
-
- createProjectionA();
-
- try {
- fSlaveDocument.addMasterDocumentRange(60, 20);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 60),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- String addition= getOriginalMasterContents().substring(60, 80);
- buffer.insert(40, addition);
- assertSlaveContents(buffer.toString());
- }
-
- public void test20_e() {
- // test adding a range to the slave document beginning in a segment gap and ending in a segment
-
- createProjectionA();
-
- try {
- fSlaveDocument.addMasterDocumentRange(70, 20);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(70, 30),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- String addition= getOriginalMasterContents().substring(70, 80);
- buffer.insert(40, addition);
- assertSlaveContents(buffer.toString());
- }
-
- public void test20_f() {
- // test adding a range to the slave document beginning in a segment and ending in a segment gap
-
- createProjectionA();
-
- try {
- fSlaveDocument.addMasterDocumentRange(50, 20);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 30),
- new Position(80, 20),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- String addition= getOriginalMasterContents().substring(60, 70);
- buffer.insert(40, addition);
- assertSlaveContents(buffer.toString());
- }
-
- public void test20_g() {
- // test adding a range to the slave document beginning in a segment and ending in a segment
-
- createProjectionA();
-
- try {
- fSlaveDocument.addMasterDocumentRange(50, 40);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 60),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- String addition= getOriginalMasterContents().substring(60, 80);
- buffer.insert(40, addition);
- assertSlaveContents(buffer.toString());
- }
-
- public void test20_h() {
- // test adding a range to the slave document beginning in a segment gap and ending in a segment gap
-
- createProjectionA();
-
- try {
- fSlaveDocument.addMasterDocumentRange(70, 40);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(70, 40),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- String addition= getOriginalMasterContents().substring(100, 110);
- buffer.insert(60, addition);
- addition= getOriginalMasterContents().substring(70, 80);
- buffer.insert(40, addition);
- assertSlaveContents(buffer.toString());
- }
-
- public void test21_a() {
- // test removing a range from the slave document at the beginning of a segment
-
- createProjectionA();
-
- try {
- fSlaveDocument.removeMasterDocumentRange(40, 10);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(50, 10),
- new Position(80, 20),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(20, 30);
- assertSlaveContents(buffer.toString());
- }
-
- public void test21_b() {
- // test removing a range from the slave document at the end of a segment
-
- createProjectionA();
-
- try {
- fSlaveDocument.removeMasterDocumentRange(50, 10);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 10),
- new Position(80, 20),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(30, 40);
- assertSlaveContents(buffer.toString());
- }
-
- public void test21_c() {
- // test removing a range from the slave document that is in the middle of a segment
-
- createProjectionA();
-
- try {
- fSlaveDocument.removeMasterDocumentRange(85, 10);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(80, 5),
- new Position(95, 5),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(45, 55);
- assertSlaveContents(buffer.toString());
- }
-
- public void test21_d() {
- // test removing a range from the slave document that is a segment
-
- createProjectionA();
-
- try {
- fSlaveDocument.removeMasterDocumentRange(40, 20);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(80, 20),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(20, 40);
- assertSlaveContents(buffer.toString());
- }
-
- public void test21_e() {
- // test removing a range from the slave document beginning in a segment and ending in a segment gap
-
- createProjectionA();
-
- try {
- fSlaveDocument.removeMasterDocumentRange(50, 20);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 10),
- new Position(80, 20),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(30, 40);
- assertSlaveContents(buffer.toString());
- }
-
- public void test21_f() {
- // test removing a range from the slave document beginning in a segment gap and ending in a segment
-
- createProjectionA();
-
- try {
- fSlaveDocument.removeMasterDocumentRange(70, 20);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(90, 10),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(40, 50);
- assertSlaveContents(buffer.toString());
- }
-
- public void test21_g() {
- // test removing a range from the slave document beginning in a segment gap and ending in a segment gap
-
- createProjectionA();
-
- try {
- fSlaveDocument.removeMasterDocumentRange(70, 40);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 20),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(40, 60);
- assertSlaveContents(buffer.toString());
- }
-
- public void test21_h() {
- // test removing a range from the slave document beginning in a segment and ending in a segment
-
- createProjectionA();
-
- try {
- fSlaveDocument.removeMasterDocumentRange(50, 40);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 20),
- new Position(40, 10),
- new Position(90, 10),
- new Position(120, 20),
- new Position(160, 20)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getProjectionASlaveContents());
- buffer.delete(30, 50);
- assertSlaveContents(buffer.toString());
- }
-
- public void test21_i() {
- // test removing a range from the slave document using identical projection
-
- createIdenticalProjection();
-
- try {
- fSlaveDocument.removeMasterDocumentRange(50, 40);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 50),
- new Position(90, 90)
- };
- assertFragmentation(expected);
-
- StringBuffer buffer= new StringBuffer(getOriginalMasterContents());
- buffer.delete(50, 90);
- assertSlaveContents(buffer.toString());
- }
-
- private void assertEquals(DocumentEvent expected, DocumentEvent received) {
- assertSame(expected.getDocument(), received.getDocument());
- assertEquals(expected.getOffset(), received.getOffset());
- assertEquals(expected.getLength(), received.getLength());
- if (expected.getText() == null || expected.getText().length() == 0)
- assertTrue(received.getText() == null || received.getText().length() == 0);
- else
- assertEquals(expected.getText(), received.getText());
- }
-
- private void assertSlaveEvents(DocumentEvent[] expected, DocumentEvent[] received) {
- if (expected == null)
- assertNull(received);
-
- assertTrue(expected.length == received.length);
-
- for (int i= 0; i < received.length; i++)
- assertEquals(received[i], expected[i]);
- }
-
- public void test22() {
- // test document events sent out by the slave document when adding segments
-
- final List receivedEvents= new ArrayList();
-
- IDocumentListener listener= new IDocumentListener() {
- public void documentAboutToBeChanged(DocumentEvent event) {}
- public void documentChanged(DocumentEvent event) {
- receivedEvents.add(event);
- }
- };
-
- fSlaveDocument.addDocumentListener(listener);
- createProjectionA();
- DocumentEvent[] actual= new DocumentEvent[receivedEvents.size()];
- receivedEvents.toArray(actual);
-
- StringBuffer buffer= new StringBuffer(getOriginalMasterContents());
- DocumentEvent[] expected= new DocumentEvent[] {
- new DocumentEvent(fSlaveDocument, 0, 0, buffer.substring(0, 20)),
- new DocumentEvent(fSlaveDocument, 20, 0, buffer.substring(40, 60)),
- new DocumentEvent(fSlaveDocument, 40, 0, buffer.substring(80, 100)),
- new DocumentEvent(fSlaveDocument, 60, 0, buffer.substring(120, 140)),
- new DocumentEvent(fSlaveDocument, 80, 0, buffer.substring(160, 180))
- };
- assertSlaveEvents(expected, actual);
- }
-
- public void test23() {
- // test document events sent out by the slave document when removing segments
-
- final List receivedEvents= new ArrayList();
-
- IDocumentListener listener= new IDocumentListener() {
- public void documentAboutToBeChanged(DocumentEvent event) {}
- public void documentChanged(DocumentEvent event) {
- receivedEvents.add(event);
- }
- };
-
- createProjectionA();
-
- fSlaveDocument.addDocumentListener(listener);
- try {
- fSlaveDocument.removeMasterDocumentRange(40, 20);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- DocumentEvent[] actual= new DocumentEvent[receivedEvents.size()];
- receivedEvents.toArray(actual);
- DocumentEvent[] expected= new DocumentEvent[] { new DocumentEvent(fSlaveDocument, 20, 20, "") };
- assertSlaveEvents(expected, actual);
- }
-
- public void test24a() {
- // test auto expand mode when manipulating the master document
- // master event completely left of slave document
-
- createProjectionB();
- fSlaveDocument.setAutoExpandMode(true);
-
- try {
- DocumentEvent event= new DocumentEvent(fMasterDocument, 5, 10, "~");
- fSlaveDocument.adaptProjectionToMasterChange2(event);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(5, 35),
- new Position(60, 20),
- new Position(100, 20),
- new Position(140, 20)
- };
- assertFragmentation(expected);
- }
-
- public void test24b() {
- // test auto expand mode when manipulating the master document
- // master event completely right of slave document
-
- createProjectionB();
- fSlaveDocument.setAutoExpandMode(true);
-
- try {
- DocumentEvent event= new DocumentEvent(fMasterDocument, 165, 10, "~");
- fSlaveDocument.adaptProjectionToMasterChange2(event);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(20,20),
- new Position(60, 20),
- new Position(100, 20),
- new Position(140, 35)
- };
- assertFragmentation(expected);
- }
-
- public void test24c() {
- // test auto expand mode when manipulating the master document
- // master event completely left of fragment
-
- createProjectionB();
- fSlaveDocument.setAutoExpandMode(true);
-
- try {
- DocumentEvent event= new DocumentEvent(fMasterDocument, 45, 10, "~");
- fSlaveDocument.adaptProjectionToMasterChange2(event);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(20, 20),
- new Position(45, 35),
- new Position(100, 20),
- new Position(140, 20)
- };
- assertFragmentation(expected);
- }
-
- public void test24d() {
- // test auto expand mode when manipulating the master document
- // master event completely right of fragment
- // -> is also left of the fragment in this setup
-
- createProjectionB();
- fSlaveDocument.setAutoExpandMode(true);
-
- try {
- DocumentEvent event= new DocumentEvent(fMasterDocument, 85, 10, "~");
- fSlaveDocument.adaptProjectionToMasterChange2(event);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(20, 20),
- new Position(60, 20),
- new Position(85, 35),
- new Position(140, 20)
- };
- assertFragmentation(expected);
- }
-
- public void test24e() {
- // test auto expand mode when manipulating the master document
- // master event start left of fragment and end inside of a fragment
-
- createProjectionB();
- fSlaveDocument.setAutoExpandMode(true);
-
- try {
- DocumentEvent event= new DocumentEvent(fMasterDocument, 50, 20, "~");
- fSlaveDocument.adaptProjectionToMasterChange2(event);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(20, 20),
- new Position(50, 30),
- new Position(100, 20),
- new Position(140, 20)
- };
- assertFragmentation(expected);
- }
-
- public void test24f() {
- // test auto expand mode when manipulating the master document
- // master event start inside of a fragment and ends right of a fragment
-
- createProjectionB();
- fSlaveDocument.setAutoExpandMode(true);
-
- try {
- DocumentEvent event= new DocumentEvent(fMasterDocument, 70, 20, "~");
- fSlaveDocument.adaptProjectionToMasterChange2(event);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(20, 20),
- new Position(60, 30),
- new Position(100, 20),
- new Position(140, 20)
- };
- assertFragmentation(expected);
- }
-
- public void test24g() {
- // test auto expand mode when manipulating the master document
- // master event starts left of a fragment and ends right of a fragment
-
- createProjectionB();
- fSlaveDocument.setAutoExpandMode(true);
-
- try {
- DocumentEvent event= new DocumentEvent(fMasterDocument, 50, 40, "~");
- fSlaveDocument.adaptProjectionToMasterChange2(event);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(20, 20),
- new Position(50, 40),
- new Position(100, 20),
- new Position(140, 20)
- };
- assertFragmentation(expected);
- }
-
- public void test25() {
- // test auto expand mode when manipulating the slave document
-
- try {
- fSlaveDocument.isUpdating= true;
- fSlaveDocument.adaptProjectionToMasterChange2(new DocumentEvent(fSlaveDocument, 0, 0, "~"));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 0)
- };
- assertFragmentation(expected, false);
- }
-
- public void test26() {
- // test multiple slave documents for the same master document
-
- createIdenticalProjection();
- ProjectionDocument slave2= (ProjectionDocument) fSlaveDocumentManager.createSlaveDocument(fMasterDocument);
- createProjectionA(slave2);
- ProjectionDocument slave3= (ProjectionDocument) fSlaveDocumentManager.createSlaveDocument(fMasterDocument);
- createProjectionB(slave3);
-
- assertContents(getOriginalMasterContents(), fSlaveDocument);
- assertContents(getProjectionASlaveContents(), slave2);
- assertContents(getProjectionBSlaveContents(), slave3);
-
- fSlaveDocumentManager.freeSlaveDocument(slave3);
- fSlaveDocumentManager.freeSlaveDocument(slave2);
- }
-}
diff --git a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionMappingTest.java b/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionMappingTest.java
deleted file mode 100644
index 4a12a7e..0000000
--- a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionMappingTest.java
+++ /dev/null
@@ -1,735 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.projection.Fragment;
-import org.eclipse.jface.text.projection.ProjectionMapping;
-import org.eclipse.jface.text.projection.Segment;
-
-/**
- * @since 3.0
- */
-public class ProjectionMappingTest extends TestCase {
-
- private IDocument fMasterDocument;
- private IDocument fSlaveDocument;
- private String fFragmentsCategory;
- private String fSegmentsCategory;
- private ProjectionMapping fProjectionMapping;
-
-
- public ProjectionMappingTest(String name) {
- super(name);
- }
-
- private String getOriginalMasterContent() {
- return
- "1111111111111111111\n" +
- "2222222222222222222\n" +
- "3333333333333333333\n" +
- "4444444444444444444\n" +
- "5555555555555555555\n" +
- "6666666666666666666\n" +
- "7777777777777777777\n" +
- "8888888888888888888\n" +
- "99999999999999999999";
- }
-
- private String getOriginalSlaveContent() {
- StringBuffer buffer= new StringBuffer(getOriginalMasterContent());
- buffer.delete(80, 180);
- buffer.delete(40, 60);
- buffer.delete(0, 20);
- return buffer.toString();
- }
-
- private String getLineWrappingSlaveContent() {
- StringBuffer buffer= new StringBuffer(getOriginalMasterContent());
- buffer.delete(80, 180);
- buffer.delete(50, 70); // ...333444...
- buffer.delete(10, 30); // ...111222...
- return buffer.toString(); // "1111111111222222222\n3333333333444444444\n"
- }
-
- private void addProjection(int fragmentOffset, int segmentOffset, int length) {
- Fragment fragment= new Fragment(fragmentOffset, length);
- Segment segment= new Segment(segmentOffset, length);
- fragment.segment= segment;
- segment.fragment= fragment;
- try {
- fMasterDocument.addPosition(fFragmentsCategory, fragment);
- fSlaveDocument.addPosition(fSegmentsCategory, segment);
- } catch (BadLocationException e) {
- assertTrue(false);
- } catch (BadPositionCategoryException e) {
- assertTrue(false);
- }
- }
-
- private void createStandardProjection() {
- fMasterDocument.set(getOriginalMasterContent());
- fSlaveDocument.set(getOriginalSlaveContent());
- addProjection(20, 0, 20);
- addProjection(60, 20, 20);
- }
-
- private void createIdenticalProjection() {
- fMasterDocument.set(getOriginalMasterContent());
- fSlaveDocument.set(getOriginalMasterContent());
- addProjection(0, 0, fMasterDocument.getLength());
- }
-
- private void createLineWrappingProjection() {
- fMasterDocument.set(getOriginalMasterContent());
- fSlaveDocument.set(getLineWrappingSlaveContent());
- addProjection(0, 0, 10);
- addProjection(30, 10, 20);
- addProjection(70, 30, 10);
- }
-
- /*
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- fMasterDocument= new Document();
- fSlaveDocument= new Document();
- fFragmentsCategory= "_fragments" + fSlaveDocument.hashCode();
- fSegmentsCategory= "_segments" + fMasterDocument.hashCode();
- fMasterDocument.addPositionCategory(fFragmentsCategory);
- fSlaveDocument.addPositionCategory(fSegmentsCategory);
- fProjectionMapping= new ProjectionMapping(fMasterDocument, fFragmentsCategory, fSlaveDocument, fSegmentsCategory);
- }
-
-
- /*
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- fMasterDocument= null;
- fSlaveDocument= null;
- fFragmentsCategory= null;
- fSegmentsCategory= null;
- fProjectionMapping= null;
- }
-
- public void test1() {
- // test getCoverage
-
- createStandardProjection();
- IRegion coverage= fProjectionMapping.getCoverage();
- assertTrue(coverage.getOffset() == 20);
- assertTrue(coverage.getLength() == 60);
- }
-
- public void test2() {
- // test toOriginOffset
-
- createStandardProjection();
- try {
- assertEquals(20, fProjectionMapping.toOriginOffset(0));
- assertEquals(25, fProjectionMapping.toOriginOffset(5));
- assertEquals(60, fProjectionMapping.toOriginOffset(20));
- assertEquals(65, fProjectionMapping.toOriginOffset(25));
- assertEquals(80, fProjectionMapping.toOriginOffset(40));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- try {
- fProjectionMapping.toOriginOffset(41);
- assertTrue(false);
- } catch (BadLocationException e) {
- }
- }
-
-
- public void test3a() {
- // test toOriginRegion
- // image region inside segment
-
- createStandardProjection();
- try {
- IRegion origin= fProjectionMapping.toOriginRegion(new Region(5, 10));
- assertEquals(new Region(25, 10), origin);
- origin= fProjectionMapping.toOriginRegion(new Region(25, 10));
- assertEquals(new Region(65, 10), origin);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test3b() {
- // test toOriginRegion
- // image region is segment
-
- createStandardProjection();
- try {
- IRegion origin= fProjectionMapping.toOriginRegion(new Region(0, 20));
- assertEquals(new Region(20, 20), origin);
- origin= fProjectionMapping.toOriginRegion(new Region(20, 20));
- assertEquals(new Region(60, 20), origin);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test3c() {
- // test toOriginRegion
- // image region overlapping segments
- createStandardProjection();
- try {
- IRegion origin= fProjectionMapping.toOriginRegion(new Region(10, 20));
- assertEquals(new Region(30, 40), origin);
- origin= fProjectionMapping.toOriginRegion(new Region(0, 40));
- assertEquals(new Region(20, 60), origin);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test3d() {
- // test toOriginRegion
- // test null projection
-
- try {
- IRegion origin= fProjectionMapping.toOriginRegion(new Region(0, 0));
- assertEquals(new Region(0, fMasterDocument.getLength()), origin);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- try {
- fProjectionMapping.toOriginRegion(new Region(0, 2));
- assertTrue(false);
- } catch (BadLocationException e) {
- }
-
- try {
- fProjectionMapping.toOriginRegion(new Region(2, 2));
- assertTrue(false);
- } catch (BadLocationException e) {
- }
- }
-
- public void test3e() {
- // test toOriginRegion
- // identical projection
-
- createIdenticalProjection();
- try {
- IRegion origin= fProjectionMapping.toOriginRegion(new Region(0, 0));
- assertEquals(new Region(0, 0), origin);
- origin= fProjectionMapping.toOriginRegion(new Region(20, 40));
- assertEquals(new Region(20, 40), origin);
- origin= fProjectionMapping.toOriginRegion(new Region(fMasterDocument.getLength(), 0));
- assertEquals(new Region(fMasterDocument.getLength(), 0), origin);
- origin= fProjectionMapping.toOriginRegion(new Region(0, fMasterDocument.getLength()));
- assertEquals(new Region(0, fMasterDocument.getLength()), origin);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test4() {
- // test toOriginLines
-
- createLineWrappingProjection();
- assertEquals(3, fSlaveDocument.getNumberOfLines());
-
- try {
- IRegion lines= fProjectionMapping.toOriginLines(0);
- assertEquals(new Region(0,2), lines);
- lines= fProjectionMapping.toOriginLines(1);
- assertEquals(new Region(2, 2), lines);
- lines= fProjectionMapping.toOriginLines(2);
- assertEquals(new Region(4, 1), lines);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test5a() {
- // test toOriginLine
- // test projection with no wrapped line
-
- createStandardProjection();
- assertEquals(3, fSlaveDocument.getNumberOfLines());
-
- try {
- assertEquals(1, fProjectionMapping.toOriginLine(0));
- assertEquals(3, fProjectionMapping.toOriginLine(1));
- assertEquals(4, fProjectionMapping.toOriginLine(2));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test5b() {
- // test toOriginLine
- // test line wrapping projection
-
- createLineWrappingProjection();
-
- try {
- assertEquals(-1, fProjectionMapping.toOriginLine(0));
- assertEquals(-1, fProjectionMapping.toOriginLine(1));
- assertEquals(4, fProjectionMapping.toOriginLine(2));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test6() {
- // test toImageOffset
-
- createStandardProjection();
-
- try {
- // test begin of slave document
- assertEquals(0, fProjectionMapping.toImageOffset(20));
- // test end of slave document
- assertEquals(39, fProjectionMapping.toImageOffset(79));
- assertEquals(40, fProjectionMapping.toImageOffset(80));
- // test begin of fragment
- assertEquals(20, fProjectionMapping.toImageOffset(60));
- // test end of fragment which is not the last fragment
- assertEquals(19, fProjectionMapping.toImageOffset(39));
- assertEquals(-1, fProjectionMapping.toImageOffset(40));
- // test middle of fragment
- assertEquals(10, fProjectionMapping.toImageOffset(30));
- // test in between two fragments
- assertEquals(-1, fProjectionMapping.toImageOffset(45));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- private IRegion computeImageRegion(IRegion region, boolean exact) throws BadLocationException {
- if (exact)
- return fProjectionMapping.toExactImageRegion(region);
- return fProjectionMapping.toImageRegion(region);
- }
-
- private void commonSubSection_toImageRegion(boolean exact) {
-
- try {
- // test a region contained by a fragment
- IRegion imageRegion= computeImageRegion(new Region(25, 10), exact);
- assertEquals(new Region(5, 10), imageRegion);
- // test region of length 0
- imageRegion= computeImageRegion(new Region(25, 0), exact);
- assertEquals(new Region(5, 0), imageRegion);
- // test a complete fragment
- imageRegion= computeImageRegion(new Region(20, 20), exact);
- assertEquals(new Region(0, 20), imageRegion);
- // test a region spanning multiple fragments incompletely
- imageRegion= computeImageRegion(new Region(25, 50), exact);
- assertEquals(new Region(5, 30), imageRegion);
- // test a region spanning multiple fragments completely
- imageRegion= computeImageRegion(new Region(20, 60), exact);
- assertEquals(new Region(0, 40), imageRegion);
- // test a region non overlapping with a fragment
- imageRegion= computeImageRegion(new Region(45, 10), exact);
- assertEquals(null, imageRegion);
- // test a zero-length region at the end of the last fragment
- imageRegion= computeImageRegion(new Region(80, 0), exact);
- assertEquals(new Region(40, 0), imageRegion);
- // test a region at the end of the last fragment
- imageRegion= computeImageRegion(new Region(80, 10), exact);
- assertEquals(null, imageRegion);
-
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test7() {
- // test toExactImageRegion
-
- createStandardProjection();
- commonSubSection_toImageRegion(true);
-
- try {
- // test a region surrounded by two fragments
- IRegion imageRegion= fProjectionMapping.toExactImageRegion(new Region(40, 20));
- assertEquals(null, imageRegion);
- // test a region starting in a fragment and ending outside a fragment
- imageRegion= fProjectionMapping.toExactImageRegion(new Region(25, 30));
- assertEquals(null, imageRegion);
- // test a region starting outside a fragment and ending inside a fragment
- imageRegion= fProjectionMapping.toExactImageRegion(new Region(45, 30));
- assertEquals(null, imageRegion);
- // test a region starting outside a fragment and ending outside a fragment
- imageRegion= fProjectionMapping.toExactImageRegion(new Region(45, 50));
- assertEquals(null, imageRegion);
-
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test8() {
- // test toImageRegion
-
- createStandardProjection();
- commonSubSection_toImageRegion(false);
-
- try {
- // test a region surrounded by two fragments
- IRegion imageRegion= fProjectionMapping.toImageRegion(new Region(40, 20));
- assertEquals(null, imageRegion);
- // test a region starting in a fragment and ending outside a fragment
- imageRegion= fProjectionMapping.toImageRegion(new Region(25, 30));
- assertEquals(new Region(5, 15), imageRegion);
- // test a region starting outside a fragment and ending inside a fragment
- imageRegion= fProjectionMapping.toImageRegion(new Region(45, 30));
- assertEquals(new Region(20, 15), imageRegion);
- // test a region starting outside a fragment and ending outside a fragment
- imageRegion= fProjectionMapping.toImageRegion(new Region(45, 50));
- assertEquals(new Region(20, 20), imageRegion);
-
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test9a() {
- // test toImageLine
- // test standard line wrapping projection
-
- createLineWrappingProjection();
- try {
- assertEquals( 0, fProjectionMapping.toImageLine(0));
- assertEquals( 0, fProjectionMapping.toImageLine(1));
- assertEquals( 1, fProjectionMapping.toImageLine(2));
- assertEquals( 1, fProjectionMapping.toImageLine(3));
- assertEquals( 2, fProjectionMapping.toImageLine(4));
- assertEquals(-1, fProjectionMapping.toImageLine(5));
- assertEquals(-1, fProjectionMapping.toImageLine(6));
- assertEquals(-1, fProjectionMapping.toImageLine(7));
- assertEquals(-1, fProjectionMapping.toImageLine(8));
- assertEquals(-1, fProjectionMapping.toImageLine(9));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test9b() {
- // test toImageLine
- // test non-line wrapping, well distributed projection of empty lines
-
- fMasterDocument.set("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- fSlaveDocument.set("\n\n\n\n\n\n");
- addProjection(3, 0, 3);
- addProjection(9, 3, 3);
-
- assertEquals(16, fMasterDocument.getNumberOfLines());
- assertEquals(7, fSlaveDocument.getNumberOfLines());
-
- try {
- assertEquals(-1, fProjectionMapping.toImageLine(0));
- assertEquals(-1, fProjectionMapping.toImageLine(1));
- assertEquals(-1, fProjectionMapping.toImageLine(2));
- assertEquals( 0, fProjectionMapping.toImageLine(3));
- assertEquals( 1, fProjectionMapping.toImageLine(4));
- assertEquals( 2, fProjectionMapping.toImageLine(5));
- assertEquals(-1, fProjectionMapping.toImageLine(6));
- assertEquals(-1, fProjectionMapping.toImageLine(7));
- assertEquals(-1, fProjectionMapping.toImageLine(8));
- assertEquals( 3, fProjectionMapping.toImageLine(9));
- assertEquals( 4, fProjectionMapping.toImageLine(10));
- assertEquals( 5, fProjectionMapping.toImageLine(11));
- assertEquals( 6, fProjectionMapping.toImageLine(12));
- assertEquals(-1, fProjectionMapping.toImageLine(13));
- assertEquals(-1, fProjectionMapping.toImageLine(14));
- assertEquals(-1, fProjectionMapping.toImageLine(15));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test10a() {
- // test toClosestImageLine
- // test standard line wrapping projection
-
- createLineWrappingProjection();
- try {
- assertEquals(0, fProjectionMapping.toClosestImageLine(0));
- assertEquals(0, fProjectionMapping.toClosestImageLine(1));
- assertEquals(1, fProjectionMapping.toClosestImageLine(2));
- assertEquals(1, fProjectionMapping.toClosestImageLine(3));
- assertEquals(2, fProjectionMapping.toClosestImageLine(4));
- assertEquals(2, fProjectionMapping.toClosestImageLine(5));
- assertEquals(2, fProjectionMapping.toClosestImageLine(6));
- assertEquals(2, fProjectionMapping.toClosestImageLine(7));
- assertEquals(2, fProjectionMapping.toClosestImageLine(8));
- assertEquals(2, fProjectionMapping.toClosestImageLine(9));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test10b() {
- // test toClosestImageLine
- // test empty projection
-
- try {
- assertEquals(-1, fProjectionMapping.toClosestImageLine(0));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test10c() {
- // test toClosestImageLine
- // test non-line wrapping, well distributed projection of empty lines
-
- fMasterDocument.set("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
-// fSlaveDocument.set(" \n\n\n \n\n\n ");
- fSlaveDocument.set("\n\n\n\n\n\n");
- addProjection(3, 0, 3);
- addProjection(9, 3, 3);
-
- assertEquals(16, fMasterDocument.getNumberOfLines());
- assertEquals(7, fSlaveDocument.getNumberOfLines());
-
- try {
- assertEquals(0, fProjectionMapping.toClosestImageLine(0));
- assertEquals(0, fProjectionMapping.toClosestImageLine(1));
- assertEquals(0, fProjectionMapping.toClosestImageLine(2));
- assertEquals(0, fProjectionMapping.toClosestImageLine(3));
- assertEquals(1, fProjectionMapping.toClosestImageLine(4));
- assertEquals(2, fProjectionMapping.toClosestImageLine(5));
- assertEquals(2, fProjectionMapping.toClosestImageLine(6));
- assertEquals(2, fProjectionMapping.toClosestImageLine(7));
- assertEquals(3, fProjectionMapping.toClosestImageLine(8));
- assertEquals(3, fProjectionMapping.toClosestImageLine(9));
- assertEquals(4, fProjectionMapping.toClosestImageLine(10));
- assertEquals(5, fProjectionMapping.toClosestImageLine(11));
- assertEquals(6, fProjectionMapping.toClosestImageLine(12));
- assertEquals(6, fProjectionMapping.toClosestImageLine(13));
- assertEquals(6, fProjectionMapping.toClosestImageLine(14));
- assertEquals(6, fProjectionMapping.toClosestImageLine(15));
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- private void assertRegions(IRegion[] expected, IRegion[] actual) {
- assertTrue("invalid number of regions", expected.length == actual.length);
- for (int i= 0; i < expected.length; i++)
- assertEquals(expected[i], actual[i]);
- }
-
- public void test11a() {
- // test toExactOriginRegions
- // test the whole slave document
-
- createStandardProjection();
-
- try {
- IRegion[] actual= fProjectionMapping.toExactOriginRegions(new Region(0, fSlaveDocument.getLength()));
- IRegion[] expected= new IRegion[] {
- new Region(20, 20),
- new Region(60, 20)
- };
- assertRegions(expected, actual);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test11b() {
- // test toExactOriginRegions
- // test a region completely comprised by a segment
-
- createStandardProjection();
-
- try {
- IRegion[] actual= fProjectionMapping.toExactOriginRegions(new Region(5, 10));
- IRegion[] expected= new IRegion[] {
- new Region(25, 10)
- };
- assertRegions(expected, actual);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test11c() {
- // test toExactOriginRegions
- // test a region completely comprised by a segment at the beginning of a segment
-
- createStandardProjection();
-
- try {
- IRegion[] actual= fProjectionMapping.toExactOriginRegions(new Region(0, 10));
- IRegion[] expected= new IRegion[] {
- new Region(20, 10)
- };
- assertRegions(expected, actual);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test11d() {
- // test toExactOriginRegions
- // test a region completely comprised by a segment at the end of a segment
-
- createStandardProjection();
-
- try {
- IRegion[] actual= fProjectionMapping.toExactOriginRegions(new Region(10, 10));
- IRegion[] expected= new IRegion[] {
- new Region(30, 10)
- };
- assertRegions(expected, actual);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test11e() {
- // test toExactOriginRegions
- // test a complete segment
-
- createStandardProjection();
-
- try {
- IRegion[] actual= fProjectionMapping.toExactOriginRegions(new Region(0, 20));
- IRegion[] expected= new IRegion[] {
- new Region(20, 20)
- };
- assertRegions(expected, actual);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test11f() {
- // test toExactOriginRegions
- // test zero-length regions
-
- createStandardProjection();
-
- try {
- IRegion[] actual= fProjectionMapping.toExactOriginRegions(new Region(0, 0));
- IRegion[] expected= new IRegion[] {
- new Region(20, 0)
- };
- assertRegions(expected, actual);
-
- actual= fProjectionMapping.toExactOriginRegions(new Region(20, 0));
- expected= new IRegion[] {
- new Region(60, 0)
- };
- assertRegions(expected, actual);
-
- actual= fProjectionMapping.toExactOriginRegions(new Region(40, 0));
- expected= new IRegion[] {
- new Region(80, 0)
- };
- assertRegions(expected, actual);
-
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test11g() {
- // test toExactOriginRegions
- // test a region starting in the middle of a segment and ending in the middle of another fragment
-
- createStandardProjection();
-
- try {
- IRegion[] actual= fProjectionMapping.toExactOriginRegions(new Region(10, 20));
- IRegion[] expected= new IRegion[] {
- new Region(30, 10),
- new Region(60, 10)
- };
- assertRegions(expected, actual);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test11h() {
- // test toExactOriginRegions
- // test a region completely comprised by a segment at the end of a segment, not the first segment
-
- createStandardProjection();
-
- try {
- IRegion[] actual= fProjectionMapping.toExactOriginRegions(new Region(30, 10));
- IRegion[] expected= new IRegion[] {
- new Region(70, 10)
- };
- assertRegions(expected, actual);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
- }
-
- public void test11i() {
- // test toExactOriginRegions
- // test a single region in the identical projection
-
- createIdenticalProjection();
-
- try {
- IRegion[] actual= fProjectionMapping.toExactOriginRegions(new Region(30, 10));
- IRegion[] expected= new IRegion[] {
- new Region(30, 10)
- };
- assertRegions(expected, actual);
- } catch (BadLocationException e) {
- assertTrue(false);
- }
-
- }
-
- public void test12a() {
- // test getImageLength
- // empty projection
- assertEquals(0, fProjectionMapping.getImageLength());
- }
-
- public void test12b() {
- // test getImageLength
- // identical projection
- createIdenticalProjection();
- assertEquals(fSlaveDocument.getLength(), fProjectionMapping.getImageLength());
- }
-
- public void test12c() {
- // test getImageLength
- // standard projection
- createStandardProjection();
- assertEquals(fSlaveDocument.getLength(), fProjectionMapping.getImageLength());
- }
-
- public void test12d() {
- // test getImageLength
- // line wrapping projection
- createLineWrappingProjection();
- assertEquals(fSlaveDocument.getLength(), fProjectionMapping.getImageLength());
- }
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/ChildDocumentTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/ChildDocumentTest.java
deleted file mode 100644
index 49a12b4..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/ChildDocumentTest.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.projection.ChildDocument;
-import org.eclipse.jface.text.projection.ChildDocumentManager;
-
-public class ChildDocumentTest extends TestCase {
-
- private IDocument fDocument;
- private Document fParent;
- private ChildDocumentManager fManager;
-
-
- public ChildDocumentTest(String name) {
- super(name);
- }
-
-
- public static void main(String args[]) {
- String a[] = { "org.eclipse.jface.text.test.ChildDocumentTest"};
- TestRunner.main(a);
- }
-
- protected void checkPositions(Position[] positions) {
-
- try {
-
- Position[] v= fDocument.getPositions(IDocument.DEFAULT_CATEGORY);
- assertTrue("invalid number of positions", v.length == positions.length);
-
- for (int i= 0; i < positions.length; i++) {
- assertEquals(print(v[i]) + " != " + print(positions[i]), positions[i], v[i]);
- }
-
- } catch (BadPositionCategoryException x) {
- assertTrue("BadPositionCategoryException thrown", false);
- }
-
- }
-
- protected void checkPositions(Position[] expected, Position[] actual) {
-
- assertTrue("invalid number of positions", expected.length == actual.length);
-
- for (int i= 0; i < expected.length; i++) {
- assertEquals(print(actual[i]) + " != " + print(expected[i]), expected[i], actual[i]);
- }
-
- }
-
- protected String print(Position p) {
- return "[" + p.getOffset() + "," + p.getLength() + "]";
- }
-
- protected void checkLineInformationConsistency() {
- DefaultLineTracker textTracker= new DefaultLineTracker();
- textTracker.set(fDocument.get());
-
- int textLines= textTracker.getNumberOfLines();
- int trackerLines= fDocument.getNumberOfLines();
-
- assertEquals("Child document store and child line tracker are inconsistent", trackerLines, textLines);
-
- for (int i= 0; i < trackerLines; i++) {
- IRegion trackerLine= null;
- IRegion textLine= null;
- try {
- trackerLine= fDocument.getLineInformation(i);
- textLine= textTracker.getLineInformation(i);
- } catch (BadLocationException e) {
- assertTrue("BadLocationException thrown", false);
- }
- assertEquals("Child document store and child line tracker are inconsistent", trackerLine.getOffset(), textLine.getOffset());
- assertEquals("Child document store and child line tracker are inconsistent", trackerLine.getLength(), textLine.getLength());
- }
- }
-
- protected void setUp() {
-
- fParent= new Document();
-
- String text=
- "package TestPackage;\n" +
- "/*\n" +
- "* comment\n" +
- "*/\n" +
- " public class Class {\n" +
- " // comment1\n" +
- " public void method1() {\n" +
- " }\n" +
- " // comment2\n" +
- " public void method2() {\n" +
- " }\n" +
- " }\n";
-
- fParent.set(text);
- fManager= new ChildDocumentManager();
- try {
- fDocument= fManager.createSlaveDocument(fParent);
- if (fDocument instanceof ChildDocument) {
- ChildDocument child= (ChildDocument) fDocument;
- child.setParentDocumentRange(0, fParent.getLength());
- }
- } catch (BadLocationException x) {
- assertTrue(false);
- }
-
- try {
-
- fDocument.addPosition(new Position( 0, 20));
- fDocument.addPosition(new Position( 21, 15));
- fDocument.addPosition(new Position( 38, 111));
- fDocument.addPosition(new Position( 61, 12));
- fDocument.addPosition(new Position( 75, 27));
- fDocument.addPosition(new Position(105, 12));
- fDocument.addPosition(new Position(119, 27));
-
- } catch (BadLocationException x) {
- assertTrue("initilization failed", false);
- }
- }
-
- public static Test suite() {
- return new TestSuite(ChildDocumentTest.class);
- }
-
- protected void tearDown () {
- fDocument= null;
- }
-
- public void testDelete1() {
-
- try {
-
- fDocument.replace(21, 16, null);
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 0),
- new Position( 22, 111),
- new Position( 45, 12),
- new Position( 59, 27),
- new Position( 89, 12),
- new Position(103, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testEditScript1() {
-
- // 1. step
-
- try {
-
- fDocument.replace(0, fDocument.getLength(), null);
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 0)
- };
-
- checkPositions(positions);
-
-
- // 2. step
- try {
-
- fDocument.replace(0, 0, "\t");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- positions= new Position[] {
- new Position( 1, 0)
- };
-
- checkPositions(positions);
-
- }
-
- public void testFindPositions() {
-
- try {
-
- fDocument.addPosition(new Position( 21, 13));
- fDocument.addPosition(new Position( 0, 19));
- fDocument.addPosition(new Position( 21, 14));
- fDocument.addPosition(new Position( 21, 16));
- fDocument.addPosition(new Position( 0, 0));
- fDocument.addPosition(new Position( 104, 1));
- fDocument.addPosition(new Position( 120, 1));
- fDocument.addPosition(new Position( 119, 1));
-
- } catch (BadLocationException x) {
- assertTrue("initilization failed", false);
- }
-
-
- Position[] positions= new Position[] {
- new Position( 0, 0),
- new Position( 0, 19),
- new Position( 0, 20),
- new Position( 21, 16),
- new Position( 21, 14),
- new Position( 21, 13),
- new Position( 21, 15),
- new Position( 38, 111),
- new Position( 61, 12),
- new Position( 75, 27),
- new Position(104, 1),
- new Position(105, 12),
- new Position(119, 1),
- new Position(119, 27),
- new Position(120, 1)
- };
-
- checkPositions(positions);
-
- }
-
- public void testInsert1() {
-
- try {
-
- fDocument.replace(0, 0, "//comment\n");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 10, 20),
- new Position( 31, 15),
- new Position( 48, 111),
- new Position( 71, 12),
- new Position( 85, 27),
- new Position(115, 12),
- new Position(129, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testInsert2() {
-
- try {
-
- fDocument.replace(61, 0, "//comment\n");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 15),
- new Position( 38, 121),
- new Position( 71, 12),
- new Position( 85, 27),
- new Position(115, 12),
- new Position(129, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testInsert3() {
-
- try {
-
- fDocument.replace(101, 0, "//comment\n");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 15),
- new Position( 38, 121),
- new Position( 61, 12),
- new Position( 75, 37),
- new Position(115, 12),
- new Position(129, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testInsert4() {
-
- try {
-
- fDocument.replace(20, 0, "// comment");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- System.out.print(fDocument.get());
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 31, 15),
- new Position( 48, 111),
- new Position( 71, 12),
- new Position( 85, 27),
- new Position(115, 12),
- new Position(129, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testReplace1() {
-
- try {
-
- fDocument.replace(8, 11, "pkg1");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 13),
- new Position( 14, 15),
- new Position( 31, 111),
- new Position( 54, 12),
- new Position( 68, 27),
- new Position( 98, 12),
- new Position(112, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testReplace2() {
-
- try {
-
- fDocument.replace(21, 16, "//comment\n");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 10),
- new Position( 32, 111),
- new Position( 55, 12),
- new Position( 69, 27),
- new Position( 99, 12),
- new Position(113, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testReplace3() {
-
- Position[] actual= new Position[] {
- new Position(0, 150),
- };
-
- try {
-
- fDocument.addPosition(actual[0]);
- fDocument.replace(0, 150, "xxxxxxxxxx");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 10)
- };
-
- checkPositions(expected, actual);
- }
-
- /*
- * Replace in the parent document at the end offset of the child document
- *
- * [formatting] IllegalArgumentException when formatting comment code snippet in segmented mode
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51594
- */
- public void testReplace4() {
- try {
- int start= fParent.getLineOffset(5);
- int end= fParent.getLineOffset(8);
- ChildDocument child= (ChildDocument) fDocument;
- child.setParentDocumentRange(start, end - start);
- fParent.replace(end, 1, "x");
- checkLineInformationConsistency();
- } catch (BadLocationException e) {
- assertTrue("BadLocationException thrown", false);
- }
- }
-
- public void testAppend() {
-
- Position[] actual= new Position[] {
- new Position(0, 2),
- };
-
- try {
-
- fDocument.replace(0, 150, null);
- fDocument.replace(fDocument.getLength(), 0, "xx");
- fDocument.addPosition(actual[0]);
- fDocument.replace(fDocument.getLength(), 0, "xxxxxxxx");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 2)
- };
-
- checkPositions(expected, actual);
- }
-
-
- public void testShiftLeft() {
-
- try {
-
- fDocument.replace(73, 1, null);
- fDocument.replace(98, 1, null);
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 15),
- new Position( 38, 109),
- new Position( 61, 12),
- new Position( 74, 26),
- new Position(103, 12),
- new Position(117, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testShiftRight() {
-
- try {
-
- fDocument.replace( 73, 0, "\t");
- fDocument.replace(100, 0, "\t");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 15),
- new Position( 38, 113),
- new Position( 61, 12),
- new Position( 76, 28),
- new Position(107, 12),
- new Position(121, 27)
- };
-
- checkPositions(positions);
- }
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
deleted file mode 100644
index 751773e..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/**********************************************************************
-Copyright (c) 2000, 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
-**********************************************************************/
-package org.eclipse.text.tests;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.projection.ChildDocument;
-import org.eclipse.jface.text.projection.ChildDocumentManager;
-
-
-
-public class DocumentExtensionTest extends TestCase {
-
-
- static class Listener implements IDocumentListener {
-
- int fRepetitions= 1;
- private int fInvocations= 0;
-
- public void documentAboutToBeChanged(DocumentEvent e) {
- ++ fInvocations;
- }
-
- public void documentChanged(DocumentEvent e) {
-
- if (fInvocations > fRepetitions) {
- fInvocations= 0;
- return;
- }
-
- if (e.getDocument() instanceof IDocumentExtension) {
- IDocumentExtension extension= (IDocumentExtension) e.getDocument();
- Replace replace= getReplace(e);
- if (replace != null)
- extension.registerPostNotificationReplace(this, replace);
- }
- }
-
- protected Replace getReplace(DocumentEvent e) {
- return null;
- }
- }
-
- static class Replace implements IDocumentExtension.IReplace {
-
- int fOffset;
- int fLength;
- String fText;
-
- public Replace() {
- }
-
- /*
- * @see IReplace#perform(IDocument, IDocumentListener)
- */
- public void perform(IDocument document, IDocumentListener owner) {
- try {
- document.replace(fOffset, fLength, fText);
- } catch (BadLocationException x) {
- assertTrue(false);
- }
- }
- }
-
- static class TestDocumentEvent extends DocumentEvent {
-
- public TestDocumentEvent(IDocument document, int offset, int length, String text) {
- super(document, offset, length, text);
- }
-
- public boolean isSameAs(DocumentEvent e) {
- return (e.getDocument() == getDocument() &&
- e.getOffset() == getOffset() &&
- e.getLength() == getLength() &&
- ((e.getText() == null && getText() == null) || e.getText().equals(getText())));
- }
- }
-
- static class TestDocumentListener implements IDocumentListener {
-
- private IDocument fDocument1;
- private List fTrace1;
- private TestDocumentEvent fExpected1;
-
- private List fTrace2;
- private TestDocumentEvent fExpected2;
-
- private boolean fPopped= false;
-
- public TestDocumentListener(IDocument d1, List t1, IDocument d2, List t2) {
- fDocument1= d1;
- fTrace1= t1;
- fTrace2= t2;
- }
-
- public void documentAboutToBeChanged(DocumentEvent received) {
- if (!fPopped) {
- fPopped= true;
- fExpected1= (TestDocumentEvent) fTrace1.remove(0);
- fExpected2= (TestDocumentEvent) fTrace2.remove(0);
- }
-
- TestDocumentEvent e= (received.getDocument() == fDocument1 ? fExpected1 : fExpected2);
- assertTrue(e.isSameAs(received));
- }
-
- public void documentChanged(DocumentEvent received) {
- TestDocumentEvent e= (received.getDocument() == fDocument1 ? fExpected1 : fExpected2);
- assertTrue(e.isSameAs(received));
- fPopped= false;
- }
- }
-
-
- public DocumentExtensionTest(String name) {
- super(name);
- }
-
-
- public static void main(String args[]) {
- String a[] = { "org.eclipse.jface.text.test.DocumentExtensionTest"};
- TestRunner.main(a);
- }
-
- public static Test suite() {
- return new TestSuite(DocumentExtensionTest.class);
- }
-
- public void testAppend() {
- Listener listener= new Listener() {
- protected Replace getReplace(DocumentEvent e) {
- String t= e.getText();
- if (t != null && t.length() > 0) {
- Replace r= new Replace();
- r.fOffset= (e.getOffset() + t.length());
- r.fLength= 0;
- r.fText= "x";
- return r;
- }
- return null;
- }
- };
-
- IDocument document= new Document();
- document.addDocumentListener(listener);
-
- try {
- document.replace(0, 0, "c");
- document.replace(0, 0, "b");
- document.replace(0, 0, "a");
- } catch (BadLocationException x) {
- assertTrue(false);
- }
-
- assertTrue("axbxcx".equals(document.get()));
- }
-
- public void testRemove() {
- Listener listener= new Listener() {
- protected Replace getReplace(DocumentEvent e) {
- String t= e.getText();
- if (t == null || t.length() == 0) {
- Replace r= new Replace();
- r.fOffset= e.getOffset();
- r.fLength= 0;
- r.fText= "y";
- return r;
- }
- return null;
- }
- };
-
- IDocument document= new Document("abc");
- document.addDocumentListener(listener);
-
- try {
- document.replace(2, 1, null);
- document.replace(1, 1, null);
- document.replace(0, 1, null);
- } catch (BadLocationException x) {
- assertTrue(false);
- }
-
- assertTrue("yyy".equals(document.get()));
- }
-
- public void testRepeatedAppend() {
- Listener listener= new Listener() {
- protected Replace getReplace(DocumentEvent e) {
- String t= e.getText();
- if (t != null && t.length() > 0) {
- Replace r= new Replace();
- r.fOffset= (e.getOffset() + t.length());
- r.fLength= 0;
- r.fText= "x";
- return r;
- }
- return null;
- }
- };
- listener.fRepetitions= 5;
-
- IDocument document= new Document();
- document.addDocumentListener(listener);
-
- try {
- document.replace(0, 0, "c");
- document.replace(0, 0, "b");
- document.replace(0, 0, "a");
- } catch (BadLocationException x) {
- assertTrue(false);
- }
-
- assertTrue("axxxxxbxxxxxcxxxxx".equals(document.get()));
- }
-
- private List createTrace(IDocument document, int repetitions) {
- int i;
- List trace= new ArrayList();
-
- trace.add(new TestDocumentEvent(document, 0, 0, "c"));
- for (i= 0; i < repetitions; i++)
- trace.add(new TestDocumentEvent(document, 1 + i, 0, "x"));
-
- trace.add(new TestDocumentEvent(document, 0, 0, "b"));
- for (i= 0; i < repetitions; i++)
- trace.add(new TestDocumentEvent(document, 1 + i, 0, "x"));
-
- trace.add(new TestDocumentEvent(document, 0, 0, "a"));
- for (i= 0; i < repetitions; i++)
- trace.add(new TestDocumentEvent(document, 1 + i, 0, "x"));
-
- return trace;
- }
-
- private void internalTestChildDocument(boolean modifyParent, boolean postModifyParent, int repetitions) {
-
- IDocument childDocument= null;
- IDocument parentDocument= new Document();
- ChildDocumentManager manager= new ChildDocumentManager();
- try {
- childDocument= manager.createSlaveDocument(parentDocument);
- if (childDocument instanceof ChildDocument) {
- ChildDocument child= (ChildDocument) childDocument;
- child.setParentDocumentRange(0, parentDocument.getLength());
- }
- } catch (BadLocationException x) {
- assertTrue(false);
- }
-
- TestDocumentListener l= new TestDocumentListener(
- parentDocument, createTrace(parentDocument, repetitions),
- childDocument, createTrace(childDocument, repetitions));
- parentDocument.addDocumentListener(l);
- childDocument.addDocumentListener(l);
-
- Listener modifier= new Listener() {
- protected Replace getReplace(DocumentEvent e) {
- String t= e.getText();
- if (t != null && t.length() > 0) {
- Replace r= new Replace();
- r.fOffset= (e.getOffset() + t.length());
- r.fLength= 0;
- r.fText= "x";
- return r;
- }
- return null;
- }
- };
- modifier.fRepetitions= repetitions;
-
- IDocument document= postModifyParent ? parentDocument : childDocument;
- document.addDocumentListener(modifier);
-
- document= modifyParent ? parentDocument : childDocument;
-
- try {
- document.replace(0, 0, "c");
- document.replace(0, 0, "b");
- document.replace(0, 0, "a");
- } catch (BadLocationException x) {
- assertTrue(false);
- }
- }
-
- public void testChildDocumentPP() {
- internalTestChildDocument(true, true, 1);
- }
-
- public void testChildDocumentCC() {
- internalTestChildDocument(false, false, 1);
- }
-
- public void testChildDocumentRepeatedPP() {
- internalTestChildDocument(true, true, 5);
- }
-
- public void testChildDocumentRepeatedCC() {
- internalTestChildDocument(false, false, 5);
- }
-
- public void testChildDocumentPC() {
- try {
- internalTestChildDocument(true, false, 1);
- assertTrue(false);
- } catch (UnsupportedOperationException x) {
- }
- }
-
- public void testChildDocumentCP() {
- internalTestChildDocument(false, true, 1);
- }
-
- public void testChildDocumentRepeatedPC() {
- try {
- internalTestChildDocument(true, false, 5);
- assertTrue(false);
- } catch (UnsupportedOperationException x) {
- }
- }
-
- public void testChildDocumentRepeatedCP() {
- internalTestChildDocument(false, true, 5);
- }
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentTest.java
deleted file mode 100644
index db56e3f..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentTest.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-
-public class DocumentTest extends TestCase {
-
- private Document fDocument;
-
-
- public DocumentTest(String name) {
- super(name);
- }
-
-
- public static void main(String args[]) {
- String a[] = { "org.eclipse.jface.text.test.DocumentTest"};
- TestRunner.main(a);
- }
-
- protected void checkPositions(Position[] expected) {
-
- try {
-
- Position[] actual= fDocument.getPositions(IDocument.DEFAULT_CATEGORY);
- assertTrue("invalid number of positions", actual.length == expected.length);
-
- for (int i= 0; i < expected.length; i++) {
- assertEquals(print(actual[i]) + " != " + print(expected[i]), expected[i], actual[i]);
- }
-
- } catch (BadPositionCategoryException x) {
- assertTrue("BadPositionCategoryException thrown", false);
- }
-
- }
-
- protected void checkPositions(Position[] expected, Position[] actual) {
-
- assertTrue("invalid number of positions", expected.length == actual.length);
-
- for (int i= 0; i < expected.length; i++) {
- assertEquals(print(actual[i]) + " != " + print(expected[i]), expected[i], actual[i]);
- }
-
- }
-
- protected String print(Position p) {
- return "[" + p.getOffset() + "," + p.getLength() + "]";
- }
-
- protected void setUp() {
-
- fDocument= new Document();
-
- String text=
- "package TestPackage;\n" +
- "/*\n" +
- "* comment\n" +
- "*/\n" +
- " public class Class {\n" +
- " // comment1\n" +
- " public void method1() {\n" +
- " }\n" +
- " // comment2\n" +
- " public void method2() {\n" +
- " }\n" +
- " }\n";
-
- fDocument.set(text);
-
- try {
-
- fDocument.addPosition(new Position( 0, 20));
- fDocument.addPosition(new Position( 21, 15));
- fDocument.addPosition(new Position( 38, 111));
- fDocument.addPosition(new Position( 61, 12));
- fDocument.addPosition(new Position( 75, 27));
- fDocument.addPosition(new Position(105, 12));
- fDocument.addPosition(new Position(119, 27));
-
- } catch (BadLocationException x) {
- assertTrue("initilization failed", false);
- }
- }
-
- public static Test suite() {
- return new TestSuite(DocumentTest.class);
- }
-
- protected void tearDown () {
- fDocument= null;
- }
-
- public void testDelete1() {
-
- try {
-
- fDocument.replace(21, 16, null);
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 0),
- new Position( 22, 111),
- new Position( 45, 12),
- new Position( 59, 27),
- new Position( 89, 12),
- new Position(103, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testEditScript1() {
-
- // 1. step
-
- try {
-
- fDocument.replace(0, fDocument.getLength(), null);
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 0)
- };
-
- checkPositions(positions);
-
-
- // 2. step
- try {
-
- fDocument.replace(0, 0, "\t");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- positions= new Position[] {
- new Position( 1, 0)
- };
-
- checkPositions(positions);
-
- }
-
- public void testFindPositions() {
-
- try {
-
- fDocument.addPosition(new Position( 21, 13));
- fDocument.addPosition(new Position( 0, 19));
- fDocument.addPosition(new Position( 21, 14));
- fDocument.addPosition(new Position( 21, 16));
- fDocument.addPosition(new Position( 0, 0));
- fDocument.addPosition(new Position( 104, 1));
- fDocument.addPosition(new Position( 120, 1));
- fDocument.addPosition(new Position( 119, 1));
-
- } catch (BadLocationException x) {
- assertTrue("initilization failed", false);
- }
-
-
- Position[] positions= new Position[] {
- new Position( 0, 0),
- new Position( 0, 19),
- new Position( 0, 20),
- new Position( 21, 16),
- new Position( 21, 14),
- new Position( 21, 13),
- new Position( 21, 15),
- new Position( 38, 111),
- new Position( 61, 12),
- new Position( 75, 27),
- new Position(104, 1),
- new Position(105, 12),
- new Position(119, 1),
- new Position(119, 27),
- new Position(120, 1)
- };
-
- checkPositions(positions);
-
- }
-
- public void testInsert1() {
-
- try {
-
- fDocument.replace(0, 0, "//comment\n");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 10, 20),
- new Position( 31, 15),
- new Position( 48, 111),
- new Position( 71, 12),
- new Position( 85, 27),
- new Position(115, 12),
- new Position(129, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testInsert2() {
-
- try {
-
- fDocument.replace(61, 0, "//comment\n");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 15),
- new Position( 38, 121),
- new Position( 71, 12),
- new Position( 85, 27),
- new Position(115, 12),
- new Position(129, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testInsert3() {
-
- try {
-
- fDocument.replace(101, 0, "//comment\n");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 15),
- new Position( 38, 121),
- new Position( 61, 12),
- new Position( 75, 37),
- new Position(115, 12),
- new Position(129, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testInsert4() {
-
- try {
-
- fDocument.replace(20, 0, "// comment");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- System.out.print(fDocument.get());
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 31, 15),
- new Position( 48, 111),
- new Position( 71, 12),
- new Position( 85, 27),
- new Position(115, 12),
- new Position(129, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testReplace1() {
-
- try {
-
- fDocument.replace(8, 11, "pkg1");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 13),
- new Position( 14, 15),
- new Position( 31, 111),
- new Position( 54, 12),
- new Position( 68, 27),
- new Position( 98, 12),
- new Position(112, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testReplace2() {
-
- try {
-
- fDocument.replace(21, 16, "//comment\n");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 10),
- new Position( 32, 111),
- new Position( 55, 12),
- new Position( 69, 27),
- new Position( 99, 12),
- new Position(113, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testReplace3() {
-
- Position[] actual= new Position[] {
- new Position(0, 150),
- };
-
- try {
-
- fDocument.addPosition(actual[0]);
- fDocument.replace(0, 150, "xxxxxxxxxx");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 10)
- };
-
- checkPositions(expected, actual);
- }
-
- public void testReplace4() {
-
- try {
-
- fDocument.replace(19, 1, "xxxxx;");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 25),
- new Position( 26, 15),
- new Position( 43, 111),
- new Position( 66, 12),
- new Position( 80, 27),
- new Position(110, 12),
- new Position(124, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testAppend() {
-
- Position[] actual= new Position[] {
- new Position(0, 2),
- };
-
- try {
-
- fDocument.replace(0, 150, null);
- fDocument.replace(fDocument.getLength(), 0, "xx");
- fDocument.addPosition(actual[0]);
- fDocument.replace(fDocument.getLength(), 0, "xxxxxxxx");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] expected= new Position[] {
- new Position(0, 2)
- };
-
- checkPositions(expected, actual);
- }
-
-
- public void testShiftLeft() {
-
- try {
-
- fDocument.replace(73, 1, null);
- fDocument.replace(98, 1, null);
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 15),
- new Position( 38, 109),
- new Position( 61, 12),
- new Position( 74, 26),
- new Position(103, 12),
- new Position(117, 27)
- };
-
- checkPositions(positions);
- }
-
- public void testShiftRight() {
-
- try {
-
- fDocument.replace( 73, 0, "\t");
- fDocument.replace(100, 0, "\t");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 0, 20),
- new Position( 21, 15),
- new Position( 38, 113),
- new Position( 61, 12),
- new Position( 76, 28),
- new Position(107, 12),
- new Position(121, 27)
- };
-
- checkPositions(positions);
- }
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/GapTextTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/GapTextTest.java
deleted file mode 100644
index b66080b..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/GapTextTest.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.jface.text.GapTextStore;
-
-
-public class GapTextTest extends TestCase {
-
- static class GapText extends GapTextStore {
-
- public GapText() {
- super(5, 10);
- }
-
- String getText() {
- return super.getContentAsString();
- }
-
- int getGapStart() {
- return super.getGapStartIndex();
- }
-
- int getGapEnd() {
- return super.getGapEndIndex();
- }
-
- int getRawLength() {
- return super.getContentAsString().length();
- }
- }
-
- private GapText fText;
-
-
- public GapTextTest(String name) {
- super(name);
- }
-
- public static void main(String args[]) {
- String a[] = { "org.eclipse.jface.ui.text.test.GapTextTest" };
- TestRunner.main(a);
- }
-
- protected String printGap() {
- return "[" + fText.getGapStart() + "," + fText.getGapEnd() + "]";
- }
-
- protected void setUp() {
-
- fText= new GapText();
- fText.set("xxxxx");
- }
-
- public static Test suite() {
- return new TestSuite(GapTextTest.class);
- }
-
- protected void tearDown () {
- fText= null;
- }
-
- public void testGetText1() {
-
- assertTrue("invalid gap", fText.getGapStart() == -1 && fText.getGapEnd() == -1);
-
- String[] expected= {
- "xyxxxx",
- "xyxyxxx",
- "xyxyxyxx",
- "xyxyxyxyx",
- "xyxyxyxyxy"
- };
-
- for (int i= 1; i < 5; i++) {
- fText.replace(2 * i - 1, 0, "y");
- String txt= fText.get(0, fText.getLength());
- assertEquals("invalid text \'" + txt + "\' returned, should be \'" + expected[i - 1] + "\'", expected[i - 1], txt);
- }
-
- }
-
- public void testGetText2() {
-
- assertTrue("invalid gap", fText.getGapStart() == -1 && fText.getGapEnd() == -1);
-
- String[] expected= {
- "yxxxxx",
- "yxyxxxx",
- "yxyxyxxx",
- "yxyxyxyxx",
- "yxyxyxyxyx"
- };
-
- for (int i= 1; i < 5; i++) {
- fText.replace(2 * (i - 1), 0, "y");
- String txt= fText.get(0, fText.getLength());
- assertEquals("invalid text \'" + txt + "\' returned, should be \'" + expected[i - 1] + "\'", expected[i - 1], txt);
- }
-
- }
-
- public void testInsert() {
-
- assertTrue("invalid gap", fText.getGapStart() == -1 && fText.getGapEnd() == -1);
- fText.replace(2, 0, "y");
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 3 && fText.getGapEnd() == 13);
-
-
- for (int i= 1; i <= 5; i++) {
- fText.replace(2 + i, 0, "y");
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == (3 + i) && fText.getGapEnd() == 13);
- }
-
- fText.replace(8, 0, "y");
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 9 && fText.getGapEnd() == 19);
- }
-
- public void testRemoveGapOverlapping() {
-
- assertTrue("invalid gap", fText.getGapStart() == -1 && fText.getGapEnd() == -1);
- fText.replace(2, 2, null);
- assertTrue("invalid gap: " + printGap(), fText.getGapStart() == 2 && fText.getGapEnd() == 12);
-
- fText.replace(1, 2, null);
- assertTrue("invalid gap: " + printGap(), fText.getGapStart() == 1 && fText.getGapEnd() == 13);
- }
-
- public void testRemoveGapOverlapping2() {
-
- assertTrue("invalid gap", fText.getGapStart() == -1 && fText.getGapEnd() == -1);
- fText.replace(0, 0, "aaaaazzzzzyyyyy");
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 15 && fText.getGapEnd() == 25);
- assertEquals("aaaaazzzzzyyyyyxxxxx", fText.get(0, fText.getLength()));
-
-
- fText.replace(5, 12, null);
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 5 && fText.getGapEnd() == 27);
- assertEquals("aaaaaxxx", fText.get(0, fText.getLength()));
- }
-
- public void testRemoveRemoteFromGap() {
-
- assertTrue("invalid gap", fText.getGapStart() == -1 && fText.getGapEnd() == -1);
- fText.replace(0, 0, "aaaaazzzzzyyyyy");
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 15 && fText.getGapEnd() == 25);
- assertEquals("aaaaazzzzzyyyyyxxxxx", fText.get(0, fText.getLength()));
-
- // before gap
- fText.replace(5, 2, null);
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 5 && fText.getGapEnd() == 15);
- assertEquals("aaaaazzzyyyyyxxxxx", fText.get(0, fText.getLength()));
-
- // after gap
- fText.replace(7, 10, null);
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 7 && fText.getGapEnd() == 17);
- assertEquals("aaaaazzx", fText.get(0, fText.getLength()));
-
- }
-
- public void testRemoveAtLeftGapEdge() {
- assertTrue("invalid gap", fText.getGapStart() == -1 && fText.getGapEnd() == -1);
- fText.replace(2, 0, "xxxxx");
- assertTrue("invalid gap: " + printGap(), fText.getGapStart() == 7 && fText.getGapEnd() == 17);
- fText.replace(6, 1, null);
- assertTrue("invalid gap: " + printGap(), fText.getGapStart() == 6 && fText.getGapEnd() == 17);
- }
-
- public void testRemoveAtRightGapEdge() {
- assertTrue("invalid gap", fText.getGapStart() == -1 && fText.getGapEnd() == -1);
- fText.replace(2, 0, "xxxxx");
- assertTrue("invalid gap: " + printGap(), fText.getGapStart() == 7 && fText.getGapEnd() == 17);
- fText.replace(7, 1, null);
- assertTrue("invalid gap: " + printGap(), fText.getGapStart() == 7 && fText.getGapEnd() == 18);
- }
-
- public void testReplace() {
-
- assertTrue("invalid gap", fText.getGapStart() == -1 && fText.getGapEnd() == -1);
- fText.replace(2, 2, "yy");
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 4 && fText.getGapEnd() == 14);
-
- fText.replace(4, 1, "yyyyyyyyyy");
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 14 && fText.getGapEnd() == 24);
-
- fText.replace(14, 0, "yyy");
- assertTrue("invalid gap:" + printGap(), fText.getGapStart() == 17 && fText.getGapEnd() == 24);
- }
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java
deleted file mode 100644
index e968ff2..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest3.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.ConfigurableLineTracker;
-import org.eclipse.jface.text.GapTextStore;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
-
-public class LineTrackerTest3 extends TestCase {
-
- private GapTextStore fText;
- private ILineTracker fTracker;
-
-
- public LineTrackerTest3(String name) {
- super(name);
- }
-
- public static void main(String args[]) {
- String a[] = { "org.eclipse.jface.text.test.LineTrackerTest3"};
- TestRunner.main(a);
- }
-
- protected int getLineOffset(int line, int[] lines) {
- int offset= 0;
- for (int i= 0; i < line; i++)
- offset += (lines[i] + 1);
- return offset;
- }
-
- protected void checkLines(int[] lines) {
-
- assertTrue("invalid number of line", fTracker.getNumberOfLines() == lines.length);
-
- for (int i= 0; i < lines.length; i++) {
-
- try {
-
- IRegion line= fTracker.getLineInformation(i);
-
- assertTrue("line: " + i + " length=" + line.getLength() + " should be:" + lines[i], line.getLength() == lines[i]);
-
- int expected= getLineOffset(i, lines);
- assertTrue("line: " + i + " offset=" + line.getOffset() + " should be:" + expected, line.getOffset() == expected);
-
- } catch (BadLocationException x) {
- assertTrue(false);
- }
- }
- }
-
- protected void setUp() {
-
- fText= new GapTextStore(50, 300);
- fTracker= new ConfigurableLineTracker(new String[] { "\n" });
- fText.set("x\nx\nx\nx\nx\n");
- fTracker.set("x\nx\nx\nx\nx\n");
- }
-
- public static Test suite() {
- return new TestSuite(LineTrackerTest3.class);
- }
-
- protected void tearDown () {
- fTracker= null;
- fText= null;
- }
-
- public void testEditScript1() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, fText.getLength(), "x");
- fText.replace(0, fText.getLength(), "x");
-
- checkLines(new int[] { 1 });
-
- fTracker.replace(1, 0, "y");
- fText.replace(1, 0, "y");
-
- checkLines(new int[] { 2 });
-
- fTracker.replace(2, 0, "z");
- fText.replace(2, 0, "z");
-
- checkLines(new int[] { 3 });
-
- fTracker.replace(3, 0, "\n");
- fText.replace(3, 0, "\n");
-
- checkLines(new int[] { 3, 0 });
-
-
- fTracker.replace(4, 0, "x");
- fText.replace(4, 0, "x");
-
- checkLines(new int[] { 3, 1 });
-
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
-
- }
-
- public void testEmptyLines() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, 10, null);
- fText.replace(0, 10, null);
- checkLines(new int[] { 0 });
-
- fTracker.replace(0, 0, "\n\n\n\n\n");
- fText.replace(0, 0, "\n\n\n\n\n");
- checkLines(new int[] { 0, 0, 0, 0, 0, 0 });
-
- for (int i= 0; i < 6; i++) {
- int no= fTracker.getLineNumberOfOffset(i);
- assertTrue("invalid line number " + no + " reported instead of " + i, no == i);
- }
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testInsert1() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(3, 0, "yyyy");
- fText.replace(3, 0, "yyyy");
- checkLines(new int[] { 1, 5, 1, 1, 1, 0 });
-
- fTracker.replace(9, 0, "y\n");
- fText.replace(9, 0, "y\n");
- checkLines(new int[] { 1, 5, 2, 0, 1, 1, 0 });
-
- fTracker.replace(11, 0, "y\n");
- fText.replace(11, 0, "y\n");
- checkLines(new int[] { 1, 5, 2, 1, 0, 1, 1, 0 });
-
- fTracker.replace(13, 0, "y");
- fText.replace(13, 0, "y");
- checkLines(new int[] { 1, 5, 2, 1, 1, 1, 1, 0 });
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testInsert2() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(3, 0, "yyyy");
- fText.replace(3, 0, "yyyy");
- checkLines(new int[] { 1, 5, 1, 1, 1, 0 });
-
- fTracker.replace(9, 0, "y\ny\ny");
- fText.replace(9, 0, "y\ny\ny");
- checkLines(new int[] { 1, 5, 2, 1, 1, 1, 1, 0 });
-
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testLinesNumbers() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, 10, "\na\nbb\nccc\ndddd\neeeee\n" );
- fText.replace(0, 10, "\na\nbb\nccc\ndddd\neeeee\n" );
- checkLines(new int[] { 0, 1, 2, 3, 4, 5, 0 });
-
- int offset= 0;
- for (int i= 0; i < 5; i++) {
- for (int j= 0; j < i; j++) {
- int no= fTracker.getLineNumberOfOffset(offset + j);
- assertTrue("invalid line number " + no + " reported instead of " + i, no == i);
- }
- offset += (i + 1);
- }
-
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testOffsets() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- for (int i= 0; i < 5; i++) {
- IRegion line= fTracker.getLineInformation(i);
- int pos= line.getOffset() + line.getLength();
- int offset= (2 * i) + 1;
- assertTrue("invalid line end offset " + pos + " for line " + i + " should be " + offset, offset == pos);
- }
-
- for (int i= 0; i < 5; i++) {
- int pos= fTracker.getLineOffset(i);
- int offset= 2 * i;
- assertTrue("invalid line start offset " + pos + " for line " + i + " should be " + offset, pos == offset);
- }
-
- for (int i= 0; i < 10; i++) {
- int line= fTracker.getLineNumberOfOffset(i);
- double l= Math.floor(i/2);
- assertTrue("invalid line number " + line + " for position " + i + " should be " + l, l == line);
- }
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testRemove() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(3, 1, null);
- fText.replace(3, 1, null);
- checkLines(new int[] { 1, 2, 1, 1, 0 });
-
- fTracker.replace(6, 1, null);
- fText.replace(6, 1, null);
- checkLines(new int[] { 1, 2, 2, 0 });
-
- fTracker.replace(3, 5, null);
- fText.replace(3, 4, null);
- checkLines(new int[] { 1, 1 });
-
- fTracker.replace(0, 3, null);
- fText.replace(0, 3, null);
- checkLines(new int[] { 0 });
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testReplace() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, fText.getLength(), "\tx\n\tx\n\tx\n\tx\n\tx\n");
- fText.replace(0, fText.getLength(), "\tx\n\tx\n\tx\n\tx\n\tx\n");
-
- checkLines(new int[] { 2, 2, 2, 2, 2, 0 });
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
-
- }
-
- public void testReplace2() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, fText.getLength(), "x");
- fText.replace(0, fText.getLength(), "x");
-
- checkLines(new int[] { 1 });
-
- fTracker.replace(0, fText.getLength(), "x\nx\nx\n");
- fText.replace(0, fText.getLength(), "x\nx\nx\n");
-
- checkLines(new int[] { 1, 1, 1, 0 });
-
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
-
- }
-
- public void testReplace3() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(1, 1, "\n");
- fText.replace(1, 1, "\n");
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
-
- }
-
- public void testReplace4() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- int lines= fTracker.getNumberOfLines();
- IRegion previous= fTracker.getLineInformation(0);
- for (int i= 1; i < lines; i++) {
- int lastLineEnd= previous.getOffset() + previous.getLength();
- int lineStart= fTracker.getLineInformation(i).getOffset();
- fTracker.replace(lastLineEnd, lineStart - lastLineEnd, "\n");
- fText.replace(lastLineEnd, lineStart - lastLineEnd, "\n");
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
- previous= fTracker.getLineInformation(i);
- }
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
-
- }
-
-
- public void testShiftLeft() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, fText.getLength(), "\tx\n\tx\n\tx\n\tx\n\tx\n");
- fText.replace(0, fText.getLength(), "\tx\n\tx\n\tx\n\tx\n\tx\n");
- checkLines(new int[] { 2, 2, 2, 2, 2, 0 });
-
- for (int i= 0; i < 5; i++) {
- int pos= fTracker.getLineOffset(i);
- fTracker.replace(pos, 1, null);
- fText.replace(pos, 1, null);
- }
-
-
- String txt= fText.get(0, fText.getLength());
- assertEquals("invalid text", "x\nx\nx\nx\nx\n", txt);
-
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testShiftRight() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- for (int i= 0; i < 5; i++) {
- int pos= fTracker.getLineOffset(i);
- fTracker.replace(pos, 0, "\t");
- fText.replace(pos, 0, "\t");
- }
-
- checkLines(new int[] { 2, 2, 2, 2, 2, 0 });
-
- String txt= fText.get(0, fText.getLength());
- assertEquals("invalid text", "\tx\n\tx\n\tx\n\tx\n\tx\n", txt);
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testMultipleNewlines() {
- fText= new GapTextStore(50, 300);
- fTracker= new ConfigurableLineTracker(new String[] { "\n" });
- fText.set("x\n\nx\nx\n\nx\nx\n");
- fTracker.set("x\n\nx\nx\n\nx\nx\n");
-
- checkLines(new int[] { 1, 0, 1, 1, 0, 1, 1, 0 });
- try {
- int line= fTracker.getLineNumberOfOffset(8);
- assertTrue(line == 5);
- } catch (BadLocationException e) {
- assertTrue("bad location", false);
- }
- }
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest4.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest4.java
deleted file mode 100644
index da6bfe4..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/LineTrackerTest4.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.ConfigurableLineTracker;
-import org.eclipse.jface.text.GapTextStore;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
-
-
-
-public class LineTrackerTest4 extends TestCase {
-
- private GapTextStore fText;
- private ILineTracker fTracker;
-
-
- public LineTrackerTest4(String name) {
- super(name);
- }
-
- public static void main(String args[]) {
- String a[] = { "org.eclipse.jface.text.test.LineTrackerTest4" };
- TestRunner.main(a);
- }
-
- protected int getLineOffset(int line, int[] lines) {
- int offset= 0;
- for (int i= 0; i < line; i++)
- offset += (lines[i] + 2);
- return offset;
- }
-
- protected void checkLines(int[] lines) {
-
- assertTrue("invalid number of line", fTracker.getNumberOfLines() == lines.length);
-
- for (int i= 0; i < lines.length; i++) {
-
- try {
-
- IRegion line= fTracker.getLineInformation(i);
-
- assertTrue("line: " + i + " length=" + line.getLength() + " should be:" + lines[i], line.getLength() == lines[i]);
-
- int expected= getLineOffset(i, lines);
- assertTrue("line: " + i + " offset=" + line.getOffset() + " should be:" + expected, line.getOffset() == expected);
-
- } catch (BadLocationException x) {
- assertTrue(false);
- }
- }
- }
-
- protected void setUp() {
-
- fText= new GapTextStore(50, 300);
- fTracker= new ConfigurableLineTracker(new String[] { "\r\n" });
- fText.set("x\r\nx\r\nx\r\nx\r\nx\r\n");
- fTracker.set("x\r\nx\r\nx\r\nx\r\nx\r\n");
- }
-
- public static Test suite() {
- return new TestSuite(LineTrackerTest4.class);
- }
-
- protected void tearDown () {
- fTracker= null;
- fText= null;
- }
-
- public void testEditScript1() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, fText.getLength(), "x");
- fText.replace(0, fText.getLength(), "x");
-
- checkLines(new int[] { 1 });
-
- fTracker.replace(1, 0, "y");
- fText.replace(1, 0, "y");
-
- checkLines(new int[] { 2 });
-
- fTracker.replace(2, 0, "z");
- fText.replace(2, 0, "z");
-
- checkLines(new int[] { 3 });
-
- fTracker.replace(3, 0, "\r\n");
- fText.replace(3, 0, "\r\n");
-
- checkLines(new int[] { 3, 0 });
-
-
- fTracker.replace(5, 0, "x");
- fText.replace(5, 0, "x");
-
- checkLines(new int[] { 3, 1 });
-
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
-
- }
-
- public void testEmptyLines() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, 15, null);
- fText.replace(0, 15, null);
- checkLines(new int[] { 0 });
-
- fTracker.replace(0, 0, "\r\n\r\n\r\n\r\n\r\n");
- fText.replace(0, 0, "\r\n\r\n\r\n\r\n\r\n");
- checkLines(new int[] { 0, 0, 0, 0, 0, 0 });
-
- for (int i= 0; i < 10; i++) {
- int no= fTracker.getLineNumberOfOffset(i);
- double l= Math.floor(i/2);
- assertTrue("invalid line number " + no + " for position " + i + " should be " + l, l == no);
- }
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testInsert1() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(4, 0, "yyyy");
- fText.replace(4, 0, "yyyy");
- checkLines(new int[] { 1, 5, 1, 1, 1, 0 });
-
- fTracker.replace(11, 0, "y\r\n");
- fText.replace(11, 0, "y\r\n");
- checkLines(new int[] { 1, 5, 2, 0, 1, 1, 0 });
-
- fTracker.replace(14, 0, "y\r\n");
- fText.replace(14, 0, "y\r\n");
- checkLines(new int[] { 1, 5, 2, 1, 0, 1, 1, 0 });
-
- fTracker.replace(17, 0, "y");
- fText.replace(17, 0, "y");
- checkLines(new int[] { 1, 5, 2, 1, 1, 1, 1, 0 });
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testInsert2() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(4, 0, "yyyy");
- fText.replace(4, 0, "yyyy");
- checkLines(new int[] { 1, 5, 1, 1, 1, 0 });
-
- fTracker.replace(11, 0, "y\r\ny\r\ny");
- fText.replace(11, 0, "y\r\ny\r\ny");
- checkLines(new int[] { 1, 5, 2, 1, 1, 1, 1, 0 });
-
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testLinesNumbers() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, 15, "\r\na\r\nbb\r\nccc\r\ndddd\r\neeeee\r\n" );
- fText.replace(0, 10, "\na\nbb\nccc\ndddd\neeeee\n" );
- checkLines(new int[] { 0, 1, 2, 3, 4, 5, 0 });
-
- int offset= 0;
- for (int i= 0; i < 5; i++) {
- for (int j= 0; j <= i; j++) {
- int no= fTracker.getLineNumberOfOffset(offset + j);
- assertTrue("invalid line number " + no + " reported instead of " + i, no == i);
- }
- offset += (i + 2);
- }
-
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testOffsets() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- for (int i= 0; i < 5; i++) {
- IRegion line= fTracker.getLineInformation(i);
- int pos= line.getOffset() + line.getLength() + 1;
- int offset= (3 * i) + 2;
- assertTrue("invalid line end offset " + pos + " for line " + i + " should be " + offset, offset == pos);
- }
-
- for (int i= 0; i < 5; i++) {
- int pos= fTracker.getLineOffset(i);
- int offset= 3 * i;
- assertTrue("invalid line start offset " + pos + " for line " + i + " should be " + offset, pos == offset);
- }
-
- for (int i= 0; i < 15; i++) {
- int line= fTracker.getLineNumberOfOffset(i);
- double l= Math.floor(i/3);
- assertTrue("invalid line number " + line + " for position " + i + " should be " + l, l == line);
- }
-
- int lastLine= fTracker.getLineNumberOfOffset(fText.getLength());
- assertTrue("invalid last line number " + lastLine, 5 == lastLine);
-
- int offset= fTracker.getLineOffset(lastLine);
- assertTrue("invalid last line start offset " + offset, fText.getLength() == offset);
-
- int length= fTracker.getLineLength(lastLine);
- assertTrue("invalid last line end offset " + (offset + length -1), 0 == length);
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testRemove() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(4, 2, null);
- fText.replace(4, 2, null);
- checkLines(new int[] { 1, 2, 1, 1, 0 });
-
- fTracker.replace(8, 2, null);
- fText.replace(8, 2, null);
- checkLines(new int[] { 1, 2, 2, 0 });
-
- fTracker.replace(4, 7, null);
- fText.replace(4, 7, null);
- checkLines(new int[] { 1, 1 });
-
- fTracker.replace(0, 4, null);
- fText.replace(0, 4, null);
- checkLines(new int[] { 0 });
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testReplace() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, fText.getLength(), "\tx\r\n\tx\r\n\tx\r\n\tx\r\n\tx\r\n");
- fText.replace(0, fText.getLength(), "\tx\r\n\tx\r\n\tx\r\n\tx\r\n\tx\r\n");
-
- checkLines(new int[] { 2, 2, 2, 2, 2, 0 });
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
-
- }
-
- public void testShiftLeft() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- fTracker.replace(0, fText.getLength(), "\tx\r\n\tx\r\n\tx\r\n\tx\r\n\tx\r\n");
- fText.replace(0, fText.getLength(), "\tx\r\n\tx\r\n\tx\r\n\tx\r\n\tx\r\n");
- checkLines(new int[] { 2, 2, 2, 2, 2, 0 });
-
- for (int i= 0; i < 5; i++) {
- int pos= fTracker.getLineOffset(i);
- fTracker.replace(pos, 1, null);
- fText.replace(pos, 1, null);
- }
-
-
- String txt= fText.get(0, fText.getLength());
- assertEquals("invalid text", "x\r\nx\r\nx\r\nx\r\nx\r\n", txt);
-
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-
- public void testShiftRight() {
-
- try {
-
- checkLines(new int[] { 1, 1, 1, 1, 1, 0 });
-
- for (int i= 0; i < 5; i++) {
- int pos= fTracker.getLineOffset(i);
- fTracker.replace(pos, 0, "\t");
- fText.replace(pos, 0, "\t");
- }
-
- checkLines(new int[] { 2, 2, 2, 2, 2, 0 });
-
- String txt= fText.get(0, fText.getLength());
- assertEquals("invalid text", "\tx\r\n\tx\r\n\tx\r\n\tx\r\n\tx\r\n", txt);
-
- } catch (BadLocationException e) {
- assertTrue("BadLocationException", false);
- }
- }
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/PositionUpdatingCornerCasesTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/PositionUpdatingCornerCasesTest.java
deleted file mode 100644
index 2e9028d..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/PositionUpdatingCornerCasesTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-
-
-public class PositionUpdatingCornerCasesTest extends TestCase {
-
- private Document fDocument;
-
-
- public PositionUpdatingCornerCasesTest(String name) {
- super(name);
- }
-
-
- public static void main(String args[]) {
- String a[] = { "org.eclipse.jface.text.test.PositionUpdatingCornerCasesTest"};
- TestRunner.main(a);
- }
-
- protected void checkPositions(Position[] expected) {
-
- try {
-
- Position[] actual= fDocument.getPositions(IDocument.DEFAULT_CATEGORY);
- assertTrue("invalid number of positions", actual.length == expected.length);
-
- for (int i= 0; i < expected.length; i++) {
- assertEquals(print(actual[i]) + " != " + print(expected[i]), expected[i], actual[i]);
- }
-
- } catch (BadPositionCategoryException x) {
- assertTrue("BadPositionCategoryException thrown", false);
- }
-
- }
-
- protected String print(Position p) {
- return "[" + p.getOffset() + "," + p.getLength() + "]";
- }
-
- protected void setUp() {
-
- fDocument= new Document("x-x-x-x-x-x-x-x-x-x-x");
-
- try {
- fDocument.addPosition(new Position( 0, 0));
- fDocument.addPosition(new Position( 0, 1));
- fDocument.addPosition(new Position( 5, 0));
- fDocument.addPosition(new Position( 5, 3));
- } catch (BadLocationException x) {
- assertTrue("initilization failed", false);
- }
- }
-
- public static Test suite() {
- return new TestSuite(PositionUpdatingCornerCasesTest.class);
- }
-
- protected void tearDown () {
- fDocument= null;
- }
-
- public void testInsert() {
-
- try {
-
- fDocument.replace(0, 0, "yy");
-
- } catch (BadLocationException x) {
- assertTrue("BadLocationException thrown", false);
- }
-
- Position[] positions= new Position[] {
- new Position( 2, 1),
- new Position( 2, 0),
- new Position( 7, 3),
- new Position( 7, 0)
- };
-
- checkPositions(positions);
- }
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java
deleted file mode 100644
index e1d4bd4..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/TextEditTests.java
+++ /dev/null
@@ -1,1041 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.text.edits.CopySourceEdit;
-import org.eclipse.text.edits.CopyTargetEdit;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.InsertEdit;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MoveSourceEdit;
-import org.eclipse.text.edits.MoveTargetEdit;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.RangeMarker;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.text.edits.TextEditCopier;
-import org.eclipse.text.edits.UndoEdit;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-
-public class TextEditTests extends TestCase {
-
- private static final Class THIS= TextEditTests.class;
-
- private IDocument fDocument;
- private MultiTextEdit fRoot;
-
- public TextEditTests(String name) {
- super(name);
- }
-
- public static Test allTests() {
- return new TestSuite(THIS);
- }
-
- public static Test suite() {
- TestSuite result= new TestSuite(THIS);
- if (false) { // For hot code replace when debugging test cases
- result.addTestSuite(THIS);
- result.addTestSuite(THIS);
- result.addTestSuite(THIS);
- result.addTestSuite(THIS);
- result.addTestSuite(THIS);
- result.addTestSuite(THIS);
- }
- return result;
- }
-
- protected void setUp() throws Exception {
- fDocument= new Document("0123456789");
- fRoot= new MultiTextEdit();
- }
-
- protected void tearDown() throws Exception {
- fRoot= null;
- fRoot= null;
- }
-
- public void testOverlap1() throws Exception {
- // [ [ ] ]
- fRoot.addChild(new ReplaceEdit(0, 2, "01"));
- boolean exception= false;
- try {
- fRoot.addChild(new ReplaceEdit(1, 2, "12"));
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testOverlap2() throws Exception {
- // [[ ] ]
- fRoot.addChild(new ReplaceEdit(0, 2, "01"));
- boolean exception= false;
- try {
- fRoot.addChild(new ReplaceEdit(0, 1, "0"));
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testOverlap3() throws Exception {
- // [ [ ]]
- fRoot.addChild(new ReplaceEdit(0, 2, "01"));
- boolean exception= false;
- try {
- fRoot.addChild(new ReplaceEdit(1, 1, "1"));
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testOverlap4() throws Exception {
- // [ [ ] ]
- fRoot.addChild(new ReplaceEdit(0, 3, "012"));
- boolean exception= false;
- try {
- fRoot.addChild(new ReplaceEdit(1, 1, "1"));
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testOverlap5() throws Exception {
- // [ [] ]
- fRoot.addChild(new ReplaceEdit(0, 3, "012"));
- boolean exception= false;
- try {
- fRoot.addChild(new InsertEdit(1, "xx"));
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testOverlap6() throws Exception {
- // [ [] ]
- fRoot.addChild(new ReplaceEdit(0, 3, "012"));
- boolean exception= false;
- try {
- fRoot.addChild(new InsertEdit(2, "xx"));
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testOverlap7() throws Exception {
- MoveSourceEdit source= new MoveSourceEdit(2, 5);
- MoveTargetEdit target= new MoveTargetEdit(3, source);
- fRoot.addChild(source);
- boolean exception= false;
- try {
- fRoot.addChild(target);
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testOverlap8() throws Exception {
- MoveSourceEdit source= new MoveSourceEdit(2, 5);
- MoveTargetEdit target= new MoveTargetEdit(6, source);
- fRoot.addChild(source);
- boolean exception= false;
- try {
- fRoot.addChild(target);
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testOverlap9() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(3, 1);
- MoveTargetEdit t1= new MoveTargetEdit(7, s1);
- MoveSourceEdit s2= new MoveSourceEdit(2, 3);
- MoveTargetEdit t2= new MoveTargetEdit(8, s2);
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- boolean exception= false;
- try {
- fRoot.addChild(s2);
- fRoot.addChild(t2);
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testUnconnected1() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(3, 1);
- boolean exception= false;
- try {
- fRoot.addChild(s1);
- fRoot.apply(fDocument);
- } catch (MalformedTreeException e) {
- exception= true;
- }
- assertTrue(exception);
- }
-
- public void testBufferLength() throws Exception {
- MultiTextEdit edit= new MultiTextEdit(0, fDocument.getLength() + 1);
- boolean exception= false;
- try {
- fRoot.addChild(edit);
- fRoot.apply(fDocument);
- } catch (MalformedTreeException e) {
- exception= true;
- assertTrue(exception);
- }
- }
-
- public void testCopy1() throws Exception {
- MultiTextEdit root= new MultiTextEdit();
- TextEdit e1= new InsertEdit(2, "yy");
- TextEdit e2= new ReplaceEdit(2, 3, "3456");
- root.addChild(e1);
- root.addChild(e2);
- List org= flatten(root);
- TextEditCopier copier= new TextEditCopier(root);
- List copy= flatten(copier.perform());
- compare(copier, org, copy);
- }
-
- public void testCopy2() throws Exception {
- MultiTextEdit root= new MultiTextEdit();
- CopySourceEdit s1= new CopySourceEdit(5, 2);
- CopyTargetEdit t1= new CopyTargetEdit(8, s1);
- CopySourceEdit s2= new CopySourceEdit(5, 2);
- CopyTargetEdit t2= new CopyTargetEdit(2, s2);
- s1.addChild(s2);
- root.addChild(s1);
- root.addChild(t1);
- root.addChild(t2);
- List org= flatten(root);
- TextEditCopier copier= new TextEditCopier(root);
- List copy= flatten(copier.perform());
- compare(copier, org, copy);
- }
-
- private List flatten(TextEdit edit) {
- List result= new ArrayList();
- flatten(result, edit);
- return result;
- }
-
- private static void flatten(List result, TextEdit edit) {
- result.add(edit);
- TextEdit[] children= edit.getChildren();
- for (int i= 0; i < children.length; i++) {
- flatten(result, children[i]);
- }
- }
-
- private static void compare(TextEditCopier copier, List org, List copy) {
- assertTrue("Same length", org.size() == copy.size());
- for (Iterator iter= copy.iterator(); iter.hasNext();) {
- TextEdit edit= (TextEdit)iter.next();
- assertTrue("Original is part of copy list", !org.contains(edit));
- if (edit instanceof MoveSourceEdit) {
- MoveSourceEdit source= (MoveSourceEdit)edit;
- assertTrue("Target edit isn't a copy", copy.contains(source.getTargetEdit()));
- assertTrue("Traget edit is a original", !org.contains(source.getTargetEdit()));
- } else if (edit instanceof MoveTargetEdit) {
- MoveTargetEdit target= (MoveTargetEdit)edit;
- assertTrue("Source edit isn't a copy", copy.contains(target.getSourceEdit()));
- assertTrue("Source edit is a original", !org.contains(target.getSourceEdit()));
- } else if (edit instanceof CopySourceEdit) {
- CopySourceEdit source= (CopySourceEdit)edit;
- assertTrue("Target edit isn't a copy", copy.contains(source.getTargetEdit()));
- assertTrue("Traget edit is a original", !org.contains(source.getTargetEdit()));
- } else if (edit instanceof CopyTargetEdit) {
- CopyTargetEdit target= (CopyTargetEdit)edit;
- assertTrue("Source edit isn't a copy", copy.contains(target.getSourceEdit()));
- assertTrue("Source edit is a original", !org.contains(target.getSourceEdit()));
- }
- }
- }
-
- public void testInsert1() throws Exception {
- // [][ ]
- TextEdit e1= new InsertEdit(2, "yy");
- TextEdit e2= new ReplaceEdit(2, 3, "3456");
- fRoot.addChild(e1);
- fRoot.addChild(e2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(fRoot, 2, 6);
- assertEquals(e1, 2, 2);
- assertEquals(e2, 4, 4);
- assertEquals("Buffer content", "01yy345656789", fDocument.get());
- doUndoRedo(undo, "01yy345656789");
- }
-
- public void testInsert2() throws Exception {
- // [][]
- TextEdit e1= new InsertEdit(2, "yy");
- TextEdit e2= new InsertEdit(2, "xx");
- fRoot.addChild(e1);
- fRoot.addChild(e2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(fRoot, 2, 4);
- assertEquals(e1, 2, 2);
- assertEquals(e2, 4, 2);
- assertEquals("Buffer content", "01yyxx23456789", fDocument.get());
- doUndoRedo(undo, "01yyxx23456789");
- }
-
- public void testInsert3() throws Exception {
- // [ ][][ ]
- TextEdit e1= new ReplaceEdit(0, 2, "011");
- TextEdit e2= new InsertEdit(2, "xx");
- TextEdit e3= new ReplaceEdit(2, 2, "2");
- fRoot.addChild(e1);
- fRoot.addChild(e2);
- fRoot.addChild(e3);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(fRoot, 0, 6);
- assertEquals(e1, 0, 3);
- assertEquals(e2, 3, 2);
- assertEquals(e3, 5, 1);
- assertEquals("Buffer content", "011xx2456789", fDocument.get());
- doUndoRedo(undo, "011xx2456789");
- }
-
- public void testInsert4() throws Exception {
- TextEdit e1= new InsertEdit(0, "xx");
- fRoot.addChild(e1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer length", 12, fDocument.getLength());
- assertEquals(fRoot, 0, 2);
- assertEquals(e1, 0, 2);
- assertEquals("Buffer content", "xx0123456789", fDocument.get());
- doUndoRedo(undo, "xx0123456789");
- }
-
- public void testInsert5() throws Exception {
- TextEdit e1= new InsertEdit(10, "xx");
- fRoot.addChild(e1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer length", 12, fDocument.getLength());
- assertEquals(fRoot, 10, 2);
- assertEquals(e1, 10, 2);
- assertEquals("Buffer content", "0123456789xx", fDocument.get());
- doUndoRedo(undo, "0123456789xx");
- }
-
- public void testInsertReplace1() throws Exception {
- TextEdit e1= new ReplaceEdit(2, 1, "y");
- TextEdit e2= new InsertEdit(2, "xx");
- fRoot.addChild(e1);
- fRoot.addChild(e2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(fRoot, 2, 3);
- assertEquals(e1, 4, 1);
- assertEquals(e2, 2, 2);
- assertEquals("Buffer content", "01xxy3456789", fDocument.get());
- doUndoRedo(undo, "01xxy3456789");
- }
-
- public void testDelete1() throws Exception {
- TextEdit e1= new DeleteEdit(3, 1);
- fRoot.addChild(e1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(fRoot, 3, 0);
- assertEquals(e1, 3, 0);
- assertEquals("Buffer content", "012456789", fDocument.get());
- doUndoRedo(undo, "012456789");
- }
-
- public void testDelete2() throws Exception {
- TextEdit e1= new DeleteEdit(4, 1);
- TextEdit e2= new DeleteEdit(3, 1);
- TextEdit e3= new DeleteEdit(5, 1);
- fRoot.addChild(e1);
- fRoot.addChild(e2);
- fRoot.addChild(e3);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(fRoot, 3, 0);
- assertEquals(e1, 3, 0);
- assertEquals(e2, 3, 0);
- assertEquals(e3, 3, 0);
- assertEquals("Buffer content", "0126789", fDocument.get());
- doUndoRedo(undo, "0126789");
- }
-
- public void testDelete3() throws Exception {
- TextEdit e1= new InsertEdit(3, "x");
- TextEdit e2= new DeleteEdit(3, 1);
- fRoot.addChild(e1);
- fRoot.addChild(e2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(fRoot, 3, 1);
- assertEquals(e1, 3, 1);
- assertEquals(e2, 4, 0);
- assertEquals("Buffer content", "012x456789", fDocument.get());
- doUndoRedo(undo, "012x456789");
- }
-
- public void testDeleteWithChildren() throws Exception {
- TextEdit e1= new DeleteEdit(2, 6);
- MultiTextEdit e2= new MultiTextEdit(3, 3);
- e1.addChild(e2);
- TextEdit e3= new ReplaceEdit(3, 1, "xx");
- TextEdit e4= new ReplaceEdit(5, 1, "yy");
- e2.addChild(e3);
- e2.addChild(e4);
- fRoot.addChild(e1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0189", fDocument.get());
- assertEquals(fRoot, 2, 0);
- assertEquals(e1, 2, 0);
- assertTrue(e2.isDeleted());
- assertTrue(e3.isDeleted());
- assertTrue(e4.isDeleted());
- doUndoRedo(undo, "0189");
- }
-
- public void testTreeUpdate1() throws Exception {
- MultiTextEdit m1= new MultiTextEdit();
- TextEdit e1= new InsertEdit(2, "aa");
- TextEdit e2= new InsertEdit(4, "bb");
- m1.addChild(e1);
- m1.addChild(e2);
- MultiTextEdit m2= new MultiTextEdit();
- TextEdit e3= new InsertEdit(6, "cc");
- TextEdit e4= new InsertEdit(8, "dd");
- m2.addChild(e3);
- m2.addChild(e4);
- fRoot.addChild(m1);
- fRoot.addChild(m2);
- assertEquals(m1, 2, 2);
- assertEquals(m2, 6, 2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "01aa23bb45cc67dd89", fDocument.get());
- assertEquals(e1, 2, 2);
- assertEquals(e2, 6, 2);
- assertEquals(e3, 10, 2);
- assertEquals(e4, 14, 2);
- assertEquals(m1, 2, 6);
- assertEquals(m2, 10, 6);
- assertEquals(fRoot, 2, 14);
- doUndoRedo(undo, "01aa23bb45cc67dd89");
- }
-
- public void testMove1() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(2, 2);
- MoveTargetEdit t1= new MoveTargetEdit(5, s1);
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0142356789", fDocument.get());
- assertEquals(s1, 2, 0);
- assertEquals(t1, 3, 2);
- doUndoRedo(undo, "0142356789");
- }
-
- public void testMove2() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(5, 2);
- MoveTargetEdit t1= new MoveTargetEdit(2, s1);
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0156234789", fDocument.get());
- assertEquals(s1, 7, 0);
- assertEquals(t1, 2, 2);
- doUndoRedo(undo, "0156234789");
- }
-
- public void testMove3() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(2, 2);
- MoveTargetEdit t1= new MoveTargetEdit(7, s1);
- TextEdit e2= new ReplaceEdit(4, 1, "x");
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- fRoot.addChild(e2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "01x5623789", fDocument.get());
- assertEquals(s1, 2, 0);
- assertEquals(t1, 5, 2);
- assertEquals(e2, 2, 1);
- doUndoRedo(undo, "01x5623789");
- }
-
- public void testMove4() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(7, 2);
- MoveTargetEdit t1= new MoveTargetEdit(2, s1);
- TextEdit e2= new ReplaceEdit(5, 1, "x");
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- fRoot.addChild(e2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0178234x69", fDocument.get());
- assertEquals(s1, 9, 0);
- assertEquals(t1, 2, 2);
- assertEquals(e2, 7, 1);
- doUndoRedo(undo, "0178234x69");
- }
-
- public void testMove5() throws Exception {
- // Move onto itself
- MoveSourceEdit s1= new MoveSourceEdit(2, 1);
- MoveTargetEdit t1= new MoveTargetEdit(3, s1);
- TextEdit e2= new ReplaceEdit(2, 1, "x");
- s1.addChild(e2);
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 2, 0);
- assertEquals(t1, 2, 1);
- assertEquals(e2, 2, 1);
- assertEquals("Buffer content", "01x3456789", fDocument.get());
- doUndoRedo(undo, "01x3456789");
- }
-
- public void testMove6() throws Exception {
- // Move onto itself
- MoveSourceEdit s1= new MoveSourceEdit(2, 1);
- MoveTargetEdit t1= new MoveTargetEdit(2, s1);
- TextEdit e2= new ReplaceEdit(2, 1, "x");
- s1.addChild(e2);
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 3, 0);
- assertEquals(t1, 2, 1);
- assertEquals(e2, 2, 1);
- assertEquals("Buffer content", "01x3456789", fDocument.get());
- doUndoRedo(undo,"01x3456789");
- }
-
- public void testMove7() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(2, 3);
- MoveTargetEdit t1= new MoveTargetEdit(7, s1);
- TextEdit e2= new ReplaceEdit(3, 1, "x");
- s1.addChild(e2);
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "01562x4789", fDocument.get());
- assertEquals(s1, 2, 0);
- assertEquals(t1, 4, 3);
- assertEquals(e2, 5, 1);
- doUndoRedo(undo, "01562x4789");
- }
-
- public void testMove8() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(5, 3);
- MoveTargetEdit t1= new MoveTargetEdit(1, s1);
- TextEdit e2= new ReplaceEdit(6, 1, "x");
- s1.addChild(e2);
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "05x7123489", fDocument.get());
- assertEquals(s1, 8, 0);
- assertEquals(t1, 1, 3);
- assertEquals(e2, 2, 1);
- doUndoRedo(undo, "05x7123489");
- }
-
- public void testMove9() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(1, 3);
- MoveTargetEdit t1= new MoveTargetEdit(5, s1);
-
- MoveSourceEdit s2= new MoveSourceEdit(1, 1);
- MoveTargetEdit t2= new MoveTargetEdit(3, s2);
- s1.addChild(s2);
- s1.addChild(t2);
-
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 1, 0);
- assertEquals(t1, 2, 3);
-
- assertEquals(s2, 2, 0);
- assertEquals(t2, 3, 1);
- assertEquals("Buffer content", "0421356789", fDocument.get());
- doUndoRedo(undo, "0421356789");
- }
-
- public void testMove10() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(2, 2);
- MoveTargetEdit t1= new MoveTargetEdit(8, s1);
- MoveSourceEdit s2= new MoveSourceEdit(5, 2);
- MoveTargetEdit t2= new MoveTargetEdit(1, s2);
-
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- fRoot.addChild(s2);
- fRoot.addChild(t2);
-
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 4, 0);
- assertEquals(t1, 6, 2);
- assertEquals(s2, 5, 0);
- assertEquals(t2, 1, 2);
- assertEquals("Buffer content", "0561472389", fDocument.get());
- doUndoRedo(undo, "0561472389");
- }
-
- public void testMoveWithRangeMarker() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(2, 2);
- MoveTargetEdit t1= new MoveTargetEdit(5, s1);
-
- RangeMarker marker= new RangeMarker(2, 2);
- s1.addChild(marker);
-
- fRoot.addChild(s1);
- fRoot.addChild(t1);
-
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0142356789", fDocument.get());
- assertEquals(s1, 2, 0);
- assertEquals(t1, 3, 2);
- assertEquals(marker, 3, 2);
- doUndoRedo(undo, "0142356789");
- }
-
- public void testMoveWithTargetDelete() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(2, 3);
- MoveTargetEdit t1= new MoveTargetEdit(7, s1);
- TextEdit e2= new DeleteEdit(6, 2);
- e2.addChild(t1);
- fRoot.addChild(s1);
- fRoot.addChild(e2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "01589", fDocument.get());
- assertEquals(s1, 2, 0);
- assertTrue(t1.isDeleted());
- assertEquals(e2, 3, 0);
- doUndoRedo(undo, "01589");
- }
-
- public void testMoveUpWithSourceDelete() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(5, 2);
- MoveTargetEdit t1= new MoveTargetEdit(2, s1);
-
- TextEdit d1= new DeleteEdit(5, 2);
- d1.addChild(s1);
-
- RangeMarker marker= new RangeMarker(5, 2);
- s1.addChild(marker);
-
- fRoot.addChild(d1);
- fRoot.addChild(t1);
-
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0156234789", fDocument.get());
- assertEquals(t1, 2, 2);
- assertEquals(marker, 2, 2);
- assertTrue(s1.isDeleted());
- assertEquals(d1, 7, 0);
- doUndoRedo(undo, "0156234789");
- }
-
- public void testMoveDown() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(2, 2);
- TextEdit i1= new InsertEdit(5, "x");
- MoveTargetEdit t1= new MoveTargetEdit(7, s1);
- TextEdit d1= new DeleteEdit(9, 1);
-
- RangeMarker m1= new RangeMarker(2, 2);
- s1.addChild(m1);
-
- fRoot.addChild(s1);
- fRoot.addChild(i1);
- fRoot.addChild(t1);
- fRoot.addChild(d1);
-
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "014x562378", fDocument.get());
- assertEquals(s1, 2, 0);
- assertEquals(i1, 3, 1);
- assertEquals(t1, 6, 2);
- assertEquals(m1, 6, 2);
- assertEquals(d1, 10, 0);
- doUndoRedo(undo, "014x562378");
- }
-
- public void testMoveUp() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(7, 2);
- MoveTargetEdit t1= new MoveTargetEdit(2, s1);
- TextEdit i1= new InsertEdit(5, "x");
- TextEdit d1= new DeleteEdit(9, 1);
-
- RangeMarker m1= new RangeMarker(7, 2);
- s1.addChild(m1);
-
- fRoot.addChild(s1);
- fRoot.addChild(i1);
- fRoot.addChild(t1);
- fRoot.addChild(d1);
-
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0178234x56", fDocument.get());
- assertEquals(s1, 10, 0);
- assertEquals(i1, 7, 1);
- assertEquals(t1, 2, 2);
- assertEquals(m1, 2, 2);
- assertEquals(d1, 10, 0);
- doUndoRedo(undo, "0178234x56");
- }
-
- public void testMoveDownWithSourceDelete() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(2, 2);
- MoveTargetEdit t1= new MoveTargetEdit(7, s1);
-
- TextEdit d1= new DeleteEdit(2, 2);
- d1.addChild(s1);
-
- RangeMarker m1= new RangeMarker(2, 2);
- s1.addChild(m1);
-
- fRoot.addChild(t1);
- fRoot.addChild(d1);
-
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0145623789", fDocument.get());
- assertEquals(d1, 2, 0);
- assertTrue(s1.isDeleted());
- assertEquals(t1, 5, 2);
- assertEquals(m1, 5, 2);
- doUndoRedo(undo, "0145623789");
- }
-
- public void testMoveUpWithInnerMark() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(7, 2);
- MoveTargetEdit t1= new MoveTargetEdit(2, s1);
- TextEdit m= new ReplaceEdit(4, 1, "yy");
- fRoot.addChild(t1);
- fRoot.addChild(m);
- fRoot.addChild(s1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "017823yy569", fDocument.get());
- assertEquals(s1, 10, 0);
- assertEquals(t1, 2, 2);
- assertEquals(m, 6, 2);
- doUndoRedo(undo, "017823yy569");
- }
-
- public void testMoveDownWithInnerMark() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(2, 2);
- MoveTargetEdit t1= new MoveTargetEdit(7, s1);
- TextEdit m= new ReplaceEdit(4, 1, "yy");
- fRoot.addChild(t1);
- fRoot.addChild(m);
- fRoot.addChild(s1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "01yy5623789", fDocument.get());
- assertEquals(s1, 2, 0);
- assertEquals(t1, 6, 2);
- assertEquals(m, 2, 2);
- doUndoRedo(undo, "01yy5623789");
- }
-
- public void testMoveUpWithParentMark() throws Exception {
- RangeMarker m= new RangeMarker(2, 6);
- MoveSourceEdit s1= new MoveSourceEdit(4, 2);
- MoveTargetEdit t1= new MoveTargetEdit(3, s1);
- m.addChild(s1);
- m.addChild(t1);
- fRoot.addChild(m);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0124536789", fDocument.get());
- assertEquals(m, 2, 6);
- assertEquals(t1, 3, 2);
- assertEquals(s1, 6, 0);
- doUndoRedo(undo, "0124536789");
- }
-
- public void testMoveDownWithParentMark() throws Exception {
- RangeMarker m= new RangeMarker(2, 6);
- MoveSourceEdit s1= new MoveSourceEdit(2, 2);
- MoveTargetEdit t1= new MoveTargetEdit(5, s1);
- m.addChild(s1);
- m.addChild(t1);
- fRoot.addChild(m);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals("Buffer content", "0142356789", fDocument.get());
- assertEquals(m, 2, 6);
- assertEquals(t1, 3, 2);
- assertEquals(s1, 2, 0);
- doUndoRedo(undo, "0142356789");
- }
-
- public void testNestedMoveSource() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(1, 5);
- MoveSourceEdit s2= new MoveSourceEdit(2, 3);
- MoveSourceEdit s3= new MoveSourceEdit(3, 1);
- s1.addChild(s2);
- s2.addChild(s3);
- MoveTargetEdit t1= new MoveTargetEdit(9, s1);
- MoveTargetEdit t2= new MoveTargetEdit(8, s2);
- MoveTargetEdit t3= new MoveTargetEdit(7, s3);
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- fRoot.addChild(t2);
- fRoot.addChild(t3);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 1, 0);
- assertEquals(s2, 8, 0);
- assertEquals(s3, 5, 0);
- assertEquals(t1, 7, 2);
- assertEquals(t2, 4, 2);
- assertEquals(t3, 2, 1);
- String result= "0637248159";
- assertEquals("Buffer content", result, fDocument.get());
- doUndoRedo(undo, result);
- }
-
- public void testNestedMoveTarget() throws Exception {
- MoveSourceEdit s1= new MoveSourceEdit(1, 2);
- MoveSourceEdit s2= new MoveSourceEdit(5, 3);
- MoveTargetEdit t1= new MoveTargetEdit(6, s1);
- MoveTargetEdit t2= new MoveTargetEdit(9, s2);
- s2.addChild(t1);
- fRoot.addChild(s1);
- fRoot.addChild(s2);
- fRoot.addChild(t2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 1, 0);
- assertEquals(s2, 3, 0);
- assertEquals(t1, 5, 2);
- assertEquals(t2, 4, 5);
- String result= "0348512679";
- assertEquals("Buffer content", result, fDocument.get());
- doUndoRedo(undo, result);
- }
-
- public void testCopyDown() throws Exception {
- CopySourceEdit s1= new CopySourceEdit(2, 3);
- CopyTargetEdit t1= new CopyTargetEdit(8, s1);
-
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 2, 3);
- assertEquals(t1, 8, 3);
- String result= "0123456723489";
- assertEquals("Buffer content", result, fDocument.get());
- doUndoRedo(undo, result);
- }
-
- public void testCopyUp() throws Exception {
- CopySourceEdit s1= new CopySourceEdit(7, 2);
- CopyTargetEdit t1= new CopyTargetEdit(3, s1);
-
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 9, 2);
- assertEquals(t1, 3, 2);
- String result= "012783456789";
- assertEquals("Buffer content", result, fDocument.get());
- doUndoRedo(undo, result);
- }
-
- public void testDoubleCopy() throws Exception {
- CopySourceEdit s1= new CopySourceEdit(5, 2);
- CopyTargetEdit t1= new CopyTargetEdit(8, s1);
- CopySourceEdit s2= new CopySourceEdit(5, 2);
- CopyTargetEdit t2= new CopyTargetEdit(2, s2);
- s1.addChild(s2);
-
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- fRoot.addChild(t2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 7, 2);
- assertEquals(t1, 10, 2);
- assertEquals(s2, 7, 2);
- assertEquals(t2, 2, 2);
- String result= "01562345675689";
- assertEquals("Buffer content", result, fDocument.get());
- doUndoRedo(undo, result);
- }
-
- public void testNestedCopySource() throws Exception {
- CopySourceEdit s1= new CopySourceEdit(1, 5);
- CopySourceEdit s2= new CopySourceEdit(2, 3);
- CopySourceEdit s3= new CopySourceEdit(3, 1);
- s1.addChild(s2);
- s2.addChild(s3);
- CopyTargetEdit t1= new CopyTargetEdit(9, s1);
- CopyTargetEdit t2= new CopyTargetEdit(8, s2);
- CopyTargetEdit t3= new CopyTargetEdit(7, s3);
- fRoot.addChild(s1);
- fRoot.addChild(t1);
- fRoot.addChild(t2);
- fRoot.addChild(t3);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 1, 5);
- assertEquals(s2, 2, 3);
- assertEquals(s3, 3, 1);
- assertEquals(t1, 13, 5);
- assertEquals(t2, 9, 3);
- assertEquals(t3, 7, 1);
- String result= "0123456372348123459";
- assertEquals("Buffer content", result, fDocument.get());
- doUndoRedo(undo, result);
- }
-
- public void testNestedCopyTarget() throws Exception {
- CopySourceEdit s1= new CopySourceEdit(1, 2);
- CopySourceEdit s2= new CopySourceEdit(5, 3);
- CopyTargetEdit t1= new CopyTargetEdit(6, s1);
- CopyTargetEdit t2= new CopyTargetEdit(9, s2);
- s2.addChild(t1);
- fRoot.addChild(s1);
- fRoot.addChild(s2);
- fRoot.addChild(t2);
- UndoEdit undo= fRoot.apply(fDocument);
- assertEquals(s1, 1, 2);
- assertEquals(s2, 5, 5);
- assertEquals(t1, 6, 2);
- assertEquals(t2, 11, 5);
- String result= "01234512678512679";
- assertEquals("Buffer content", result, fDocument.get());
- doUndoRedo(undo, result);
- }
-
- public void testSwap1() throws Exception {
- IDocument document= new Document("foo(1, 2), 3");
-
- MultiTextEdit root= new MultiTextEdit();
- {
- CopySourceEdit innerRoot= new CopySourceEdit(0, 9);
-
- TextEdit e1= new ReplaceEdit(0, 9, "");
- e1.addChild(innerRoot);
- CopyTargetEdit t1= new CopyTargetEdit(11, innerRoot);
-
- TextEdit e2= new ReplaceEdit(11, 1, "");
- CopySourceEdit s2= new CopySourceEdit(11, 1);
- e2.addChild(s2);
- CopyTargetEdit t2= new CopyTargetEdit(0, s2);
-
- root.addChild(e1);
- root.addChild(t2);
- root.addChild(e2);
- root.addChild(t1);
- }
-
- root.apply(document);
-
- String result= "3, foo(1, 2)";
- assertEquals("Buffer content", result, document.get());
- }
-
- public void testSwap2() throws Exception {
- IDocument document= new Document("foo(1, 2), 3");
-
- MultiTextEdit root= new MultiTextEdit();
- {
- TextEdit e1= new ReplaceEdit(4, 1, "");
- CopySourceEdit s1= new CopySourceEdit(4, 1);
- e1.addChild(s1);
- CopyTargetEdit t1= new CopyTargetEdit(7, s1);
-
- TextEdit e2= new ReplaceEdit(7, 1, "");
- CopySourceEdit s2= new CopySourceEdit(7, 1);
- e2.addChild(s2);
- CopyTargetEdit t2= new CopyTargetEdit(4, s2);
-
- root.addChild(e1);
- root.addChild(t2);
- root.addChild(e2);
- root.addChild(t1);
- }
-
- root.apply(document);
-
- String result= "foo(2, 1), 3";
- assertEquals("Buffer content", result, document.get());
- }
-
- public void testSwap2InSwap1() throws Exception {
- IDocument document= new Document("foo(1, 2), 3");
-
- CopySourceEdit innerRoot= new CopySourceEdit(0, 9);
- {
- TextEdit e1= new ReplaceEdit(4, 1, "");
- CopySourceEdit s1= new CopySourceEdit(4, 1);
- e1.addChild(s1);
- CopyTargetEdit t1= new CopyTargetEdit(7, s1);
-
- TextEdit e2= new ReplaceEdit(7, 1, "");
- CopySourceEdit s2= new CopySourceEdit(7, 1);
- e2.addChild(s2);
- CopyTargetEdit t2= new CopyTargetEdit(4, s2);
-
- innerRoot.addChild(e1);
- innerRoot.addChild(t2);
- innerRoot.addChild(e2);
- innerRoot.addChild(t1);
- }
- MultiTextEdit root= new MultiTextEdit();
- {
- TextEdit e1= new ReplaceEdit(0, 9, "");
- e1.addChild(innerRoot);
- CopyTargetEdit t1= new CopyTargetEdit(11, innerRoot);
-
- TextEdit e2= new ReplaceEdit(11, 1, "");
- CopySourceEdit s2= new CopySourceEdit(11, 1);
- e2.addChild(s2);
- CopyTargetEdit t2= new CopyTargetEdit(0, s2);
-
- root.addChild(e1);
- root.addChild(t2);
- root.addChild(e2);
- root.addChild(t1);
- }
-
- root.apply(document);
-
- String result= "3, foo(2, 1)";
- assertEquals("Buffer content", result, document.get());
- }
-
- private void doUndoRedo(UndoEdit undo, String redoResult) throws Exception {
- UndoEdit redo= undo.apply(fDocument);
- assertBufferContent();
- undo= redo.apply(fDocument);
- assertEquals("Buffer content redo", redoResult, fDocument.get());
- undo.apply(fDocument);
- assertBufferContent();
- }
-
- private void assertEquals(TextEdit edit, int offset, int length) {
- assertEquals("Offset", offset, edit.getOffset());
- assertEquals("Length", length, edit.getLength());
- }
-
- private void assertBufferContent() {
- assertEquals("Buffer content restored", "0123456789", fDocument.get());
- }
-}
-
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/ExclusivePositionUpdaterTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/link/ExclusivePositionUpdaterTest.java
deleted file mode 100644
index 5348813..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/ExclusivePositionUpdaterTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests.link;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.link.ExclusivePositionUpdater;
-
-public class ExclusivePositionUpdaterTest extends TestCase {
-
- private ExclusivePositionUpdater fUpdater;
- private static final String CATEGORY= "testcategory";
- private Position fPos;
- private IDocument fDoc;
- /*
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- fUpdater= new ExclusivePositionUpdater(CATEGORY);
- fDoc= new Document("ccccccccccccccccccccccccccccccccccccccccccccc");
- fPos= new Position(5, 5);
- fDoc.addPositionUpdater(fUpdater);
- fDoc.addPositionCategory(CATEGORY);
- fDoc.addPosition(CATEGORY, fPos);
- }
-
- public void testDeleteAfter() throws BadLocationException {
- fDoc.replace(20, 2, null);
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testAddAfter() throws BadLocationException {
- fDoc.replace(20, 0, "yy");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testDeleteBefore() throws BadLocationException {
- fDoc.replace(2, 2, null);
- Assert.assertEquals(3, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testAddBefore() throws BadLocationException {
- fDoc.replace(2, 0, "yy");
- Assert.assertEquals(7, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testAddRightBefore() throws BadLocationException {
- fDoc.replace(5, 0, "yy");
- Assert.assertEquals(7, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testDeleteRightBefore() throws BadLocationException {
- fDoc.replace(5, 2, "");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(3, fPos.length);
- }
-
- public void testAddRightAfter() throws BadLocationException {
- fDoc.replace(10, 0, "yy");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testDeleteRightAfter() throws BadLocationException {
- fDoc.replace(10, 2, "");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testAddWithin() throws BadLocationException {
- fDoc.replace(6, 0, "yy");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(7, fPos.length);
- }
-
- public void testDeleteWithin() throws BadLocationException {
- fDoc.replace(6, 2, "");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(3, fPos.length);
- }
-
- public void testReplaceLeftBorder() throws BadLocationException {
- fDoc.replace(4, 2, "yy");
- Assert.assertEquals(6, fPos.offset);
- Assert.assertEquals(4, fPos.length);
- }
-
- public void testReplaceRightBorder() throws BadLocationException {
- fDoc.replace(9, 2, "yy");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(4, fPos.length);
- }
-
- public void testDeleteOverRightBorder() throws BadLocationException {
- fDoc.replace(9, 2, "");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(4, fPos.length);
- }
-
- public void testDeleted() throws BadLocationException {
- fDoc.replace(4, 7, null);
- Assert.assertTrue(fPos.isDeleted);
- }
-
- public void testReplaced() throws BadLocationException {
- fDoc.replace(4, 7, "yyyyyyy");
- Assert.assertTrue(fPos.isDeleted);
- }
-
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/InclusivePositionUpdaterTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/link/InclusivePositionUpdaterTest.java
deleted file mode 100644
index 6fd987c..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/InclusivePositionUpdaterTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests.link;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.link.InclusivePositionUpdater;
-
-public class InclusivePositionUpdaterTest extends TestCase {
-
- private InclusivePositionUpdater fUpdater;
- private static final String CATEGORY= "testcategory";
- private Position fPos;
- private IDocument fDoc;
- /*
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- fUpdater= new InclusivePositionUpdater(CATEGORY);
- fDoc= new Document("ccccccccccccccccccccccccccccccccccccccccccccc");
- fPos= new Position(5, 5);
- fDoc.addPositionUpdater(fUpdater);
- fDoc.addPositionCategory(CATEGORY);
- fDoc.addPosition(CATEGORY, fPos);
- }
-
- /*
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- fDoc.removePositionUpdater(fUpdater);
- fDoc.removePositionCategory(CATEGORY);
- }
-
- public void testDeleteAfter() throws BadLocationException {
- fDoc.replace(20, 2, null);
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testAddAfter() throws BadLocationException {
- fDoc.replace(20, 0, "yy");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testDeleteBefore() throws BadLocationException {
- fDoc.replace(2, 2, null);
- Assert.assertEquals(3, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testAddBefore() throws BadLocationException {
- fDoc.replace(2, 0, "yy");
- Assert.assertEquals(7, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testAddRightBefore() throws BadLocationException {
- fDoc.replace(5, 0, "yy");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(7, fPos.length);
- }
-
- public void testDeleteAtOffset() throws BadLocationException {
- fDoc.replace(5, 2, "");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(3, fPos.length);
- }
-
- public void testDeleteRightBefore() throws BadLocationException {
- fDoc.replace(3, 2, "");
- Assert.assertEquals(3, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testAddRightAfter() throws BadLocationException {
- fDoc.replace(10, 0, "yy");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(7, fPos.length);
- }
-
- public void testDeleteRightAfter() throws BadLocationException {
- fDoc.replace(10, 2, "");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(5, fPos.length);
- }
-
- public void testAddWithin() throws BadLocationException {
- fDoc.replace(6, 0, "yy");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(7, fPos.length);
- }
-
- public void testDeleteWithin() throws BadLocationException {
- fDoc.replace(6, 2, "");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(3, fPos.length);
- }
-
- public void testReplaceLeftBorder() throws BadLocationException {
- fDoc.replace(4, 2, "yy");
- Assert.assertEquals(4, fPos.offset);
- Assert.assertEquals(6, fPos.length);
- }
-
- public void testReplaceRightBorder() throws BadLocationException {
- fDoc.replace(9, 2, "yy");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(6, fPos.length);
- }
-
- public void testDeleteOverRightBorder() throws BadLocationException {
- fDoc.replace(9, 2, "");
- Assert.assertEquals(5, fPos.offset);
- Assert.assertEquals(4, fPos.length);
- }
-
- public void testDeleted() throws BadLocationException {
- fDoc.replace(4, 7, null);
- Assert.assertTrue(fPos.isDeleted);
- }
-
- public void testReplaced() throws BadLocationException {
- fDoc.replace(4, 7, "yyyyyyy");
- Assert.assertTrue(fPos.isDeleted);
- }
-
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedEnvironmentTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedEnvironmentTest.java
deleted file mode 100644
index 550289b..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedEnvironmentTest.java
+++ /dev/null
@@ -1,679 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests.link;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.link.ILinkedListener;
-import org.eclipse.jface.text.link.LinkedEnvironment;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.link.LinkedPositionGroup;
-
-
-public class LinkedEnvironmentTest extends TestCase {
-
- private List fPositions= new LinkedList();
-
- private List fDocumentMap= new ArrayList();
-
- public void testUpdate() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group1);
- env.forceInstall();
-
- // edit the document
- doc1.replace(1, 9, "GRETCHEN");
-
- assertEquals(group1, "GRETCHEN");
- assertUnchanged(group1);
- }
-
- public void testUpdateTwoGroups() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
-
- LinkedPositionGroup group2= new LinkedPositionGroup();
- createLinkedPositions(group2, doc1, "FAUST");
-
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group1);
- env.addGroup(group2);
-
- env.forceInstall();
-
-
- // edit the document
- doc1.replace(7, 3, "INE");
-
- assertEquals(group1, "MARGARINE");
- assertEquals(group2, "FAUST");
- assertUnchanged(group1, group2);
- }
-
- public void testUpdateMultipleGroups() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
-
- LinkedPositionGroup group2= new LinkedPositionGroup();
- createLinkedPositions(group2, doc1, "FAUST");
-
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group1);
- env.addGroup(group2);
-
- env.forceInstall();
-
-
- // edit the document
- doc1.replace(7, 3, "INE");
- doc1.replace(42, 1, "");
- doc1.replace(44, 2, "GE");
-
- assertEquals(group1, "MARGARINE");
- assertEquals(group2, "AUGE");
- assertUnchanged(group1, group2);
- }
-
- public void testUpdateMultiDocument() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
- IDocument doc2= new Document(GARTEN2);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
- createLinkedPositions(group1, doc2, "MARGARETE");
-
- LinkedPositionGroup group2= new LinkedPositionGroup();
- createLinkedPositions(group2, doc1, "FAUST");
- createLinkedPositions(group2, doc2, "FAUST");
-
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group1);
- env.addGroup(group2);
-
- env.forceInstall();
-
-
- // edit the document
- doc1.replace(7, 3, "INE");
- doc1.replace(42, 1, "");
- doc1.replace(44, 2, "GE");
-
- assertEquals(group1, "MARGARINE");
- assertEquals(group2, "AUGE");
- assertUnchanged(group1, group2);
-
- }
-
- public void testAddCompatibleGroups() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
-
- LinkedPositionGroup group2= new LinkedPositionGroup();
- createLinkedPositions(group2, doc1, "FAUST");
-
- LinkedEnvironment env= new LinkedEnvironment();
- try {
- env.addGroup(group1);
- env.addGroup(group2);
- } catch (BadLocationException e) {
- assertFalse(true);
- }
- assertUnchanged(group1, group2);
-
- }
-
- public void testAddIncompatibleGroups() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
-
- LinkedPositionGroup group2= new LinkedPositionGroup();
- createLinkedPositions(group2, doc1, "MARGA");
-
- LinkedEnvironment env= new LinkedEnvironment();
- try {
- env.addGroup(group1);
- env.addGroup(group2);
- } catch (BadLocationException e) {
- return;
- }
- assertFalse(true);
- }
-
- public void testAddNullGroup() throws BadLocationException {
- LinkedEnvironment env= new LinkedEnvironment();
- try {
- env.addGroup(null);
- } catch (IllegalArgumentException e) {
- return;
- }
-
- assertFalse(true);
- }
-
- public void testAddGroupWhenSealed() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group1);
- env.forceInstall();
-
- LinkedPositionGroup group2= new LinkedPositionGroup();
- createLinkedPositions(group2, doc1, "FAUST");
- try {
- env.addGroup(group2);
- } catch (IllegalStateException e) {
- return;
- }
-
- assertFalse(true);
- }
-
- public void testDoubleInstall() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group1);
-
- env.forceInstall();
-
- try {
- env.forceInstall();
- } catch (IllegalStateException e) {
- return;
- }
-
- assertFalse(true);
- }
-
- public void testEmptyInstall() throws BadLocationException {
- LinkedEnvironment env= new LinkedEnvironment();
-
- try {
- env.forceInstall();
- } catch (IllegalStateException e) {
- return;
- }
-
- assertFalse(true);
- }
-
- public void testNestedUpdate() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
-
- LinkedPositionGroup group2= new LinkedPositionGroup();
- createLinkedPositions(group2, doc1, "FAUST");
-
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group1);
- env.addGroup(group2);
-
- env.forceInstall();
-
- // second level
-
- LinkedPositionGroup group1_2= new LinkedPositionGroup();
- group1_2.createPosition(doc1, 7, 3);
-
-
- LinkedEnvironment childEnv= new LinkedEnvironment();
- childEnv.addGroup(group1_2);
- childEnv.forceInstall();
-
- assertTrue(childEnv.isNested());
- assertFalse(env.isNested());
-
-
- // edit the document
- doc1.replace(7, 3, "INE");
-
- assertEquals(group1_2, "INE");
- assertEquals(group1, "MARGARINE");
- assertEquals(group2, "FAUST");
- assertUnchanged(group1, group2);
- }
-
- public void testNestedForceInstall() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
-
- LinkedPositionGroup group2= new LinkedPositionGroup();
- createLinkedPositions(group2, doc1, "FAUST");
-
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group1);
- env.addGroup(group2);
-
- final boolean[] isExit= { false } ;
- env.addLinkedListener(new LinkedAdapter() {
- public void left(LinkedEnvironment environment, int flags) {
- isExit[0]= true;
- }
- });
-
- env.forceInstall();
-
-
- // second level
-
- LinkedPositionGroup group1_2= new LinkedPositionGroup();
-
- group1_2.createPosition(doc1, 12, 3);
-
- LinkedEnvironment childEnv= new LinkedEnvironment();
- childEnv.addGroup(group1_2);
- childEnv.forceInstall();
-
- assertFalse(childEnv.isNested());
- assertTrue(isExit[0]);
-
-
- // edit the document
- doc1.replace(12, 3, "INE");
-
- assertEquals(group1_2, "INE");
- }
-
- public void testNestedTryInstall() throws BadLocationException {
- IDocument doc1= new Document(GARTEN1);
-
- // set up linked mode
- LinkedPositionGroup group1= new LinkedPositionGroup();
- createLinkedPositions(group1, doc1, "MARGARETE");
-
- LinkedPositionGroup group2= new LinkedPositionGroup();
- createLinkedPositions(group2, doc1, "FAUST");
-
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group1);
- env.addGroup(group2);
- env.forceInstall();
-
-
- // second level
-
- LinkedPositionGroup group1_2= new LinkedPositionGroup();
- group1_2.createPosition(doc1, 12, 3);
-
- LinkedEnvironment childEnv= new LinkedEnvironment();
- childEnv.addGroup(group1_2);
-
- final boolean[] isExit= { false } ;
- env.addLinkedListener(new LinkedAdapter() {
- public void left(LinkedEnvironment environment, int flags) {
- isExit[0]= true;
- }
- });
-
- assertFalse(childEnv.tryInstall());
- assertFalse(childEnv.isNested());
-
-
- // edit the document
- doc1.replace(7, 3, "INE");
-
- assertEquals(group1, "MARGARINE");
- assertUnchanged(group1, group2);
- }
-
- private void assertEquals(LinkedPositionGroup group, String expected) throws BadLocationException {
- LinkedPosition[] positions= group.getPositions();
- for (int i= 0; i < positions.length; i++) {
- LinkedPosition pos= positions[i];
- assertEquals(expected, pos.getContent());
- }
- }
-
- private void assertUnchanged(LinkedPositionGroup actual1) throws BadLocationException {
- assertUnchanged(actual1, new LinkedPositionGroup());
- }
-
- private void assertUnchanged(LinkedPositionGroup actual1, LinkedPositionGroup actual2) throws BadLocationException {
- LinkedPosition[] exp= (LinkedPosition[]) fPositions.toArray(new LinkedPosition[0]);
- LinkedPosition[] act1= actual1.getPositions();
- LinkedPosition[] act2= actual2.getPositions();
- LinkedPosition[] act= new LinkedPosition[act1.length + act2.length];
- System.arraycopy(act1, 0, act, 0, act1.length);
- System.arraycopy(act2, 0, act, act1.length, act2.length);
- Arrays.sort(act, new PositionComparator());
- Arrays.sort(exp, new PositionComparator());
-
- assertEquals(exp.length, act.length);
-
- LinkedPosition e_prev= null, a_prev= null;
- for (int i= 0; i <= exp.length; i++) {
- LinkedPosition e_next= i == exp.length ? null : exp[i];
- LinkedPosition a_next= i == exp.length ? null : act[i];
-
- IDocument e_doc= e_prev != null ? e_prev.getDocument() : e_next.getDocument();
- if (e_next != null && e_next.getDocument() != e_doc) {
- // split at document boundaries
- assertEquals(getContentBetweenPositions(e_prev, null), getContentBetweenPositions(a_prev, null));
- assertEquals(getContentBetweenPositions(null, e_next), getContentBetweenPositions(null, a_next));
- } else {
- assertEquals(getContentBetweenPositions(e_prev, e_next), getContentBetweenPositions(a_prev, a_next));
- }
-
- e_prev= e_next;
- a_prev= a_next;
- }
- }
-
- private String getContentBetweenPositions(LinkedPosition p1, LinkedPosition p2) throws BadLocationException {
- if (p1 == null && p2 == null)
- return null;
- if (p1 == null)
- p1= new LinkedPosition(p2.getDocument(), 0, 0);
-
- if (p2 == null)
- p2= new LinkedPosition(p1.getDocument(), p1.getDocument().getLength(), 0);
-
- IDocument document= p1.getDocument();
-
- int offset= p1.getOffset() + p1.getLength();
- int length= p2.getOffset() - offset;
-
- return document.get(offset, length);
- }
-
-
- /**
- * {@inheritDoc}
- */
- protected void setUp() throws Exception {
- fPositions.clear();
- fDocumentMap.clear();
- }
-
- /**
- * Returns a test group on a copy of the document
- */
- private void createLinkedPositions(LinkedPositionGroup group, IDocument doc, String substring) throws BadLocationException {
- String text= doc.get();
-
- IDocument original= getOriginal(doc);
- if (original == null) {
- original= new Document(text);
- putOriginal(doc, original);
- }
-
-
- for (int offset= text.indexOf(substring); offset != -1; offset= text.indexOf(substring, offset + 1)) {
- group.createPosition(doc, offset, substring.length());
- fPositions.add(new LinkedPosition(original, offset, substring.length()));
- }
-
- }
-
- private void putOriginal(IDocument doc, IDocument original) {
- fDocumentMap.add(new IDocument[] { doc, original });
- }
-
- private IDocument getOriginal(IDocument doc) {
- for (Iterator it = fDocumentMap.iterator(); it.hasNext(); ) {
- IDocument[] docs = (IDocument[]) it.next();
- if (docs[0] == doc)
- return docs[1];
- }
- return null;
- }
-
- private static final String GARTEN1=
- " MARGARETE:\n" +
- " Versprich mir, Heinrich!\n" +
- " \n" +
- " FAUST:\n" +
- " Was ich kann!\n" +
- " \n" +
- " MARGARETE:\n" +
- " Nun sag, wie hast du\'s mit der Religion?\n" +
- " Du bist ein herzlich guter Mann,\n" +
- " Allein ich glaub, du hältst nicht viel davon.\n" +
- " \n" +
- " FAUST:\n" +
- " Laß das, mein Kind! Du fühlst, ich bin dir gut;\n" +
- " Für meine Lieben ließ\' ich Leib und Blut,\n" +
- " Will niemand sein Gefühl und seine Kirche rauben.\n" +
- " \n" +
- " MARGARETE:\n" +
- " Das ist nicht recht, man muß dran glauben.\n" +
- " \n" +
- " FAUST:\n" +
- " Muß man?\n" +
- " \n" +
- " MARGARETE:\n" +
- " Ach! wenn ich etwas auf dich konnte! Du ehrst auch nicht die heil\'gen Sakramente.\n" +
- " \n" +
- " FAUST:\n" +
- " Ich ehre sie.\n" +
- " \n" +
- " MARGARETE:\n" +
- " Doch ohne Verlangen. Zur Messe, zur Beichte bist du lange nicht gegangen.\n" +
- " Glaubst du an Gott?\n" +
- " \n" +
- " FAUST:\n" +
- " Mein Liebchen, wer darf sagen: Ich glaub an Gott?\n" +
- " Magst Priester oder Weise fragen,\n" +
- " Und ihre Antwort scheint nur Spott\n" +
- " Über den Frager zu sein.\n" +
- " \n" +
- " MARGARETE:\n" +
- " So glaubst du nicht?\n" +
- " \n" +
- " FAUST:\n" +
- " Mißhör mich nicht, du holdes Angesicht!\n" +
- " Wer darf ihn nennen?\n" +
- " Und wer bekennen:\n" +
- " »Ich glaub ihn!«?\n" +
- " Wer empfinden,\n" +
- " Und sich unterwinden\n" +
- " Zu sagen: »Ich glaub ihn nicht!«?\n" +
- " Der Allumfasser,\n" +
- " Der Allerhalter,\n" +
- " Faßt und erhält er nicht\n" +
- " Dich, mich, sich selbst?\n" +
- " Wölbt sich der Himmel nicht da droben?\n" +
- " Liegt die Erde nicht hier unten fest?\n" +
- " Und steigen freundlich blickend\n" +
- " Ewige Sterne nicht herauf?\n" +
- " Schau ich nicht Aug in Auge dir,\n" +
- " Und drängt nicht alles\n" +
- " Nach Haupt und Herzen dir,\n" +
- " Und webt in ewigem Geheimnis\n" +
- " Unsichtbar sichtbar neben dir?\n" +
- " Erfüll davon dein Herz, so groß es ist,\n" +
- " Und wenn du ganz in dem Gefühle selig bist,\n" +
- " Nenn es dann, wie du willst,\n" +
- " Nenn\'s Glück! Herz! Liebe! Gott\n" +
- " Ich habe keinen Namen\n" +
- " Dafür! Gefühl ist alles;\n" +
- " Name ist Schall und Rauch,\n" +
- " Umnebelnd Himmelsglut.\n";
-
- private static final String GARTEN2=
- " MARGARETE:\n" +
- " Das ist alles recht schön und gut;\n" +
- " Ungefähr sagt das der Pfarrer auch,\n" +
- " Nur mit ein bißchen andern Worten.\n" +
- " \n" +
- " FAUST:\n" +
- " Es sagen\'s allerorten\n" +
- " Alle Herzen unter dem himmlischen Tage,\n" +
- " Jedes in seiner Sprache;\n" +
- " Warum nicht ich in der meinen?\n" +
- " \n" +
- " MARGARETE:\n" +
- " Wenn man\'s so hört, möcht\'s leidlich scheinen,\n" +
- " Steht aber doch immer schief darum;\n" +
- " Denn du hast kein Christentum.\n" +
- " \n" +
- " FAUST:\n" +
- " Liebs Kind!\n" +
- " \n" +
- " MARGARETE:\n" +
- " Es tut mir lange schon weh, Daß ich dich in der Gesellschaft seh.\n" +
- " \n" +
- " FAUST:\n" +
- " Wieso?\n" +
- " \n" +
- " MARGARETE:\n" +
- " Der Mensch, den du da bei dir hast, Ist mir in tiefer innrer Seele verhaßt;\n" +
- " Es hat mir in meinem Leben\n" +
- " So nichts einen Stich ins Herz gegeben\n" +
- " Als des Menschen widrig Gesicht.\n" +
- " \n" +
- " FAUST:\n" +
- " Liebe Puppe, fürcht ihn nicht!\n" +
- " \n" +
- " MARGARETE:\n" +
- " Seine Gegenwart bewegt mir das Blut.\n" +
- " Ich bin sonst allen Menschen gut;\n" +
- " Aber wie ich mich sehne, dich zu schauen,\n" +
- " Hab ich vor dem Menschen ein heimlich Grauen,\n" +
- " Und halt ihn für einen Schelm dazu!\n" +
- " Gott verzeih mir\'s, wenn ich ihm unrecht tu!\n" +
- " \n" +
- " FAUST:\n" +
- " Es muß auch solche Käuze geben.\n" +
- " \n" +
- " MARGARETE:\n" +
- " Wollte nicht mit seinesgleichen leben!\n" +
- " Kommt er einmal zur Tür herein,\n" +
- " Sieht er immer so spöttisch drein\n" +
- " Und halb ergrimmt;\n" +
- " Man sieht, daß er an nichts keinen Anteil nimmt;\n" +
- " Es steht ihm an der Stirn geschrieben,\n" +
- " Daß er nicht mag eine Seele lieben.\n" +
- " Mir wird\'s so wohl in deinem Arm,\n" +
- " So frei, so hingegeben warm,\n" +
- " Und seine Gegenwart schnürt mir das Innre zu.\n" +
- " \n" +
- " FAUST:\n" +
- " Du ahnungsvoller Engel du!\n" +
- " \n" +
- " MARGARETE:\n" +
- " Das übermannt mich so sehr,\n" +
- " Daß, wo er nur mag zu uns treten,\n" +
- " Mein ich sogar, ich liebte dich nicht mehr.\n" +
- " Auch, wenn er da ist, könnt ich nimmer beten,\n" +
- " Und das frißt mir ins Herz hinein;\n" +
- " Dir, Heinrich, muß es auch so sein.\n" +
- " \n" +
- " FAUST:\n" +
- " Du hast nun die Antipathie!\n" +
- " \n" +
- " MARGARETE:\n" +
- " Ich muß nun fort.\n" +
- " \n" +
- " FAUST:\n" +
- " Ach kann ich nie Ein Stündchen ruhig dir am Busen hängen\n" +
- " Und Brust an Brust und Seel in Seele drängen?\n" +
- " \n" +
- " MARGARETE:\n" +
- " Ach wenn ich nur alleine schlief!\n" +
- " Ich ließ dir gern heut nacht den Riegel offen;\n" +
- " Doch meine Mutter schläft nicht tief,\n" +
- " Und würden wir von ihr betroffen,\n" +
- " Ich wär gleich auf der Stelle tot!\n" +
- " \n" +
- " FAUST:\n" +
- " Du Engel, das hat keine Not.\n" +
- " Hier ist ein Fläschchen!\n" +
- " Drei Tropfen nur In ihren Trank umhüllen\n" +
- " Mit tiefem Schlaf gefällig die Natur.\n" +
- " \n" +
- " MARGARETE:\n" +
- " Was tu ich nicht um deinetwillen?\n" +
- " Es wird ihr hoffentlich nicht schaden!\n" +
- " \n" +
- " FAUST:\n" +
- " Würd ich sonst, Liebchen, dir es raten?\n" +
- " \n" +
- " MARGARETE:\n" +
- " Seh ich dich, bester Mann, nur an,\n" +
- " Weiß nicht, was mich nach deinem Willen treibt,\n" +
- " Ich habe schon so viel für dich getan,\n" +
- " Daß mir zu tun fast nichts mehr übrigbleibt.";
-
- private class LinkedAdapter implements ILinkedListener {
- public void left(LinkedEnvironment environment, int flags) {}
- public void suspend(LinkedEnvironment environment) {}
- public void resume(LinkedEnvironment environment, int flags) {}
- }
-
- public class PositionComparator implements Comparator {
-
- public int compare(Object o1, Object o2) {
- LinkedPosition p1= (LinkedPosition) o1;
- LinkedPosition p2= (LinkedPosition) o2;
-
- IDocument d1= p1.getDocument();
- IDocument d2= p2.getDocument();
-
- if (d1 == d2)
- // sort by offset inside the same document
- return p1.getOffset() - p2.getOffset();
- else
- return getIndex(d1) - getIndex(d2);
- }
-
- private int getIndex(IDocument doc) {
- int i= 0;
- for (Iterator it= fDocumentMap.iterator(); it.hasNext(); i++) {
- IDocument[] docs= (IDocument[]) it.next();
- if (docs[0] == doc || docs[1] == doc)
- return i;
- }
- return -1;
- }
- }
-
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionGroupTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionGroupTest.java
deleted file mode 100644
index 269b21a..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionGroupTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests.link;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.link.LinkedEnvironment;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.link.LinkedPositionGroup;
-
-
-public class LinkedPositionGroupTest extends TestCase {
-
- public void testIsEmtpy() {
- LinkedPositionGroup group= new LinkedPositionGroup();
- assertTrue(group.isEmtpy());
- }
-
- public void testIsNotEmtpy() throws BadLocationException {
- LinkedPositionGroup group= new LinkedPositionGroup();
- group.addPosition(new LinkedPosition(new Document(), 0, 0));
- assertFalse(group.isEmtpy());
- }
-
- public void testGetPositions() throws BadLocationException {
- LinkedPositionGroup group= new LinkedPositionGroup();
- group.addPosition(new LinkedPosition(new Document(), 0, 0));
- group.addPosition(new LinkedPosition(new Document(), 0, 0));
- assertEquals(2, group.getPositions().length);
- }
-
- public void testAddPosition() throws BadLocationException {
- LinkedPositionGroup group= new LinkedPositionGroup();
- LinkedPosition p= new LinkedPosition(new Document(), 0, 0);
- group.addPosition(p);
- assertSame(p, group.getPositions()[0]);
- }
-
- public void testAddIllegalState() throws BadLocationException {
- LinkedPositionGroup group= new LinkedPositionGroup();
- LinkedEnvironment env= new LinkedEnvironment();
- env.addGroup(group);
-
- LinkedPosition p= new LinkedPosition(new Document(), 0, 0);
- try {
- group.addPosition(p);
- } catch (IllegalStateException e) {
- return;
- }
-
- assertFalse(true);
- }
-
- public void testAddBadLocation() throws BadLocationException {
- LinkedPositionGroup group= new LinkedPositionGroup();
- IDocument doc= new Document(GARTEN);
- group.addPosition(new LinkedPosition(doc, 1, 9));
- try {
- group.addPosition(new LinkedPosition(doc, 3, 9));
- } catch (BadLocationException e) {
- return;
- }
-
- assertFalse(true);
- }
-
- public void testAddEqualContent() {
- LinkedPositionGroup group= new LinkedPositionGroup();
- IDocument doc= new Document(GARTEN);
- try {
- group.addPosition(new LinkedPosition(doc, 1, 9));
- group.addPosition(new LinkedPosition(doc, 68, 9));
- } catch (BadLocationException e) {
- assertFalse(true);
- }
- }
-
- public void testAddNotEqualContent() {
- LinkedPositionGroup group= new LinkedPositionGroup();
- IDocument doc= new Document(GARTEN);
- try {
- group.addPosition(new LinkedPosition(doc, 1, 9));
- group.addPosition(new LinkedPosition(doc, 68, 10));
- } catch (BadLocationException e) {
- return;
- }
- assertFalse(true);
- }
-
- private static final String GARTEN=
- " MARGARETE:\n" +
- " Versprich mir, Heinrich!\n" +
- " \n" +
- " FAUST:\n" +
- " Was ich kann!\n" +
- " \n" +
- " MARGARETE:\n" +
- " Nun sag, wie hast du\'s mit der Religion?\n" +
- " Du bist ein herzlich guter Mann,\n" +
- " Allein ich glaub, du hältst nicht viel davon.\n" +
- " \n" +
- " FAUST:\n" +
- " Laß das, mein Kind! Du fühlst, ich bin dir gut;\n" +
- " Für meine Lieben ließ\' ich Leib und Blut,\n" +
- " Will niemand sein Gefühl und seine Kirche rauben.\n" +
- " \n" +
- " MARGARETE:\n" +
- " Das ist nicht recht, man muß dran glauben.\n" +
- " \n" +
- " FAUST:\n" +
- " Muß man?\n" +
- " \n" +
- " MARGARETE:\n" +
- " Ach! wenn ich etwas auf dich konnte! Du ehrst auch nicht die heil\'gen Sakramente.\n" +
- " \n" +
- " FAUST:\n" +
- " Ich ehre sie.\n" +
- " \n" +
- " MARGARETE:\n" +
- " Doch ohne Verlangen. Zur Messe, zur Beichte bist du lange nicht gegangen.\n" +
- " Glaubst du an Gott?\n" +
- " \n" +
- " FAUST:\n" +
- " Mein Liebchen, wer darf sagen: Ich glaub an Gott?\n" +
- " Magst Priester oder Weise fragen,\n" +
- " Und ihre Antwort scheint nur Spott\n" +
- " Über den Frager zu sein.\n" +
- " \n" +
- " MARGARETE:\n" +
- " So glaubst du nicht?\n" +
- " \n" +
- " FAUST:\n" +
- " Mißhör mich nicht, du holdes Angesicht!\n" +
- " Wer darf ihn nennen?\n" +
- " Und wer bekennen:\n" +
- " »Ich glaub ihn!«?\n" +
- " Wer empfinden,\n" +
- " Und sich unterwinden\n" +
- " Zu sagen: »Ich glaub ihn nicht!«?\n" +
- " Der Allumfasser,\n" +
- " Der Allerhalter,\n" +
- " Faßt und erhält er nicht\n" +
- " Dich, mich, sich selbst?\n" +
- " Wölbt sich der Himmel nicht da droben?\n" +
- " Liegt die Erde nicht hier unten fest?\n" +
- " Und steigen freundlich blickend\n" +
- " Ewige Sterne nicht herauf?\n" +
- " Schau ich nicht Aug in Auge dir,\n" +
- " Und drängt nicht alles\n" +
- " Nach Haupt und Herzen dir,\n" +
- " Und webt in ewigem Geheimnis\n" +
- " Unsichtbar sichtbar neben dir?\n" +
- " Erfüll davon dein Herz, so groß es ist,\n" +
- " Und wenn du ganz in dem Gefühle selig bist,\n" +
- " Nenn es dann, wie du willst,\n" +
- " Nenn\'s Glück! Herz! Liebe! Gott\n" +
- " Ich habe keinen Namen\n" +
- " Dafür! Gefühl ist alles;\n" +
- " Name ist Schall und Rauch,\n" +
- " Umnebelnd Himmelsglut.\n";
-}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionTest.java
deleted file mode 100644
index bd0cd84..0000000
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/link/LinkedPositionTest.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.text.tests.link;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.link.LinkedPositionGroup;
-
-
-public class LinkedPositionTest extends TestCase {
-
- public void setUp() {
- fDoc= new Document(GARTEN1);
- fPos= new LinkedPosition(fDoc, 3, 10);
- }
-
- public void testCreate() {
- new LinkedPosition(fDoc, 1, 9);
- new LinkedPosition(new Document(), 123, 234);
- }
-
- public void testNullCreate() {
- try {
- new LinkedPosition(null, 1, 9);
- } catch (Throwable e) {
- return;
- }
- assertFalse(true);
- }
-
- /*
- * Class to test for boolean includes(int)
- */
- public void testIncludesint() {
- assertEquals(true, fPos.includes(3));
- assertEquals(true, fPos.includes(6));
- assertEquals(true, fPos.includes(13));
- assertEquals(false, fPos.includes(2));
- assertEquals(false, fPos.includes(15));
- }
-
- public void testGetDocument() {
- assertEquals(fDoc, fPos.getDocument());
- }
-
- /*
- * Class to test for boolean overlapsWith(LinkedPosition)
- */
- public void testOverlapsWithLinkedPosition() {
- LinkedPosition pos= new LinkedPosition(fDoc, 0, 2);
- assertEquals(false, fPos.overlapsWith(pos));
-
- pos= new LinkedPosition(fDoc, 0, 3);
- assertEquals(false, fPos.overlapsWith(pos));
-
- pos= new LinkedPosition(fDoc, 1, 4);
- assertEquals(true, fPos.overlapsWith(pos));
-
- pos= new LinkedPosition(fDoc, 3, 5);
- assertEquals(true, fPos.overlapsWith(pos));
-
- pos= new LinkedPosition(fDoc, 5, 7);
- assertEquals(true, fPos.overlapsWith(pos));
-
- pos= new LinkedPosition(fDoc, 7, 6);
- assertEquals(true, fPos.overlapsWith(pos));
-
- pos= new LinkedPosition(fDoc, 7, 7);
- assertEquals(true, fPos.overlapsWith(pos));
-
- pos= new LinkedPosition(fDoc, 13, 1);
- assertEquals(false, fPos.overlapsWith(pos));
-
- pos= new LinkedPosition(fDoc, 14, 4);
- assertEquals(false, fPos.overlapsWith(pos));
- }
-
- /*
- * Class to test for boolean includes(DocumentEvent)
- */
- public void testIncludesDocumentEvent() {
- DocumentEvent de= new DocumentEvent(fDoc, 0, 2, "ignore");
- assertEquals(false, fPos.includes(de));
-
- de= new DocumentEvent(fDoc, 0, 3, "ignore");
- assertEquals(false, fPos.includes(de));
-
- de= new DocumentEvent(fDoc, 1, 4, "ignore");
- assertEquals(false, fPos.includes(de));
-
- de= new DocumentEvent(fDoc, 3, 5, "ignore");
- assertEquals(true, fPos.includes(de));
-
- de= new DocumentEvent(fDoc, 5, 7, "ignore");
- assertEquals(true, fPos.includes(de));
-
- de= new DocumentEvent(fDoc, 7, 6, "ignore");
- assertEquals(true, fPos.includes(de));
-
- de= new DocumentEvent(fDoc, 7, 7, "ignore");
- assertEquals(false, fPos.includes(de));
-
- de= new DocumentEvent(fDoc, 13, 1, "ignore");
- assertEquals(false, fPos.includes(de));
-
- de= new DocumentEvent(fDoc, 14, 4, "ignore");
- assertEquals(false, fPos.includes(de));
- }
-
- /*
- * Class to test for boolean includes(LinkedPosition)
- */
- public void testIncludesLinkedPosition() {
- LinkedPosition pos= new LinkedPosition(fDoc, 0, 2);
- assertEquals(false, fPos.includes(pos));
-
- pos= new LinkedPosition(fDoc, 0, 3);
- assertEquals(false, fPos.includes(pos));
-
- pos= new LinkedPosition(fDoc, 1, 4);
- assertEquals(false, fPos.includes(pos));
-
- pos= new LinkedPosition(fDoc, 3, 5);
- assertEquals(true, fPos.includes(pos));
-
- pos= new LinkedPosition(fDoc, 5, 7);
- assertEquals(true, fPos.includes(pos));
-
- pos= new LinkedPosition(fDoc, 7, 6);
- assertEquals(true, fPos.includes(pos));
-
- pos= new LinkedPosition(fDoc, 7, 7);
- assertEquals(false, fPos.includes(pos));
-
- pos= new LinkedPosition(fDoc, 13, 1);
- assertEquals(false, fPos.includes(pos));
-
- pos= new LinkedPosition(fDoc, 14, 4);
- assertEquals(false, fPos.includes(pos));
- }
-
- public void testGetContent() throws BadLocationException {
- LinkedPosition p= new LinkedPosition(fDoc, 1, 9);
- assertEquals("MARGARETE", p.getContent());
-
- p= new LinkedPosition(fDoc, 42, 5);
- assertEquals("FAUST", p.getContent());
-
- fDoc.replace(42, 2, "");
- assertEquals("UST:\n", p.getContent()); // not linked!
-
- fDoc.set(GARTEN1);
- assertEquals("FAUST", p.getContent());
- }
-
- public void testBadLocationContent() {
- LinkedPosition p= new LinkedPosition(new Document(), 23, 3);
- try {
- p.getContent();
- } catch (BadLocationException e) {
- return;
- }
- assertFalse(true);
-
- p= new LinkedPosition(fDoc, 23, 3);
- fDoc.set("");
- try {
- p.getContent();
- } catch (BadLocationException e) {
- return;
- }
- assertFalse(true);
- }
-
- public void testGetSequenceNumber() {
- LinkedPosition p= new LinkedPosition(fDoc, 1, 9);
- assertEquals(LinkedPositionGroup.NO_STOP, p.getSequenceNumber());
-
- p= new LinkedPosition(fDoc, 1, 9, 18);
- assertEquals(18, p.getSequenceNumber());
- }
-
- public void testSetSequenceNumber() {
- fPos.setSequenceNumber(28);
- assertEquals(28, fPos.getSequenceNumber());
- }
-
- public void testEquals() {
- LinkedPosition p1= new LinkedPosition(fDoc, 1, 9);
- LinkedPosition p2= new LinkedPosition(fDoc, 1, 9);
-
- assertEquals(p1, p2);
- }
-
- public void testNotEquals() {
- LinkedPosition p1= new LinkedPosition(fDoc, 1, 9);
- LinkedPosition p2= new LinkedPosition(fDoc, 1, 10);
-
- assertFalse(p1.equals(p2));
- }
-
- public void testNotEqualsPosition() {
- LinkedPosition p1= new LinkedPosition(fDoc, 1, 9);
- Position p2= new Position(1, 9);
-
- assertFalse(p1.equals(p2));
- }
-
- public void testNotEqualsPositionSymmetry() {
-// LinkedPosition p1= new LinkedPosition(fDoc, 1, 9);
-// Position p2= new Position(1, 9);
-//
-// // breaking equals contract
-// assertFalse(p2.equals(p1));
- }
-
- public void testNotEqualsDifferentDoc() {
- LinkedPosition p1= new LinkedPosition(fDoc, 1, 9);
- IDocument doc= new Document();
- LinkedPosition p2= new LinkedPosition(doc, 1, 9);
-
- assertFalse(p1.equals(p2));
- }
-
- private static final String GARTEN1=
- " MARGARETE:\n" +
- " Versprich mir, Heinrich!\n" +
- " \n" +
- " FAUST:\n" +
- " Was ich kann!\n" +
- " \n" +
- " MARGARETE:\n" +
- " Nun sag, wie hast du\'s mit der Religion?\n" +
- " Du bist ein herzlich guter Mann,\n" +
- " Allein ich glaub, du hältst nicht viel davon.\n" +
- " \n" +
- " FAUST:\n" +
- " Laß das, mein Kind! Du fühlst, ich bin dir gut;\n" +
- " Für meine Lieben ließ\' ich Leib und Blut,\n" +
- " Will niemand sein Gefühl und seine Kirche rauben.\n" +
- " \n" +
- " MARGARETE:\n" +
- " Das ist nicht recht, man muß dran glauben.\n" +
- " \n" +
- " FAUST:\n" +
- " Muß man?\n" +
- " \n" +
- " MARGARETE:\n" +
- " Ach! wenn ich etwas auf dich konnte! Du ehrst auch nicht die heil\'gen Sakramente.\n" +
- " \n" +
- " FAUST:\n" +
- " Ich ehre sie.\n" +
- " \n" +
- " MARGARETE:\n" +
- " Doch ohne Verlangen. Zur Messe, zur Beichte bist du lange nicht gegangen.\n" +
- " Glaubst du an Gott?\n" +
- " \n" +
- " FAUST:\n" +
- " Mein Liebchen, wer darf sagen: Ich glaub an Gott?\n" +
- " Magst Priester oder Weise fragen,\n" +
- " Und ihre Antwort scheint nur Spott\n" +
- " Über den Frager zu sein.\n" +
- " \n" +
- " MARGARETE:\n" +
- " So glaubst du nicht?\n" +
- " \n" +
- " FAUST:\n" +
- " Mißhör mich nicht, du holdes Angesicht!\n" +
- " Wer darf ihn nennen?\n" +
- " Und wer bekennen:\n" +
- " »Ich glaub ihn!«?\n" +
- " Wer empfinden,\n" +
- " Und sich unterwinden\n" +
- " Zu sagen: »Ich glaub ihn nicht!«?\n" +
- " Der Allumfasser,\n" +
- " Der Allerhalter,\n" +
- " Faßt und erhält er nicht\n" +
- " Dich, mich, sich selbst?\n" +
- " Wölbt sich der Himmel nicht da droben?\n" +
- " Liegt die Erde nicht hier unten fest?\n" +
- " Und steigen freundlich blickend\n" +
- " Ewige Sterne nicht herauf?\n" +
- " Schau ich nicht Aug in Auge dir,\n" +
- " Und drängt nicht alles\n" +
- " Nach Haupt und Herzen dir,\n" +
- " Und webt in ewigem Geheimnis\n" +
- " Unsichtbar sichtbar neben dir?\n" +
- " Erfüll davon dein Herz, so groß es ist,\n" +
- " Und wenn du ganz in dem Gefühle selig bist,\n" +
- " Nenn es dann, wie du willst,\n" +
- " Nenn\'s Glück! Herz! Liebe! Gott\n" +
- " Ich habe keinen Namen\n" +
- " Dafür! Gefühl ist alles;\n" +
- " Name ist Schall und Rauch,\n" +
- " Umnebelnd Himmelsglut.\n";
- private IDocument fDoc;
- private LinkedPosition fPos;
-}
diff --git a/org.eclipse.text.tests/test.xml b/org.eclipse.text.tests/test.xml
index 313fa7b..81012ed 100644
--- a/org.eclipse.text.tests/test.xml
+++ b/org.eclipse.text.tests/test.xml
@@ -20,19 +20,6 @@
</delete>
</target>
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="eclipse-text-folder"
- value="${eclipse-home}/eclipse_text_folder"/>
- <delete dir="${eclipse-text-folder}" quiet="true"/>
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${eclipse-text-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.text.tests.EclipseTextTestSuite"/>
- </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. -->
@@ -41,11 +28,7 @@
<!-- 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 name="run">
</target>
<!-- This target runs the performance test suites. -->
diff --git a/org.eclipse.ui.editors.tests/plugin.xml b/org.eclipse.ui.editors.tests/plugin.xml
index 968a57a..7347d59 100644
--- a/org.eclipse.ui.editors.tests/plugin.xml
+++ b/org.eclipse.ui.editors.tests/plugin.xml
@@ -11,10 +11,8 @@
<export name="*"/>
</library>
</runtime>
-
<requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
<import plugin="org.junit"/>
</requires>
-
+
</plugin>
diff --git a/org.eclipse.ui.editors.tests/test.xml b/org.eclipse.ui.editors.tests/test.xml
index 1359041..6a77dbc 100644
--- a/org.eclipse.ui.editors.tests/test.xml
+++ b/org.eclipse.ui.editors.tests/test.xml
@@ -20,19 +20,6 @@
</delete>
</target>
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="eclipse-editors-folder"
- value="${eclipse-home}/eclipse_editors_folder"/>
- <delete dir="${eclipse-editors-folder}" quiet="true"/>
- <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${eclipse-editors-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.ui.editors.tests.EditorsTestSuite"/>
- </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. -->
@@ -41,11 +28,7 @@
<!-- 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 name="run">
</target>
<!-- This target runs the performance test suites. -->
diff --git a/org.eclipse.ui.workbench.texteditor.tests/build.properties b/org.eclipse.ui.workbench.texteditor.tests/build.properties
index 5de03eb..16e9e45 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/build.properties
+++ b/org.eclipse.ui.workbench.texteditor.tests/build.properties
@@ -11,6 +11,5 @@
bin.includes = plugin.xml,\
test.xml,\
about.html,\
- testresources/,\
*.jar,\
source.workbenchtexteditortests.jar = src/
diff --git a/org.eclipse.ui.workbench.texteditor.tests/plugin.xml b/org.eclipse.ui.workbench.texteditor.tests/plugin.xml
index 3cabb2e..cf2e836 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/plugin.xml
+++ b/org.eclipse.ui.workbench.texteditor.tests/plugin.xml
@@ -13,7 +13,6 @@
</runtime>
<requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
<import plugin="org.junit"/>
</requires>
diff --git a/org.eclipse.ui.workbench.texteditor.tests/test.xml b/org.eclipse.ui.workbench.texteditor.tests/test.xml
index 0e48b73..d461925 100644
--- a/org.eclipse.ui.workbench.texteditor.tests/test.xml
+++ b/org.eclipse.ui.workbench.texteditor.tests/test.xml
@@ -20,19 +20,6 @@
</delete>
</target>
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <property name="eclipse-workbench-texteditor-folder"
- value="${eclipse-home}/eclipse_workbench_texteditor_folder"/>
- <delete dir="${eclipse-workbench-texteditor-folder}" quiet="true"/>
- <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${eclipse-workbench-texteditor-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname"
- value="org.eclipse.ui.workbench.texteditor.tests.WorkbenchTextEditorTestSuite"/>
- </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. -->
@@ -41,11 +28,7 @@
<!-- 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 name="run">
</target>
<!-- This target runs the performance test suites. -->