Skip to content
Browse files

Merge branch 'master' of git://github.com/scala-ide/scala-ide into qu…

…ickFixTypeMismatch
  • Loading branch information...
2 parents ef389f1 + ca44dc9 commit c9e80956fe43485c79ca5691b05c1f1c3e1a8fc3 @kaptoxic committed Sep 29, 2012
Showing with 922 additions and 353 deletions.
  1. +3 −1 eclipse-director.sh
  2. +1 −0 org.scala-ide.product/.gitignore
  3. +156 −0 org.scala-ide.product/pom.xml
  4. +7 −0 org.scala-ide.product/scalaide.p2.inf
  5. +80 −0 org.scala-ide.product/scalaide.product
  6. +1 −4 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/EclipseUserSimulator.scala
  7. +18 −0 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/completion/CompletionTests.scala
  8. +32 −17 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/hyperlink/HyperlinkDetectorTests.scala
  9. +4 −10 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/hyperlink/HyperlinkTester.scala
  10. +5 −4 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/occurrences/OccurrencesFinderTest.scala
  11. +7 −0 org.scala-ide.sdt.core.tests/test-workspace/completion/src/ticket_1001207/T1207.scala
  12. +1 −1 org.scala-ide.sdt.core.tests/test-workspace/hyperlinks/src/bug1000656/Client.scala
  13. +2 −1 org.scala-ide.sdt.core.tests/test-workspace/hyperlinks/src/hyperlinks/SimpleHyperlinking.scala
  14. +12 −0 org.scala-ide.sdt.core.tests/test-workspace/hyperlinks/src/scalalinks/ScalaListLinks.scala
  15. +5 −0 org.scala-ide.sdt.core.tests/test-workspace/hyperlinks/src/t1001215/A.scala
  16. +1 −0 org.scala-ide.sdt.core/.classpath
  17. +6 −0 org.scala-ide.sdt.core/about.mappings
  18. +5 −1 org.scala-ide.sdt.core/build.properties
  19. BIN org.scala-ide.sdt.core/intro-scala.png
  20. +24 −0 org.scala-ide.sdt.core/plugin.properties
  21. +47 −0 org.scala-ide.sdt.core/plugin.xml
  22. +50 −0 org.scala-ide.sdt.core/plugin_customization.ini
  23. +17 −0 org.scala-ide.sdt.core/pom.xml
  24. BIN org.scala-ide.sdt.core/product.png
  25. +17 −0 org.scala-ide.sdt.core/src-2.10/scala/tools/eclipse/SymbolsCompatibility.scala
  26. +10 −0 org.scala-ide.sdt.core/src-2.9/scala/tools/eclipse/SymbolsCompatibility.scala
  27. +14 −0 org.scala-ide.sdt.core/src/scala/tools/eclipse/InteractiveCompilationUnit.scala
  28. +14 −0 org.scala-ide.sdt.core/src/scala/tools/eclipse/PreferenceInitializer.scala
  29. +5 −0 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaClassFileEditor.scala
  30. +0 −14 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaDamagerRepairer.scala
  31. +2 −3 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaEditor.scala
  32. +31 −37 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaHover.scala
  33. +166 −155 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaPresentationCompiler.scala
  34. +2 −2 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaProject.scala
  35. +29 −18 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaSourceFileEditor.scala
  36. +11 −7 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaSourceViewerConfiguration.scala
  37. +4 −1 ...ala-ide.sdt.core/src/scala/tools/eclipse/buildmanager/sbtintegration/EclipseSbtBuildManager.scala
  38. +1 −2 org.scala-ide.sdt.core/src/scala/tools/eclipse/diagnostic/StartupDiagnostics.scala
  39. +1 −1 org.scala-ide.sdt.core/src/scala/tools/eclipse/hyperlink/text/detector/BaseHyperlinkDetector.scala
  40. +28 −16 ...a-ide.sdt.core/src/scala/tools/eclipse/hyperlink/text/detector/DeclarationHyperlinkDetector.scala
  41. +22 −11 ....sdt.core/src/scala/tools/eclipse/hyperlink/text/detector/ScalaDeclarationHyperlinkComputer.scala
  42. +0 −8 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaCompilationUnit.scala
  43. +1 −1 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaJavaMapper.scala
  44. +3 −3 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaOverrideIndicatorBuilder.scala
  45. +3 −3 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaSelectionEngine.scala
  46. +4 −4 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaStructureBuilder.scala
  47. +27 −10 org.scala-ide.sdt.core/src/scala/tools/eclipse/markoccurrences/ScalaOccurrencesFinder.scala
  48. +2 −1 org.scala-ide.sdt.core/src/scala/tools/eclipse/properties/IDESettings.scala
  49. +1 −1 org.scala-ide.sdt.core/src/scala/tools/eclipse/properties/ImplicitsPreferencePage.scala
  50. +1 −0 org.scala-ide.sdt.core/src/scala/tools/eclipse/properties/ScalaCompilerPreferenceInitializer.scala
  51. +1 −1 org.scala-ide.sdt.core/src/scala/tools/eclipse/refactoring/EditorHelpers.scala
  52. +4 −1 org.scala-ide.sdt.core/src/scala/tools/eclipse/refactoring/ExtractMethodAction.scala
  53. +4 −1 org.scala-ide.sdt.core/src/scala/tools/eclipse/refactoring/InlineLocalAction.scala
  54. +4 −1 org.scala-ide.sdt.core/src/scala/tools/eclipse/refactoring/rename/LocalRenameAction.scala
  55. +3 −1 org.scala-ide.sdt.core/src/scala/tools/eclipse/semantichighlighting/classifier/SafeSymbol.scala
  56. +9 −0 org.scala-ide.sdt.core/src/scala/tools/eclipse/ui/InteractiveCompilationUnitEditor.scala
  57. +7 −11 org.scala-ide.sdt.core/src/scala/tools/eclipse/util/EditorUtils.scala
  58. +1 −0 org.scala-ide.sdt.feature/feature.xml
  59. +6 −0 org.scala-ide.sdt.update-site/plugin-signing.sh
View
4 eclipse-director.sh
@@ -132,7 +132,9 @@ while [ $# -gt 0 ]; do
$eclipse_dir/eclipse $eclipse_opt \
-application $app \
-repository $eclipse_repo \
- -list
+ -list \
+ | grep feature.group \
+ | awk -F "=" '{print $1}'
shift
;;
View
1 org.scala-ide.product/.gitignore
@@ -0,0 +1 @@
+target/
View
156 org.scala-ide.product/pom.xml
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.scala-ide</groupId>
+ <artifactId>org.scala-ide.build</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.scala-ide.product</artifactId>
+ <packaging>eclipse-repository</packaging>
+
+ <properties>
+ <!-- some default values, can be overwritten by profiles -->
+ <repo.scala-ide.ecosystem>${repo.scala-ide.root}/ecosystem/dev-milestone-2.9/site/</repo.scala-ide.ecosystem>
+ </properties>
+
+ <profiles>
+ <profile>
+ <!--- the profile using the default values. Scala 2.9.x -->
+ <id>scala-2.9.x</id>
+ </profile>
+
+ <profile>
+ <!-- Scala 2.10.x -->
+ <id>scala-2.10.x</id>
+ <properties>
+ <repo.scala-ide.ecosystem>${repo.scala-ide.root}/ecosystem/dev-milestone-milestone/site/</repo.scala-ide.ecosystem>
+ <scala.major.minor.version>2.10.0-M7</scala.major.minor.version>
+ </properties>
+ </profile>
+ </profiles>
+
+ <repositories>
+ <repository>
+ <id>scala-ide ecosystem</id>
+ <url>${repo.scala-ide.ecosystem}</url>
+ <layout>p2</layout>
+ </repository>
+ <repository>
+ <id>eclipse.${eclipse.codename}</id>
+ <name>Eclipse p2 repository</name>
+ <layout>p2</layout>
+ <url>${repo.eclipse}</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>ajdt.${eclipse.codename}</id>
+ <name>AJDT for Eclipse p2 repository</name>
+ <layout>p2</layout>
+ <url>${repo.ajdt}</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <!-- enable tycho to support eclipse type artifacts -->
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tycho.plugin.version}</version>
+ <configuration>
+ <environments>
+ <environment>
+ <os>linux</os>
+ <ws>gtk</ws>
+ <arch>x86_64</arch>
+ </environment>
+ <environment>
+ <os>linux</os>
+ <ws>gtk</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>macosx</os>
+ <ws>carbon</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>macosx</os>
+ <ws>cocoa</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>macosx</os>
+ <ws>cocoa</ws>
+ <arch>x86_64</arch>
+ </environment>
+ <environment>
+ <os>win32</os>
+ <ws>win32</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>win32</os>
+ <ws>win32</ws>
+ <arch>x86_64</arch>
+ </environment>
+ </environments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-repository-plugin</artifactId>
+ <version>${tycho.plugin.version}</version>
+ <configuration>
+ <includeAllDependencies>true</includeAllDependencies>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-director-plugin</artifactId>
+ <version>${tycho.plugin.version}</version>
+ <executions>
+ <execution>
+ <id>materialize-products</id>
+ <goals>
+ <goal>materialize-products</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>archive-products</id>
+ <goals>
+ <goal>archive-products</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <formats>
+ <linux>tar.gz</linux>
+ </formats>
+ <products>
+ <product>
+ <id>scalaide.product.id</id>
+ <rootFolder>eclipse</rootFolder>
+ <archiveFileName>scala-SDK-2.1-M2-${scala.major.minor.version}</archiveFileName>
+ </product>
+ </products>
+ <installFeatures>true</installFeatures>
+ <profile>SDKProfile</profile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
7 org.scala-ide.product/scalaide.p2.inf
@@ -0,0 +1,7 @@
+instructions.configure=\
+ addRepository(type:0,location:http${#58}//download.eclipse.org/eclipse/updates/3.7,name:The Eclipse Project Updates);\
+ addRepository(type:1,location:http${#58}//download.eclipse.org/eclipse/updates/3.7,name:The Eclipse Project Updates);\
+ addRepository(type:0,location:http${#58}//download.eclipse.org/releases/indigo,name:Indigo);\
+ addRepository(type:1,location:http${#58}//download.eclipse.org/releases/indigo,name:Indigo);\
+ addRepository(type:0,location:http${#58}//download.scala-ide.org/ecosystem/dev-milestone-2.9/site/,name:Scala IDE);\
+ addRepository(type:1,location:http${#58}//download.scala-ide.org/ecosystem/dev-milestone-2.9/site/,name:Scala IDE);
View
80 org.scala-ide.product/scalaide.product
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?pde version="3.5"?>
+
+<product name="Typesafe Scala IDE" uid="scalaide.product.id" id="org.scala-ide.sdt.product" application="org.eclipse.ui.ide.workbench" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="true">
+
+ <aboutInfo>
+ <image path="eclipse_lg.gif"/>
+ <text>
+ %productBlurb
+ </text>
+ </aboutInfo>
+
+ <configIni use="default">
+<!-- <macosx>config.ini</macosx>
+ <linux>config.ini</linux>
+ <win32>config.ini</win32> -->
+ </configIni>
+
+ <launcherArgs>
+ <vmArgs>-Xmx1500m
+-Xms100m
+-XX:MaxPermSize=128m</vmArgs>
+ <vmArgsMac>
+-XstartOnFirstThread
+-Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
+ </launcherArgs>
+
+ <windowImages i16="eclipse.gif" i32="eclipse32.gif" i48="eclipse48.gif" i64="eclipse.png" i128="eclipse32.png"/>
+
+ <splash
+ location="org.eclipse.platform"
+ startupProgressRect="0,280,455,15"
+ startupMessageRect="7,220,441,20"
+ startupForegroundColor="C8D5EA" />
+ <launcher>
+ <solaris/>
+ <win useIco="false">
+ <bmp/>
+ </win>
+ </launcher>
+
+ <intro introId="org.eclipse.ui.intro.universal"/>
+
+ <vm>
+ <macos include="true">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</macos>
+ </vm>
+
+ <features>
+ <feature id="org.scala-ide.sdt.feature"/>
+ <feature id="org.scala-ide.sdt.weaving.feature"/>
+ <feature id="org.scalaide.worksheet.feature"/>
+ <feature id="org.eclipse.cvs"/>
+ <feature id="org.eclipse.equinox.p2.core.feature"/>
+ <feature id="org.eclipse.equinox.p2.extras.feature"/>
+ <feature id="org.eclipse.equinox.p2.rcp.feature"/>
+ <feature id="org.eclipse.equinox.p2.user.ui"/>
+ <feature id="org.eclipse.equinox.weaving.sdk"/>
+ <feature id="org.eclipse.help"/>
+ <feature id="org.eclipse.pde"/>
+ <feature id="org.eclipse.jdt"/>
+ <feature id="org.eclipse.platform"/>
+ <feature id="org.eclipse.rcp"/>
+ </features>
+ <configurations>
+ <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="4" />
+ <plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
+
+ <!-- Needed in order for the update manager to work. -->
+ <plugin id="org.eclipse.equinox.common" autostart="true" startLevel="2" />
+ <plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="4" />
+ <plugin id="org.eclipse.update.configurator" autostart="true" level="4" />
+ <property name="equinox.use.ds" value="true" />
+ <property name="org.eclipse.update.reconcile" value="false" />
+
+ <property name="eclipse.p2.data.area" value="@config.dir/../p2/" />
+ <property name="eclipse.p2.profile" value="SDKProfile" />
+ <property name="eclipse.buildId" value="2.1-M2-Typesafe" />
+ </configurations>
+
+</product>
View
5 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/EclipseUserSimulator.scala
@@ -34,10 +34,7 @@ class EclipseUserSimulator {
javaProject.setOutputLocation(new Path("/" + projectName + "/bin"), null);
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 += JavaRuntime.getDefaultJREContainerEntry()
if (withSourceRoot) {
val sourceFolder = project.getFolder("/src");
View
18 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/completion/CompletionTests.scala
@@ -217,4 +217,22 @@ class CompletionTests {
runTest("t1001014/F.scala", false)(oracle)
}
+
+ @Test
+ def t1001207() {
+ val unit = scalaCompilationUnit("ticket_1001207/T1207.scala")
+ reload(unit)
+
+ withCompletions("ticket_1001207/T1207.scala") {
+ (index, position, completions) =>
+ assertEquals("There is only one completion location", 0, index)
+ assertTrue("The completion should return java.util", completions.exists(
+ _ match {
+ case CompletionProposal(MemberKind.Package, _, "util", _, _, _, _, _, _, _, _, _) =>
+ true
+ case _ =>
+ false
+ }))
+ }
+ }
}
View
49 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/hyperlink/HyperlinkDetectorTests.scala
@@ -16,26 +16,34 @@ object HyperlinkDetectorTests extends TestProjectSetup("hyperlinks") with Hyperl
class HyperlinkDetectorTests {
import HyperlinkDetectorTests._
-
+
@Test
def simpleHyperlinks() {
- val unit = scalaCompilationUnit("hyperlinks/SimpleHyperlinking.scala")
+ val oracle = List(
+ Link("type scala.Predef.Set"),
+ Link("type hyperlinks.SimpleHyperlinking.Tpe"),
+ Link("method scala.Array.apply", "object scala.Array"),
+ Link("method scala.collection.TraversableOnce.sum"),
+ Link("type scala.Predef.String"),
+ Link("object scala.Some"),
+ Link("class scala.Option"),
+ Link("type scala.Predef.String"))
- reload(unit)
+ loadTestUnit("hyperlinks/SimpleHyperlinking.scala").andCheckAgainst(oracle)
+ }
+
+ @Test
+ def scalaPackageLinks() {
+ val oracle = List(
+ Link("method scala.collection.immutable.List.apply", "object scala.collection.immutable.List"),
+ Link("object scala.collection.immutable.List"),
+ Link("method scala.collection.generic.GenericCompanion.apply", "object scala.collection.Seq"),
+ Link("object scala.collection.Seq"),
+ Link("object scala.collection.immutable.Nil"),
+ Link("method scala.collection.LinearSeqOptimized.apply", "value scalalinks.Foo.xs")
+ )
- val contents = unit.getContents
- val positions = SDTTestUtils.positionsOf(contents, "/*^*/")
-
- println("checking %d positions".format(positions.size))
- val resolver = new ScalaDeclarationHyperlinkComputer
- for (pos <- positions) {
- val wordRegion = ScalaWordFinder.findWord(unit.getContents, pos - 1)
- val word = new String(unit.getContents.slice(wordRegion.getOffset, wordRegion.getOffset + wordRegion.getLength))
- val links = resolver.findHyperlinks(unit, wordRegion)
- println("Found links: " + links)
- assertTrue(links.isDefined)
- assertEquals("Failed hyperlinking at position %d (%s)".format(pos, word), 1, links.get.size)
- }
+ loadTestUnit("scalalinks/ScalaListLinks.scala").andCheckAgainst(oracle)
}
@Test
@@ -76,7 +84,14 @@ class HyperlinkDetectorTests {
// and make sure the classpath is up to date
project.resetPresentationCompiler()
- val oracle = List(Link("type util.Box.myInt"), Link("method util.Full.apply"))
+ val oracle = List(Link("type util.Box.myInt"), Link("method util.Full.apply", "object util.Full"))
loadTestUnit("bug1000656/Client.scala").andCheckAgainst(oracle)
}
+
+ @Test
+ def hyperlinkOnList_t1001215() {
+ val oracle = List(Link("method scala.collection.immutable.List.apply", "object scala.collection.immutable.List"))
+
+ loadTestUnit("t1001215/A.scala").andCheckAgainst(oracle)
+ }
}
View
14 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/hyperlink/HyperlinkTester.scala
@@ -15,7 +15,7 @@ trait HyperlinkTester extends TestProjectSetup {
private final val HyperlinkMarker = "/*^*/"
- case class Link(text: String)
+ case class Link(text: String*)
/** Given a source `path`, load the corresponding scala `unit`. */
def loadTestUnit(path: String): VerifyHyperlink = {
@@ -47,15 +47,9 @@ trait HyperlinkTester extends TestProjectSetup {
// Verify Expectations
assertTrue("no links found for `%s`".format(word), maybeLinks.isDefined)
val links = maybeLinks.get
- assertEquals("expected %d link, found %d".format(1, links.size), 1, links.size)
- val link = links.head
- assertEquals("text", oracle.text, link.getTypeLabel)
- //assertEquals("offset", oracle.region.getOffset(), link.getHyperlinkRegion().getOffset())
- unit.withSourceFile({ (sourceFile, compiler) =>
- val offset = link.getHyperlinkRegion().getOffset()
- val length = link.getHyperlinkRegion().getLength
- val linkedPos = compiler.rangePos(sourceFile, offset, offset, offset + length)
- })(None)
+ assertEquals("expected %d link, found %d".format(oracle.text.size, links.size), oracle.text.size, links.size)
+ val linkResults = links map (_.getTypeLabel)
+ assertEquals("text", oracle.text.toList.toString, linkResults.toList.toString)
}
}
}
View
9 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/occurrences/OccurrencesFinderTest.scala
@@ -19,6 +19,7 @@ object OccurrencesFinderTest extends TestProjectSetup("occurrences-hyperlinking"
class OccurrencesFinderTest {
import OccurrencesFinderTest._
+ @Ignore("Fails in 2.10.0-SNAPSHOT, not finding any occurrences of 'func'")
@Test def typeOccurrences() {
val unit = compilationUnit("occ/DummyOccurrences.scala").asInstanceOf[ScalaCompilationUnit];
@@ -41,11 +42,11 @@ class OccurrencesFinderTest {
for ((pos, count) <- positions) {
println("looking at position %d for %d occurrences".format(pos, count))
val region = ScalaWordFinder.findWord(contents, pos - 1)
+ val word = new String(contents.slice(region.getOffset(), region.getOffset() + region.getLength()))
println("using word region: " + region)
- val finder = new ScalaOccurrencesFinder(unit, region.getOffset, region.getLength)
- val occurrences = finder.findOccurrences
- assertTrue(finder.findOccurrences.isDefined)
- assertEquals(count, occurrences.get.locations.size)
+ val occurrences = ScalaOccurrencesFinder.findOccurrences(unit, region.getOffset, region.getLength, 1)
+ assertTrue("No occurrences of %s".format(word), occurrences.isDefined)
+ assertEquals("Not enough occurrences (%s): expected: %d, found: %d".format(word, count, occurrences.get.locations.size), count, occurrences.get.locations.size)
}
}
View
7 org.scala-ide.sdt.core.tests/test-workspace/completion/src/ticket_1001207/T1207.scala
@@ -0,0 +1,7 @@
+package ticket_1001207
+
+import java.u /*!*/
+
+class T1207 {
+
+}
View
2 org.scala-ide.sdt.core.tests/test-workspace/hyperlinks/src/bug1000656/Client.scala
@@ -10,6 +10,6 @@ class Client {
val t: b.myInt/*^*/ = 10
- val x = Full.apply/*^*/("a")
+ val x = Full/*^*/("a")
}
}
View
3 ...cala-ide.sdt.core.tests/test-workspace/hyperlinks/src/hyperlinks/SimpleHyperlinking.scala
@@ -5,12 +5,13 @@ package hyperlinks
*/
class SimpleHyperlinking {
- type Tpe[T] = List/*^*/[T]
+ type Tpe[T] = Set/*^*/[T]
def foo(xs: Tpe/*^*/[Int]) = {
val arr = Array/*^*/(1, 2, 3)
val sum = xs.sum/*^*/
val x: String/*^*/ = "Hello, world"
val Some/*^*/(x): Option/*^*/[Int] = Some(10)
+ classOf[String/*^*/]
}
}
View
12 org.scala-ide.sdt.core.tests/test-workspace/hyperlinks/src/scalalinks/ScalaListLinks.scala
@@ -0,0 +1,12 @@
+package scalalinks
+
+class Foo {
+ def bar {
+ val xs = List/*^*/(1, 2, 3)
+ List/*^*/
+ Seq/*^*/()
+ Seq/*^*/
+ Nil/*^*/
+ xs/*^*/(1)
+ }
+}
View
5 org.scala-ide.sdt.core.tests/test-workspace/hyperlinks/src/t1001215/A.scala
@@ -0,0 +1,5 @@
+package t1001215
+
+class A {
+ List/*^*/()
+}
View
1 org.scala-ide.sdt.core/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src"/>
+ <classpathentry kind="src" path="src-2.9"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_COMPILER_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
View
6 org.scala-ide.sdt.core/about.mappings
@@ -0,0 +1,6 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
+0=$eclipse.buildId$
View
6 org.scala-ide.sdt.core/build.properties
@@ -11,4 +11,8 @@ bin.includes = META-INF/,\
about.png,\
templates/,\
target/lib/,\
- plugin.properties
+ plugin.properties,\
+ plugin_customization.ini,\
+ product.png,\
+ intro-scala.png,\
+ about.mappings
View
BIN org.scala-ide.sdt.core/intro-scala.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
24 org.scala-ide.sdt.core/plugin.properties
@@ -2,3 +2,27 @@ JUnitShortcut.label= JUnit Test
RunJUnitLaunchShortcut.description=Runs a set of JUnit tests
DebugJUnitLaunchShortcut.description=Debugs a set of JUnit tests
+productIntroTitle=Scala IDE build of Eclipse SDK
+productBlurb=Scala IDE build of Eclipse SDK\n\
+\n\
+Build id: {0}\n\
+\n\
+(c) LAMP/EPFL and Typesafe for Scala IDE and associated plugins\n\
+\n\
+The Scala IDE for Eclipse provides an integrated environment for creating Scala programs.\n\
+Visit http://scala-ide.org/\n\
+\n\
+Typesafe Team: Luc Bourlier, Mirco Dotta, Iulian Dragos, Martin Odersky, and Hubert Plocinicak.\n\
+Many thanks to David Bernard, Donna Malayeri, Eric Molitor, Matt Russell, Miles Sabin,\n\
+Mirko Stocker, Joshua Suereth, Eugene Vigdorchik, and all other contributors.\n\
+\n\
+\n\
+Eclipse SDK\n\
+\n\
+Version: 3.7.2\n\
+\n\
+(c) Copyright Eclipse contributors and others 2000, 2012. All rights reserved.\n\
+Visit http://www.eclipse.org/platform\n\
+\n\
+This product includes software developed by the\n\
+Apache Software Foundation http://www.apache.org/
View
47 org.scala-ide.sdt.core/plugin.xml
@@ -1464,4 +1464,51 @@
</enablement>
</moveParticipant>
</extension>
+ <extension
+ id="org.scala-ide.sdt.product"
+ point="org.eclipse.core.runtime.products">
+ <product
+ application="org.eclipse.ui.ide.workbench"
+ description="Scala IDE for Eclipse"
+ name="Scala IDE">
+ <property name="aboutImage" value="product.png"/>
+ <property name="aboutText" value="%productBlurb"/>
+ <property
+ name="preferenceCustomization"
+ value="plugin_customization.ini">
+ </property>
+ <property
+ name="introTitle"
+ value="%productIntroTitle"/>
+ <property
+ name="introBrandingImage"
+ value="product:intro-scala.png"/>
+ <property
+ name="startupForegroundColor"
+ value="C8D5EA"/>
+ <property
+ name="startupMessageRect"
+ value="7,220,441,20"/>
+ <property
+ name="startupProgressRect"
+ value="0,280,455,15"/>
+ <property
+ name="buildIdLocation"
+ value="312,190">
+ </property>
+ </product>
+ </extension>
+ <extension point="org.eclipse.ui.intro">
+ <introProductBinding
+ introId="org.eclipse.ui.intro.universal"
+ productId="org.scala-ide.sdt.product">
+ </introProductBinding>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="scala.tools.eclipse.PreferenceInitializer">
+ </initializer>
+ </extension>
+
</plugin>
View
50 org.scala-ide.sdt.core/plugin_customization.ini
@@ -0,0 +1,50 @@
+# plugin_customization.ini
+# sets default values for plug-in-specific preferences
+# keys are qualified by plug-in id
+# e.g., com.example.acmeplugin/myproperty=myvalue
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in plugin_customization.properties
+# This file does not need to be translated.
+
+# Property "org.eclipse.ui/defaultPerspectiveId" controls the
+# perspective that the workbench opens initially
+org.eclipse.ui/defaultPerspectiveId=org.scala-ide.sdt.core.perspective
+
+# new-style tabs by default
+org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false
+
+# put the perspective switcher on the top right
+org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight
+
+# show progress on startup
+org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP=true
+
+# show build id in the splash - only for nightly, integration, and milestone builds
+org.eclipse.ui.workbench/SHOW_BUILDID_ON_STARTUP=true
+
+# use the window set by default
+org.eclipse.ui/USE_WINDOW_WORKING_SET_BY_DEFAULT=true
+
+# Intro-related preferences (since 3.2)
+
+# Welcome theme to use
+org.eclipse.ui.intro/INTRO_THEME = org.eclipse.ui.intro.universal.slate
+
+# Root page links to show in the Universal Welcome
+org.eclipse.ui.intro.universal/INTRO_ROOT_PAGES = overview,tutorials,samples,whatsnew
+
+# Initial page layout of the Universal Welcome
+org.eclipse.ui.intro.universal/INTRO_DATA = product:introData.xml
+
+# Order help books in table of contents
+org.eclipse.help/HELP_DATA = helpData.xml
+
+
+
+# Scala IDE SDK specific settings
+
+# hide startup preference dialog
+org.scala-ide.sdt.core/org.scala-ide.sdt.core.diagnostic.askOnUpgrade=false
+
+# set the content assist auto-activation to a more slower pace
+org.eclipse.jdt.ui/content_assist_autoactivation_delay=500
View
17 org.scala-ide.sdt.core/pom.xml
@@ -83,6 +83,23 @@
</execution>
</executions>
</plugin>
+ <!-- added source folder containing the code specific to the scala version -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals><goal>add-source</goal></goals>
+ <configuration>
+ <sources>
+ <source>src-${scala.major.minor.version}</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
View
BIN org.scala-ide.sdt.core/product.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
17 org.scala-ide.sdt.core/src-2.10/scala/tools/eclipse/SymbolsCompatibility.scala
@@ -0,0 +1,17 @@
+package scala.tools.eclipse
+
+import scala.reflect.internal.Symbols
+
+/**
+ * Trait used to keep 2.9-2.10 source compatibility
+ */
+trait SymbolsCompatibility { self: Symbols =>
+
+ /**
+ * This class as been removed in 2.10, but we need its real implementation in 2.9
+ */
+ case class InvalidCompanions(sym1: Symbol, sym2: Symbol) extends Throwable {
+
+ }
+
+}
View
10 org.scala-ide.sdt.core/src-2.9/scala/tools/eclipse/SymbolsCompatibility.scala
@@ -0,0 +1,10 @@
+package scala.tools.eclipse
+
+import scala.tools.nsc.symtab.Symbols
+
+/**
+ * Trait used to keep 2.9-2.10 source compatibility
+ */
+trait SymbolsCompatibility { self: Symbols =>
+
+}
View
14 org.scala-ide.sdt.core/src/scala/tools/eclipse/InteractiveCompilationUnit.scala
@@ -6,6 +6,10 @@ import scala.tools.nsc.util.BatchSourceFile
import scala.tools.nsc.util.SourceFile
import scala.tools.nsc.interactive.Response
import scala.tools.nsc.io.AbstractFile
+import org.eclipse.jdt.core.WorkingCopyOwner
+import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner
+import org.eclipse.jdt.internal.core.SearchableEnvironment
+import org.eclipse.jdt.internal.core.JavaProject
/** A Scala compilation unit. It can be backed up by a `ScalaCompilationUnit` in usual
* Scala projects, or any other implementation (such as a specialized Scala DSL, a
@@ -66,4 +70,14 @@ trait InteractiveCompilationUnit {
* ensuring faster response when calling `getProblems`.
*/
def scheduleReconcile(): Response[Unit]
+
+ /** Returns a new search name environment for the scala project.
+ *
+ * @param workingCopyOwner The owner of an this Compilation Unit in working copy mode.
+ */
+ def newSearchableEnvironment(workingCopyOwner : WorkingCopyOwner = DefaultWorkingCopyOwner.PRIMARY) : SearchableEnvironment = {
+ val javaProject = scalaProject.javaProject.asInstanceOf[JavaProject]
+ javaProject.newSearchableNameEnvironment(workingCopyOwner)
+ }
+
}
View
14 org.scala-ide.sdt.core/src/scala/tools/eclipse/PreferenceInitializer.scala
@@ -0,0 +1,14 @@
+package scala.tools.eclipse
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer
+import org.eclipse.core.runtime.preferences.DefaultScope
+import scala.tools.eclipse.diagnostic.StartupDiagnostics
+
+class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ def initializeDefaultPreferences(): Unit = {
+ val node = new DefaultScope().getNode("org.scala-ide.sdt.core");
+ node.putBoolean(StartupDiagnostics.ASK_DIAGNOSTICS, true);
+ }
+
+}
View
5 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaClassFileEditor.scala
@@ -53,4 +53,9 @@ class ScalaClassFileEditor extends ClassFileEditor with ScalaEditor {
openAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR)
setAction("OpenEditor", openAction)
}
+
+ override def getInteractiveCompilationUnit(): Option[InteractiveCompilationUnit] =
+ // getInputJavaElement always returns the right value
+ Some(getInputJavaElement().asInstanceOf[InteractiveCompilationUnit])
+
}
View
14 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaDamagerRepairer.scala
@@ -1,14 +0,0 @@
-/*
- * Copyright 2005-2010 LAMP/EPFL
- */
-// $Id$
-
-package scala.tools.eclipse
-
-import org.eclipse.jface.text.{ TextPresentation, ITypedRegion }
-import org.eclipse.jface.text.rules.{ DefaultDamagerRepairer, ITokenScanner }
-
-class ScalaDamagerRepairer(scanner : ITokenScanner) extends DefaultDamagerRepairer(scanner) {
- override def createPresentation(presentation : TextPresentation, damage : ITypedRegion) : Unit =
- super.createPresentation(presentation, damage);
-}
View
5 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaEditor.scala
@@ -7,13 +7,12 @@ package scala.tools.eclipse
import org.eclipse.jface.text.rules.FastPartitioner
import org.eclipse.jface.text.IDocumentPartitioner
-
import org.eclipse.jdt.ui.text.IJavaPartitions
-
import scala.tools.eclipse.contribution.weaving.jdt.ui.javaeditor.IScalaEditor
import scala.tools.eclipse.lexical._
+import scala.tools.eclipse.ui.InteractiveCompilationUnitEditor
-trait ScalaEditor extends IScalaEditor with ISourceViewerEditor {
+trait ScalaEditor extends IScalaEditor with ISourceViewerEditor with InteractiveCompilationUnitEditor {
def createDocumentPartitioner = new ScalaDocumentPartitioner
View
68 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaHover.scala
@@ -8,48 +8,42 @@ package scala.tools.eclipse
import org.eclipse.jdt.core.ICodeAssist
import org.eclipse.jface.text.{ ITextViewer, IRegion, ITextHover }
-import scala.tools.eclipse.javaelements.ScalaCompilationUnit
import scala.tools.nsc.symtab.Flags
import scala.tools.eclipse.util.EclipseUtils._
-class ScalaHover(codeAssist : () => Option[ICodeAssist]) extends ITextHover {
-
+class ScalaHover(val icu: InteractiveCompilationUnit) extends ITextHover {
+
private val NoHoverInfo = "" // could return null, but prefer to return empty (see API of ITextHover).
-
- override def getHoverInfo(viewer : ITextViewer, region : IRegion) = {
- codeAssist() match {
- case Some(scu : ScalaCompilationUnit) => {
- val start = region.getOffset
- val end = start + region.getLength
- scu.withSourceFile ({ (src, compiler) =>
- import compiler._
-
- def hoverInfo(t: Tree): Option[String] = askOption { () =>
- def compose(ss: List[String]): String = ss.filter("" !=).mkString("", " ", "")
- def defString(sym: Symbol, tpe: Type): String = {
- // NoType is returned for defining occurrences, in this case we want to display symbol info itself.
- val tpeinfo = if (tpe ne NoType) tpe.widen else sym.info
- compose(List(sym.hasFlagsToString(Flags.ExplicitFlags), sym.keyString, sym.varianceString + sym.nameString +
- sym.infoString(tpeinfo)))
- }
-
- for (sym <- Option(t.symbol); tpe <- Option(t.tpe))
- yield if (sym.isClass || sym.isModule) sym.fullName else defString(sym, tpe)
- } getOrElse None
-
-
-
- val resp = new Response[Tree]
- askTypeAt(region.toRangePos(src), resp)
- (for (t <- resp.get.left.toOption;
- hover <- hoverInfo(t)) yield hover) getOrElse NoHoverInfo
- }) (NoHoverInfo)
- }
- case _ => NoHoverInfo
- }
+
+ override def getHoverInfo(viewer: ITextViewer, region: IRegion) = {
+ val start = region.getOffset
+ val end = start + region.getLength
+ icu.withSourceFile({ (src, compiler) =>
+ import compiler._
+
+ def hoverInfo(t: Tree): Option[String] = askOption { () =>
+ def compose(ss: List[String]): String = ss.filter("" !=).mkString("", " ", "")
+ def defString(sym: Symbol, tpe: Type): String = {
+ // NoType is returned for defining occurrences, in this case we want to display symbol info itself.
+ val tpeinfo = if (tpe ne NoType) tpe.widen else sym.info
+ compose(List(sym.hasFlagsToString(Flags.ExplicitFlags), sym.keyString, sym.varianceString + sym.nameString +
+ sym.infoString(tpeinfo)))
+ }
+
+ for (sym <- Option(t.symbol); tpe <- Option(t.tpe))
+ yield if (sym.isClass || sym.isModule) sym.fullName else defString(sym, tpe)
+ } getOrElse None
+
+ val resp = new Response[Tree]
+ askTypeAt(region.toRangePos(src), resp)
+ (for (
+ t <- resp.get.left.toOption;
+ hover <- hoverInfo(t)
+ ) yield hover) getOrElse NoHoverInfo
+ })(NoHoverInfo)
}
-
- override def getHoverRegion(viewer : ITextViewer, offset : Int) = {
+
+ override def getHoverRegion(viewer: ITextViewer, offset: Int) = {
ScalaWordFinder.findWord(viewer.getDocument, offset)
}
}
View
321 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaPresentationCompiler.scala
@@ -11,52 +11,59 @@ import scala.collection.mutable.{ ArrayBuffer, SynchronizedMap }
import org.eclipse.jdt.core.compiler.IProblem
import org.eclipse.jdt.internal.compiler.problem.{ DefaultProblem, ProblemSeverities }
import scala.tools.nsc.Settings
-import scala.tools.nsc.interactive.{Global, InteractiveReporter, Problem}
+import scala.tools.nsc.interactive.{ Global, InteractiveReporter, Problem }
import scala.tools.nsc.io.AbstractFile
import scala.tools.nsc.reporters.Reporter
import scala.tools.nsc.util.{ BatchSourceFile, Position, SourceFile }
import scala.tools.eclipse.javaelements.{
- ScalaCompilationUnit, ScalaIndexBuilder, ScalaJavaMapper, ScalaMatchLocator, ScalaStructureBuilder,
- ScalaOverrideIndicatorBuilder }
+ ScalaCompilationUnit,
+ ScalaIndexBuilder,
+ ScalaJavaMapper,
+ ScalaMatchLocator,
+ ScalaStructureBuilder,
+ ScalaOverrideIndicatorBuilder
+}
import scala.tools.eclipse.util.{ Cached, EclipseFile, EclipseResource }
import scala.tools.eclipse.logging.HasLogger
import scala.tools.nsc.util.FailedInterrupt
import scala.tools.nsc.symtab.Flags
import scala.tools.eclipse.completion.CompletionProposal
import org.eclipse.jdt.core.IMethod
+import scala.tools.nsc.io.VirtualFile
-class ScalaPresentationCompiler(project : ScalaProject, settings : Settings)
+class ScalaPresentationCompiler(project: ScalaProject, settings: Settings)
extends Global(settings, new ScalaPresentationCompiler.PresentationReporter, project.underlying.getName)
- with ScalaStructureBuilder
- with ScalaIndexBuilder
+ with ScalaStructureBuilder
+ with ScalaIndexBuilder
with ScalaMatchLocator
- with ScalaOverrideIndicatorBuilder
- with ScalaJavaMapper
+ with ScalaOverrideIndicatorBuilder
+ with ScalaJavaMapper
with JavaSig
- with JVMUtils
- with LocateSymbol
- with HasLogger { self =>
-
+ with JVMUtils
+ with LocateSymbol
+ with HasLogger
+ with SymbolsCompatibility { self =>
+
def presentationReporter = reporter.asInstanceOf[ScalaPresentationCompiler.PresentationReporter]
presentationReporter.compiler = this
-
+
/** A map from compilation units to the BatchSourceFile that the compiler understands.
- *
- * This map is populated by having a default source file created when calling 'apply',
+ *
+ * This map is populated by having a default source file created when calling 'apply',
* which currently happens in 'withSourceFile'.
*/
private val sourceFiles = new mutable.HashMap[InteractiveCompilationUnit, SourceFile] {
- override def default(k : InteractiveCompilationUnit) = {
+ override def default(k: InteractiveCompilationUnit) = {
val v = k.sourceFile()
ScalaPresentationCompiler.this.synchronized {
get(k) match {
case Some(v) => v
- case None => put(k, v); v
+ case None => put(k, v); v
}
}
- }
+ }
}
-
+
/** Return the Scala compilation units that are currently maintained by this presentation compiler.
*/
def compilationUnits: Seq[InteractiveCompilationUnit] = {
@@ -66,39 +73,38 @@ class ScalaPresentationCompiler(project : ScalaProject, settings : Settings)
if managedFiles(sourceFile.file)
} yield cu).toSeq
}
-
- def problemsOf(file : AbstractFile) : List[IProblem] = {
+
+ def problemsOf(file: AbstractFile): List[IProblem] = {
unitOfFile get file match {
- case Some(unit) =>
+ case Some(unit) =>
val response = new Response[Tree]
askLoadedTyped(unit.source, response)
response.get
unit.problems.toList flatMap presentationReporter.eclipseProblem
- case None =>
+ case None =>
logger.info("Missing unit for file %s when retrieving errors. Errors will not be shown in this file".format(file))
logger.info(unitOfFile.toString)
Nil
}
}
-
- def problemsOf(scu : ScalaCompilationUnit) : List[IProblem] = problemsOf(scu.file)
-
-
- /** Run the operation on the given compilation unit. If the source file is not yet tracked by
+
+ def problemsOf(scu: ScalaCompilationUnit): List[IProblem] = problemsOf(scu.file)
+
+ /** Run the operation on the given compilation unit. If the source file is not yet tracked by
* the presentation compiler, a new BatchSourceFile is created and kept for future reference.
*/
- def withSourceFile[T](scu : InteractiveCompilationUnit)(op : (SourceFile, ScalaPresentationCompiler) => T) : T =
- op(sourceFiles(scu), this)
-
- def body(sourceFile : SourceFile) = {
+ def withSourceFile[T](icu: InteractiveCompilationUnit)(op: (SourceFile, ScalaPresentationCompiler) => T): T =
+ op(sourceFiles(icu), this)
+
+ def body(sourceFile: SourceFile) = {
val response = new Response[Tree]
askType(sourceFile, false, response)
response.get match {
case Left(tree) => tree
case Right(exc) => throw exc
}
}
-
+
def loadedType(sourceFile: SourceFile) = {
val response = new Response[Tree]
askLoadedTyped(sourceFile, response)
@@ -107,66 +113,68 @@ class ScalaPresentationCompiler(project : ScalaProject, settings : Settings)
case Right(exc) => throw exc
}
}
-
- def withParseTree[T](sourceFile : SourceFile)(op : Tree => T) : T = {
+
+ def withParseTree[T](sourceFile: SourceFile)(op: Tree => T): T = {
op(parseTree(sourceFile))
}
- def withStructure[T](sourceFile : SourceFile, keepLoaded: Boolean = false)(op : Tree => T) : T = {
+ def withStructure[T](sourceFile: SourceFile, keepLoaded: Boolean = false)(op: Tree => T): T = {
val tree = {
val response = new Response[Tree]
askStructure(keepLoaded)(sourceFile, response)
response.get match {
- case Left(tree) => tree
+ case Left(tree) => tree
case Right(thr) => throw thr
}
}
op(tree)
}
- /** Perform `op' on the compiler thread. Catch all exceptions, and return
+ /** Perform `op' on the compiler thread. Catch all exceptions, and return
* None if an exception occured. TypeError and FreshRunReq are printed to
* stdout, all the others are logged in the platform error log.
+ *
+ * There's a default timeout of 10s.
*/
- def askOption[A](op: () => A): Option[A] =
- try Some(ask(op))
- catch {
- case fi: FailedInterrupt =>
- fi.getCause() match {
- case e: TypeError =>
- logger.info("TypeError in ask:\n" + e)
- None
- case f: FreshRunReq =>
- logger.info("FreshRunReq in ask:\n" + f)
- None
- case e @ InvalidCompanions(c1, c2) =>
- reporter.warning(c1.pos, e.getMessage)
- None
- case e: InterruptedException =>
- Thread.currentThread().interrupt()
- logger.info("interrupted exception in askOption")
+ def askOption[A](op: () => A, timeout: Int = 10000): Option[A] = {
+ val res = askForResponse(op)
+
+ res.get(timeout) match {
+ case None =>
+ eclipseLog.info("Timeout in askOption", new Throwable) // log a throwable for its stacktrace
+ None
+
+ case Some(result) =>
+ result match {
+ case Right(fi: FailedInterrupt) =>
+ fi.getCause() match {
+ case e: TypeError => logger.info("TypeError in ask:\n" + e)
+ case f: FreshRunReq => logger.info("FreshRunReq in ask:\n" + f)
+ case e @ InvalidCompanions(c1, c2) => reporter.warning(c1.pos, e.getMessage)
+ case e => eclipseLog.error("Error during askOption", e)
+ }
None
-
- case e =>
+
+ case Right(e: Throwable) =>
eclipseLog.error("Error during askOption", e)
None
+
+ case Left(v) => Some(v)
}
- case e: Throwable =>
- eclipseLog.error("Error during askOption", e)
- None
}
-
+ }
+
/** Ask to put scu in the beginning of the list of files to be typechecked.
- *
+ *
* If the file has not been 'reloaded' first, it does nothing.
*/
def askToDoFirst(scu: ScalaCompilationUnit) {
sourceFiles.get(scu) foreach askToDoFirst
}
/** Reload the given compilation unit. If this CU is not tracked by the presentation
- * compiler, it's a no-op.
- *
+ * compiler, it's a no-op.
+ *
* TODO: This logic seems broken: the only way to add a source file to the sourceFiles
* map is by a call to 'withSourceFile', which creates a default batch source file.
* Come back to this and make it more explicit.
@@ -178,7 +186,7 @@ class ScalaPresentationCompiler(project : ScalaProject, settings : Settings)
case Some(f) =>
val newF = new BatchSourceFile(f.file, content)
synchronized { sourceFiles(scu) = newF }
-
+
// avoid race condition by looking up the source file, as someone else
// might have swapped it in the meantime
askReload(List(sourceFiles(scu)), res)
@@ -187,94 +195,94 @@ class ScalaPresentationCompiler(project : ScalaProject, settings : Settings)
}
res
}
-
- def filesDeleted(files : List[ScalaCompilationUnit]) {
+
+ def filesDeleted(files: List[ScalaCompilationUnit]) {
logger.info("files deleted:\n" + (files map (_.getPath) mkString "\n"))
synchronized {
val srcs = files.map(sourceFiles remove _).foldLeft(List[SourceFile]()) {
- case (acc, None) => acc
- case (acc, Some(f)) => f::acc
+ case (acc, None) => acc
+ case (acc, Some(f)) => f :: acc
}
if (!srcs.isEmpty)
askFilesDeleted(srcs, new Response[Unit])
}
}
- def discardSourceFile(scu : ScalaCompilationUnit) {
- logger.info("discarding " + scu.getPath)
- synchronized {
- sourceFiles.get(scu) foreach { source =>
- removeUnitOf(source)
- sourceFiles.remove(scu)
- }
- }
- }
-
- def withResponse[A](op: Response[A] => Any): Response[A] = {
- val response = new Response[A]
- op(response)
- response
- }
-
- override def logError(msg : String, t : Throwable) =
+ def discardSourceFile(scu: ScalaCompilationUnit) {
+ logger.info("discarding " + scu.getPath)
+ synchronized {
+ sourceFiles.get(scu) foreach { source =>
+ removeUnitOf(source)
+ sourceFiles.remove(scu)
+ }
+ }
+ }
+
+ def withResponse[A](op: Response[A] => Any): Response[A] = {
+ val response = new Response[A]
+ op(response)
+ response
+ }
+
+ override def logError(msg: String, t: Throwable) =
eclipseLog.error(msg, t)
-
+
def destroy() {
logger.info("shutting down presentation compiler on project: " + project)
askShutdown()
}
-
/** Add a new completion proposal to the buffer. Skip constructors and accessors.
- *
- * Computes a very basic relevance metric based on where the symbol comes from
+ *
+ * Computes a very basic relevance metric based on where the symbol comes from
* (in decreasing order of relevance):
* - members defined by the owner
* - inherited members
* - members added by views
* - packages
* - members coming from Any/AnyRef/Object
- *
+ *
* TODO We should have a more refined strategy based on the context (inside an import, case
* pattern, 'new' call, etc.)
*/
def mkCompletionProposal(start: Int, sym: Symbol, tpe: Type, inherited: Boolean, viaView: Symbol): CompletionProposal = {
import scala.tools.eclipse.completion.MemberKind._
-
- val kind = if (sym.isSourceMethod && !sym.hasFlag(Flags.ACCESSOR | Flags.PARAMACCESSOR)) Def
- else if (sym.isPackage) Package
- else if (sym.isClass) Class
- else if (sym.isTrait) Trait
- else if (sym.isPackageObject) PackageObject
- else if (sym.isModule) Object
- else if (sym.isType) Type
- else Val
- val name = sym.decodedName
- val signature =
- if (sym.isMethod) { name +
- (if(!sym.typeParams.isEmpty) sym.typeParams.map{_.name}.mkString("[", ",", "]") else "") +
- tpe.paramss.map(_.map(_.tpe.toString).mkString("(", ", ", ")")).mkString +
- ": " + tpe.finalResultType.toString}
- else name
- val container = sym.owner.enclClass.fullName
-
- // rudimentary relevance, place own members before ineherited ones, and before view-provided ones
- var relevance = 100
- if (inherited) relevance -= 10
- if (viaView != NoSymbol) relevance -= 20
- if (sym.isPackage) relevance -= 30
- // theoretically we'd need an 'ask' around this code, but given that
- // Any and AnyRef are definitely loaded, we call directly to definitions.
- if (sym.owner == definitions.AnyClass
- || sym.owner == definitions.AnyRefClass
- || sym.owner == definitions.ObjectClass) {
- relevance -= 40
- }
-
- val scalaParamNames = for {
- section <- sym.paramss
- if section.nonEmpty && !section.head.isImplicit
- } yield for (param <- section) yield param.name.toString
+
+ val kind = if (sym.isSourceMethod && !sym.hasFlag(Flags.ACCESSOR | Flags.PARAMACCESSOR)) Def
+ else if (sym.isPackage) Package
+ else if (sym.isClass) Class
+ else if (sym.isTrait) Trait
+ else if (sym.isPackageObject) PackageObject
+ else if (sym.isModule) Object
+ else if (sym.isType) Type
+ else Val
+ val name = sym.decodedName
+ val signature =
+ if (sym.isMethod) {
+ name +
+ (if (!sym.typeParams.isEmpty) sym.typeParams.map { _.name }.mkString("[", ",", "]") else "") +
+ tpe.paramss.map(_.map(_.tpe.toString).mkString("(", ", ", ")")).mkString +
+ ": " + tpe.finalResultType.toString
+ } else name
+ val container = sym.owner.enclClass.fullName
+
+ // rudimentary relevance, place own members before ineherited ones, and before view-provided ones
+ var relevance = 100
+ if (inherited) relevance -= 10
+ if (viaView != NoSymbol) relevance -= 20
+ if (sym.isPackage) relevance -= 30
+ // theoretically we'd need an 'ask' around this code, but given that
+ // Any and AnyRef are definitely loaded, we call directly to definitions.
+ if (sym.owner == definitions.AnyClass
+ || sym.owner == definitions.AnyRefClass
+ || sym.owner == definitions.ObjectClass) {
+ relevance -= 40
+ }
+
+ val scalaParamNames = for {
+ section <- sym.paramss
+ if section.nonEmpty && !section.head.isImplicit
+ } yield for (param <- section) yield param.name.toString
val paramNames = if (sym.isJavaDefined) {
getJavaElement(sym) collect {
@@ -309,44 +317,47 @@ class ScalaPresentationCompiler(project : ScalaProject, settings : Settings)
object ScalaPresentationCompiler {
class PresentationReporter extends InteractiveReporter {
- var compiler : ScalaPresentationCompiler = null
-
- def nscSeverityToEclipse(severityLevel: Int) =
+ var compiler: ScalaPresentationCompiler = null
+
+ def nscSeverityToEclipse(severityLevel: Int) =
severityLevel match {
- case ERROR.id => ProblemSeverities.Error
+ case ERROR.id => ProblemSeverities.Error
case WARNING.id => ProblemSeverities.Warning
- case INFO.id => ProblemSeverities.Ignore
+ case INFO.id => ProblemSeverities.Ignore
}
-
+
def eclipseProblem(prob: Problem): Option[IProblem] = {
import prob._
if (pos.isDefined) {
- val source = pos.source
- val pos1 = pos.toSingleLine
+ val source = pos.source
+ val pos1 = pos.toSingleLine
+ val fileName =
source.file match {
- case ef@EclipseFile(file) =>
- Some(
- new DefaultProblem(
- file.getFullPath.toString.toCharArray,
- formatMessage(msg),
- 0,
- new Array[String](0),
- nscSeverityToEclipse(severityLevel),
- pos1.startOrPoint,
- math.max(pos1.startOrPoint, pos1.endOrPoint - 1),
- pos1.line,
- pos1.column
- ))
- case _ => None
+ case EclipseFile(file) =>
+ Some(file.getFullPath().toString.toCharArray)
+ case vf: VirtualFile =>
+ Some(vf.path.toCharArray)
+ case _ =>
+ None
}
- } else None
- }
+ fileName.map(new DefaultProblem(
+ _,
+ formatMessage(msg),
+ 0,
+ new Array[String](0),
+ nscSeverityToEclipse(severityLevel),
+ pos1.startOrPoint,
+ math.max(pos1.startOrPoint, pos1.endOrPoint - 1),
+ pos1.line,
+ pos1.column))
+ } else None
+ }
- def formatMessage(msg : String) = msg.map{
- case '\n' => ' '
- case '\r' => ' '
- case c => c
- }
+ def formatMessage(msg: String) = msg.map {
+ case '\n' => ' '
+ case '\r' => ' '
+ case c => c
+ }
}
}
View
4 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaProject.scala
@@ -44,15 +44,15 @@ object ScalaProject {
/** Listen for [[IWorkbenchPart]] event and takes care of loading/discarding scala compilation units.*/
private class ProjectPartListener(project: ScalaProject) extends PartAdapter with HasLogger {
override def partOpened(part: IWorkbenchPart) {
- logger.debug("open " + part.getTitle)
doWithCompilerAndFile(part) { (compiler, ssf) =>
+ logger.debug("open " + part.getTitle)
ssf.forceReload()
}
}
override def partClosed(part: IWorkbenchPart) {
- logger.debug("close " + part.getTitle)
doWithCompilerAndFile(part) { (compiler, ssf) =>
+ logger.debug("close " + part.getTitle)
ssf.discard()
}
}
View
47 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaSourceFileEditor.scala
@@ -67,6 +67,7 @@ import ScalaSourceFileEditor.bundleForConstructedKeys
import org.eclipse.swt.events.VerifyEvent
import org.eclipse.jface.text.ITextViewerExtension
import scala.tools.eclipse.ui.SurroundSelectionStrategy
+import org.eclipse.jface.text.IDocumentExtension4
class ScalaSourceFileEditor extends CompilationUnitEditor with ScalaEditor {
@@ -145,8 +146,7 @@ class ScalaSourceFileEditor extends CompilationUnitEditor with ScalaEditor {
private var occurrenceAnnotations: Set[Annotation] = Set()
override def updateOccurrenceAnnotations(selection: ITextSelection, astRoot: CompilationUnit) {
- askForOccurrencesUpdate(selection, astRoot)
- super.updateOccurrenceAnnotations(selection, astRoot)
+ askForOccurrencesUpdate(selection)
}
private def getAnnotationModelOpt: Option[IAnnotationModel] =
@@ -155,18 +155,15 @@ class ScalaSourceFileEditor extends CompilationUnitEditor with ScalaEditor {
annotationModel <- Option(documentProvider.getAnnotationModel(getEditorInput))
} yield annotationModel
- private def performOccurrencesUpdate(selection: ITextSelection, astRoot: CompilationUnit) {
-
- if (getDocumentProvider == null)
- return
+ private def performOccurrencesUpdate(selection: ITextSelection, documentLastModified: Long) {
// TODO: find out why this code does a cast to IAdaptable before calling getAdapter
val adaptable = getEditorInput.asInstanceOf[IAdaptable].getAdapter(classOf[IJavaElement])
// logger.info("adaptable: " + adaptable.getClass + " : " + adaptable.toString)
adaptable match {
case scalaSourceFile: ScalaSourceFile =>
- val annotations = getAnnotations(selection, scalaSourceFile)
+ val annotations = getAnnotations(selection, scalaSourceFile, documentLastModified)
for (annotationModel <- getAnnotationModelOpt)
annotationModel.withLock {
annotationModel.replaceAnnotations(occurrenceAnnotations, annotations)
@@ -179,27 +176,37 @@ class ScalaSourceFileEditor extends CompilationUnitEditor with ScalaEditor {
}
}
- private def getAnnotations(selection: ITextSelection, scalaSourceFile: ScalaSourceFile): Map[Annotation, Position] = {
- val occurrencesFinder = new ScalaOccurrencesFinder(scalaSourceFile, selection.getOffset, selection.getLength)
+ private def getAnnotations(selection: ITextSelection, scalaSourceFile: ScalaSourceFile, documentLastModified: Long): Map[Annotation, Position] = {
+ val occurrences = ScalaOccurrencesFinder.findOccurrences(scalaSourceFile, selection.getOffset, selection.getLength, documentLastModified)
for {
- Occurrences(name, locations) <- occurrencesFinder.findOccurrences.toList
+ Occurrences(name, locations) <- occurrences.toList
location <- locations
annotation = new Annotation(OCCURRENCE_ANNOTATION, false, "Occurrence of '" + name + "'")
position = new Position(location.getOffset, location.getLength)
} yield annotation -> position
}.toMap
- def askForOccurrencesUpdate(selection: ITextSelection, astRoot: CompilationUnit) {
+ def askForOccurrencesUpdate(selection: ITextSelection) {
- if (selection.getLength < 0 || selection.getOffset < 0) return
+ if (selection.getLength < 0 || selection.getOffset < 0)
+ return
+
+ if (getDocumentProvider == null || !isActiveEditor)
+ return
+
+ val lastModified = getSourceViewer.getDocument match {
+ case document: IDocumentExtension4 =>
+ document.getModificationStamp
+ case _ => return
+ }
import org.eclipse.core.runtime.jobs.Job
import org.eclipse.core.runtime.IProgressMonitor
- import org.eclipse.core.runtime.{ IStatus, Status }
+ import org.eclipse.core.runtime.Status
- val job = new Job("updateOccurrenceAnnotations") {
- def run(monitor: IProgressMonitor): IStatus = {
- performOccurrencesUpdate(selection, astRoot)
+ val job = new Job("Updating occurrence annotations") {
+ def run(monitor: IProgressMonitor) = {
+ performOccurrencesUpdate(selection, lastModified)
Status.OK_STATUS
}
}
@@ -213,15 +220,15 @@ class ScalaSourceFileEditor extends CompilationUnitEditor with ScalaEditor {
val selectionProvider = getSelectionProvider
if (selectionProvider != null)
selectionProvider.getSelection match {
- case textSel: ITextSelection => askForOccurrencesUpdate(textSel, null)
+ case textSel: ITextSelection => askForOccurrencesUpdate(textSel)
case _ =>
}
}
lazy val selectionListener = new ISelectionListener() {
def selectionChanged(part: IWorkbenchPart, selection: ISelection) {
selection match {
- case textSel: ITextSelection => askForOccurrencesUpdate(textSel, null)
+ case textSel: ITextSelection => askForOccurrencesUpdate(textSel)
case _ =>
}
}
@@ -361,6 +368,10 @@ class ScalaSourceFileEditor extends CompilationUnitEditor with ScalaEditor {
}
+ override def getInteractiveCompilationUnit(): Option[InteractiveCompilationUnit] =
+ // getInputJavaElement always returns the right value
+ Some(getInputJavaElement().asInstanceOf[InteractiveCompilationUnit])
+
}
object ScalaSourceFileEditor {
View
18 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaSourceViewerConfiguration.scala
@@ -37,18 +37,14 @@ import scala.tools.eclipse.ui.AutoCloseBracketStrategy
import scala.tools.eclipse.properties.syntaxcolouring.ScalaSyntaxClasses
import scala.tools.eclipse.hyperlink.text.detector.{CompositeHyperlinkDetector, DeclarationHyperlinkDetector, ImplicitHyperlinkDetector}
import scalariform.ScalaVersions
+import org.eclipse.jface.text.DefaultTextHover
+import scala.tools.eclipse.javaelements.ScalaCompilationUnit
class ScalaSourceViewerConfiguration(store: IPreferenceStore, scalaPreferenceStore: IPreferenceStore, editor: ITextEditor)
extends JavaSourceViewerConfiguration(JavaPlugin.getDefault.getJavaTextTools.getColorManager, store, editor, IJavaPartitions.JAVA_PARTITIONING) {
- private val codeScanner = new ScalaCodeScanner(getColorManager, store, ScalaVersions.DEFAULT)
-
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)
@@ -84,7 +80,15 @@ class ScalaSourceViewerConfiguration(store: IPreferenceStore, scalaPreferenceSto
private val xmlPIScanner = new XmlPIScanner(getColorManager, scalaPreferenceStore)
override def getTextHover(sv: ISourceViewer, contentType: String, stateMask: Int) = {
- new ScalaHover(getCodeAssist _)
+// new ScalaHover(getCodeAssist _)
+ val scuOption = getCodeAssist match {
+ case Some(scu: ScalaCompilationUnit) => Some(scu)
+ case _ => None
+ }
+ scuOption match {
+ case Some(scu) => new ScalaHover(scu)
+ case None => new DefaultTextHover(sv)
+ }
}
override def getHyperlinkDetectors(sv: ISourceViewer): Array[IHyperlinkDetector] = {
View
5 ...sdt.core/src/scala/tools/eclipse/buildmanager/sbtintegration/EclipseSbtBuildManager.scala
@@ -12,9 +12,10 @@ import xsbti.compile.CompileProgress
import xsbti.{ Logger, F0 }
import sbt.{Process, ClasspathOptions}
import scala.tools.eclipse.util.{ EclipseResource, FileUtils }
+import scala.tools.eclipse.properties.ScalaPluginSettings
import org.eclipse.core.resources.IResource
import scala.tools.eclipse.logging.HasLogger
-import sbt.inc.{ AnalysisStore, Analysis, FileBasedStore }
+import sbt.inc.{ AnalysisStore, Analysis, FileBasedStore, Incremental }
import sbt.compiler.{ IC, CompileFailed }
import org.eclipse.core.resources.IProject
import java.lang.ref.SoftReference
@@ -119,6 +120,8 @@ class EclipseSbtBuildManager(val project: ScalaProject, settings0: Settings)
}
private def runCompiler(sources: Seq[File]) {
+ System.setProperty(Incremental.incDebugProp,
+ project.storage.getString(SettingConverterUtil.convertNameToProperty(ScalaPluginSettings.debugIncremental.name)))
val inputs = new SbtInputs(sources.toSeq, project, monitor, new SbtProgress, cacheFile, sbtReporter, sbtLogger)
val analysis =
try
View
3 org.scala-ide.sdt.core/src/scala/tools/eclipse/diagnostic/StartupDiagnostics.scala
@@ -14,15 +14,14 @@ object StartupDiagnostics extends HasLogger {
import ScalaPlugin.plugin
private val INSTALLED_VERSION_KEY = plugin.pluginId + ".diagnostic.currentPluginVersion"
- private val ASK_DIAGNOSTICS = plugin.pluginId + ".diagnostic.askOnUpgrade"
+ val ASK_DIAGNOSTICS = plugin.pluginId + ".diagnostic.askOnUpgrade"
private val weavingState = new WeavingStateConfigurer
def run {
val prefStore = plugin.getPreferenceStore
val previousVersion = prefStore.getString(INSTALLED_VERSION_KEY)
val currentVersion = plugin.getBundle.getVersion.toString
- prefStore.setDefault(ASK_DIAGNOSTICS, true)
val askDiagnostics = prefStore.getBoolean(ASK_DIAGNOSTICS)
logger.info("startup diagnostics: previous version = " + previousVersion)
View
2 ...-ide.sdt.core/src/scala/tools/eclipse/hyperlink/text/detector/BaseHyperlinkDetector.scala
@@ -18,7 +18,7 @@ abstract class BaseHyperlinkDetector extends AbstractHyperlinkDetector {
final def detectHyperlinks(textEditor: ITextEditor, currentSelection: IRegion, canShowMultipleHyperlinks: Boolean): Array[IHyperlink] = {
if (textEditor == null) null // can be null if generated through ScalaPreviewerFactory
else {
- EditorUtils.getEditorScalaInput(textEditor) match {
+ EditorUtils.getEditorCompilationUnit(textEditor) match {
case Some(scu) =>
val hyperlinks = runDetectionStrategy(scu, textEditor, currentSelection)
View
44 ...t.core/src/scala/tools/eclipse/hyperlink/text/detector/DeclarationHyperlinkDetector.scala
@@ -15,52 +15,64 @@ import scala.tools.eclipse.logging.HasLogger
import scala.tools.eclipse.InteractiveCompilationUnit
import org.eclipse.jdt.internal.core.JavaProject
import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner
+import org.eclipse.jdt.internal.core.Openable
+import scala.tools.eclipse.InteractiveCompilationUnit
class DeclarationHyperlinkDetector extends BaseHyperlinkDetector with HasLogger {
- private val resolver: ScalaDeclarationHyperlinkComputer = new ScalaDeclarationHyperlinkComputer
+ protected val resolver: ScalaDeclarationHyperlinkComputer = new ScalaDeclarationHyperlinkComputer
- override protected[detector] def runDetectionStrategy(scu: InteractiveCompilationUnit, textEditor: ITextEditor, currentSelection: IRegion): List[IHyperlink] = {
+ override protected def runDetectionStrategy(icu: InteractiveCompilationUnit, textEditor: ITextEditor, currentSelection: IRegion): List[IHyperlink] = {
val input = textEditor.getEditorInput
val doc = textEditor.getDocumentProvider.getDocument(input)
val wordRegion = ScalaWordFinder.findWord(doc.get, currentSelection.getOffset)
- resolver.findHyperlinks(scu, wordRegion) match {
+ findHyperlinks(textEditor, icu, wordRegion)
+ }
+
+ protected def findHyperlinks(textEditor: ITextEditor, icu: InteractiveCompilationUnit, wordRegion: IRegion): List[IHyperlink] = {
+ findHyperlinks(textEditor, icu, wordRegion, wordRegion)
+ }
+
+ protected def findHyperlinks(textEditor: ITextEditor, icu: InteractiveCompilationUnit, wordRegion: IRegion, mappedRegion: IRegion): List[IHyperlink] = {
+ resolver.findHyperlinks(icu, wordRegion, mappedRegion) match {
case None => List()
case Some(List()) =>
- scu match {
- case scalaCU: ScalaCompilationUnit =>
+ icu match {
+ case icuOpenable: InteractiveCompilationUnit with Openable =>
// the following assumes too heavily a Java compilation unit, being based on the dreaded
// ScalaSelectionEngine. However, this is a last-resort hyperlinking that uses search for
// top-level types, and unless there are bugs, normal hyperlinking (through compiler symbols)
// would find it. So we go here only for `ScalaCompilationUnit`s.
- javaDeclarationHyperlinkComputer(textEditor, wordRegion, scalaCU)
+ javaDeclarationHyperlinkComputer(textEditor, wordRegion, icuOpenable, icuOpenable, mappedRegion)
case _ =>
- Nil
+ javaDeclarationHyperlinkComputer(textEditor, wordRegion, icu, null, mappedRegion)
}
case Some(hyperlinks) =>
hyperlinks
}
- }
-
- private def javaDeclarationHyperlinkComputer(textEditor: ITextEditor, wordRegion: IRegion, scu: ScalaCompilationUnit): List[IHyperlink] = {
+ }
+
+ private def javaDeclarationHyperlinkComputer(textEditor: ITextEditor, wordRegion: IRegion, icu: InteractiveCompilationUnit, openable: Openable, mappedRegion: IRegion): List[IHyperlink] = {
try {
- val environment = scu.newSearchableEnvironment()
- val requestor = new ScalaSelectionRequestor(environment.nameLookup, scu)
- val engine = new ScalaSelectionEngine(environment, requestor, scu.scalaProject.javaProject.getOptions(true))
- val offset = wordRegion.getOffset
- engine.select(scu, offset, offset + wordRegion.getLength - 1)
+ val environment = icu.newSearchableEnvironment()
+ val requestor = new ScalaSelectionRequestor(environment.nameLookup, openable)
+ val engine = new ScalaSelectionEngine(environment, requestor, icu.scalaProject.javaProject.getOptions(true))
+ val offset = mappedRegion.getOffset
+ engine.select(icu, offset, offset + mappedRegion.getLength - 1)
val elements = requestor.getElements.toList
lazy val qualify = elements.length > 1
- lazy val openAction = new OpenAction(textEditor.asInstanceOf[JavaEditor])
+ lazy val openAction = new OpenAction(textEditor.getEditorSite()) // changed from asInstanceOf[JavaEditor] to getEditorSite because
+ // some editors can be non java editor
elements.map(new JavaElementHyperlink(wordRegion, openAction, _, qualify))
} catch {
case t: Throwable =>
logger.debug("Exception while computing hyperlink", t)
Nil
}
}
+
}
object DeclarationHyperlinkDetector {
View
33 ...e/src/scala/tools/eclipse/hyperlink/text/detector/ScalaDeclarationHyperlinkComputer.scala
@@ -9,19 +9,28 @@ import scala.tools.eclipse.javaelements.ScalaCompilationUnit
import scala.tools.eclipse.logging.HasLogger
import scala.tools.eclipse.hyperlink.text._
import scala.tools.eclipse.InteractiveCompilationUnit
+import scala.tools.eclipse.ScalaPresentationCompiler
-private[hyperlink] class ScalaDeclarationHyperlinkComputer extends HasLogger {
- def findHyperlinks(scu: InteractiveCompilationUnit, wordRegion: IRegion): Option[List[IHyperlink]] = {
- scu.withSourceFile({ (sourceFile, compiler) =>
+class ScalaDeclarationHyperlinkComputer extends HasLogger {
+ def findHyperlinks(icu: InteractiveCompilationUnit, wordRegion: IRegion): Option[List[IHyperlink]] = {
+ findHyperlinks(icu, wordRegion, wordRegion)
+ }
+
+ def findHyperlinks(icu: InteractiveCompilationUnit, wordRegion: IRegion, mappedRegion: IRegion): Option[List[IHyperlink]] = {
+ /** In 2.9 ClazzTag was called ClassTag. Source-compatibility hack */
+ implicit def compatClazzTag(com: ScalaPresentationCompiler) = new {
+ def ClazzTag = 12 // we really, really hope this constant won't change in 2.9.x
+ }
+ icu.withSourceFile({ (sourceFile, compiler) =>
object DeclarationHyperlinkFactory extends HyperlinkFactory {
protected val global: compiler.type = compiler
}
- if (wordRegion == null || wordRegion.getLength == 0)
+ if (mappedRegion == null || mappedRegion.getLength == 0)
None
else {
- val start = wordRegion.getOffset
- val regionEnd = wordRegion.getOffset + wordRegion.getLength
+ val start = mappedRegion.getOffset
+ val regionEnd = mappedRegion.getOffset + mappedRegion.getLength
// removing 1 handles correctly hyperlinking requests @ EOF
val end = if (sourceFile.length == regionEnd) regionEnd - 1 else regionEnd
@@ -33,7 +42,7 @@ private[hyperlink] class ScalaDeclarationHyperlinkComputer extends HasLogger {
askTypeAt(pos, response)
val typed = response.get
- logger.info("detectHyperlinks: wordRegion = " + wordRegion)
+ logger.info("detectHyperlinks: wordRegion = " + mappedRegion)
compiler.askOption { () =>
typed.left.toOption map {
case Import(expr, sels) =>
@@ -53,16 +62,18 @@ private[hyperlink] class ScalaDeclarationHyperlinkComputer extends HasLogger {
List(tpe.member(sel.name), tpe.member(sel.name.toTypeName))
} getOrElse Nil
}
- case Annotated(atp, _) => List(atp.symbol)
- case st: SymTree => List(st.symbol)
- case t => logger.info("unhandled tree " + t.getClass); List()
+ case Annotated(atp, _) => List(atp.symbol)
+ case Literal(const) if const.tag == compiler.ClazzTag => List(const.typeValue.typeSymbol)
+ case ap @ Select(qual, nme.apply) => List(qual.symbol, ap.symbol)
+ case st if st.symbol ne null => List(st.symbol)
+ case _ => List()
} flatMap { list =>
val filteredSyms = list filterNot { sym => sym.isPackage || sym == NoSymbol }
if (filteredSyms.isEmpty) None else Some(
filteredSyms.foldLeft(List[IHyperlink]()) { (links, sym) =>
if (sym.isJavaDefined) links
else
- DeclarationHyperlinkFactory.create(Hyperlink.withText("Open Declaration"), scu, sym, wordRegion).toList ::: links
+ DeclarationHyperlinkFactory.create(Hyperlink.withText("Open Declaration (%s)".format(sym.toString)), icu, sym, wordRegion).toList ::: links
})
}
}.flatten.headOption match {
View
8 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaCompilationUnit.scala
@@ -124,14 +124,6 @@ trait ScalaCompilationUnit extends Openable
}
}
- def newSearchableEnvironment(workingCopyOwner : WorkingCopyOwner) : SearchableEnvironment = {
- val javaProject = getJavaProject.asInstanceOf[JavaProject]
- javaProject.newSearchableNameEnvironment(workingCopyOwner)
- }
-
- def newSearchableEnvironment() : SearchableEnvironment =
- newSearchableEnvironment(DefaultWorkingCopyOwner.PRIMARY)
-
override def getSourceElementAt(pos : Int) : IJavaElement = {
getChildAt(this, pos) match {
case smie : ScalaModuleInstanceElement => smie.getParent;
View
2 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaJavaMapper.scala
@@ -41,7 +41,7 @@ trait ScalaJavaMapper extends ScalaAnnotationHelper with SymbolNameUtil with Has
if (sym.isPackage) {
val fullName = sym.fullName
- val results = projects.map(p => Option(p.findPackageFragment(new Path(fullName))))
+ val results = projects.map(p => Option(p.findElement(new Path(fullName.replace('.', '/')))))
results.flatten.headOption
} else if (sym.isClass || sym.isModule) {
val fullClassName = mapType(sym)
View
6 ...ala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaOverrideIndicatorBuilder.scala
@@ -9,7 +9,7 @@ import java.util.{ Map => JMap }
import org.eclipse.jdt.ui.JavaUI
import org.eclipse.jdt.internal.core.Openable
import org.eclipse.jface.text.{ Position => JFacePosition }
-import org.eclipse.jface.text.source.Annotation
+import org.eclipse.jface.text.source
import scala.tools.eclipse.contribution.weaving.jdt.IScalaOverrideIndicator
import org.eclipse.ui.texteditor.ITextEditor
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility
@@ -26,7 +26,7 @@ case class JavaIndicator(scu: ScalaCompilationUnit,
methodName: String,
methodTypeSignatures: List[String],
text: String,
- val isOverwrite: Boolean) extends Annotation(ScalaOverrideIndicatorBuilder.OVERRIDE_ANNOTATION_TYPE, false, text) with IScalaOverrideIndicator {
+ val isOverwrite: Boolean) extends source.Annotation(ScalaOverrideIndicatorBuilder.OVERRIDE_ANNOTATION_TYPE, false, text) with IScalaOverrideIndicator {
def open() {
val tpe0 = JDTUtils.resolveType(scu.newSearchableEnvironment().nameLookup, packageName, typeNames, 0)
@@ -44,7 +44,7 @@ trait ScalaOverrideIndicatorBuilder { self : ScalaPresentationCompiler =>
import ScalaOverrideIndicatorBuilder.OVERRIDE_ANNOTATION_TYPE
case class ScalaIndicator(scu: ScalaCompilationUnit, text: String, base: Symbol, val isOverwrite: Boolean)
- extends Annotation(OVERRIDE_ANNOTATION_TYPE, false, text) with IScalaOverrideIndicator {
+ extends source.Annotation(OVERRIDE_ANNOTATION_TYPE, false, text) with IScalaOverrideIndicator {
def open = {
ask { () => locate(base, scu) } map {
case (file, pos) =>
View
6 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaSelectionEngine.scala
@@ -32,12 +32,12 @@ class ScalaSelectionEngine(nameEnvironment: SearchableEnvironment, requestor: Sc
val acceptedEnums = new ArrayBuffer[(Array[Char], Array[Char], Int)]
val acceptedAnnotations = new ArrayBuffer[(Array[Char], Array[Char], Int)]
- def select(scu: ScalaCompilationUnit, selectionStart0: Int, selectionEnd0: Int) {
- scu.doWithSourceFile { (src, compiler) =>
+ def select(icu: InteractiveCompilationUnit, selectionStart0: Int, selectionEnd0: Int) {
+ icu.doWithSourceFile { (src, compiler) =>
import compiler.{ log => _, _ }
- val source = scu.getContents
+ val source = icu.getContents
val region = ScalaWordFinder.findWord(source, selectionStart0)
val (selectionStart, selectionEnd) =
View
8 org.scala-ide.sdt.core/src/scala/tools/eclipse/javaelements/ScalaStructureBuilder.scala
@@ -11,7 +11,7 @@ import org.eclipse.core.resources.IFile
import org.eclipse.jdt.core.{ IAnnotation, ICompilationUnit, IJavaElement, IMemberValuePair, Signature }
import org.eclipse.jdt.core.compiler.CharOperation
import org.eclipse.jdt.internal.core.{
- Annotation, AnnotationInfo => JDTAnnotationInfo, AnnotatableInfo, CompilationUnit => JDTCompilationUnit, ImportContainer,
+ Annotation => JDTAnnotation, AnnotationInfo => JDTAnnotationInfo, AnnotatableInfo, CompilationUnit => JDTCompilationUnit, ImportContainer,
ImportContainerInfo, ImportDeclaration, ImportDeclarationElementInfo, JavaElement, JavaElementInfo,
MemberValuePair, OpenableElementInfo, SourceRefElement, TypeParameter, TypeParameterElementInfo}
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants
@@ -786,7 +786,7 @@ trait ScalaStructureBuilder extends ScalaAnnotationHelper { pc : ScalaPresentati
pos
else {
var name = annot.atp.typeSymbol.nameString
- val handle = new Annotation(parentHandle, name)
+ val handle = new JDTAnnotation(parentHandle, name)
val info = buildInfoForJavaAnnotation(annot, handle)
@@ -811,7 +811,7 @@ trait ScalaStructureBuilder extends ScalaAnnotationHelper { pc : ScalaPresentati
}}
}
- private def buildInfoForJavaAnnotation(ann: AnnotationInfo, handle: Annotation): JDTAnnotationInfo = {
+ private def buildInfoForJavaAnnotation(ann: AnnotationInfo, handle: JDTAnnotation): JDTAnnotationInfo = {
assert(ann.atp.typeSymbolDirect.isJavaDefined, "You are passing a Scala annotation. Scala annotations cannot be exposed to JDT and they should be filtered out")
def getMemberValuePairs(owner : JavaElement, memberValuePairs : List[(Name, ClassfileAnnotArg)]) : Array[IMemberValuePair] = {
@@ -857,7 +857,7 @@ trait ScalaStructureBuilder extends ScalaAnnotationHelper { pc : ScalaPresentati
val info = new JDTAnnotationInfo
info.nameStart = ann.pos.startOrPoint