From 5e09be93675c4954defe6a3579946bcbe0512c2b Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Fri, 20 Jul 2012 18:07:50 +0200 Subject: [PATCH] Initial commit. A script editor (working for *.sc files) has rudimentary syntax highlighting. --- .gitignore | 2 + README.md | 31 +- org.scalaide.worksheet.feature/.project | 17 + .../build.properties | 1 + org.scalaide.worksheet.feature/feature.xml | 81 +++++ org.scalaide.worksheet.feature/pom.xml | 12 + .../.project | 17 + .../build.properties | 2 + .../feature.xml | 65 ++++ org.scalaide.worksheet.source.feature/pom.xml | 11 + org.scalaide.worksheet.tests/.classpath | 8 + org.scalaide.worksheet.tests/.project | 18 ++ .../META-INF/MANIFEST.MF | 16 + org.scalaide.worksheet.tests/build.properties | 5 + org.scalaide.worksheet.tests/pom.xml | 25 ++ .../worksheet/SomeInterestingCodeTest.scala | 17 + .../test-workspace/.gitignore | 1 + .../test-workspace/aProject/.classpath | 7 + .../test-workspace/aProject/.project | 18 ++ .../aProject/src/org/example/ScalaClass.scala | 9 + org.scalaide.worksheet.update-site/.project | 17 + org.scalaide.worksheet.update-site/pom.xml | 12 + org.scalaide.worksheet.update-site/site.xml | 11 + org.scalaide.worksheet/.classpath | 8 + org.scalaide.worksheet/.project | 26 ++ org.scalaide.worksheet/META-INF/MANIFEST.MF | 33 ++ org.scalaide.worksheet/build.properties | 6 + org.scalaide.worksheet/icons/sample.gif | Bin 0 -> 983 bytes org.scalaide.worksheet/plugin.properties | 0 org.scalaide.worksheet/plugin.xml | 15 + org.scalaide.worksheet/pom.xml | 13 + .../editors/ScriptConfiguration.scala | 96 ++++++ .../editors/ScriptDocumentProvider.scala | 27 ++ .../worksheet/editors/ScriptEditor.scala | 25 ++ pom.xml | 300 ++++++++++++++++++ 35 files changed, 949 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 org.scalaide.worksheet.feature/.project create mode 100644 org.scalaide.worksheet.feature/build.properties create mode 100644 org.scalaide.worksheet.feature/feature.xml create mode 100644 org.scalaide.worksheet.feature/pom.xml create mode 100644 org.scalaide.worksheet.source.feature/.project create mode 100644 org.scalaide.worksheet.source.feature/build.properties create mode 100644 org.scalaide.worksheet.source.feature/feature.xml create mode 100644 org.scalaide.worksheet.source.feature/pom.xml create mode 100644 org.scalaide.worksheet.tests/.classpath create mode 100644 org.scalaide.worksheet.tests/.project create mode 100644 org.scalaide.worksheet.tests/META-INF/MANIFEST.MF create mode 100644 org.scalaide.worksheet.tests/build.properties create mode 100644 org.scalaide.worksheet.tests/pom.xml create mode 100644 org.scalaide.worksheet.tests/src/org/scalaide/worksheet/SomeInterestingCodeTest.scala create mode 100644 org.scalaide.worksheet.tests/test-workspace/.gitignore create mode 100644 org.scalaide.worksheet.tests/test-workspace/aProject/.classpath create mode 100644 org.scalaide.worksheet.tests/test-workspace/aProject/.project create mode 100644 org.scalaide.worksheet.tests/test-workspace/aProject/src/org/example/ScalaClass.scala create mode 100644 org.scalaide.worksheet.update-site/.project create mode 100644 org.scalaide.worksheet.update-site/pom.xml create mode 100644 org.scalaide.worksheet.update-site/site.xml create mode 100644 org.scalaide.worksheet/.classpath create mode 100644 org.scalaide.worksheet/.project create mode 100644 org.scalaide.worksheet/META-INF/MANIFEST.MF create mode 100644 org.scalaide.worksheet/build.properties create mode 100644 org.scalaide.worksheet/icons/sample.gif create mode 100644 org.scalaide.worksheet/plugin.properties create mode 100644 org.scalaide.worksheet/plugin.xml create mode 100644 org.scalaide.worksheet/pom.xml create mode 100644 org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptConfiguration.scala create mode 100644 org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptDocumentProvider.scala create mode 100644 org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptEditor.scala create mode 100644 pom.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01c8c4d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target/ +.cache \ No newline at end of file diff --git a/README.md b/README.md index 2307482..229a52e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,29 @@ -scala-worksheet -=============== +scala-ide-plugin.g8 +=================== -A Scala IDE plugin for a multi-line REPL (called worksheet) \ No newline at end of file +Giger8 template for Eclipse plugins based on the Scala IDE. + +This template produces 5 Eclipse plugins: + +* the plugin itself +* the `plugin.tests` fragment +* an Eclipse feature +* an Eclipse source feature +* an Eclipse update-site + +The projects can readily be imported inside Eclipse. Additionally, you have maven `pom` files +based on Tycho, enabling command line builds. + +## Note: + +There is no default profile. You need to specify a profile manually, choosing what version +of the Scala IDE and Scala compiler you want to build against: + +* `scala-ide-2.0-scala-2.9` +* `scala-ide-2.0.x-scala-2.9` +* `scala-ide-master-scala-2.9` +* `scala-ide-master-scala-trunk` + +Run maven like this: + + mvn -P scala-ide-master-scala-trunk clean install diff --git a/org.scalaide.worksheet.feature/.project b/org.scalaide.worksheet.feature/.project new file mode 100644 index 0000000..1220bd7 --- /dev/null +++ b/org.scalaide.worksheet.feature/.project @@ -0,0 +1,17 @@ + + + org.scalaide.worksheet.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/org.scalaide.worksheet.feature/build.properties b/org.scalaide.worksheet.feature/build.properties new file mode 100644 index 0000000..64f93a9 --- /dev/null +++ b/org.scalaide.worksheet.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/org.scalaide.worksheet.feature/feature.xml b/org.scalaide.worksheet.feature/feature.xml new file mode 100644 index 0000000..89616e0 --- /dev/null +++ b/org.scalaide.worksheet.feature/feature.xml @@ -0,0 +1,81 @@ + + + + + Template of a Scala IDE plug-in + + + + Copyright (C) 2012 _______TO_UPDATE_______. +All rights reserved. + + + + SCALA LICENSE + +Copyright (C) 2011-2012 Artima, Inc. All rights reserved. + +This software was developed by _______TO_UPDATE_______. + +Permission to use, copy, modify, and distribute this software in source +or binary form for any purpose with or without fee is hereby granted, +provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the EPFL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.scalaide.worksheet.feature/pom.xml b/org.scalaide.worksheet.feature/pom.xml new file mode 100644 index 0000000..9c09bd0 --- /dev/null +++ b/org.scalaide.worksheet.feature/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.scalaide + org.scalaide.worksheet.build + 0.1.0-SNAPSHOT + + org.scalaide.worksheet.feature + eclipse-feature + diff --git a/org.scalaide.worksheet.source.feature/.project b/org.scalaide.worksheet.source.feature/.project new file mode 100644 index 0000000..e710794 --- /dev/null +++ b/org.scalaide.worksheet.source.feature/.project @@ -0,0 +1,17 @@ + + + org.scalaide.worksheet.source.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/org.scalaide.worksheet.source.feature/build.properties b/org.scalaide.worksheet.source.feature/build.properties new file mode 100644 index 0000000..7ae4bc6 --- /dev/null +++ b/org.scalaide.worksheet.source.feature/build.properties @@ -0,0 +1,2 @@ +bin.includes = \ +feature.xml diff --git a/org.scalaide.worksheet.source.feature/feature.xml b/org.scalaide.worksheet.source.feature/feature.xml new file mode 100644 index 0000000..e4aceff --- /dev/null +++ b/org.scalaide.worksheet.source.feature/feature.xml @@ -0,0 +1,65 @@ + + + + + The source of ScalaTest plugin for Scala IDE to provides a platform to run + tests written using ScalaTest or other test frameworks. + + + + Copyright (C) 2011-2012 ______TO_UPDATE_______. +All rights reserved. + + + +SCALA LICENSE + +Copyright (C) 2011-2012 Artima, Inc. All rights reserved. + +This software was developed by ______TO_UPDATE_______. + +Permission to use, copy, modify, and distribute this software in source +or binary form for any purpose with or without fee is hereby granted, +provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the EPFL nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + + + + + + + + + diff --git a/org.scalaide.worksheet.source.feature/pom.xml b/org.scalaide.worksheet.source.feature/pom.xml new file mode 100644 index 0000000..fcd7880 --- /dev/null +++ b/org.scalaide.worksheet.source.feature/pom.xml @@ -0,0 +1,11 @@ + + 4.0.0 + + org.scalaide + org.scalaide.worksheet.build + 0.1.0-SNAPSHOT + + org.scalaide.worksheet.source.feature + eclipse-feature + diff --git a/org.scalaide.worksheet.tests/.classpath b/org.scalaide.worksheet.tests/.classpath new file mode 100644 index 0000000..7d8e776 --- /dev/null +++ b/org.scalaide.worksheet.tests/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.scalaide.worksheet.tests/.project b/org.scalaide.worksheet.tests/.project new file mode 100644 index 0000000..a04c4a5 --- /dev/null +++ b/org.scalaide.worksheet.tests/.project @@ -0,0 +1,18 @@ + + + org.scalaide.worksheet.tests + + + + + + org.scala-ide.sdt.core.scalabuilder + + + + + + org.scala-ide.sdt.core.scalanature + org.eclipse.jdt.core.javanature + + diff --git a/org.scalaide.worksheet.tests/META-INF/MANIFEST.MF b/org.scalaide.worksheet.tests/META-INF/MANIFEST.MF new file mode 100644 index 0000000..172867e --- /dev/null +++ b/org.scalaide.worksheet.tests/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Scala Plugin (Test) +Bundle-SymbolicName: org.scalaide.worksheet.tests +Bundle-Version: 0.1.0.qualifier +Bundle-Vendor: scala-ide.org +Fragment-Host: org.scalaide.worksheet +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: org.scala-ide.scala.library, + org.eclipse.equinox.weaving.aspectj, + org.junit4;bundle-version="4.5.0", + org.scala-ide.sdt.core +Import-Package: scala.tools.eclipse.testsetup, + org.aspectj.weaver.loadtime.definition +Bundle-ClassPath: ., + target/lib/mockito-all-1.9.0.jar diff --git a/org.scalaide.worksheet.tests/build.properties b/org.scalaide.worksheet.tests/build.properties new file mode 100644 index 0000000..eb5eee8 --- /dev/null +++ b/org.scalaide.worksheet.tests/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = target/classes/ +bin.includes = META-INF/,\ + test-workspace/,\ + . diff --git a/org.scalaide.worksheet.tests/pom.xml b/org.scalaide.worksheet.tests/pom.xml new file mode 100644 index 0000000..cf1ecf3 --- /dev/null +++ b/org.scalaide.worksheet.tests/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + org.scalaide + org.scalaide.worksheet.build + 0.1.0-SNAPSHOT + + org.scalaide.worksheet.tests + eclipse-test-plugin + + + src + + + org.eclipse.tycho + tycho-surefire-plugin + + ${project.artifactId} + org.scalaide.worksheet.SomeInterestingCodeTest + + + + + + diff --git a/org.scalaide.worksheet.tests/src/org/scalaide/worksheet/SomeInterestingCodeTest.scala b/org.scalaide.worksheet.tests/src/org/scalaide/worksheet/SomeInterestingCodeTest.scala new file mode 100644 index 0000000..69653ad --- /dev/null +++ b/org.scalaide.worksheet.tests/src/org/scalaide/worksheet/SomeInterestingCodeTest.scala @@ -0,0 +1,17 @@ +package org.scalaide.worksheet + +import org.junit.Test +import org.junit.Assert._ +import scala.tools.eclipse.testsetup.TestProjectSetup + +class SomeInterestingCodeTest extends TestProjectSetup("aProject", bundleName= "org.scalaide.worksheet") { + + @Test + def numberOfTypes() { + val compilationUnit= scalaCompilationUnit("org/example/ScalaClass.scala") + + assertEquals("Wrong number of types", 2, SomeInterestingCode.numberOfTypes(compilationUnit)) + + } + +} \ No newline at end of file diff --git a/org.scalaide.worksheet.tests/test-workspace/.gitignore b/org.scalaide.worksheet.tests/test-workspace/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/org.scalaide.worksheet.tests/test-workspace/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/org.scalaide.worksheet.tests/test-workspace/aProject/.classpath b/org.scalaide.worksheet.tests/test-workspace/aProject/.classpath new file mode 100644 index 0000000..bc01bff --- /dev/null +++ b/org.scalaide.worksheet.tests/test-workspace/aProject/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.scalaide.worksheet.tests/test-workspace/aProject/.project b/org.scalaide.worksheet.tests/test-workspace/aProject/.project new file mode 100644 index 0000000..cbacc23 --- /dev/null +++ b/org.scalaide.worksheet.tests/test-workspace/aProject/.project @@ -0,0 +1,18 @@ + + + aProject + + + + + + org.scala-ide.sdt.core.scalabuilder + + + + + + org.scala-ide.sdt.core.scalanature + org.eclipse.jdt.core.javanature + + diff --git a/org.scalaide.worksheet.tests/test-workspace/aProject/src/org/example/ScalaClass.scala b/org.scalaide.worksheet.tests/test-workspace/aProject/src/org/example/ScalaClass.scala new file mode 100644 index 0000000..7f2b789 --- /dev/null +++ b/org.scalaide.worksheet.tests/test-workspace/aProject/src/org/example/ScalaClass.scala @@ -0,0 +1,9 @@ +package org.example + +class ScalaClass { + +} + +object ScalaClass { + +} \ No newline at end of file diff --git a/org.scalaide.worksheet.update-site/.project b/org.scalaide.worksheet.update-site/.project new file mode 100644 index 0000000..122d904 --- /dev/null +++ b/org.scalaide.worksheet.update-site/.project @@ -0,0 +1,17 @@ + + + org.scalaide.worksheet.update-site + + + + + + org.eclipse.pde.UpdateSiteBuilder + + + + + + org.eclipse.pde.UpdateSiteNature + + diff --git a/org.scalaide.worksheet.update-site/pom.xml b/org.scalaide.worksheet.update-site/pom.xml new file mode 100644 index 0000000..1e5fcf8 --- /dev/null +++ b/org.scalaide.worksheet.update-site/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.scalaide + org.scalaide.worksheet.build + 0.1.0-SNAPSHOT + + org.scalaide.worksheet.update-site + eclipse-update-site + diff --git a/org.scalaide.worksheet.update-site/site.xml b/org.scalaide.worksheet.update-site/site.xml new file mode 100644 index 0000000..6344757 --- /dev/null +++ b/org.scalaide.worksheet.update-site/site.xml @@ -0,0 +1,11 @@ + + + + + + + + + + --> + diff --git a/org.scalaide.worksheet/.classpath b/org.scalaide.worksheet/.classpath new file mode 100644 index 0000000..35e6162 --- /dev/null +++ b/org.scalaide.worksheet/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.scalaide.worksheet/.project b/org.scalaide.worksheet/.project new file mode 100644 index 0000000..3d5071c --- /dev/null +++ b/org.scalaide.worksheet/.project @@ -0,0 +1,26 @@ + + + org.scalaide.worksheet + + + + + + org.scala-ide.sdt.core.scalabuilder + + + + org.eclipse.pde.ManifestBuilder + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.PluginNature + org.scala-ide.sdt.core.scalanature + org.eclipse.jdt.core.javanature + + diff --git a/org.scalaide.worksheet/META-INF/MANIFEST.MF b/org.scalaide.worksheet/META-INF/MANIFEST.MF new file mode 100644 index 0000000..7e32ccc --- /dev/null +++ b/org.scalaide.worksheet/META-INF/MANIFEST.MF @@ -0,0 +1,33 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: ScalaTest Plugin +Bundle-SymbolicName: org.scalaide.worksheet;singleton:=true +Bundle-Version: 0.1.0.qualifier +Bundle-Vendor: scala-ide.org +Bundle-ActivationPolicy: lazy +Bundle-Localization: plugin +Require-Bundle: + org.eclipse.core.runtime, + org.eclipse.debug.ui, + org.eclipse.help, + org.eclipse.jdt.core;bundle-version="[3.6.0,3.7.10)", + org.eclipse.jdt.debug.ui, + org.eclipse.jdt.junit, + org.eclipse.jdt.launching, + org.eclipse.jdt.ui, + org.eclipse.jface.text, + org.eclipse.ui, + org.eclipse.ui.console, + org.eclipse.ui.editors, + org.eclipse.ui.forms, + org.eclipse.ui.ide, + org.scala-ide.scala.library, + org.scala-ide.scala.compiler, + org.scala-ide.sdt.core;bundle-version="[2.0.0,2.2.0)", + scalariform;bundle-version="0.1.3" +Import-Package: + com.ibm.icu.text;apply-aspects:=false;org.eclipse.swt.graphics;apply-aspects:=false, + scala.tools.eclipse;apply-aspects:=false, + scala.tools.eclipse.contribution.weaving.jdt.ui.javaeditor.formatter;apply-aspects:=false +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ClassPath: . diff --git a/org.scalaide.worksheet/build.properties b/org.scalaide.worksheet/build.properties new file mode 100644 index 0000000..12a9ae0 --- /dev/null +++ b/org.scalaide.worksheet/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = target/classes/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + plugin.properties diff --git a/org.scalaide.worksheet/icons/sample.gif b/org.scalaide.worksheet/icons/sample.gif new file mode 100644 index 0000000000000000000000000000000000000000..34fb3c9d8cb7d489681b7f7aee4bdcd7eaf53610 GIT binary patch literal 983 zcmZ?wbhEHb6krfw_|CxKYUg-n!?izO{@9*?jxd%4aX0yzy`dymabz zw#(eg=y~&N&n)dZv2xzduG}5lraiApo3(c4*{Ylg5#|$JO_EEZ<^|a2`Z*=9ns7DV zy=TR&gYw*7f%auV?ip3tvjRPmcdoho{K?x$_vR?C#t5&<;~V}S*>OMCr>h}%%bLZ9 zmo3`hYEwTICo-TTCZwgTsC&VjZRgJ1eE#fBa^%9R zmmfWS@;bnyJ27HWY}kxYzv(Hl>yu;FCPlAEh+34Muq-8Rb6C)<8qA3{r2e5 z`$vyngh#H=FWlqqvnapfc5%(!sQ4v?r7J61-&eJNEN^;KTK}T7{#i-gJh%G*9vcYdwv_*~xdw!Gz4Va?T!sXyyF@8?w<>X`X=#j%uHV4GRvj@+tE@ zQ%F!a)GKcn^~8abN>4la1UNXVL;{ZWi)lEwyeatDu%Lr6;aASiLrXXW zQm# + + + + + + + diff --git a/org.scalaide.worksheet/pom.xml b/org.scalaide.worksheet/pom.xml new file mode 100644 index 0000000..61d3fc7 --- /dev/null +++ b/org.scalaide.worksheet/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + + org.scalaide + org.scalaide.worksheet.build + 0.1.0-SNAPSHOT + + org.scalaide.worksheet + eclipse-plugin + + diff --git a/org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptConfiguration.scala b/org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptConfiguration.scala new file mode 100644 index 0000000..5c269e4 --- /dev/null +++ b/org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptConfiguration.scala @@ -0,0 +1,96 @@ +package org.scalaide.worksheet.editors + +import scala.tools.eclipse.properties.syntaxcolouring.ScalaSyntaxClasses +import org.eclipse.jface.text.source.SourceViewerConfiguration +import org.eclipse.jdt.ui.text.IJavaPartitions +import scala.tools.eclipse.lexical.ScalaPartitions +import org.eclipse.jface.text.rules.DefaultDamagerRepairer +import scala.tools.eclipse.ScalaDamagerRepairer +import org.eclipse.jface.text.presentation.PresentationReconciler +import org.eclipse.jface.text.source.ISourceViewer +import scala.tools.eclipse.lexical._ +import org.eclipse.jface.text.IDocument +import org.eclipse.jface.text.rules.ITokenScanner +import org.eclipse.jdt.internal.ui.JavaPlugin +import scala.tools.eclipse.ScalaPlugin +import org.eclipse.jface.text.hyperlink.IHyperlinkDetector +import scala.tools.eclipse.ScalaHover +import scalariform.ScalaVersions +import scala.tools.eclipse.ScalaEditor + +class ScriptConfiguration extends SourceViewerConfiguration { + private val scalaPreferenceStore = ScalaPlugin.plugin.getPreferenceStore + + val codeScanner = new ScalaCodeScanner(javaColorManager, scalaPreferenceStore, ScalaVersions.DEFAULT) + + val javaColorManager = JavaPlugin.getDefault.getJavaTextTools.getColorManager + + override def getPresentationReconciler(sv: ISourceViewer) = { + val reconciler = super.getPresentationReconciler(sv).asInstanceOf[PresentationReconciler] + val dr = new ScalaDamagerRepairer(codeScanner) + + reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE) + reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE) + + def handlePartition(partitionType: String, tokenScanner: ITokenScanner) { + val dr = new DefaultDamagerRepairer(tokenScanner) + reconciler.setDamager(dr, partitionType) + reconciler.setRepairer(dr, partitionType) + } + + handlePartition(IDocument.DEFAULT_CONTENT_TYPE, scalaCodeScanner) + handlePartition(IJavaPartitions.JAVA_DOC, scaladocScanner) + handlePartition(IJavaPartitions.JAVA_SINGLE_LINE_COMMENT, singleLineCommentScanner) + handlePartition(IJavaPartitions.JAVA_MULTI_LINE_COMMENT, multiLineCommentScanner) + handlePartition(IJavaPartitions.JAVA_STRING, stringScanner) + handlePartition(ScalaPartitions.SCALA_MULTI_LINE_STRING, multiLineStringScanner) + handlePartition(ScalaPartitions.XML_TAG, xmlTagScanner) + handlePartition(ScalaPartitions.XML_COMMENT, xmlCommentScanner) + handlePartition(ScalaPartitions.XML_CDATA, xmlCDATAScanner) + handlePartition(ScalaPartitions.XML_PCDATA, xmlPCDATAScanner) + handlePartition(ScalaPartitions.XML_PI, xmlPIScanner) + + reconciler + } + + override def getConfiguredDocumentPartitioning(sourceViewer: ISourceViewer): String = { + ScalaPartitioning.SCALA_PARTITIONING + } + + override def getConfiguredContentTypes(sourceViewer: ISourceViewer): Array[String] = { + Array(IDocument.DEFAULT_CONTENT_TYPE, + IJavaPartitions.JAVA_DOC, + IJavaPartitions.JAVA_MULTI_LINE_COMMENT, + IJavaPartitions.JAVA_SINGLE_LINE_COMMENT, + IJavaPartitions.JAVA_STRING, + IJavaPartitions.JAVA_CHARACTER, + ScalaPartitions.SCALA_MULTI_LINE_STRING) + } + + private val scalaCodeScanner = new ScalaCodeScanner(javaColorManager, scalaPreferenceStore, ScalaVersions.DEFAULT) + private val singleLineCommentScanner = new SingleTokenScanner(ScalaSyntaxClasses.SINGLE_LINE_COMMENT, javaColorManager, scalaPreferenceStore) + private val multiLineCommentScanner = new SingleTokenScanner(ScalaSyntaxClasses.MULTI_LINE_COMMENT, javaColorManager, scalaPreferenceStore) + private val scaladocScanner = new SingleTokenScanner(ScalaSyntaxClasses.SCALADOC, javaColorManager, scalaPreferenceStore) + private val stringScanner = new SingleTokenScanner(ScalaSyntaxClasses.STRING, javaColorManager, scalaPreferenceStore) + private val multiLineStringScanner = new SingleTokenScanner(ScalaSyntaxClasses.MULTI_LINE_STRING, javaColorManager, scalaPreferenceStore) + private val xmlTagScanner = new XmlTagScanner(javaColorManager, scalaPreferenceStore) + private val xmlCommentScanner = new XmlCommentScanner(javaColorManager, scalaPreferenceStore) + private val xmlCDATAScanner = new XmlCDATAScanner(javaColorManager, scalaPreferenceStore) + private val xmlPCDATAScanner = new SingleTokenScanner(ScalaSyntaxClasses.DEFAULT, javaColorManager, scalaPreferenceStore) + private val xmlPIScanner = new XmlPIScanner(javaColorManager, scalaPreferenceStore) + + // override def getTextHover(sv: ISourceViewer, contentType: String, stateMask: Int) = { + // new ScalaHover(getCodeAssist _) + // } + // + // override def getHyperlinkDetectors(sv: ISourceViewer): Array[IHyperlinkDetector] = { + // val detector = HyperlinksDetector() + // if (editor != null) detector.setContext(editor) + // Array(detector) + // } +} + + +object ScalaPartitioning { + final val SCALA_PARTITIONING = "__scala_partitioning" +} diff --git a/org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptDocumentProvider.scala b/org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptDocumentProvider.scala new file mode 100644 index 0000000..620c37f --- /dev/null +++ b/org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptDocumentProvider.scala @@ -0,0 +1,27 @@ +package org.scalaide.worksheet.editors + +import org.eclipse.ui.editors.text.TextFileDocumentProvider +import org.eclipse.jface.text.IDocument +import org.eclipse.ui.editors.text.FileDocumentProvider +import org.eclipse.jface.text.IDocumentExtension3 +import scala.tools.eclipse.lexical.ScalaDocumentPartitioner + +/** A Document provider for Scala scripts. It sets the Scala + * partitioner. + */ +class ScriptDocumentProvider extends FileDocumentProvider { + + override def createDocument(input: Object): IDocument = { + val doc = super.createDocument(input) + + doc match { + case docExt: IDocumentExtension3 => + val partitioner = new ScalaDocumentPartitioner + docExt.setDocumentPartitioner(ScalaPartitioning.SCALA_PARTITIONING, partitioner) + partitioner.connect(doc) + } + + doc + } + +} \ No newline at end of file diff --git a/org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptEditor.scala b/org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptEditor.scala new file mode 100644 index 0000000..9037f21 --- /dev/null +++ b/org.scalaide.worksheet/src/org/scalaide/worksheet/editors/ScriptEditor.scala @@ -0,0 +1,25 @@ +package org.scalaide.worksheet.editors + +import org.eclipse.ui.IEditorInput +import org.eclipse.swt.graphics.Image +import scala.tools.eclipse.ScalaSourceFileEditor +import org.eclipse.ui.editors.text.TextEditor +import org.eclipse.jface.text.source.SourceViewerConfiguration +import scala.tools.eclipse.ScalaSourceViewerConfiguration +import scala.tools.eclipse.ScalaPlugin +import org.eclipse.jdt.internal.ui.JavaPlugin + +class ScriptEditor extends TextEditor { + + setPartName("Scala Script Editor") + setDocumentProvider(new ScriptDocumentProvider) + + def scalaPrefStore = ScalaPlugin.prefStore + def javaPrefStore = JavaPlugin.getDefault.getPreferenceStore + + + override def initializeEditor() { + super.initializeEditor() + setSourceViewerConfiguration(new ScriptConfiguration) + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1abfee2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,300 @@ + + + 4.0.0 + + 3.0 + + org.scalaide + org.scalaide.worksheet.build + 0.1.0-SNAPSHOT + Scala Worksheet + pom + + + org.scalaide.worksheet + org.scalaide.worksheet.tests + org.scalaide.worksheet.feature + org.scalaide.worksheet.source.feature + org.scalaide.worksheet.update-site + + + + UTF-8 + + http://download.eclipse.org/releases/indigo/ + http://download.eclipse.org/releases/juno/ + http://download.eclipse.org/tools/ajdt/37/dev/update + http://download.scala-ide.org + + + 0.15.0 + 3.0.2 + + + + + -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dosgi.classloader.lock=classname + -Xmx800m -XX:MaxPermSize=256m -Dsdtcore.headless ${tycho.test.weaving} ${tycho.test.OSspecific} + + + indigo + ${repo.eclipse.indigo} + ${repo.ajdt.indigo} + + + 2.9.3-SNAPSHOT + 2_09 + 2.9 + local + ${repo.scala-ide.root}/releases-29/stable/site + 4.10 + + + + + + scala-ide-2.0-scala-2.9 + + + + scala-ide-2.0.x-scala-2.9 + + ${repo.scala-ide.root}/nightly-update-2-0-x-29x + + + + + scala-ide-master-scala-2.9 + + ${repo.scala-ide.root}/nightly-update-master-29x + + + + + scala-ide-master-scala-trunk + + 2.10.0-SNAPSHOT + 2_10 + 2.10 + ${repo.scala-ide.root}/nightly-update-master-trunk + + + + + + macOs + + + mac + + + + -Dosgi.ws=cocoa -XstartOnFirstThread + + + + + + org.eclipse.tycho + tycho-surefire-plugin + + + + org.eclipse.jdt.launching.macosx + eclipse-plugin + + + + + + + + + + + + + scm:git://github.com/skyluc/plugin.git + https://github.com/skyluc/plugin + + + + + + junit + junit + ${junit.version} + + + + + + + sonatype.release + Sonatype maven release repository + https://oss.sonatype.org/content/repositories/releases/ + false + + + sonatype.snapshot + Sonatype maven snapshot repository + https://oss.sonatype.org/content/repositories/snapshots + + daily + + + + scala-ide + Scala IDE p2 repository + p2 + ${repo.scala-ide} + false + + + eclipse.${eclipse.codename} + Eclipse p2 repository + p2 + ${repo.eclipse} + false + + + ajdt.${eclipse.codename} + AJDT for Eclipse p2 repository + p2 + ${repo.ajdt} + false + + + + + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho.version} + + false + false + + + + true + true + true + + + + p2.osgi.bundle + org.eclipse.equinox.weaving.hook + 1.0.200.I20120427-0800 + + + + + org.eclipse.equinox.weaving.aspectj + 2 + true + + + ${tycho.test.jvmArgs} + + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho.version} + true + + + org.eclipse.tycho + tycho-compiler-plugin + ${tycho.version} + + + **/*.scala + + + + + + net.alchim31.maven + scala-maven-plugin + ${scala.plugin.version} + + + + compile + + + + + + -Xms512m + -Xmx1024m + + + + + org.eclipse.tycho + tycho-source-plugin + ${tycho.version} + + + attach-source + + plugin-source + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + attach-sources + + jar + + + + + + + org.eclipse.tycho + tycho-packaging-plugin + ${tycho.version} + + '${version.tag}-${version.suffix}-'yyyyMMddHHmm'-${buildNumber}' + true + + + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.1 + + + validate + + create + + + + + false + false + 7 + + + + + +