Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added Scala Plugin Spy. #203

Merged
merged 1 commit into from

5 participants

Iulian Dragos scala-jenkins Mirko Stocker Mirco Dotta Eric Molitor
Iulian Dragos
Owner

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
Mirko Stocker
Owner

Very nice! Just one point: do you need the sample.gif? :-)

Iulian Dragos
Owner

Just pushed another version without the sample.gif file.

Iulian Dragos dragos Added Scala Plugin Spy.
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
a9fd272
Iulian Dragos
Owner

any thumbs up? :)

Mirko Stocker
Owner

+1 from me (there doesn't seem to be a thumbs up unicode character ;-) )

Mirco Dotta
Owner

LGTM

Eric Molitor
Collaborator

<3

Iulian Dragos
Owner

Best LGTM so far :D

Iulian Dragos dragos merged commit f7589c4 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 4, 2012
  1. Iulian Dragos

    Added Scala Plugin Spy.

    dragos authored
    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
This page is out of date. Refresh to see the latest.
1  org.scala-ide.sdt.build/pom.xml
View
@@ -20,6 +20,7 @@
<module>../org.scala-ide.sdt.aspects</module>
<module>../org.scala-ide.sdt.core</module>
<module>../org.scala-ide.sdt.core.tests</module>
+ <module>../org.scala-ide.sdt.spy</module>
<module>../org.scala-ide.sdt.debug</module>
<module>../org.scala-ide.sdt.debug.tests</module>
<module>../org.scala-ide.sdt.weaving.feature</module>
7 org.scala-ide.sdt.dev.feature/feature.xml
View
@@ -69,4 +69,11 @@ SUCH DAMAGE.
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.scala-ide.sdt.spy"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
8 org.scala-ide.sdt.spy/.classpath
View
@@ -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>
1  org.scala-ide.sdt.spy/.gitignore
View
@@ -0,0 +1 @@
+target/
26 org.scala-ide.sdt.spy/.project
View
@@ -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>
32 org.scala-ide.sdt.spy/META-INF/MANIFEST.MF
View
@@ -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: .
7 org.scala-ide.sdt.spy/build.properties
View
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = target/classes/
+bin.includes = META-INF/,\
+ icons/,\
+ .,\
+ plugin.xml,\
+ plugin.properties
BIN  org.scala-ide.sdt.spy/icons/cog.ico
View
Binary file not shown
0  org.scala-ide.sdt.spy/plugin.properties
View
No changes.
16 org.scala-ide.sdt.spy/plugin.xml
View
@@ -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>
14 org.scala-ide.sdt.spy/pom.xml
View
@@ -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>
75 org.scala-ide.sdt.spy/src/org/scalaide/spy/SpyView.scala
View
@@ -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 _ =>
+ }
+ }
+ }
+}
Something went wrong with that request. Please try again.