forked from scala-ide/scala-ide
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a view that can show the cursor offset in the current document, and additional Scala compiler information: * tree.pos (range positions) * tree.tpe * tree.symbol * tree.tpe
- Loading branch information
Showing
12 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.scala-ide.sdt.spy</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.scala-ide.sdt.core.scalabuilder</name> | ||
<arguments></arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments></arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments></arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.scala-ide.sdt.core.scalanature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Scala Plugin Spy | ||
Bundle-SymbolicName: org.scala-ide.sdt.spy;singleton:=true | ||
Bundle-Version: 2.1.0.qualifier | ||
Bundle-Vendor: Scala IDE | ||
Bundle-ActivationPolicy: lazy | ||
Bundle-Localization: plugin | ||
Require-Bundle: | ||
org.eclipse.core.runtime, | ||
org.eclipse.debug.ui, | ||
org.eclipse.help, | ||
org.eclipse.jdt.core, | ||
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.1.0, 2.2.0)" | ||
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: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source.. = src/ | ||
output.. = target/classes/ | ||
bin.includes = META-INF/,\ | ||
icons/,\ | ||
.,\ | ||
plugin.xml,\ | ||
plugin.properties |
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.2"?> | ||
<plugin> | ||
<extension | ||
point="org.eclipse.ui.views"> | ||
<view | ||
allowMultiple="false" | ||
category="org.scala-ide.sdt.core.viewCategory" | ||
class="org.scalaide.spy.SpyView" | ||
icon="icons/cog.ico" | ||
id="org.scalaide.spy.view" | ||
name="Scala Spy View" | ||
restorable="true"> | ||
</view> | ||
</extension> | ||
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?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.sdt.build</artifactId> | ||
<version>2.1.0-SNAPSHOT</version> | ||
<relativePath>../org.scala-ide.sdt.build/pom.xml</relativePath> | ||
</parent> | ||
<artifactId>org.scala-ide.sdt.spy</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.scalaide.spy | ||
|
||
import org.eclipse.jface.text.ITextSelection | ||
import org.eclipse.jface.viewers.ISelection | ||
import org.eclipse.swt.SWT | ||
import org.eclipse.swt.widgets.Composite | ||
import org.eclipse.swt.widgets.Text | ||
import org.eclipse.ui.ISelectionListener | ||
import org.eclipse.ui.IWorkbenchPart | ||
import org.eclipse.ui.part.ViewPart | ||
import scala.tools.eclipse.InteractiveCompilationUnit | ||
import scala.tools.eclipse.ui.InteractiveCompilationUnitEditor | ||
import org.eclipse.swt.graphics.Font | ||
import org.eclipse.jface.resource.JFaceResources | ||
|
||
class SpyView extends ViewPart { | ||
private var textArea: Text = _ | ||
|
||
def setFocus() { | ||
textArea.setFocus() | ||
} | ||
|
||
def createPartControl(parent: Composite) { | ||
textArea = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL) | ||
textArea.setFont(JFaceResources.getTextFont()) // fixed width font | ||
|
||
getSite.getWorkbenchWindow().getSelectionService().addPostSelectionListener(listener) | ||
} | ||
|
||
override def dispose() { | ||
super.dispose() | ||
getSite.getWorkbenchWindow().getSelectionService().removePostSelectionListener(listener) | ||
} | ||
|
||
private def updateView(offset: Int, length: Int, part: IWorkbenchPart) { | ||
textArea.setText("Offset: \t%s".format(offset.toString)) | ||
textArea.append("\nLength: \t%s".format(length.toString)) | ||
|
||
part match { | ||
case icuEditor: InteractiveCompilationUnitEditor => | ||
for (cu <- icuEditor.getInteractiveCompilationUnit) { | ||
cu.doWithSourceFile { (source, compiler) => | ||
import compiler._ | ||
|
||
val response = new Response[Tree] | ||
compiler.askTypeAt(rangePos(source, offset, offset, offset + length), response) | ||
response.get match { | ||
case Left(tree) => | ||
textArea.append("\n\n============\n\nTree: \t\t" + tree.productPrefix) | ||
textArea.append("\ntree.pos: \t%s".format(tree.pos)) | ||
textArea.append("\ntree.tpe: \t%s".format(tree.tpe)) | ||
textArea.append("\n\nsymbol: \t\t%s".format(tree.symbol)) | ||
for (sym <- Option(tree.symbol) if sym ne NoSymbol) | ||
textArea.append("\nsymbol.info: \t%s".format(tree.symbol.info)) | ||
|
||
case _ => | ||
|
||
} | ||
|
||
} | ||
} | ||
} | ||
textArea.setSelection(0, 0) | ||
} | ||
|
||
object listener extends ISelectionListener { | ||
override def selectionChanged(sourcePart: IWorkbenchPart, selection: ISelection) { | ||
selection match { | ||
case textSelection: ITextSelection => | ||
updateView(textSelection.getOffset(), textSelection.getLength(), sourcePart) | ||
case _ => | ||
} | ||
} | ||
} | ||
} |