Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Starting with a tests fragment.
- Loading branch information
Showing
18 changed files
with
945 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_COMPILER_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bin | ||
target | ||
compiler-plugins | ||
.scala_dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.scala-ide.sdt.core.tests</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.scala-ide.sdt.core.scalabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.scala-ide.sdt.core.scalanature</nature> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
8 changes: 8 additions & 0 deletions
8
org.scala-ide.sdt.core.tests/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#Tue Dec 14 12:15:58 CET 2010 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | ||
org.eclipse.jdt.core.compiler.compliance=1.5 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Scala Plugin (Test) | ||
Bundle-SymbolicName: org.scala_ide.sdt.core.tests | ||
Bundle-Version: 2.0.0.qualifier | ||
Bundle-Vendor: scala-ide.org | ||
Fragment-Host: org.scala-ide.sdt.core | ||
Bundle-RequiredExecutionEnvironment: J2SE-1.5 | ||
Require-Bundle: org.scala-ide.scala.library, | ||
org.junit4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source.. = src/ | ||
output.. = target/classes/ | ||
bin.includes = META-INF/,\ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.scala-ide</groupId> | ||
<artifactId>scala-ide-for-eclipse</artifactId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
<relativePath>../org.scala-ide.build/pom.xml</relativePath> | ||
</parent> | ||
<artifactId>org.scala-ide.sdt.core.tests</artifactId> | ||
<packaging>eclipse-test-plugin</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.8.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<sourceDirectory>src</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.scala-tools</groupId> | ||
<artifactId>maven-scala-plugin</artifactId> | ||
<version>2.15.0</version> | ||
<executions> | ||
<execution> | ||
<phase>process-resources</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<jvmArgs> | ||
<jvmArg>-Xms512m</jvmArg> | ||
<jvmArg>-Xmx1024m</jvmArg> | ||
</jvmArgs> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.sonatype.tycho</groupId> | ||
<artifactId>maven-osgi-test-plugin</artifactId> | ||
<version>${tycho.version}</version> | ||
<configuration> | ||
<useUIHarness>true</useUIHarness> | ||
<includes> | ||
<include>scala/tools/eclipse/*Test.class</include> | ||
</includes> | ||
<!-- | ||
<testSuite>${project.artifactId}</testSuite> | ||
<testClass>scala.tools.eclipse.TestsSuite</testClass> | ||
--> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
|
118 changes: 118 additions & 0 deletions
118
org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/EclipseUserSimulator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package scala.tools.eclipse | ||
|
||
import org.eclipse.core.internal.resources.{ Workspace, Project, File } | ||
import org.eclipse.ui.part.FileEditorInput; | ||
import org.eclipse.core.runtime.Path; | ||
import org.eclipse.core.resources.IWorkspace; | ||
import org.eclipse.core.runtime.NullProgressMonitor | ||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.jdt.core.search.SearchRequestor | ||
import org.eclipse.jdt.core.search.SearchMatch | ||
|
||
class EclipseUserSimulator { | ||
import org.eclipse.jdt.core._; | ||
|
||
var root: IPackageFragmentRoot = null; | ||
var workspace: IWorkspace = null; | ||
|
||
def createProjectInWorkspace(projectName: String) = { | ||
import org.eclipse.core.resources.ResourcesPlugin; | ||
import org.eclipse.pde.internal.core.util.CoreUtility; | ||
import org.eclipse.jdt.internal.core.JavaProject; | ||
import org.eclipse.jdt.core._; | ||
import org.eclipse.jdt.launching.JavaRuntime; | ||
import scala.collection.mutable._; | ||
|
||
workspace = ResourcesPlugin.getWorkspace(); | ||
val workspaceRoot = workspace.getRoot(); | ||
val project = workspaceRoot.getProject(projectName); | ||
project.create(null); | ||
project.open(null); | ||
|
||
val description = project.getDescription(); | ||
description.setNatureIds(Array(ScalaPlugin.plugin.natureId, JavaCore.NATURE_ID)); | ||
project.setDescription(description, null); | ||
|
||
val javaProject = JavaCore.create(project); | ||
javaProject.setOutputLocation(new Path("/" + projectName + "/bin"), null); | ||
|
||
val sourceFolder = project.getFolder("/src"); | ||
sourceFolder.create(false, true, null); | ||
|
||
root = javaProject.getPackageFragmentRoot(sourceFolder); | ||
|
||
var entries = new ArrayBuffer[IClasspathEntry](); | ||
val vmInstall = JavaRuntime.getDefaultVMInstall(); | ||
val locations = JavaRuntime.getLibraryLocations(vmInstall); | ||
for (element <- locations) | ||
entries += JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null); | ||
entries += JavaCore.newSourceEntry(root.getPath()); | ||
entries += JavaCore.newContainerEntry(Path.fromPortableString(ScalaPlugin.plugin.scalaLibId)) | ||
javaProject.setRawClasspath(entries.toArray[IClasspathEntry], null); | ||
|
||
ScalaPlugin.plugin.getScalaProject(project); | ||
} | ||
|
||
def createPackage(packageName: String) = | ||
root.createPackageFragment(packageName, false, null); | ||
|
||
def createCompilationUnit(pack: IPackageFragment, name: String, sourceCode: String) = { | ||
val cu = pack.createCompilationUnit(name, sourceCode, false, null); | ||
Thread.sleep(200) | ||
cu; | ||
} | ||
|
||
def buildWorkspace { | ||
import org.eclipse.core.internal.resources.Workspace; | ||
import org.eclipse.core.resources.IncrementalProjectBuilder; | ||
val buildManager = workspace.asInstanceOf[Workspace].getBuildManager(); | ||
buildManager.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor()) | ||
} | ||
|
||
var fileEditorInput: FileEditorInput = null; | ||
var currentEditor: ScalaSourceFileEditor = null; | ||
def openInEditor(compilationUnit: ICompilationUnit) = { | ||
import org.eclipse.ui.internal.WorkbenchPage; | ||
|
||
val activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); | ||
val editorManager = activePage.asInstanceOf[WorkbenchPage].getEditorManager() | ||
|
||
val root = workspace.getRoot() | ||
val path = workspace.asInstanceOf[Workspace].getFileSystemManager().locationFor(compilationUnit.getResource) | ||
|
||
fileEditorInput = new FileEditorInput(root.getFileForLocation(path)); | ||
editorManager.openEditor("scala.tools.eclipse.ScalaSourceFileEditor", | ||
fileEditorInput, | ||
true, null) | ||
|
||
currentEditor = activePage.getActiveEditor().asInstanceOf[ScalaSourceFileEditor]; | ||
} | ||
|
||
def saveCurrentEditor() = | ||
currentEditor.doSave(new NullProgressMonitor()) | ||
|
||
def setContentOfCurrentEditor(code: String) = | ||
currentEditor.getDocumentProvider().getDocument(fileEditorInput).set(code) | ||
|
||
def searchType(typeName: String) = { | ||
import org.eclipse.jdt.core.search._ | ||
val searchPattern = SearchPattern.createPattern(typeName, | ||
IJavaSearchConstants.CLASS, | ||
IJavaSearchConstants.REFERENCES, | ||
SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE); | ||
val engine = new SearchEngine; | ||
val requestor = new ClassSearchRequestor | ||
engine.search(searchPattern, Array(SearchEngine.getDefaultSearchParticipant()), SearchEngine.createWorkspaceScope, requestor, null) | ||
|
||
requestor.matches | ||
} | ||
|
||
class ClassSearchRequestor extends SearchRequestor { | ||
|
||
var matches = List.empty[SearchMatch] | ||
|
||
def acceptSearchMatch(sm: SearchMatch) { | ||
matches = sm :: matches; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/TestsSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package scala.tools.eclipse; | ||
|
||
import scala.tools.eclipse.lexical.ScalaDocumentPartitionerTest; | ||
import scala.tools.eclipse.lexical.ScalaPartitionTokeniserTest; | ||
import scala.tools.eclipse.ui.TestScalaIndenter; | ||
import scala.tools.eclipse.wizards.*; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
|
||
|
||
/** | ||
* To run this class DO NOT FORGET to set the config.ini in the "configuration" tab. | ||
* @author ratiu | ||
*/ | ||
@RunWith(Suite.class) | ||
@Suite.SuiteClasses({ | ||
ScalaDocumentPartitionerTest.class, | ||
ScalaPartitionTokeniserTest.class, | ||
TestScalaIndenter.class, | ||
ImportSupportTest.class, | ||
QualifiedNameSupportTest.class | ||
}) | ||
class TestsSuite { } |
102 changes: 102 additions & 0 deletions
102
org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/lexical/MockDocument.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package scala.tools.eclipse.lexical | ||
|
||
import org.eclipse.jface.text.IRegion | ||
import org.eclipse.jface.text.IDocumentPartitioner | ||
import org.eclipse.jface.text.IDocumentPartitioningListener | ||
import org.eclipse.jface.text.ITypedRegion | ||
import org.eclipse.jface.text.IPositionUpdater | ||
import org.eclipse.jface.text.Position | ||
import org.eclipse.jface.text.IDocumentListener | ||
import org.eclipse.jface.text.IDocument | ||
|
||
class MockDocument(private var s: String) extends IDocument { | ||
|
||
def getChar(offset: Int): Char = s.charAt(offset) | ||
|
||
def getLength(): Int = s.length | ||
|
||
def get(): String = s | ||
|
||
def get(offset: Int, length: Int): String = s.substring(offset, length) | ||
|
||
def set(text: String) { s = text } | ||
|
||
def replace(offset: Int, length: Int, text: String) = set(s.patch(offset, text, length)) | ||
|
||
def addDocumentListener(listener: IDocumentListener): Unit = {} | ||
|
||
def removeDocumentListener(listener: IDocumentListener): Unit = {} | ||
|
||
def addPrenotifiedDocumentListener(documentAdapter: IDocumentListener): Unit = {} | ||
|
||
def removePrenotifiedDocumentListener(documentAdapter: IDocumentListener): Unit = {} | ||
|
||
def addPositionCategory(category: String): Unit = {} | ||
|
||
def removePositionCategory(category: String): Unit = {} | ||
|
||
def getPositionCategories() = throw new UnsupportedOperationException | ||
|
||
def containsPositionCategory(category: String): Boolean = { false } | ||
|
||
def addPosition(position: Position): Unit = {} | ||
|
||
def removePosition(position: Position): Unit = {} | ||
|
||
def addPosition(category: String, position: Position): Unit = {} | ||
|
||
def removePosition(category: String, position: Position): Unit = {} | ||
|
||
def getPositions(category: String) = Array() | ||
|
||
def containsPosition(category: String, offset: Int, length: Int): Boolean = { false } | ||
|
||
def computeIndexInCategory(category: String, offset: Int): Int = { 0 } | ||
|
||
def addPositionUpdater(updater: IPositionUpdater): Unit = {} | ||
|
||
def removePositionUpdater(updater: IPositionUpdater): Unit = {} | ||
|
||
def insertPositionUpdater(updater: IPositionUpdater, index: Int): Unit = {} | ||
|
||
def getPositionUpdaters() = throw new UnsupportedOperationException | ||
|
||
def getLegalContentTypes() = throw new UnsupportedOperationException | ||
|
||
def getContentType(offset: Int): String = { null } | ||
|
||
def getPartition(offset: Int): ITypedRegion = { null } | ||
|
||
def computePartitioning(offset: Int, length: Int) = throw new UnsupportedOperationException | ||
|
||
def addDocumentPartitioningListener(listener: IDocumentPartitioningListener): Unit = {} | ||
|
||
def removeDocumentPartitioningListener(listener: IDocumentPartitioningListener): Unit = {} | ||
|
||
def setDocumentPartitioner(partitioner: IDocumentPartitioner): Unit = {} | ||
|
||
def getDocumentPartitioner(): IDocumentPartitioner = { null } | ||
|
||
def getLineLength(line: Int): Int = { 0 } | ||
|
||
def getLineOfOffset(offset: Int): Int = { 0 } | ||
|
||
def getLineOffset(line: Int): Int = { 0 } | ||
|
||
def getLineInformation(line: Int): IRegion = { null } | ||
|
||
def getLineInformationOfOffset(offset: Int): IRegion = { null } | ||
|
||
def getNumberOfLines(): Int = { 0 } | ||
|
||
def getNumberOfLines(offset: Int, length: Int): Int = { 0 } | ||
|
||
def computeNumberOfLines(text: String): Int = { 0 } | ||
|
||
def getLegalLineDelimiters() = Array("\n") | ||
|
||
def getLineDelimiter(line: Int): String = "\n" | ||
|
||
def search(startOffset: Int, findString: String, forwardSearch: Boolean, caseSensitive: Boolean, wholeWord: Boolean): Int = { 0 } | ||
|
||
} |
Oops, something went wrong.