xslt debugger plugin layout fixed (IDEA-71024)
authorSascha Weinreuter <sascha.weinreuter@gmail.com>
Thu, 16 Jun 2011 14:33:32 +0000 (16:33 +0200)
committerSascha Weinreuter <sascha.weinreuter@gmail.com>
Thu, 16 Jun 2011 14:33:37 +0000 (16:33 +0200)
90 files changed:
.idea/modules.xml
build/scripts/layouts.gant
community-main.iml
plugins/xslt-debugger/build.xml
plugins/xslt-debugger/engine/impl/lib/rmi-stubs.jar [moved from plugins/xslt-debugger/rt/lib/rmi-stubs.jar with 91% similarity]
plugins/xslt-debugger/engine/impl/lib/saxon-conditions.html [moved from plugins/xslt-debugger/rt/lib/saxon-conditions.html with 100% similarity]
plugins/xslt-debugger/engine/impl/lib/saxon.jar [moved from plugins/xslt-debugger/rt/lib/saxon.jar with 100% similarity]
plugins/xslt-debugger/engine/impl/lib/saxon9he.jar [moved from plugins/xslt-debugger/rt/lib/saxon9he.jar with 100% similarity]
plugins/xslt-debugger/engine/impl/lib/serializer.jar [moved from plugins/xslt-debugger/rt/lib/serializer.jar with 100% similarity]
plugins/xslt-debugger/engine/impl/lib/xalan.jar [moved from plugins/xslt-debugger/rt/lib/xalan.jar with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/XSLTDebuggerMain.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/XSLTDebuggerMain.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/AbstractFrame.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/AbstractFrame.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/LocalDebugger.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/LocalDebugger.java with 97% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/OutputEventQueueImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/OutputEventQueueImpl.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableComparator.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableComparator.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableImpl.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/AbstractSaxonFrame.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/AbstractSaxonFrame.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonFrameImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonFrameImpl.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSourceFrame.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSourceFrame.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSupport.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSupport.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonTraceListener.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonTraceListener.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/AbstractSaxon9Frame.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/AbstractSaxon9Frame.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9SourceFrame.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9SourceFrame.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9Support.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9Support.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9TraceListener.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9TraceListener.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/TracingOutputter.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/TracingOutputter.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/TracingSerializationHandler.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/TracingSerializationHandler.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XObjectValue.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XObjectValue.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanStyleFrame.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanStyleFrame.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanSupport.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanSupport.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanTraceListener.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanTraceListener.java with 100% similarity]
plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/DebuggerServer.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/DebuggerServer.java with 100% similarity]
plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml [moved from plugins/xslt-debugger/rt/xslt-debugger-rt.iml with 74% similarity]
plugins/xslt-debugger/engine/lib/rmi-stubs.jar [new file with mode: 0644]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/Breakpoint.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/Breakpoint.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/BreakpointImpl.java with 95% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointManager.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointManager.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointManagerImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/BreakpointManagerImpl.java with 94% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/Debugger.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/Debugger.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/DebuggerStoppedException.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/DebuggerStoppedException.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/OutputEventQueue.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/OutputEventQueue.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/Value.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/Value.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/Watchable.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/Watchable.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteBreakpoint.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteBreakpoint.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteBreakpointImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteBreakpointImpl.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteBreakpointManager.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteBreakpointManager.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteBreakpointManagerImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteBreakpointManagerImpl.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteDebugger.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteDebugger.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteDebuggerClient.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteDebuggerClient.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteEventQueueImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteEventQueueImpl.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteFrameImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteFrameImpl.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteVariableImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/RemoteVariableImpl.java with 100% similarity]
plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/ValueImpl.java [moved from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/ValueImpl.java with 100% similarity]
plugins/xslt-debugger/engine/xslt-debugger-engine.iml [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/lib/rmi-stubs.jar [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/lib/saxon-conditions.html [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/lib/saxon.jar [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/lib/saxon9he.jar [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/lib/serializer.jar [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/lib/xalan.jar [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/XSLTDebuggerMain.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/AbstractFrame.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/LocalDebugger.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/OutputEventQueueImpl.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableComparator.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableImpl.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/AbstractSaxonFrame.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonFrameImpl.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSourceFrame.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSupport.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonTraceListener.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/AbstractSaxon9Frame.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9SourceFrame.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9Support.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9TraceListener.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/TracingOutputter.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/TracingSerializationHandler.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XObjectValue.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanStyleFrame.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanSupport.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanTraceListener.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/DebuggerServer.java [new file with mode: 0644]
plugins/xslt-debugger/rt/impl/xslt-debugger-engine-impl.iml [new file with mode: 0644]
plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointImpl.java [new file with mode: 0644]
plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointManagerImpl.java [new file with mode: 0644]
plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/XsltDebuggerExtension.java
plugins/xslt-debugger/src/org/intellij/plugins/xsltDebugger/impl/XsltDebugProcess.java
plugins/xslt-debugger/xslt-debugger.iml

index 1abf9c5878f1f957c631bccbf22fb4a71f0d6f67..129a137cf5ceafdd1f46615b05ac48269cb992a1 100644 (file)
       <module fileurl="file://$PROJECT_DIR$/xml/openapi/xml-openapi.iml" filepath="$PROJECT_DIR$/xml/openapi/xml-openapi.iml" group="xml" />
       <module fileurl="file://$PROJECT_DIR$/plugins/xpath/xpath.iml" filepath="$PROJECT_DIR$/plugins/xpath/xpath.iml" group="plugins" />
       <module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/xslt-debugger.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/xslt-debugger.iml" group="plugins" />
-      <module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/rt/xslt-debugger-rt.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/rt/xslt-debugger-rt.iml" group="plugins" />
+      <module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/engine/xslt-debugger-engine.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/engine/xslt-debugger-rt.iml" group="plugins" />
+      <module fileurl="file://$PROJECT_DIR$/plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml" filepath="$PROJECT_DIR$/plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml" group="plugins" />
       <module fileurl="file://$PROJECT_DIR$/plugins/xpath/xslt-rt/xslt-rt.iml" filepath="$PROJECT_DIR$/plugins/xpath/xslt-rt/xslt-rt.iml" group="plugins" />
     </modules>
   </component>
index 106b834d52a2748e52ecc5da8de1ddb7307357a5..e192e1934549b0201125e46c8cf86db6b3be2e3f 100644 (file)
@@ -233,15 +233,22 @@ public def layoutCommunityPlugins(String home) {
 
     layoutPlugin("xslt-debugger") {
       jar("xslt-debugger-engine.jar") {
-        module("xslt-rt") {
+        module("xslt-debugger-engine") {
           excludes: "lib"
         }
       }
-      fileset(dir: "$home/plugins/xslt-debugger/rt/lib") {
+      fileset(dir: "$home/plugins/xslt-debugger/engine/lib") {
         include(name: "**/rmi-stubs.jar")
       }
       dir("rt") {
-        fileset(dir: "$home/plugins/xslt-debugger/rt/lib") {
+        jar("xslt-debugger-engine-impl.jar") {
+          module("xslt-debugger-engine-impl") {
+            exclude(name: "lib")
+            exclude(name: "**/*.jar")
+            exclude(name: "**/*.html")
+          }
+        }
+        fileset(dir: "$home/plugins/xslt-debugger/engine/impl/lib") {
           include(name: "**/*.jar")
           exclude(name: "**/rmi-stubs.jar")
           include(name: "**/*.html")
index 4b5a9e3fa21d090ed165631e86c1442948f3904e..e31cc191e6a482f8a260068e390f49f996a17b31 100644 (file)
@@ -78,6 +78,7 @@
     <orderEntry type="module" module-name="IntelliLang-xml" />
     <orderEntry type="module" module-name="xpath" />
     <orderEntry type="module" module-name="xslt-debugger" />
+    <orderEntry type="module" module-name="xslt-debugger-engine" />
     <orderEntry type="module" module-name="tasks-core" />
     <orderEntry type="module" module-name="jira-connector" />
     <orderEntry type="module" module-name="tasks-api" />
index e0b869c3b3f94c9c8b5ca3866a6c6f887bddbcd6..eaa52c35f45a90053165880d12ebe0a59232f397 100644 (file)
@@ -4,7 +4,8 @@
 
   <dirname file="${ant.file}" property="project.dir"/>
   <property name="src.dir" value="${project.dir}/src"/>
-  <property name="src.rt.dir" value="${project.dir}/rt/src"/>
+  <property name="src.rt.dir" value="${project.dir}/engine/src"/>
+  <property name="src.rt.impl.dir" value="${project.dir}/engine/impl/src"/>
 
   <property name="build.dir" value="${basedir}/build"/>
   <property name="build.classes.dir" value="${build.dir}/classes"/>
@@ -35,7 +36,7 @@
     <fileset dir="${idea.home}/lib">
       <include name="trove4j.jar" />
     </fileset>
-    <fileset dir="rt/lib">
+    <fileset dir="engine/impl/lib">
       <include name="*.jar"/>
     </fileset>
   </path>
       <exclude name="com/**/*"/>
     </javac2>
 
+    <javac2 srcdir="${src.rt.impl.dir}" destdir="${build.classes.rt.dir}" source="1.5" target="1.5" debug="${compile.debug}"
+            optimize="${compile.optimize}">
+      <classpath refid="rt.classpath"/>
+      <classpath refid="xpathview.rt.classpath"/>
+      <exclude name="com/**/*"/>
+    </javac2>
+
     <javac2 srcdir="${src.dir}" destdir="${build.classes.dir}" source="1.5" target="1.5" debug="${compile.debug}"
             optimize="${compile.optimize}">
       <classpath refid="idea.classpath"/>
       <zipfileset dir="build" prefix="xslt-debugger/lib">
         <include name="*.jar"/>
       </zipfileset>
-      <zipfileset dir="rt/lib" prefix="xslt-debugger/lib/rt">
+      <zipfileset dir="engine/impl/lib" prefix="xslt-debugger/lib/rt">
         <include name="saxon*"/>
         <include name="xalan.jar"/>
         <include name="serializer.jar"/>
similarity index 91%
rename from plugins/xslt-debugger/rt/lib/rmi-stubs.jar
rename to plugins/xslt-debugger/engine/impl/lib/rmi-stubs.jar
index cb5ad8a8f43d5fcd5daf004cca43efa237eb722f..069ff156706a8898c27f2ccd67e5471a313b6640 100644 (file)
Binary files a/plugins/xslt-debugger/rt/lib/rmi-stubs.jar and b/plugins/xslt-debugger/engine/impl/lib/rmi-stubs.jar differ
similarity index 97%
rename from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/LocalDebugger.java
rename to plugins/xslt-debugger/engine/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/LocalDebugger.java
index c0dfabc9a8ba5719cdaed18827e6201400336beb..8593e334946a882ff7b7fbffafd1a584b82bbd4f 100644 (file)
  */
 package org.intellij.plugins.xsltDebugger.rt.engine.local;
 
-import org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint;
-import org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager;
-import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
-import org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException;
+import org.intellij.plugins.xsltDebugger.rt.engine.*;
 import org.intellij.plugins.xsltDebugger.rt.engine.local.saxon.SaxonSupport;
 import org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9.Saxon9Support;
 import org.intellij.plugins.xsltDebugger.rt.engine.local.xalan.XalanSupport;
similarity index 74%
rename from plugins/xslt-debugger/rt/xslt-debugger-rt.iml
rename to plugins/xslt-debugger/engine/impl/xslt-debugger-engine-impl.iml
index fcebed0229de0b65834bb83d25f48a9429049495..42f7d567ac8cf8bef11ee249775fd3f94d7ad34e 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<module relativePaths="true" type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
@@ -9,10 +9,12 @@
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="module" module-name="xslt-rt" />
+    <orderEntry type="module" module-name="xslt-debugger-engine" />
+    <orderEntry type="library" name="Trove4j" level="project" />
     <orderEntry type="module-library">
-      <library name="RMI Stubs">
+      <library name="Saxon-6.3">
         <CLASSES>
-          <root url="jar://$MODULE_DIR$/lib/rmi-stubs.jar!/" />
+          <root url="jar://$MODULE_DIR$/lib/saxon.jar!/" />
         </CLASSES>
         <JAVADOC />
         <SOURCES />
       </library>
     </orderEntry>
     <orderEntry type="module-library">
-      <library name="Saxon-6.5.5">
-        <CLASSES>
-          <root url="jar://$MODULE_DIR$/lib/saxon.jar!/" />
-        </CLASSES>
-        <JAVADOC />
-        <SOURCES />
-      </library>
-    </orderEntry>
-    <orderEntry type="module-library">
       <library name="Xalan-2.7.1">
         <CLASSES>
           <root url="jar://$MODULE_DIR$/lib/xalan.jar!/" />
@@ -46,7 +39,6 @@
         <SOURCES />
       </library>
     </orderEntry>
-    <orderEntry type="library" name="Trove4j" level="project" />
   </component>
 </module>
 
diff --git a/plugins/xslt-debugger/engine/lib/rmi-stubs.jar b/plugins/xslt-debugger/engine/lib/rmi-stubs.jar
new file mode 100644 (file)
index 0000000..069ff15
Binary files /dev/null and b/plugins/xslt-debugger/engine/lib/rmi-stubs.jar differ
similarity index 95%
rename from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/BreakpointImpl.java
rename to plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointImpl.java
index 8b7388e68d08d9fb6a36a2bc016bd56d25f97d12..bf87f3a061ae9a769b5053cd002bc180e28d0409 100644 (file)
@@ -14,9 +14,7 @@
  * limitations under the License.
  */
 
-package org.intellij.plugins.xsltDebugger.rt.engine.local;
-
-import org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint;
+package org.intellij.plugins.xsltDebugger.rt.engine;
 
 /**
  * Created by IntelliJ IDEA.
similarity index 94%
rename from plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/local/BreakpointManagerImpl.java
rename to plugins/xslt-debugger/engine/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointManagerImpl.java
index 9b514509dc06fb692b891cfd202be54da24c7396..4ce8b6fa26af030d8e5abb4f669a86022ea9fd04 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.intellij.plugins.xsltDebugger.rt.engine.local;
+package org.intellij.plugins.xsltDebugger.rt.engine;
 
 import gnu.trove.TIntObjectHashMap;
 import gnu.trove.TIntObjectProcedure;
-import org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint;
-import org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager;
 
 import java.io.File;
 import java.net.URI;
diff --git a/plugins/xslt-debugger/engine/xslt-debugger-engine.iml b/plugins/xslt-debugger/engine/xslt-debugger-engine.iml
new file mode 100644 (file)
index 0000000..7567de0
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="xslt-rt" />
+    <orderEntry type="module-library">
+      <library name="RMI Stubs">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/lib/rmi-stubs.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="library" name="Trove4j" level="project" />
+  </component>
+</module>
+
diff --git a/plugins/xslt-debugger/rt/impl/lib/rmi-stubs.jar b/plugins/xslt-debugger/rt/impl/lib/rmi-stubs.jar
new file mode 100644 (file)
index 0000000..069ff15
Binary files /dev/null and b/plugins/xslt-debugger/rt/impl/lib/rmi-stubs.jar differ
diff --git a/plugins/xslt-debugger/rt/impl/lib/saxon-conditions.html b/plugins/xslt-debugger/rt/impl/lib/saxon-conditions.html
new file mode 100644 (file)
index 0000000..cd33c42
--- /dev/null
@@ -0,0 +1,148 @@
+<html>
+
+<head>
+  <title>SAXON: Conditions of Use</title>
+
+</head>
+
+<body leftmargin="150" bgcolor="#ddeeff"><font face="Arial, Helvetica, sans-serif">
+  <div align=right><a href="index.html">SAXON home page</a></div>
+  <h1><big><font color="#FF0080">SAXON: Conditions of Use</font></big></h1>
+
+
+  <h2>Saxon</h2>
+
+  <p>The contents of the downloaded file (saxon.zip), with the exception of the
+    &AElig;lfred parser (see below),
+    are subject to the Mozilla Public License Version 1.0
+    (the "License"); you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+    <a href="http://www.mozilla.org/MPL/">http://www.mozilla.org/MPL/</a></p>
+
+  <p>Software distributed under the License is distributed on an "AS IS" basis,
+    WITHOUT WARRANTY OF ANY KIND, either express or implied.
+    See the License for the specific language governing rights and limitations under the License.
+
+  <p>
+
+  <p>The Original Code of SAXON comprises all those components which are not explicitly attributed
+    to other parties. It does not include the &AElig;lfred parser, which is redistributed under
+    the licence described below.</p>
+
+  <p>The Initial Developer of the Original Code was Michael Kay.
+    Individual modules identified as being created by James Clark, David Megginson, or John Cowan include
+    separate IPR notices. All Rights Reserved.</p>
+
+  <p>
+    <small><i>Until January 2001 Michael Kay worked for International Computers Limited (ICL, now part
+      of Fujitsu), and from February 2001 to January 2004 he worked for Software AG. These two companies
+      both sponsored the development of Saxon and authorised its release under this license, but are not
+      themselves parties to the license. Michael Kay now runs his own company, Saxonica, which has taken
+      over all responsibility for Saxon development and support.</i></small>
+  </p>
+
+  <p>
+    <small><i>For reasons of continuity,
+      the icl.com domain name is retained in package names and namespace URIs with the tacit
+      consent of ICL, but this should not be taken to imply any ongoing ICL involvement.</small>
+    </i></p>
+
+  <p>If you produce a product that includes or requires SAXON, please refer to it as
+    &quot;The SAXON XSLT Processor from Michael Kay&quot;, and include the URL of the
+    home page, which is at
+    <a HREF="http://saxon.sourceforge.net/">http://saxon.sourceforge.net/</a>.</p>
+
+  <p>There is no guarantee of technical support, though I am usually able to answer enquiries
+    within a few days. Please subscribe to the mailing list available at
+    <a href="http://lists.sourceforge.net/lists/listinfo/saxon-help"/>
+    http://lists.sourceforge.net/lists/listinfo/saxon-help</a> and raise any enquiries there.
+    Also check the Saxon project pages on sourceforge for details of known errors; all bugs are
+    listed there as soon as I have sufficient evidence to describe the nature of the problem.</p>
+  <hr>
+
+  <h2>&AElig;lfred</h2>
+
+  <p>Included in the Saxon distribution is a modified version of the &AElig;lfred XML parser
+    originally developed by David Megginson at Microstar (no longer in existence).
+    I have taken the relevant part of
+    <A href="mailto:david-b@pacbell.net">David Brownell</a>'s
+    <a href="http://home.pacbell.net/david-b/xml/">&AElig;lfred2</a> distribution, repackaged it,
+    and fixed a few bugs. All changes are clearly documented in the source code.</p>
+
+  <p>This is distributed under the terms of Microstar's terms and conditions, which are as follows:</p>
+
+  <table>
+    <tr>
+      <td width=100></td>
+      <td>
+        <p>AElfred, Version 1.2<br>
+          Microstar's Java-Based XML Parser<br>
+          Copyright (c) 1997, 1998 by Microstar Software Ltd.<br>
+          Home Page: http://www.microstar.com/XML/</p>
+
+        <p>AElfred is free for both commercial and non-commercial use and
+          redistribution, provided that Microstar's copyright and disclaimer are
+          retained intact. You are free to modify AElfred for your own use and
+          to redistribute AElfred with your modifications, provided that the
+          modifications are clearly documented.</p>
+
+
+        <p><u>DISCLAIMER</u></p>
+
+
+        <p>This program is distributed in the hope that it will be useful, but
+          WITHOUT ANY WARRANTY; without even the implied warranty of
+          merchantability or fitness for a particular purpose. Please use it AT
+          YOUR OWN RISK.</p>
+
+
+      </td>
+      <td width=100></td>
+    </tr>
+  </table>
+
+  <p>David Brownell added the following statement: </p>
+  <code><pre>
+
+/*
+ * Copyright (c) 1999-2000 by David Brownell.  All Rights Reserved.
+ *
+ * This program is open source software; you may use, copy, modify, and
+ * redistribute it under the terms of the LICENSE with which it was
+ * originally distributed.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * LICENSE for more details.
+ */
+</pre>
+  </code>
+
+  <p>The version included with Saxon is David Brownell's code of 26 Feb 2000,
+    modified as follows:</p>
+
+  <ul>
+    <li>Changed the package name to com.icl.saxon.aelfred to prevent any accidental confusion with the
+      original Microstar code or with David Brownell's version.
+    </li>
+    <li>Fixed several bugs: (1) a bug in namespace handling (where an attribute xxx:name precedes the xmlns:xxx
+      declaration) (2) poor diagnostics when end of file occurs prematurely
+    </li>
+    <li>Subsetting the code to include only the XML non-validating parser and SAX driver, with appropriate
+      changes to the setFeature() and getFeature() methods.
+    </li>
+    <li>Some further changes made by David Brownell up to June 2001 have been incorporated.</li>
+  </ul>
+
+  <hr>
+
+  <p align="center">Michael H. Kay<br>
+    <a href="http://www.saxonica.com/">Saxonica Limited</a><br>
+    22 June 2005</p>
+
+
+</font>
+
+</body>
+</html>
diff --git a/plugins/xslt-debugger/rt/impl/lib/saxon.jar b/plugins/xslt-debugger/rt/impl/lib/saxon.jar
new file mode 100644 (file)
index 0000000..15aa83a
Binary files /dev/null and b/plugins/xslt-debugger/rt/impl/lib/saxon.jar differ
diff --git a/plugins/xslt-debugger/rt/impl/lib/saxon9he.jar b/plugins/xslt-debugger/rt/impl/lib/saxon9he.jar
new file mode 100644 (file)
index 0000000..5d86f50
Binary files /dev/null and b/plugins/xslt-debugger/rt/impl/lib/saxon9he.jar differ
diff --git a/plugins/xslt-debugger/rt/impl/lib/serializer.jar b/plugins/xslt-debugger/rt/impl/lib/serializer.jar
new file mode 100644 (file)
index 0000000..99f98db
Binary files /dev/null and b/plugins/xslt-debugger/rt/impl/lib/serializer.jar differ
diff --git a/plugins/xslt-debugger/rt/impl/lib/xalan.jar b/plugins/xslt-debugger/rt/impl/lib/xalan.jar
new file mode 100644 (file)
index 0000000..458fa73
Binary files /dev/null and b/plugins/xslt-debugger/rt/impl/lib/xalan.jar differ
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/XSLTDebuggerMain.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/XSLTDebuggerMain.java
new file mode 100644 (file)
index 0000000..4e578a8
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2002-2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt;
+
+import org.intellij.plugins.xslt.run.rt.XSLTMain;
+import org.intellij.plugins.xslt.run.rt.XSLTRunner;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.saxon.SaxonSupport;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9.Saxon9Support;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.xalan.XalanSupport;
+import org.intellij.plugins.xsltDebugger.rt.engine.remote.DebuggerServer;
+
+import javax.xml.transform.*;
+import java.rmi.RemoteException;
+
+
+/*
+* Created by IntelliJ IDEA.
+* User: sweinreuter
+* Date: 23.11.2007
+*/
+public class XSLTDebuggerMain implements XSLTMain {
+
+  public TransformerFactory createTransformerFactory() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+    final String type = System.getProperty("xslt.transformer.type");
+    if ("xalan".equalsIgnoreCase(type)) {
+      return XalanSupport.createTransformerFactory();
+    } else if ("saxon".equalsIgnoreCase(type)) {
+      return SaxonSupport.createTransformerFactory();
+    } else if ("saxon9".equalsIgnoreCase(type)) {
+      return Saxon9Support.createTransformerFactory();
+    } else if (type != null) {
+      throw new UnsupportedOperationException("Unsupported Transformer type '" + type + "'");
+    }
+    return XalanSupport.prepareFactory(XSLTRunner.createTransformerFactoryStatic());
+  }
+
+  public void start(Transformer transformer, Source source, Result result) throws TransformerException {
+    try {
+      DebuggerServer.create(transformer, source, result, Integer.getInteger("xslt.debugger.port"));
+    } catch (RemoteException e) {
+      throw new TransformerException(e.getMessage(), e.getCause());
+    }
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/AbstractFrame.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/AbstractFrame.java
new file mode 100644 (file)
index 0000000..87bd44f
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local;
+
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger.Frame;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 02.06.2007
+ */
+public abstract class AbstractFrame<F extends Frame> implements Frame<F> {
+  private final F myPrev;
+  private F myNext;
+
+  private boolean myValid = true;
+
+  public AbstractFrame(F prev) {
+    myPrev = prev;
+
+    if (prev != null) {
+      ((AbstractFrame)prev).myNext = this;
+    }
+  }
+
+  public void invalidate() {
+    assert myValid;
+    assert myNext == null;
+    if (myPrev != null) {
+      ((AbstractFrame)myPrev).myNext = null;
+    }
+    myValid = false;
+  }
+
+  public F getNext() {
+    assert myValid;
+    return myNext;
+  }
+
+  public F getPrevious() {
+    assert myValid;
+    return myPrev;
+  }
+
+  public boolean isValid() {
+    return myValid;
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/LocalDebugger.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/LocalDebugger.java
new file mode 100644 (file)
index 0000000..8593e33
--- /dev/null
@@ -0,0 +1,405 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.intellij.plugins.xsltDebugger.rt.engine.local;
+
+import org.intellij.plugins.xsltDebugger.rt.engine.*;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.saxon.SaxonSupport;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9.Saxon9Support;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.xalan.XalanSupport;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 19.05.2007
+ */
+public class LocalDebugger implements Debugger {
+  private final Thread myThread;
+
+  private final BreakpointManager myBreakpointManager;
+  private final OutputEventQueueImpl myEventQueue;
+  private volatile Condition myCurrentStopCondition;
+
+  private final Object theLock = new Object();
+
+  private volatile State myState = State.CREATED;
+
+  private final LinkedList<StyleFrame> myFrames = new LinkedList<StyleFrame>();
+  private final LinkedList<SourceFrame> mySourceFrames = new LinkedList<SourceFrame>();
+
+  public LocalDebugger(final Transformer transformer, final Source source, final Result result) {
+    prepareTransformer(transformer);
+
+    myBreakpointManager = new BreakpointManagerImpl();
+    myEventQueue = new OutputEventQueueImpl(this);
+
+    myThread = new Thread(new Runnable() {
+      public void run() {
+        try {
+          synchronized (theLock) {
+            myState = State.RUNNING;
+            theLock.notifyAll();
+          }
+          transformer.transform(source, result);
+          stopped();
+        } catch (DebuggerStoppedException e) {
+          // OK
+        } catch (TransformerException e) {
+          // TODO: log, pass to client
+          e.printStackTrace();
+          stopped();
+        }
+      }
+    });
+  }
+
+  protected void prepareTransformer(Transformer transformer) {
+    try {
+      if (Saxon9Support.init(transformer, this)) {
+        return;
+      }
+    } catch (NoClassDefFoundError e1) {
+      // ignore
+    }
+    try {
+      if (SaxonSupport.init(transformer, this)) {
+        return;
+      }
+    } catch (NoClassDefFoundError e) {
+      // ignore
+    }
+    try {
+      if (XalanSupport.init(transformer, this)) {
+        return;
+      }
+    } catch (NoClassDefFoundError e1) {
+      // ignore
+    }
+    throw new UnsupportedOperationException("Unsupported Transformer: " + transformer.getClass().getName());
+  }
+
+  private void suspendAndWait() throws DebuggerStoppedException {
+    try {
+      synchronized (theLock) {
+        myCurrentStopCondition = null;
+
+        myState = State.SUSPENDED;
+        theLock.notifyAll();
+
+        do {
+          theLock.wait();
+        }
+        while (myState == State.SUSPENDED);
+
+        if (myState == State.STOPPED) {
+          throw new DebuggerStoppedException();
+        }
+      }
+    } catch (InterruptedException e) {
+      throw new DebuggerStoppedException();
+    }
+  }
+
+  public void resume() throws DebuggerStoppedException {
+    synchronized (theLock) {
+      if (myState == State.STOPPED) {
+        throw new DebuggerStoppedException();
+      } else if (myState != State.SUSPENDED) {
+        throw new IllegalStateException();
+      }
+
+      myState = State.RUNNING;
+      theLock.notifyAll();
+    }
+  }
+
+  public void pause() {
+    synchronized (theLock) {
+      if (myState == State.STOPPED) {
+        throw new DebuggerStoppedException();
+      } else if (myState != State.RUNNING) {
+        throw new IllegalStateException();
+      }
+
+      myCurrentStopCondition = Condition.TRUE;
+    }
+  }
+
+  public void stopped() {
+    assert Thread.currentThread() == myThread;
+    stop0();
+  }
+
+  private void stop0() {
+    synchronized (theLock) {
+      myState = State.STOPPED;
+      theLock.notifyAll();
+    }
+  }
+
+  public State getState() {
+    synchronized (theLock) {
+      return myState;
+    }
+  }
+
+  @SuppressWarnings({ "deprecation" })
+  public void stop(boolean force) {
+    stop0();
+    myThread.interrupt();
+
+    if (!force) {
+      return;
+    }
+    try {
+      myThread.join(1000);
+      if (myThread.isAlive()) {
+        myThread.stop();
+      }
+    } catch (InterruptedException e) {
+      //
+    }
+  }
+
+  public State waitForStateChange(State state) {
+    try {
+      synchronized (theLock) {
+        if (myState == State.STOPPED) {
+          return State.STOPPED;
+        }
+        while (myState == state) {
+          theLock.wait();
+        }
+
+        return myState;
+      }
+    } catch (InterruptedException e) {
+      return null;
+    }
+  }
+
+  public boolean waitForDebuggee() {
+    try {
+      synchronized (theLock) {
+        while (myState == State.RUNNING) {
+          theLock.wait();
+        }
+
+        return myState != State.STOPPED;
+      }
+    } catch (InterruptedException e) {
+      return false;
+    }
+  }
+
+  public boolean isStopped() {
+    synchronized (theLock) {
+      return myState == State.STOPPED;
+    }
+  }
+
+  public boolean start() {
+    assert myState == State.CREATED : "Already started";
+
+    myThread.start();
+
+    try {
+      synchronized (theLock) {
+        while (myState == State.CREATED) {
+          theLock.wait();
+        }
+      }
+      return true;
+    } catch (InterruptedException e) {
+      //
+    }
+    return false;
+  }
+
+  public void enter(StyleFrame frame) {
+    assert Thread.currentThread() == myThread;
+
+    myFrames.addFirst(frame);
+    final String uri = frame.getURI();
+
+    final StyleFrame previous = frame.getPrevious();
+    if (previous != null && previous.getLineNumber() == frame.getLineNumber() && uri != null && uri.equals(previous.getURI())) {
+      if (frame.getInstruction().equals(previous.getInstruction())) {
+        System.err.println(
+          "WARN: Same instruction <" + frame.getInstruction() + "> on line " + frame.getLineNumber() + " encountered more than once");
+      }
+    }
+
+    if (isStopped()) {
+      throw new DebuggerStoppedException();
+    } else if (myCurrentStopCondition != null && myCurrentStopCondition.value()) {
+      suspendAndWait();
+    } else {
+      final int lineNumber = frame.getLineNumber();
+      final Breakpoint breakpoint = myBreakpointManager.getBreakpoint(uri, lineNumber);
+      if (breakpoint != null && breakpoint.isEnabled()) {
+        // do not evaluate a log or condition bp more than once on the same line
+        if (previous == null || previous.getLineNumber() != lineNumber) {
+          final String condition = breakpoint.getCondition();
+          try {
+            if (evalCondition(condition)) {
+              final String logMessage = breakpoint.getLogMessage();
+              final String traceMessage = breakpoint.getTraceMessage();
+
+              if (logBreakpoint(frame, logMessage, traceMessage) || breakpoint.isSuspend()) {
+                suspendAndWait();
+              }
+            }
+          } catch (EvaluationException e) {
+            // TODO: send to IDEA
+            System.err.println("[" + lineNumber + "]: Failed to evaluate expression: " + condition + " -- " + e.getMessage());
+            breakpoint.setEnabled(false);
+          }
+        }
+      }
+    }
+  }
+
+  private boolean evalCondition(String condition) throws EvaluationException {
+    if (condition != null && condition.length() > 0) {
+      if (!"true".equals(eval("boolean(" + condition + ")").getValue().toString())) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  private boolean logBreakpoint(StyleFrame frame, String logMessage, String traceMessage) throws EvaluationException {
+    if (logMessage != null) {
+      final String uri = frame.getURI();
+      final String pos = uri.substring(uri.lastIndexOf('/') + 1) + ":" + frame.getLineNumber();
+      System.out.println("[" + pos + "]: " + (logMessage.length() > 0 ? eval(logMessage).getValue().toString() : "<no message>"));
+
+      if (traceMessage != null) {
+        myEventQueue.trace(makeTraceMessage(traceMessage));
+      }
+      return false;
+    } else if (traceMessage != null) {
+      myEventQueue.trace(makeTraceMessage(traceMessage));
+      return false;
+    }
+    return true;
+  }
+
+  private String makeTraceMessage(String traceMessage) throws EvaluationException {
+    if (traceMessage.length() > 0) {
+      return eval(traceMessage).getValue().toString();
+    } else {
+      return null;
+    }
+  }
+
+  public void leave() {
+    assert Thread.currentThread() == myThread;
+
+    if (isStopped()) {
+      throw new DebuggerStoppedException();
+//        } else if (myBreakpointManager.isBreakpoint(uri, lineNumber)) {
+//            suspendAndWait();
+//        } else if (myCurrentStopCondition != null && myCurrentStopCondition.value()) {
+//            suspendAndWait();
+    }
+
+    ((AbstractFrame)myFrames.removeFirst()).invalidate();
+  }
+
+  public void step() {
+    final int targetSize = myFrames.size();
+
+    myCurrentStopCondition = new Condition() {
+      public boolean value() {
+        return myFrames.size() <= targetSize;
+      }
+    };
+    resume();
+  }
+
+  public void stepInto() {
+    myCurrentStopCondition = Condition.TRUE;
+
+    resume();
+  }
+
+  public org.intellij.plugins.xsltDebugger.rt.engine.Value eval(String expr) throws EvaluationException {
+    final StyleFrame frame = getCurrentFrame();
+    if (frame == null) {
+      throw new EvaluationException("No frame available");
+    }
+    return frame.eval(expr);
+  }
+
+  public StyleFrame getCurrentFrame() {
+    return myFrames.size() > 0 ? myFrames.getFirst() : null;
+  }
+
+  public SourceFrame getSourceFrame() {
+    return mySourceFrames.size() > 0 ? mySourceFrames.getFirst() : null;
+  }
+
+  public List<Debugger.Variable> getGlobalVariables() {
+    final List<Variable> vars = getCurrentFrame().getVariables();
+    for (Iterator<Variable> it = vars.iterator(); it.hasNext(); ) {
+      Variable var = it.next();
+      if (!var.isGlobal()) {
+        it.remove();
+      }
+    }
+    return vars;
+  }
+
+  public BreakpointManager getBreakpointManager() {
+    return myBreakpointManager;
+  }
+
+  public void pushSource(SourceFrame sourceFrame) {
+    mySourceFrames.addFirst(sourceFrame);
+  }
+
+  public void popSource() {
+    ((AbstractFrame)mySourceFrames.removeFirst()).invalidate();
+  }
+
+  interface Condition {
+    Condition TRUE = new Condition() {
+      public boolean value() {
+        return true;
+      }
+    };
+
+    boolean value();
+  }
+
+  public OutputEventQueueImpl getEventQueue() {
+    return myEventQueue;
+  }
+
+  public boolean ping() {
+    System.out.println(".");
+    return true;
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/OutputEventQueueImpl.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/OutputEventQueueImpl.java
new file mode 100644 (file)
index 0000000..04ccf25
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2002-2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local;
+
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.OutputEventQueue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 08.06.2007
+ */
+public class OutputEventQueueImpl implements OutputEventQueue {
+  private final Debugger myDebugger;
+
+  private final List<NodeEvent> myEvents = new ArrayList<NodeEvent>();
+
+  private boolean myEnabled = true;
+
+  public OutputEventQueueImpl(Debugger debugger) {
+    myDebugger = debugger;
+  }
+
+  public void startDocument() {
+    if (myEnabled) {
+      myEvents.add(new NodeEvent(START_DOCUMENT, null, null));
+    }
+  }
+
+  public void endDocument() {
+    if (myEnabled) {
+      myEvents.add(new NodeEvent(END_DOCUMENT, null, null));
+    }
+  }
+
+  public void startElement(String prefix, String localName, String uri) {
+    addEvent(new NodeEvent(OutputEventQueue.START_ELEMENT, new NodeEvent.QName(prefix, localName, uri), null));
+  }
+
+  public void attribute(String prefix, String localName, String uri, String value) {
+    addEvent(new NodeEvent(ATTRIBUTE, new NodeEvent.QName(prefix, localName, uri), value));
+  }
+
+  public void endElement() {
+    addEvent(new NodeEvent(END_ELEMENT, null, null));
+  }
+
+  public void characters(String s) {
+    addEvent(new NodeEvent(CHARACTERS, null, s));
+  }
+
+  public void comment(String s) {
+    addEvent(new NodeEvent(COMMENT, null, s));
+  }
+
+  public void pi(String target, String data) {
+    addEvent(new NodeEvent(PI, new NodeEvent.QName(target), data));
+  }
+
+  public void trace(String text) {
+    addEvent(new NodeEvent(TRACE_POINT, null, text));
+  }
+
+  public void setEnabled(boolean b) {
+    myEnabled = b;
+  }
+
+  public boolean isEnabled() {
+    return myEnabled;
+  }
+
+  private void addEvent(NodeEvent event) {
+    if (myEnabled) {
+      final Debugger.StyleFrame frame = myDebugger.getCurrentFrame();
+      if (frame != null) {
+        event.setLocation(frame.getURI(), frame.getLineNumber());
+      }
+      myEvents.add(event);
+    }
+  }
+
+  public List<NodeEvent> getEvents() {
+    try {
+      return new ArrayList<NodeEvent>(myEvents);
+    } finally {
+      myEvents.clear();
+    }
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableComparator.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableComparator.java
new file mode 100644 (file)
index 0000000..638674d
--- /dev/null
@@ -0,0 +1,24 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local;
+
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+
+import java.util.Comparator;
+
+public final class VariableComparator implements Comparator<Debugger.Variable> {
+  public static final VariableComparator INSTANCE = new VariableComparator();
+
+  private VariableComparator() {
+  }
+
+  public int compare(Debugger.Variable o1, Debugger.Variable o2) {
+    final boolean og = o2.isGlobal();
+    final boolean g = o1.isGlobal();
+    if (og && !g) {
+      return 1;
+    } else if (!og && g) {
+      return -1;
+    } else {
+      return o1.getName().compareTo(o2.getName());
+    }
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableImpl.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/VariableImpl.java
new file mode 100644 (file)
index 0000000..fdde205
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local;
+
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.Value;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 23.05.2007
+ */
+public class VariableImpl implements Debugger.Variable {
+  private final boolean myGlobal;
+  private final Kind myKind;
+  private final String myRealname;
+  private final Value myValue;
+  private final String myUri;
+  private final int myLineNumber;
+
+  public VariableImpl(String realname, Value value, boolean global, Kind kind, String uri, int lineNumber) {
+    myValue = value;
+    myRealname = realname;
+    myGlobal = global;
+    myKind = kind;
+    myUri = uri;
+    myLineNumber = lineNumber;
+  }
+
+  public String getURI() {
+    return myUri;
+  }
+
+  public int getLineNumber() {
+    return myLineNumber;
+  }
+
+  public String getName() {
+    return myRealname;
+  }
+
+  public Value getValue() {
+    return myValue;
+  }
+
+  public boolean isGlobal() {
+    return myGlobal;
+  }
+
+  public Kind getKind() {
+    return myKind;
+  }
+
+  @Override
+  public String toString() {
+    return (myGlobal ? "global:" : "") + "{" + myKind + ":" + myRealname + "=" + myValue + "}";
+  }
+
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    final VariableImpl that = (VariableImpl)o;
+
+    return myRealname.equals(that.myRealname);
+  }
+
+  public int hashCode() {
+    return myRealname.hashCode();
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/AbstractSaxonFrame.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/AbstractSaxonFrame.java
new file mode 100644 (file)
index 0000000..1719b6a
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon;
+
+import com.icl.saxon.om.NodeInfo;
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.AbstractFrame;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 02.06.2007
+ */
+class AbstractSaxonFrame<F extends Debugger.Frame, N extends NodeInfo> extends AbstractFrame<F> {
+  protected final N myElement;
+
+  protected AbstractSaxonFrame(F prev, N element) {
+    super(prev);
+    myElement = element;
+  }
+
+  public int getLineNumber() {
+    return myElement.getLineNumber();
+  }
+
+  public String getURI() {
+    final String uri = myElement.getSystemId();
+    return uri != null ? uri.replaceAll(" ", "%20") : null;
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonFrameImpl.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonFrameImpl.java
new file mode 100644 (file)
index 0000000..9f93824
--- /dev/null
@@ -0,0 +1,269 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon;
+
+import com.icl.saxon.Bindery;
+import com.icl.saxon.Binding;
+import com.icl.saxon.Context;
+import com.icl.saxon.expr.*;
+import com.icl.saxon.om.*;
+import com.icl.saxon.output.GeneralOutputter;
+import com.icl.saxon.style.ExpressionContext;
+import com.icl.saxon.style.StyleElement;
+import com.icl.saxon.style.XSLGeneralVariable;
+import com.icl.saxon.style.XSLParam;
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.Value;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.VariableComparator;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.VariableImpl;
+import org.w3c.dom.Node;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamResult;
+import java.io.StringWriter;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 23.05.2007
+ */
+class SaxonFrameImpl extends AbstractSaxonFrame<Debugger.StyleFrame, StyleElement> implements Debugger.StyleFrame {
+
+  private static Field fGeneralUseAllowed;
+
+  static {
+    try {
+      fGeneralUseAllowed = SingletonNodeSet.class.getDeclaredField("generalUseAllowed");
+      fGeneralUseAllowed.setAccessible(true);
+    } catch (NoSuchFieldException e) {
+      fGeneralUseAllowed = null;
+      System.err.println("Failed to get field com.icl.saxon.expr.SingletonNodeSet.generalUseAllowed - incompatible Saxon version?");
+      e.printStackTrace();
+    }
+  }
+
+  private final Context myContext;
+  private final int myFrameId;
+
+  SaxonFrameImpl(Debugger.StyleFrame prev, Context context, StyleElement element) {
+    super(prev, element);
+    myContext = context;
+    myFrameId = context.getBindery().getFrameId();
+  }
+
+  public String getInstruction() {
+    return myElement.getDisplayName();
+  }
+
+  public List<Debugger.Variable> getVariables() {
+    assert isValid();
+
+    final ArrayList<Debugger.Variable> variables = new ArrayList<Debugger.Variable>();
+    final Enumeration[] variableNames = myElement.getVariableNames();
+
+    this.addVariables(myElement, variables, variableNames[0], true);
+    this.addVariables(myElement, variables, variableNames[1], false);
+
+    Collections.sort(variables, VariableComparator.INSTANCE);
+
+    return variables;
+  }
+
+  public Value eval(String expr) throws Debugger.EvaluationException {
+    assert isValid();
+
+    try {
+      // trick to avoid exception when evaluating variable references on xsl:template frames
+      final MyDummyElement dummy = new MyDummyElement(myElement);
+      final Expression expression = Expression.make(expr, dummy.getStaticContext());
+      return convertValue(expression.evaluate(myContext));
+    } catch (XPathException e) {
+      throw new Debugger.EvaluationException(e.getMessage());
+    }
+  }
+
+  private Value convertValue(com.icl.saxon.expr.Value v) throws XPathException {
+    return MyValue.create(v, myContext);
+  }
+
+  void addVariables(StyleElement element, ArrayList<Debugger.Variable> variables, Enumeration enumeration, boolean isGlobal) {
+    final Context context = myContext;
+    final StaticContext ctx = context.getStaticContext();
+
+    final NamePool pool = element.getNamePool();
+    final Bindery bindery = context.getBindery();
+
+    while (enumeration.hasMoreElements()) {
+      String name = (String)enumeration.nextElement();
+      try {
+        final String[] parts = name.split("\\^");
+        final String realname = parts[1];
+        final int fingerprint = ctx != null ? ctx.getFingerprint(realname, false) : pool.getFingerprint(parts[0], realname);
+        final Binding binding = element.getVariableBinding(fingerprint);
+        final Debugger.Variable.Kind kind =
+          binding instanceof XSLParam ? Debugger.Variable.Kind.PARAMETER : Debugger.Variable.Kind.VARIABLE;
+        final com.icl.saxon.expr.Value value = bindery.getValue(binding, myFrameId);
+
+        if (binding instanceof XSLGeneralVariable) {
+          final XSLGeneralVariable v = (XSLGeneralVariable)binding;
+          final String id = v.getSystemId();
+          variables.add(new VariableImpl(realname, convertValue(value), isGlobal, kind, id != null ? id.replaceAll(" ", "%20") : null,
+                                         v.getLineNumber()));
+        } else {
+          variables.add(new VariableImpl(realname, convertValue(value), isGlobal, kind, null, -1));
+        }
+      } catch (XPathException e) {
+        // this should never happen I guess...
+        e.printStackTrace();
+      }
+    }
+  }
+
+  private static class MyValue implements Value {
+    private final Object myValue;
+    private final Type myType;
+
+    public MyValue(Object value, String type) {
+      myValue = value;
+      myType = new ObjectType(type);
+    }
+
+    public MyValue(Object value, int type) {
+      myValue = value;
+      myType = mapType(type);
+    }
+
+    public Object getValue() {
+      return myValue;
+    }
+
+    public Type getType() {
+      return myType;
+    }
+
+    private static Type mapType(int type) {
+      switch (type) {
+        case com.icl.saxon.expr.Value.BOOLEAN:
+          return XPathType.BOOLEAN;
+        case com.icl.saxon.expr.Value.NODESET:
+          return XPathType.NODESET;
+        case com.icl.saxon.expr.Value.NUMBER:
+          return XPathType.NUMBER;
+        case com.icl.saxon.expr.Value.STRING:
+          return XPathType.STRING;
+        case com.icl.saxon.expr.Value.OBJECT:
+          return XPathType.OBJECT;
+        default:
+          return XPathType.UNKNOWN;
+      }
+    }
+
+    public static Value create(com.icl.saxon.expr.Value v, Context context) throws XPathException {
+      if (v instanceof NodeSetValue) {
+        if (v instanceof FragmentValue) {
+          final FragmentValue value = (FragmentValue)v;
+          final boolean b = value.isGeneralUseAllowed();
+          try {
+            if (!b) value.allowGeneralUse();
+
+            final DocumentInfo node = value.getRootNode();
+            final GeneralOutputter outputter = new GeneralOutputter(node.getNamePool());
+            final StringWriter writer = new StringWriter();
+            final Properties props = new Properties();
+            props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+            outputter.setOutputDestination(props, new StreamResult(writer));
+            node.copy(outputter);
+
+            return new MyValue(writer.toString(), v.getDataType());
+          } catch (TransformerException e) {
+            return new MyValue(v.asString(), v.getDataType());
+          } finally {
+            if (!b && fGeneralUseAllowed != null) {
+              resetGeneralUseAllowed(value);
+            }
+          }
+        } else if (v instanceof TextFragmentValue) {
+          // this really is just a string
+          return new MyValue(v.asString(), com.icl.saxon.expr.Value.STRING);
+        }
+
+        final List<Node> list = new ArrayList<Node>();
+        final NodeEnumeration nodeEnumeration = ((NodeSetValue)v).enumerate();
+        while (nodeEnumeration.hasMoreElements()) {
+          final NodeInfo node = nodeEnumeration.nextElement();
+          final String path = Navigator.getPath(node);
+          final String id = node.getSystemId();
+          if (id != null) {
+            try {
+              list.add(new Node(new URI(id.replaceAll(" ", "%20")).normalize().toASCIIString(), node.getLineNumber(), path,
+                                node.getStringValue()));
+            } catch (URISyntaxException e) {
+              e.printStackTrace();
+              list.add(new Node(id, node.getLineNumber(), path, node.getStringValue()));
+            }
+          } else {
+            list.add(new Node(null, -1, path, node.getStringValue()));
+          }
+        }
+        return new MyValue(new NodeSet(v.asString(), list), v.getDataType());
+      } else if (v instanceof ObjectValue) {
+        final Object o = ((ObjectValue)v).getObject();
+        return new MyValue(o, o != null ? o.getClass().getName() : "null");
+      } else {
+        return new MyValue(v.evaluateAsString(context), v.getDataType());
+      }
+    }
+  }
+
+  private static void resetGeneralUseAllowed(FragmentValue value) {
+    try {
+      fGeneralUseAllowed.set(value, false);
+    } catch (IllegalAccessException e) {
+      e.printStackTrace();
+    }
+  }
+
+  private static class MyDummyElement extends StyleElement {
+    private final StyleElement myElement;
+
+    public MyDummyElement(StyleElement element) {
+      myElement = element;
+      substituteFor(element);
+    }
+
+    public void prepareAttributes() throws TransformerConfigurationException {
+    }
+
+    public void process(Context context) throws TransformerException {
+    }
+
+    public StaticContext getStaticContext() {
+      return new ExpressionContext(this);
+    }
+
+    @Override
+    public Node getPreviousSibling() {
+      return myElement.getPreviousSibling();
+    }
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSourceFrame.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSourceFrame.java
new file mode 100644 (file)
index 0000000..1125b5f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon;
+
+import com.icl.saxon.om.Navigator;
+import com.icl.saxon.om.NodeInfo;
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 03.06.2007
+ */
+class SaxonSourceFrame extends AbstractSaxonFrame<Debugger.SourceFrame, NodeInfo> implements Debugger.SourceFrame {
+  public SaxonSourceFrame(Debugger.SourceFrame prev, NodeInfo element) {
+    super(prev, element);
+  }
+
+  public String getXPath() {
+    return Navigator.getPath(myElement);
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSupport.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonSupport.java
new file mode 100644 (file)
index 0000000..21961e4
--- /dev/null
@@ -0,0 +1,30 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon;
+
+import com.icl.saxon.Controller;
+import com.icl.saxon.TransformerFactoryImpl;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.LocalDebugger;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+
+/*
+* Created by IntelliJ IDEA.
+* User: sweinreuter
+* Date: 12.01.2009
+*/
+public class SaxonSupport {
+  public static boolean init(Transformer transformer, LocalDebugger dbg) {
+    if (transformer instanceof Controller) {
+      System.out.println("SAXON");
+      final Controller controller = (Controller)transformer;
+      controller.setLineNumbering(true);
+      controller.addTraceListener(new SaxonTraceListener(dbg, controller));
+      return true;
+    }
+    return false;
+  }
+
+  public static TransformerFactory createTransformerFactory() {
+    return new TransformerFactoryImpl();
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonTraceListener.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon/SaxonTraceListener.java
new file mode 100644 (file)
index 0000000..b19e63e
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon;
+
+import com.icl.saxon.Context;
+import com.icl.saxon.Controller;
+import com.icl.saxon.Mode;
+import com.icl.saxon.NodeHandler;
+import com.icl.saxon.om.NamePool;
+import com.icl.saxon.om.Navigator;
+import com.icl.saxon.om.NodeInfo;
+import com.icl.saxon.output.Emitter;
+import com.icl.saxon.output.GeneralOutputter;
+import com.icl.saxon.style.StyleElement;
+import com.icl.saxon.trace.TraceListener;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.LocalDebugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.OutputEventQueueImpl;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.TransformerException;
+import java.lang.reflect.Field;
+import java.util.Properties;
+
+/**
+ * A Simple trace listener that writes messages to System.err
+ */
+
+public class SaxonTraceListener implements TraceListener {
+  private static final boolean TRACE = "true".equals(System.getProperty("xslt.debugger.trace", "false"));
+
+  private String indent = "";
+  private final LocalDebugger myDebugger;
+  private final Controller myController;
+  private boolean myIsInitialized;
+
+  public SaxonTraceListener(LocalDebugger debugger, Controller controller) {
+    myDebugger = debugger;
+    myController = controller;
+  }
+
+  /**
+   * Called at start
+   */
+
+  public void open() {
+    myDebugger.getEventQueue().startDocument();
+    if (TRACE) {
+      trace("<trace>");
+    }
+  }
+
+  private static void trace(String s) {
+    if (TRACE) {
+      System.err.println(s);
+    }
+  }
+
+  /**
+   * Called at end
+   */
+
+  public void close() {
+    myDebugger.getEventQueue().endDocument();
+//        myDebugger.stopped();
+    if (TRACE) {
+      trace("</trace>");
+    }
+  }
+
+
+  /**
+   * Called for all top level elements
+   */
+  public void toplevel(NodeInfo element) {
+    if (!myIsInitialized) {
+      myIsInitialized = true;
+
+      final Properties properties = myController.getOutputProperties();
+      final String method = properties.getProperty(OutputKeys.METHOD);
+      if (method == null || "xml".equals(method) || "html".equals(method)) {
+        try {
+          final Emitter emitter = myController.getOutputter().getEmitter();
+          final GeneralOutputter outputter = new TracingOutputter(emitter, myController.getNamePool());
+
+          final Field fOutputter = Controller.class.getDeclaredField("currentOutputter");
+          fOutputter.setAccessible(true);
+          fOutputter.set(myController, outputter);
+        } catch (Exception e1) {
+          System.err.println("Failed to change output emitter");
+          e1.printStackTrace();
+        }
+      }
+    }
+
+    if (TRACE) {
+      StyleElement e = (StyleElement)element;
+      trace("<Top-level element=\"" + e.getDisplayName() + "\" line=\"" + e.getLineNumber() +
+            "\" file=\"" + e.getSystemId() + "\" precedence=\"" + e.getPrecedence() + "\"/>");
+    }
+  }
+
+  /**
+   * Called when a node of the source tree gets processed
+   */
+  public void enterSource(NodeHandler handler, Context context) {
+    NodeInfo curr = context.getContextNodeInfo();
+    final String path = Navigator.getPath(curr);
+    if (TRACE) {
+      trace(indent + "<Source node=\"" + path
+            + "\" line=\"" + curr.getLineNumber()
+            + "\" mode=\"" + getModeName(context) + "\">");
+      indent += " ";
+    }
+
+    myDebugger.pushSource(new SaxonSourceFrame(myDebugger.getSourceFrame(), curr));
+  }
+
+  /**
+   * Called after a node of the source tree got processed
+   */
+  public void leaveSource(NodeHandler handler, Context context) {
+    if (TRACE) {
+      indent = indent.substring(0, indent.length() - 1);
+      trace(indent + "</Source><!-- " +
+            Navigator.getPath(context.getContextNodeInfo()) + " -->");
+    }
+
+    myDebugger.popSource();
+  }
+
+  /**
+   * Called when an element of the stylesheet gets processed
+   */
+  public void enter(NodeInfo element, Context context) {
+    if (element.getNodeType() == NodeInfo.ELEMENT) {
+      if (TRACE) {
+        trace(indent + "<Instruction element=\"" + element.getDisplayName() + "\" line=\"" + element.getLineNumber() + "\">");
+        indent += " ";
+      }
+
+      myDebugger.enter(new SaxonFrameImpl(myDebugger.getCurrentFrame(), context, (StyleElement)element));
+    }
+  }
+
+  /**
+   * Called after an element of the stylesheet got processed
+   */
+  public void leave(NodeInfo element, Context context) {
+    if (element.getNodeType() == NodeInfo.ELEMENT) {
+//            final int lineNumber = element.getLineNumber();
+//            final String uri = element.getSystemId();
+
+      myDebugger.leave();
+
+      if (TRACE) {
+        indent = indent.substring(0, indent.length() - 1);
+        trace(indent + "</Instruction> <!-- " +
+              element.getDisplayName() + " -->");
+      }
+    }
+  }
+
+  static String getModeName(Context context) {
+    Mode mode = context.getMode();
+    if (mode == null) return "#none";
+    int nameCode = mode.getNameCode();
+    if (nameCode == -1) {
+      return "#default";
+    } else {
+      return context.getController().getNamePool().getDisplayName(nameCode);
+    }
+  }
+
+  private final class TracingOutputter extends GeneralOutputter {
+    private final NamePool myNamePool;
+    private final OutputEventQueueImpl myEventQueue;
+
+    public TracingOutputter(Emitter emitter, NamePool namePool) {
+      super(namePool);
+      this.emitter = emitter;
+      myNamePool = namePool;
+      myEventQueue = myDebugger.getEventQueue();
+    }
+
+    public void writeAttribute(int nameCode, String value, boolean noEscape) throws TransformerException {
+      if (myEventQueue.isEnabled()) {
+        final String localName = myNamePool.getLocalName(nameCode);
+        final String prefix = myNamePool.getPrefix(nameCode);
+        myEventQueue.attribute(prefix, localName, myNamePool.getURI(nameCode), value);
+      }
+      super.writeAttribute(nameCode, value, noEscape);
+    }
+
+    public void writeComment(String comment) throws TransformerException {
+      myEventQueue.comment(comment);
+      super.writeComment(comment);
+    }
+
+    public void writeContent(char[] chars, int start, int length) throws TransformerException {
+      myEventQueue.characters(new String(chars, start, length));
+      super.writeContent(chars, start, length);
+    }
+
+    public void writeContent(StringBuffer chars, int start, int len) throws TransformerException {
+      myEventQueue.characters(chars.substring(start, start + len));
+      super.writeContent(chars, start, len);
+    }
+
+    public void writeEndTag(int nameCode) throws TransformerException {
+      myEventQueue.endElement();
+      super.writeEndTag(nameCode);
+    }
+
+    public void writePI(String target, String data) throws TransformerException {
+      myEventQueue.pi(target, data);
+      super.writePI(target, data);
+    }
+
+    public void writeStartTag(int nameCode) throws TransformerException {
+      if (myEventQueue.isEnabled()) {
+        final String localName = myNamePool.getLocalName(nameCode);
+        final String prefix = myNamePool.getPrefix(nameCode);
+        myEventQueue.startElement(prefix, localName, myNamePool.getURI(nameCode));
+      }
+      super.writeStartTag(nameCode);
+    }
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/AbstractSaxon9Frame.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/AbstractSaxon9Frame.java
new file mode 100644 (file)
index 0000000..8018944
--- /dev/null
@@ -0,0 +1,30 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9;
+
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.AbstractFrame;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.SourceLocator;
+
+/*
+* Created by IntelliJ IDEA.
+* User: sweinreuter
+* Date: 04.05.11
+*/
+class AbstractSaxon9Frame<F extends Debugger.Frame, N extends Source> extends AbstractFrame<F> {
+  protected final N myElement;
+
+  protected AbstractSaxon9Frame(F prev, N element) {
+    super(prev);
+    myElement = element;
+  }
+
+  public int getLineNumber() {
+    return ((SourceLocator)myElement).getLineNumber();
+  }
+
+  public String getURI() {
+    final String uri = myElement.getSystemId();
+    return uri != null ? uri.replaceAll(" ", "%20") : null;
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9SourceFrame.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9SourceFrame.java
new file mode 100644 (file)
index 0000000..1b8385e
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9;
+
+import net.sf.saxon.om.NodeInfo;
+import net.sf.saxon.tree.util.Navigator;
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 02.06.2007
+ */
+class Saxon9SourceFrame<N extends NodeInfo> extends AbstractSaxon9Frame<Debugger.SourceFrame, N> implements Debugger.SourceFrame {
+
+  protected Saxon9SourceFrame(Debugger.SourceFrame prev, N element) {
+    super(prev, element);
+  }
+
+
+  public String getXPath() {
+    return Navigator.getPath(myElement);
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9StyleFrame.java
new file mode 100644 (file)
index 0000000..15363a8
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9;
+
+import net.sf.saxon.expr.StackFrame;
+import net.sf.saxon.expr.XPathContext;
+import net.sf.saxon.expr.instruct.SlotManager;
+import net.sf.saxon.om.ValueRepresentation;
+import net.sf.saxon.style.StyleElement;
+import net.sf.saxon.trans.XPathException;
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.Value;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.VariableImpl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 02.06.2007
+ */
+class Saxon9StyleFrame<N extends StyleElement> extends AbstractSaxon9Frame<Debugger.StyleFrame, N> implements Debugger.StyleFrame {
+
+  private final XPathContext myXPathContext;
+  private final StackFrame myStackFrame;
+
+  protected Saxon9StyleFrame(Debugger.StyleFrame prev, N element, XPathContext xPathContext) {
+    super(prev, element);
+    myXPathContext = xPathContext;
+    myStackFrame = myXPathContext.getStackFrame();
+  }
+
+  public String getInstruction() {
+    return myElement.getDisplayName();
+  }
+
+  public Value eval(String expr) throws Debugger.EvaluationException {
+    return null;
+  }
+
+  public List<Debugger.Variable> getVariables() {
+    final ArrayList<Debugger.Variable> variables = new ArrayList<Debugger.Variable>();
+
+    XPathContext context = myXPathContext;
+    while (context != null) {
+      final StackFrame frame = context.getStackFrame();
+      final SlotManager map = frame.getStackFrameMap();
+      final int numberOfVariables = map.getNumberOfVariables();
+      System.out.println("numberOfVariables = " + numberOfVariables);
+
+      for (int i = 0; i < numberOfVariables; i++) {
+        final ValueRepresentation valueRepresentation = context.evaluateLocalVariable(i);
+        System.out.println("valueRepresentation = " + valueRepresentation);
+      }
+      final ValueRepresentation[] values = frame.getStackFrameValues();
+      System.out.println("values = " + Arrays.toString(values));
+
+      for (int i = 0, valuesLength = values.length; i < valuesLength; i++) {
+        final ValueRepresentation value = values[i];
+
+        variables.add(new VariableImpl(map.getVariableMap().get(i).getDisplayName(), new Value() {
+          public Object getValue() {
+            try {
+              return value.getStringValue();
+            } catch (XPathException e) {
+              return " - error: " + e.getMessage() + " - ";
+            }
+          }
+
+          public Type getType() {
+            return XPathType.UNKNOWN;
+          }
+        }, false, Debugger.Variable.Kind.VARIABLE, "", -1));
+      }
+
+      context = context.getCaller();
+      System.out.println("context = " + context);
+    }
+
+    return variables;
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9Support.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9Support.java
new file mode 100644 (file)
index 0000000..c871a99
--- /dev/null
@@ -0,0 +1,72 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9;
+
+import net.sf.saxon.Controller;
+import net.sf.saxon.TransformerFactoryImpl;
+import net.sf.saxon.event.PipelineConfiguration;
+import net.sf.saxon.event.ProxyReceiver;
+import net.sf.saxon.event.Receiver;
+import net.sf.saxon.expr.instruct.Debugger;
+import net.sf.saxon.expr.instruct.SlotManager;
+import net.sf.saxon.lib.FeatureKeys;
+import net.sf.saxon.lib.SerializerFactory;
+import net.sf.saxon.om.StructuredQName;
+import net.sf.saxon.serialize.CharacterMapExpander;
+import net.sf.saxon.serialize.Emitter;
+import net.sf.saxon.trans.XPathException;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.LocalDebugger;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import java.util.Properties;
+
+/*
+* Created by IntelliJ IDEA.
+* User: sweinreuter
+* Date: 12.01.2009
+*/
+public class Saxon9Support {
+  public static boolean init(Transformer transformer, final LocalDebugger dbg) {
+    if (transformer instanceof Controller) {
+      System.out.println("SAXON 9");
+      final Controller controller = (Controller)transformer;
+      ((Saxon9TraceListener)controller.getConfiguration().getTraceListener()).setDebugger(dbg);
+      controller.getConfiguration().setLineNumbering(true);
+      controller.getConfiguration().setCompileWithTracing(true);
+      controller.getConfiguration().setMultiThreading(false);
+      controller.getConfiguration().setSerializerFactory(new SerializerFactory(controller.getConfiguration()) {
+        @Override
+        protected Receiver createXMLSerializer(Emitter emitter,
+                                               Properties props,
+                                               PipelineConfiguration pipe,
+                                               CharacterMapExpander characterMapExpander,
+                                               ProxyReceiver normalizer) throws XPathException {
+          return super.createXMLSerializer(emitter, props, pipe, characterMapExpander, normalizer);
+        }
+
+        @Override
+        protected Emitter newXMLEmitter() {
+          return new TracingOutputter(dbg.getEventQueue(), super.newXMLEmitter());
+        }
+      });
+      controller.getConfiguration().setDebugger(new Debugger() {
+        public SlotManager makeSlotManager() {
+          return new SlotManager() {
+            @Override
+            public int allocateSlotNumber(StructuredQName qName) {
+              System.out.println("qName = " + qName);
+              return super.allocateSlotNumber(qName);
+            }
+          };
+        }
+      });
+      return true;
+    }
+    return false;
+  }
+
+  public static TransformerFactory createTransformerFactory() {
+    final TransformerFactoryImpl factory = new TransformerFactoryImpl();
+    factory.setAttribute(FeatureKeys.TRACE_LISTENER, new Saxon9TraceListener());
+    return factory;
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9TraceListener.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/Saxon9TraceListener.java
new file mode 100644 (file)
index 0000000..19e132a
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9;
+
+import net.sf.saxon.expr.XPathContext;
+import net.sf.saxon.lib.TraceListener;
+import net.sf.saxon.om.Item;
+import net.sf.saxon.om.NodeInfo;
+import net.sf.saxon.style.StyleElement;
+import net.sf.saxon.trace.InstructionInfo;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.LocalDebugger;
+
+public class Saxon9TraceListener implements TraceListener {
+  private static final boolean TRACE = "true".equals(System.getProperty("xslt.debugger.trace", "false"));
+
+  private LocalDebugger myDebugger;
+
+  public Saxon9TraceListener() {
+  }
+
+  public void setDebugger(LocalDebugger debugger) {
+    myDebugger = debugger;
+  }
+
+  private static void trace(String s) {
+    if (TRACE) {
+      System.err.println(s);
+    }
+  }
+
+  public void open() {
+    myDebugger.getEventQueue().startDocument();
+    if (TRACE) {
+      trace("<trace>");
+    }
+  }
+
+  public void close() {
+    myDebugger.getEventQueue().endDocument();
+
+    if (TRACE) {
+      trace("</trace>");
+    }
+  }
+
+  public void enter(InstructionInfo instructionInfo, XPathContext xPathContext) {
+    if (TRACE) {
+      trace("<" + instructionInfo + ">");
+    }
+    if (instructionInfo instanceof StyleElement) {
+      myDebugger.enter(new Saxon9StyleFrame(myDebugger.getCurrentFrame(), (StyleElement)instructionInfo, xPathContext));
+    }
+  }
+
+  public void leave(InstructionInfo instructionInfo) {
+    if (TRACE) {
+      trace("</>");
+    }
+    if (instructionInfo instanceof StyleElement) {
+      myDebugger.leave();
+    }
+  }
+
+  public void startCurrentItem(Item item) {
+    if (item instanceof NodeInfo) {
+      if (TRACE) {
+        trace("<" + ((NodeInfo)item).getDisplayName() + ">");
+      }
+      myDebugger.pushSource(new Saxon9SourceFrame(myDebugger.getSourceFrame(), (NodeInfo)item));
+    }
+  }
+
+  public void endCurrentItem(Item item) {
+    myDebugger.popSource();
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/TracingOutputter.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/saxon9/TracingOutputter.java
new file mode 100644 (file)
index 0000000..74171cf
--- /dev/null
@@ -0,0 +1,124 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local.saxon9;
+
+import net.sf.saxon.event.PipelineConfiguration;
+import net.sf.saxon.serialize.Emitter;
+import net.sf.saxon.trans.XPathException;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.OutputEventQueueImpl;
+
+import javax.xml.transform.stream.StreamResult;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Properties;
+
+final class TracingOutputter extends Emitter {
+  private final OutputEventQueueImpl myEventQueue;
+  private final Emitter myEmitter;
+
+  public TracingOutputter(OutputEventQueueImpl queue, Emitter emitter) {
+    myEmitter = emitter;
+    myEventQueue = queue;
+  }
+
+  @Override
+  public void setPipelineConfiguration(PipelineConfiguration pipe) {
+    super.setPipelineConfiguration(pipe);
+    myEmitter.setPipelineConfiguration(pipe);
+  }
+
+  @Override
+  public void setSystemId(String systemId) {
+    myEmitter.setSystemId(systemId);
+  }
+
+  @Override
+  public void setOutputProperties(Properties details) throws XPathException {
+    myEmitter.setOutputProperties(details);
+  }
+
+  @Override
+  public void setStreamResult(StreamResult result) throws XPathException {
+    myEmitter.setStreamResult(result);
+  }
+
+  @Override
+  public void setWriter(Writer writer) throws XPathException {
+    myEmitter.setWriter(writer);
+  }
+
+  @Override
+  public void setOutputStream(OutputStream stream) throws XPathException {
+    myEmitter.setOutputStream(stream);
+  }
+
+  @Override
+  public void setUnparsedEntity(String name, String uri, String publicId) throws XPathException {
+    myEmitter.setUnparsedEntity(name, uri, publicId);
+  }
+
+  public void open() throws XPathException {
+    myEmitter.open();
+  }
+
+  public void startDocument(int properties) throws XPathException {
+    myEmitter.startDocument(properties);
+  }
+
+  public void endDocument() throws XPathException {
+    myEmitter.endDocument();
+  }
+
+  public void namespace(int namespaceCode, int properties) throws XPathException {
+    myEmitter.namespace(namespaceCode, properties);
+  }
+
+  @Override
+  public void close() throws XPathException {
+    myEmitter.close();
+  }
+
+  public void startElement(int nameCode, int typeCode, int locationId, int properties) throws XPathException {
+    if (myEventQueue.isEnabled()) {
+      final String localName = namePool.getLocalName(nameCode);
+      final String prefix = namePool.getPrefix(nameCode);
+      myEventQueue.startElement(prefix, localName, namePool.getURI(nameCode));
+    }
+    myEmitter.startElement(nameCode, typeCode, locationId, properties);
+  }
+
+
+  public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties) throws XPathException {
+    if (myEventQueue.isEnabled()) {
+      final String localName = namePool.getLocalName(nameCode);
+      final String prefix = namePool.getPrefix(nameCode);
+      myEventQueue.attribute(prefix, localName, namePool.getURI(nameCode), value.toString());
+    }
+    myEmitter.attribute(nameCode, typeCode, value, locationId, properties);
+  }
+
+  public void startContent() throws XPathException {
+  }
+
+  public void endElement() throws XPathException {
+    myEventQueue.endElement();
+    myEmitter.endElement();
+  }
+
+  public void characters(CharSequence chars, int locationId, int properties) throws XPathException {
+    myEventQueue.characters(chars.toString());
+    myEmitter.characters(chars, locationId, properties);
+  }
+
+  public void processingInstruction(String name, CharSequence data, int locationId, int properties) throws XPathException {
+    myEventQueue.pi(name, data.toString());
+    myEmitter.processingInstruction(name, data, locationId, properties);
+  }
+
+  public void comment(CharSequence content, int locationId, int properties) throws XPathException {
+    myEventQueue.comment(content.toString());
+    myEmitter.comment(content, locationId, properties);
+  }
+
+  public boolean usesTypeAnnotations() {
+    return false;
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/TracingSerializationHandler.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/TracingSerializationHandler.java
new file mode 100644 (file)
index 0000000..9d0026c
--- /dev/null
@@ -0,0 +1,397 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local.xalan;
+
+import org.apache.xml.serializer.DOMSerializer;
+import org.apache.xml.serializer.NamespaceMappings;
+import org.apache.xml.serializer.SerializationHandler;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.LocalDebugger;
+import org.w3c.dom.Node;
+import org.xml.sax.*;
+
+import javax.xml.transform.SourceLocator;
+import javax.xml.transform.Transformer;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Properties;
+import java.util.Vector;
+
+class TracingSerializationHandler implements SerializationHandler {
+  private final LocalDebugger myDebugger;
+  private final SerializationHandler mySerializationHandler;
+
+  public TracingSerializationHandler(LocalDebugger debugger, SerializationHandler handler) {
+    myDebugger = debugger;
+    mySerializationHandler = handler;
+
+//        final URL location = SerializationHandler.class.getProtectionDomain().getCodeSource().getLocation();
+//        System.out.println("location = " + location);
+  }
+
+  private static String calcPrefix(String qname) {
+    return qname.indexOf(':') == -1 ? "" : qname.split(":")[0];
+  }
+
+  public void setContentHandler(ContentHandler ch) {
+    mySerializationHandler.setContentHandler(ch);
+  }
+
+  public void close() {
+    mySerializationHandler.close();
+  }
+
+  public void serialize(Node node) throws IOException {
+    mySerializationHandler.serialize(node);
+  }
+
+  public boolean setEscaping(boolean escape) throws SAXException {
+    return mySerializationHandler.setEscaping(escape);
+  }
+
+  public void setIndentAmount(int spaces) {
+    mySerializationHandler.setIndentAmount(spaces);
+  }
+
+  public void setTransformer(Transformer transformer) {
+    mySerializationHandler.setTransformer(transformer);
+  }
+
+  public Transformer getTransformer() {
+    return mySerializationHandler.getTransformer();
+  }
+
+  public void setNamespaceMappings(NamespaceMappings mappings) {
+    mySerializationHandler.setNamespaceMappings(mappings);
+  }
+
+  public void flushPending() throws SAXException {
+    mySerializationHandler.flushPending();
+  }
+
+  public void setDTDEntityExpansion(boolean expand) {
+    mySerializationHandler.setDTDEntityExpansion(expand);
+  }
+
+  public void addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute)
+    throws SAXException {
+    myDebugger.getEventQueue().attribute(calcPrefix(rawName), localName, uri, value);
+    mySerializationHandler.addAttribute(uri, localName, rawName, type, value, XSLAttribute);
+  }
+
+  public void addAttribute(String uri, String localName, String rawName, String type, String value) throws SAXException {
+    myDebugger.getEventQueue().attribute("", localName, uri, value);
+    mySerializationHandler.addAttribute(uri, localName, rawName, type, value);
+  }
+
+  public void addAttributes(Attributes atts) throws SAXException {
+    mySerializationHandler.addAttributes(atts);
+  }
+
+  public void addAttribute(String qName, String value) {
+    mySerializationHandler.addAttribute(qName, value);
+  }
+
+  public void characters(String chars) throws SAXException {
+    mySerializationHandler.characters(chars);
+  }
+
+  public void characters(Node node) throws SAXException {
+    mySerializationHandler.characters(node);
+  }
+
+  public void endElement(String elemName) throws SAXException {
+    mySerializationHandler.endElement(elemName);
+  }
+
+  public void startElement(String uri, String localName, String qName) throws SAXException {
+    myDebugger.getEventQueue().startElement(calcPrefix(qName), localName, uri);
+    mySerializationHandler.startElement(uri, localName, qName);
+  }
+
+  public void startElement(String qName) throws SAXException {
+    mySerializationHandler.startElement(qName);
+  }
+
+  public void namespaceAfterStartElement(String uri, String prefix) throws SAXException {
+    mySerializationHandler.namespaceAfterStartElement(uri, prefix);
+  }
+
+  public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush) throws SAXException {
+    return mySerializationHandler.startPrefixMapping(prefix, uri, shouldFlush);
+  }
+
+  public void entityReference(String entityName) throws SAXException {
+    mySerializationHandler.entityReference(entityName);
+  }
+
+  public NamespaceMappings getNamespaceMappings() {
+    return mySerializationHandler.getNamespaceMappings();
+  }
+
+  public String getPrefix(String uri) {
+    return mySerializationHandler.getPrefix(uri);
+  }
+
+  public String getNamespaceURI(String name, boolean isElement) {
+    return mySerializationHandler.getNamespaceURI(name, isElement);
+  }
+
+  public String getNamespaceURIFromPrefix(String prefix) {
+    return mySerializationHandler.getNamespaceURIFromPrefix(prefix);
+  }
+
+  public void setSourceLocator(SourceLocator locator) {
+    mySerializationHandler.setSourceLocator(locator);
+  }
+
+  public void addUniqueAttribute(String qName, String value, int flags) throws SAXException {
+    mySerializationHandler.addUniqueAttribute(qName, value, flags);
+  }
+
+  public void addXSLAttribute(String qName, String value, String uri) {
+    mySerializationHandler.addXSLAttribute(qName, value, uri);
+  }
+
+  public void setDocumentLocator(Locator locator) {
+    mySerializationHandler.setDocumentLocator(locator);
+  }
+
+  public void startDocument() throws SAXException {
+    mySerializationHandler.startDocument();
+  }
+
+  public void endDocument() throws SAXException {
+    mySerializationHandler.endDocument();
+  }
+
+  public void startPrefixMapping(String prefix, String uri) throws SAXException {
+    mySerializationHandler.startPrefixMapping(prefix, uri);
+  }
+
+  public void endPrefixMapping(String prefix) throws SAXException {
+    mySerializationHandler.endPrefixMapping(prefix);
+  }
+
+  public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+    mySerializationHandler.startElement(uri, localName, qName, atts);
+  }
+
+  public void endElement(String uri, String localName, String qName) throws SAXException {
+    mySerializationHandler.endElement(uri, localName, qName);
+  }
+
+  public void characters(char[] ch, int start, int length) throws SAXException {
+    mySerializationHandler.characters(ch, start, length);
+  }
+
+  public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+    mySerializationHandler.ignorableWhitespace(ch, start, length);
+  }
+
+  public void processingInstruction(String target, String data) throws SAXException {
+    mySerializationHandler.processingInstruction(target, data);
+  }
+
+  public void skippedEntity(String name) throws SAXException {
+    mySerializationHandler.skippedEntity(name);
+  }
+
+  public void comment(String comment) throws SAXException {
+    mySerializationHandler.comment(comment);
+  }
+
+  public void startDTD(String name, String publicId, String systemId) throws SAXException {
+    mySerializationHandler.startDTD(name, publicId, systemId);
+  }
+
+  public void endDTD() throws SAXException {
+    mySerializationHandler.endDTD();
+  }
+
+  public void startEntity(String name) throws SAXException {
+    mySerializationHandler.startEntity(name);
+  }
+
+  public void endEntity(String name) throws SAXException {
+    mySerializationHandler.endEntity(name);
+  }
+
+  public void startCDATA() throws SAXException {
+    mySerializationHandler.startCDATA();
+  }
+
+  public void endCDATA() throws SAXException {
+    mySerializationHandler.endCDATA();
+  }
+
+  public void comment(char[] ch, int start, int length) throws SAXException {
+    mySerializationHandler.comment(ch, start, length);
+  }
+
+  public String getDoctypePublic() {
+    return mySerializationHandler.getDoctypePublic();
+  }
+
+  public String getDoctypeSystem() {
+    return mySerializationHandler.getDoctypeSystem();
+  }
+
+  public String getEncoding() {
+    return mySerializationHandler.getEncoding();
+  }
+
+  public boolean getIndent() {
+    return mySerializationHandler.getIndent();
+  }
+
+  public int getIndentAmount() {
+    return mySerializationHandler.getIndentAmount();
+  }
+
+  public String getMediaType() {
+    return mySerializationHandler.getMediaType();
+  }
+
+  public boolean getOmitXMLDeclaration() {
+    return mySerializationHandler.getOmitXMLDeclaration();
+  }
+
+  public String getStandalone() {
+    return mySerializationHandler.getStandalone();
+  }
+
+  public String getVersion() {
+    return mySerializationHandler.getVersion();
+  }
+
+  public void setCdataSectionElements(Vector URI_and_localNames) {
+    mySerializationHandler.setCdataSectionElements(URI_and_localNames);
+  }
+
+  public void setDoctype(String system, String pub) {
+    mySerializationHandler.setDoctype(system, pub);
+  }
+
+  public void setDoctypePublic(String doctype) {
+    mySerializationHandler.setDoctypePublic(doctype);
+  }
+
+  public void setDoctypeSystem(String doctype) {
+    mySerializationHandler.setDoctypeSystem(doctype);
+  }
+
+  public void setEncoding(String encoding) {
+    mySerializationHandler.setEncoding(encoding);
+  }
+
+  public void setIndent(boolean indent) {
+    mySerializationHandler.setIndent(indent);
+  }
+
+  public void setMediaType(String mediatype) {
+    mySerializationHandler.setMediaType(mediatype);
+  }
+
+  public void setOmitXMLDeclaration(boolean b) {
+    mySerializationHandler.setOmitXMLDeclaration(b);
+  }
+
+  public void setStandalone(String standalone) {
+    mySerializationHandler.setStandalone(standalone);
+  }
+
+  public void setVersion(String version) {
+    mySerializationHandler.setVersion(version);
+  }
+
+  public String getOutputProperty(String name) {
+    return mySerializationHandler.getOutputProperty(name);
+  }
+
+  public String getOutputPropertyDefault(String name) {
+    return mySerializationHandler.getOutputPropertyDefault(name);
+  }
+
+  public void setOutputProperty(String name, String val) {
+    mySerializationHandler.setOutputProperty(name, val);
+  }
+
+  public void setOutputPropertyDefault(String name, String val) {
+    mySerializationHandler.setOutputPropertyDefault(name, val);
+  }
+
+  public void elementDecl(String name, String model) throws SAXException {
+    mySerializationHandler.elementDecl(name, model);
+  }
+
+  public void attributeDecl(String eName, String aName, String type, String mode, String value) throws SAXException {
+    mySerializationHandler.attributeDecl(eName, aName, type, mode, value);
+  }
+
+  public void internalEntityDecl(String name, String value) throws SAXException {
+    mySerializationHandler.internalEntityDecl(name, value);
+  }
+
+  public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException {
+    mySerializationHandler.externalEntityDecl(name, publicId, systemId);
+  }
+
+  public void notationDecl(String name, String publicId, String systemId) throws SAXException {
+    mySerializationHandler.notationDecl(name, publicId, systemId);
+  }
+
+  public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException {
+    mySerializationHandler.unparsedEntityDecl(name, publicId, systemId, notationName);
+  }
+
+  public void warning(SAXParseException exception) throws SAXException {
+    mySerializationHandler.warning(exception);
+  }
+
+  public void error(SAXParseException exception) throws SAXException {
+    mySerializationHandler.error(exception);
+  }
+
+  public void fatalError(SAXParseException exception) throws SAXException {
+    mySerializationHandler.fatalError(exception);
+  }
+
+  public void setOutputStream(OutputStream output) {
+    mySerializationHandler.setOutputStream(output);
+  }
+
+  public OutputStream getOutputStream() {
+    return mySerializationHandler.getOutputStream();
+  }
+
+  public void setWriter(Writer writer) {
+    mySerializationHandler.setWriter(writer);
+  }
+
+  public Writer getWriter() {
+    return mySerializationHandler.getWriter();
+  }
+
+  public void setOutputFormat(Properties format) {
+    mySerializationHandler.setOutputFormat(format);
+  }
+
+  public Properties getOutputFormat() {
+    return mySerializationHandler.getOutputFormat();
+  }
+
+  public ContentHandler asContentHandler() throws IOException {
+    return mySerializationHandler.asContentHandler();
+  }
+
+  public DOMSerializer asDOMSerializer() throws IOException {
+    return mySerializationHandler.asDOMSerializer();
+  }
+
+  public boolean reset() {
+    return mySerializationHandler.reset();
+  }
+
+  public Object asDOM3Serializer() throws IOException {
+    return mySerializationHandler.asDOM3Serializer();
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XObjectValue.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XObjectValue.java
new file mode 100644 (file)
index 0000000..4d1a39d
--- /dev/null
@@ -0,0 +1,80 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local.xalan;
+
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.ref.DTMNodeIterator;
+import org.apache.xml.serializer.ToXMLStream;
+import org.apache.xpath.objects.XNodeSet;
+import org.apache.xpath.objects.XObject;
+import org.apache.xpath.objects.XRTreeFrag;
+import org.intellij.plugins.xsltDebugger.rt.engine.Value;
+
+import javax.xml.transform.SourceLocator;
+import javax.xml.transform.TransformerException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+
+class XObjectValue implements Value {
+  private String myTypeString;
+  private Object myValue;
+
+  public XObjectValue(XObject value) {
+    try {
+      if (value != null) {
+        myTypeString = value.getTypeString().replaceAll("#", "");
+      } else {
+        myTypeString = "undefined";
+      }
+
+      if (value instanceof XNodeSet) {
+        final ArrayList<Node> nodes = new ArrayList<Node>();
+        final DTMIterator v = value.mutableNodeset();
+        for (int i = 0; i < v.getLength(); i++) {
+          final int p = v.item(i);
+          final DTM dtm = v.getDTM(p);
+          if (dtm == null) continue;
+
+          final SourceLocator loc = dtm.getSourceLocatorFor(p);
+          nodes.add(new Node(loc != null ? loc.getSystemId() : null, loc != null ? loc.getLineNumber() : -1, XalanSupport.getPath(dtm, p),
+                             dtm.getStringValue(p).toString()));
+        }
+
+        myValue = new NodeSet(value.str(), nodes);
+      } else if (value instanceof XRTreeFrag) {
+        final org.w3c.dom.Node node = ((DTMNodeIterator)value.object()).nextNode();
+        if (node == null) {
+          myValue = "";
+        } else {
+          try {
+            final ToXMLStream stream = new ToXMLStream();
+            final StringWriter writer = new StringWriter();
+            stream.setWriter(writer);
+            stream.setOmitXMLDeclaration(true);
+            stream.serialize(node);
+
+            myValue = writer.toString();
+          } catch (Exception e) {
+            e.printStackTrace();
+            myValue = "???";
+          }
+        }
+      } else if (value != null) {
+        myValue = value.object();
+      }
+    } catch (TransformerException e) {
+      myTypeString = "UNKNOWN";
+    }
+  }
+
+  public Object getValue() {
+    return myValue;
+  }
+
+  public Type getType() {
+    try {
+      return XPathType.valueOf(myTypeString.toUpperCase());
+    } catch (IllegalArgumentException e) {
+      return new ObjectType(myTypeString);
+    }
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanStyleFrame.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanStyleFrame.java
new file mode 100644 (file)
index 0000000..047a638
--- /dev/null
@@ -0,0 +1,182 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local.xalan;
+
+import org.apache.xalan.templates.ElemLiteralResult;
+import org.apache.xalan.templates.ElemParam;
+import org.apache.xalan.templates.ElemTemplateElement;
+import org.apache.xalan.templates.ElemVariable;
+import org.apache.xalan.trace.TracerEvent;
+import org.apache.xalan.transformer.TransformerImpl;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.dtm.ref.DTMNodeProxy;
+import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.PrefixResolverDefault;
+import org.apache.xpath.XPath;
+import org.apache.xpath.XPathContext;
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.Value;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.AbstractFrame;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.VariableComparator;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.VariableImpl;
+import org.w3c.dom.Node;
+
+import javax.xml.transform.TransformerException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+class XalanStyleFrame extends AbstractFrame<Debugger.StyleFrame> implements Debugger.StyleFrame {
+  private final boolean myWithSourceFrame;
+
+  private final TransformerImpl myTransformer;
+  private final ElemTemplateElement myCurrentElement;
+  private final XPathContext myContext;
+  private final int myCurrentNode;
+
+  private final int myLineNumber;
+  private final String myURI;
+  private final String myInstr;
+
+  public XalanStyleFrame(TracerEvent ev, Debugger.StyleFrame currentFrame, boolean withSourceFrame) {
+    super(currentFrame);
+    myWithSourceFrame = withSourceFrame;
+
+    myInstr = getInstruction(ev.m_styleNode);
+
+    myLineNumber = ev.m_styleNode.getLineNumber();
+    if (ev.m_styleNode.getSystemId() != null) {
+      myURI = ev.m_styleNode.getSystemId();
+    } else if (currentFrame != null && currentFrame.getURI() != null) {
+      myURI = currentFrame.getURI();
+    } else {
+      myURI = ev.m_processor.getStylesheet().getSystemId();
+    }
+    myTransformer = ev.m_processor;
+
+    myCurrentElement = myTransformer.getCurrentElement();
+    myContext = ev.m_processor.getXPathContext();
+    myCurrentNode = myContext.getCurrentNode();
+  }
+
+  private void addVariable(ElemVariable variable, boolean global, List<Debugger.Variable> variables) {
+    final Debugger.Variable.Kind kind = variable instanceof ElemParam ?
+                                        Debugger.Variable.Kind.PARAMETER : Debugger.Variable.Kind.VARIABLE;
+
+    assert global == variable.getIsTopLevel() : global + " vs. " + variable.getIsTopLevel() + " (" + variable.getName() + ")";
+
+    final String name = variable.getName().getLocalName();
+    try {
+      final Value value = new XObjectValue(variable.getValue(myTransformer, myCurrentNode));
+
+      variables.add(new VariableImpl(name, value, global, kind, variable.getSystemId(), variable.getLineNumber()));
+    } catch (TransformerException e) {
+      // TODO
+      e.printStackTrace();
+    }
+  }
+
+  public boolean isWithSourceFrame() {
+    return myWithSourceFrame;
+  }
+
+  public String getInstruction() {
+    return myInstr;
+  }
+
+  public List<Debugger.Variable> getVariables() {
+    return collectVariables();
+  }
+
+  private List<Debugger.Variable> collectVariables() {
+    List<Debugger.Variable> variables = new ArrayList<Debugger.Variable>();
+
+    @SuppressWarnings({ "unchecked" })
+    final Vector<ElemVariable> globals = myTransformer.getStylesheet().getVariablesAndParamsComposed();
+    for (ElemVariable variable : globals) {
+      addVariable(variable, true, variables);
+    }
+
+    ElemTemplateElement p = myCurrentElement;
+    while (p != null) {
+      ElemTemplateElement s = p;
+      while ((s = s.getPreviousSiblingElem()) != null) {
+        if (s instanceof ElemVariable) {
+          final ElemVariable variable = (ElemVariable)s;
+          if (variable.getIsTopLevel()) {
+            continue;
+          }
+
+          addVariable(variable, false, variables);
+        }
+      }
+      p = p.getParentElem();
+    }
+
+    Collections.sort(variables, VariableComparator.INSTANCE);
+
+    return variables;
+  }
+
+  public String getURI() {
+    return myURI;
+  }
+
+  public int getLineNumber() {
+    return myLineNumber;
+  }
+
+  public Value eval(String expr) throws Debugger.EvaluationException {
+    try {
+      final DTMIterator context = myTransformer.getContextNodeList();
+
+      final int ctx;
+      final DTM dtm = context.getDTM(myCurrentNode);
+      if (dtm.getDocumentRoot(myCurrentNode) == myCurrentNode) {
+        ctx = dtm.getFirstChild(myCurrentNode);
+      } else {
+        ctx = myCurrentNode;
+      }
+
+      final DTMNodeProxy c = new DTMNodeProxy(dtm, ctx);
+      final PrefixResolver prefixResolver = new PrefixResolverDefault(c) {
+        public String getNamespaceForPrefix(String prefix, Node context) {
+          if (context instanceof DTMNodeProxy) {
+            final DTMNodeProxy proxy = (DTMNodeProxy)context;
+            final DTM dtm = proxy.getDTM();
+            int p = proxy.getDTMNodeNumber();
+            while (p != DTM.NULL) {
+              int nsNode = dtm.getFirstNamespaceNode(p, true);
+              while (nsNode != DTM.NULL) {
+                final String s = dtm.getLocalName(nsNode);
+                if (s.equals(prefix)) {
+                  return dtm.getNodeValue(nsNode);
+                }
+                nsNode = dtm.getNextNamespaceNode(p, nsNode, true);
+              }
+              p = dtm.getParent(p);
+            }
+          }
+          return super.getNamespaceForPrefix(prefix, context);
+        }
+      };
+
+      final XPath xPath = new XPath(expr, myCurrentElement, prefixResolver, XPath.SELECT, myTransformer.getErrorListener());
+      return new XObjectValue(xPath.execute(myContext, myCurrentNode, myCurrentElement));
+    } catch (Exception e) {
+      e.printStackTrace();
+      final String message = e.getMessage();
+      throw new Debugger.EvaluationException(message != null ? message : e.getClass().getSimpleName());
+    }
+  }
+
+  static String getInstruction(ElemTemplateElement node) {
+    final String name = node.getNodeName();
+    if (node instanceof ElemLiteralResult) {
+      return name;
+    } else if (name != null && name.indexOf(':') == -1) {
+      return "xsl:" + name;
+    }
+    return name;
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanSupport.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanSupport.java
new file mode 100644 (file)
index 0000000..66cd89c
--- /dev/null
@@ -0,0 +1,123 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local.xalan;
+
+import org.apache.xalan.processor.TransformerFactoryImpl;
+import org.apache.xalan.transformer.TransformerImpl;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.utils.DefaultErrorHandler;
+import org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.LocalDebugger;
+import org.w3c.dom.Node;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import java.util.TooManyListenersException;
+
+/*
+* Created by IntelliJ IDEA.
+* User: sweinreuter
+* Date: 12.01.2009
+*/
+public class XalanSupport {
+  public static boolean init(Transformer transformer, LocalDebugger dbg) {
+    if (transformer instanceof TransformerImpl) {
+      try {
+        System.out.println("XALAN: " +
+                           Class.forName("org.apache.xalan.Version", true, transformer.getClass().getClassLoader()).getMethod("getVersion")
+                             .invoke(null));
+        final TransformerImpl tr = (TransformerImpl)transformer;
+
+        tr.setErrorListener(new DefaultErrorHandler(false) {
+          @Override
+          public void fatalError(TransformerException exception) throws TransformerException {
+            if (!(exception.getCause() instanceof DebuggerStoppedException)) {
+              super.fatalError(exception);
+            }
+          }
+        });
+
+        try {
+          tr.getTraceManager().addTraceListener(new XalanTraceListener(dbg, tr));
+        } catch (TooManyListenersException e) {
+          throw new AssertionError(e);
+        }
+
+        return true;
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
+    }
+    return false;
+  }
+
+  public static TransformerFactory createTransformerFactory() {
+    final TransformerFactoryImpl factory = new TransformerFactoryImpl();
+    prepareFactory(factory);
+    return factory;
+  }
+
+  public static TransformerFactory prepareFactory(TransformerFactory factory) {
+    try {
+      factory.setAttribute("http://xml.apache.org/xalan/properties/source-location", Boolean.TRUE);
+      factory.setAttribute("http://xml.apache.org/xalan/features/optimize", Boolean.FALSE);
+    } catch (Exception e) {
+      // ignore
+    }
+    return factory;
+  }
+
+  public static String getPath(DTM dtm, int node) {
+    String pre;
+    switch (dtm.getNodeType(node)) {
+      case Node.DOCUMENT_NODE:
+        return "/";
+      case Node.ELEMENT_NODE:
+        pre = getPath(dtm, dtm.getParent(node));
+        return (pre.equals("/") ? "" : pre) +
+               "/" + dtm.getNodeName(node) + "[" + getNumberSimple(dtm, node) + "]";
+      case Node.ATTRIBUTE_NODE:
+        return getPath(dtm, dtm.getParent(node)) + "/@" + dtm.getNodeNameX(node);
+      case Node.TEXT_NODE:
+        pre = getPath(dtm, dtm.getParent(node));
+        return (pre.equals("/") ? "" : pre) +
+               "/text()[" + getNumberSimple(dtm, node) + "]";
+      case Node.COMMENT_NODE:
+        pre = getPath(dtm, dtm.getParent(node));
+        return (pre.equals("/") ? "" : pre) +
+               "/comment()[" + getNumberSimple(dtm, node) + "]";
+      case Node.PROCESSING_INSTRUCTION_NODE:
+        pre = getPath(dtm, dtm.getParent(node));
+        return (pre.equals("/") ? "" : pre) +
+               "/processing-instruction()[" + getNumberSimple(dtm, node) + "]";
+    }
+    return "?";
+  }
+
+  private static int getNumberSimple(DTM dtm, int node) {
+    final String localName = dtm.getLocalName(node);
+
+    String uri = dtm.getNamespaceURI(node);
+    if (uri == null) uri = "";
+
+    final short type = dtm.getNodeType(node);
+
+    int i = 1;
+    int p = node;
+    while ((p = dtm.getPreviousSibling(p)) != DTM.NULL) {
+      if (dtm.getNodeType(p) == type) {
+        switch (type) {
+          case Node.TEXT_NODE:
+          case Node.COMMENT_NODE:
+          case Node.PROCESSING_INSTRUCTION_NODE:
+            i++;
+            break;
+          default:
+            if (localName.equals(dtm.getLocalName(p)) && uri.equals(dtm.getNamespaceURI(p))) {
+              i++;
+            }
+        }
+      }
+    }
+    return i;
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanTraceListener.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/local/xalan/XalanTraceListener.java
new file mode 100644 (file)
index 0000000..dbb5ad3
--- /dev/null
@@ -0,0 +1,162 @@
+package org.intellij.plugins.xsltDebugger.rt.engine.local.xalan;
+
+import org.apache.xalan.trace.GenerateEvent;
+import org.apache.xalan.trace.PrintTraceListener;
+import org.apache.xalan.trace.TracerEvent;
+import org.apache.xalan.transformer.TransformerImpl;
+import org.apache.xml.dtm.DTM;
+import org.apache.xml.dtm.DTMIterator;
+import org.apache.xml.serializer.SerializationHandler;
+import org.apache.xml.serializer.SerializerTrace;
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.AbstractFrame;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.LocalDebugger;
+
+import javax.xml.transform.SourceLocator;
+import java.io.PrintWriter;
+
+/*
+* Created by IntelliJ IDEA.
+* User: sweinreuter
+* Date: 09.01.2009
+*/
+public class XalanTraceListener extends PrintTraceListener {
+  private final LocalDebugger myDebugger;
+  private final TransformerImpl myTransformer;
+
+  private volatile boolean myTracing = false;
+  private boolean firstTrace = true;
+
+  public XalanTraceListener(LocalDebugger localDebugger, TransformerImpl tr) {
+    super(new PrintWriter(System.out, true));
+    m_traceElements = false;
+    m_traceGeneration = false;
+    m_traceSelection = false;
+
+    myDebugger = localDebugger;
+    myTransformer = tr;
+  }
+
+  @Override
+  public void trace(TracerEvent ev) {
+    if (myTracing) return;
+    myTracing = true; // prevents handling of recursive trace() events
+
+    try {
+      // init
+      if (firstTrace) {
+        firstTrace = false;
+        final SerializationHandler handler = myTransformer.getSerializationHandler();
+        myTransformer.setSerializationHandler(new TracingSerializationHandler(myDebugger, handler));
+      }
+
+      super.trace(ev);
+
+      final DTMIterator iterator = myTransformer.getContextNodeList();
+      final int node = myTransformer.getMatchedNode();
+      final Debugger.SourceFrame sourceFrame = myDebugger.getSourceFrame();
+      final boolean withSource;
+      if (sourceFrame == null || ((MySourceFrame)sourceFrame).getMatchedNode() != node) {
+        myDebugger.pushSource(new MySourceFrame(sourceFrame, iterator.getDTM(node), node));
+        withSource = true;
+      } else {
+        withSource = false;
+      }
+      myDebugger.enter(new XalanStyleFrame(ev, myDebugger.getCurrentFrame(), withSource));
+    } finally {
+      myTracing = false;
+    }
+  }
+
+  @Override
+  public void traceEnd(TracerEvent ev) {
+    if (myTracing) return;
+
+    if (myDebugger.getCurrentFrame() == null) {
+      return;
+    }
+
+    // xsl:choose (and maybe others) don't generate traceEnd()-events
+    final String instr = XalanStyleFrame.getInstruction(ev.m_styleNode);
+    if (instr != null) {
+      while (!instr.equals(myDebugger.getCurrentFrame().getInstruction())) {
+        leave();
+      }
+    }
+
+    super.traceEnd(ev);
+    leave();
+  }
+
+  private void leave() {
+    if (((XalanStyleFrame)myDebugger.getCurrentFrame()).isWithSourceFrame()) {
+      myDebugger.popSource();
+    }
+    myDebugger.leave();
+  }
+
+  @Override
+  public void generated(GenerateEvent ev) {
+    if (!(myTransformer.getSerializationHandler() instanceof TracingSerializationHandler)) {
+      // internal RTF evaluation, don't care
+      return;
+    }
+    switch (ev.m_eventtype) {
+      case SerializerTrace.EVENTTYPE_STARTDOCUMENT:
+        myDebugger.getEventQueue().startDocument();
+        break;
+      case SerializerTrace.EVENTTYPE_ENDDOCUMENT:
+        myDebugger.getEventQueue().endDocument();
+        break;
+
+      case SerializerTrace.EVENTTYPE_ENDELEMENT:
+        myDebugger.getEventQueue().endElement();
+        break;
+
+      case SerializerTrace.EVENTTYPE_CDATA:
+      case SerializerTrace.EVENTTYPE_CHARACTERS:
+        myDebugger.getEventQueue().characters(new String(ev.m_characters, ev.m_start, ev.m_length));
+        break;
+      case SerializerTrace.EVENTTYPE_COMMENT:
+        myDebugger.getEventQueue().comment(ev.m_data);
+        break;
+      case SerializerTrace.EVENTTYPE_PI:
+        myDebugger.getEventQueue().pi(ev.m_name, ev.m_data);
+        break;
+    }
+  }
+
+  private static class MySourceFrame extends AbstractFrame<Debugger.SourceFrame> implements Debugger.SourceFrame {
+    private final String mySystemId;
+    private final int myLineNumber;
+    private final int myMatchedNode;
+    private String myPath;
+
+    public MySourceFrame(Debugger.SourceFrame sourceFrame, DTM dtm, int node) {
+      super(sourceFrame);
+
+      final SourceLocator loc = dtm.getSourceLocatorFor(node);
+      mySystemId = loc.getSystemId();
+      myLineNumber = loc.getLineNumber();
+
+      myPath = XalanSupport.getPath(dtm, node);
+      myMatchedNode = node;
+    }
+
+    public String getXPath() {
+      return myPath;
+    }
+
+    public String getURI() {
+      return mySystemId;
+    }
+
+    public int getLineNumber() {
+      return myLineNumber;
+    }
+
+    public int getMatchedNode() {
+      return myMatchedNode;
+    }
+  }
+}
\ No newline at end of file
diff --git a/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/DebuggerServer.java b/plugins/xslt-debugger/rt/impl/src/org/intellij/plugins/xsltDebugger/rt/engine/remote/DebuggerServer.java
new file mode 100644 (file)
index 0000000..674029d
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine.remote;
+
+import com.icl.saxon.TransformerFactoryImpl;
+import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
+import org.intellij.plugins.xsltDebugger.rt.engine.Value;
+import org.intellij.plugins.xsltDebugger.rt.engine.local.LocalDebugger;
+
+import javax.rmi.PortableRemoteObject;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.File;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 23.05.2007
+ */
+public class DebuggerServer extends PortableRemoteObject implements RemoteDebugger {
+  private static final String XSLT_DEBUGGER = "XsltDebugger";
+  public static final int PORT = 34275;
+
+  private final Debugger myDebugger;
+  private final RemoteBreakpointManagerImpl myBreakpointManager;
+  private final RemoteEventQueueImpl myEventQueue;
+  private final int myPort;
+
+  private DebuggerServer(Transformer transformer, Source xml, Result out, int port)
+    throws TransformerConfigurationException, RemoteException {
+    myPort = port;
+    myDebugger = new LocalDebugger(transformer, xml, out) {
+      @Override
+      public void stop(boolean b) {
+        try {
+          super.stop(b);
+        } finally {
+          if (b) System.exit(0);
+        }
+      }
+    };
+    myBreakpointManager = new RemoteBreakpointManagerImpl(myDebugger.getBreakpointManager());
+    myEventQueue = new RemoteEventQueueImpl(myDebugger.getEventQueue());
+  }
+
+  public static DebuggerServer create(Transformer xsl, Source xml, Result out, int port)
+    throws TransformerConfigurationException, RemoteException {
+    final DebuggerServer server = new DebuggerServer(xsl, xml, out, port);
+    final Registry registry = LocateRegistry.createRegistry(port);
+    registry.rebind(XSLT_DEBUGGER, server);
+    return server;
+  }
+
+  public static DebuggerServer create(File f, File x) throws TransformerConfigurationException, RemoteException {
+    return create(new TransformerFactoryImpl().newTransformer(new StreamSource(f)), new StreamSource(x), new StreamResult(), PORT);
+  }
+
+  public void stop(boolean force) throws RemoteException {
+    myDebugger.stop(force);
+    try {
+      LocateRegistry.getRegistry(myPort).unbind(XSLT_DEBUGGER);
+    } catch (NotBoundException e) {
+      // hu?
+    }
+  }
+
+  public boolean ping() throws RemoteException {
+    return myDebugger.ping();
+  }
+
+  public Debugger.State waitForStateChange(Debugger.State state) throws RemoteException {
+    return myDebugger.waitForStateChange(state);
+  }
+
+  public boolean waitForDebuggee() throws RemoteException {
+    return myDebugger.waitForDebuggee();
+  }
+
+  public boolean start() throws RemoteException {
+    return myDebugger.start();
+  }
+
+  public void step() throws RemoteException {
+    myDebugger.step();
+  }
+
+  public void stepInto() throws RemoteException {
+    myDebugger.stepInto();
+  }
+
+  public void resume() throws RemoteException {
+    myDebugger.resume();
+  }
+
+  public boolean isStopped() throws RemoteException {
+    return myDebugger.isStopped();
+  }
+
+  public Frame getCurrentFrame() throws RemoteException {
+    return RemoteFrameImpl.create(myDebugger.getCurrentFrame());
+  }
+
+  public Frame getSourceFrame() throws RemoteException {
+    return RemoteFrameImpl.create(myDebugger.getSourceFrame());
+  }
+
+  public Value eval(String expr) throws RemoteException, Debugger.EvaluationException {
+    return getCurrentFrame().eval(expr);
+  }
+
+  public List<Variable> getGlobalVariables() throws RemoteException {
+    return RemoteVariableImpl.convert(myDebugger.getGlobalVariables());
+  }
+
+  public RemoteBreakpointManager getBreakpointManager() throws RemoteException {
+    return myBreakpointManager;
+  }
+
+  public Debugger.State getState() throws RemoteException {
+    return myDebugger.getState();
+  }
+
+  public void pause() throws RemoteException {
+    myDebugger.pause();
+  }
+
+  public EventQueue getEventQueue() throws RemoteException {
+    return myEventQueue;
+  }
+}
diff --git a/plugins/xslt-debugger/rt/impl/xslt-debugger-engine-impl.iml b/plugins/xslt-debugger/rt/impl/xslt-debugger-engine-impl.iml
new file mode 100644 (file)
index 0000000..bec77c7
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$/../../engine/impl">
+      <sourceFolder url="file://$MODULE_DIR$/../../engine/impl/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/../../engine/impl/lib" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="xslt-rt" />
+    <orderEntry type="module" module-name="xslt-debugger-engine" />
+    <orderEntry type="library" name="Trove4j" level="project" />
+    <orderEntry type="module-library">
+      <library name="Saxon-6.3">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/lib/saxon.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="Saxon-9HE">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/lib/saxon9he.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="Xalan-2.7.1">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/lib/xalan.jar!/" />
+          <root url="jar://$MODULE_DIR$/lib/serializer.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+  </component>
+</module>
+
diff --git a/plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointImpl.java b/plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointImpl.java
new file mode 100644 (file)
index 0000000..bf87f3a
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.intellij.plugins.xsltDebugger.rt.engine;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 29.05.2007
+ */
+class BreakpointImpl implements Breakpoint {
+  private final String myUri;
+  private final int myLine;
+  private boolean myEnabled;
+  private String myCondition;
+  private String myLogMsg;
+  private String myTraceMsg;
+  private boolean mySuspend;
+
+  public BreakpointImpl(String uri, int line) {
+    myUri = uri;
+    myLine = line;
+    myEnabled = true;
+  }
+
+  public void setEnabled(boolean b) {
+    myEnabled = b;
+  }
+
+  public void setCondition(String expr) {
+    myCondition = expr;
+  }
+
+  public void setLogMessage(String expr) {
+    myLogMsg = expr;
+  }
+
+  public String getTraceMessage() {
+    return myTraceMsg;
+  }
+
+  public void setTraceMessage(String expr) {
+    myTraceMsg = expr;
+  }
+
+  public boolean isSuspend() {
+    return mySuspend;
+  }
+
+  public void setSuspend(boolean suspend) {
+    mySuspend = suspend;
+  }
+
+  public String getCondition() {
+    return myCondition;
+  }
+
+  public String getLogMessage() {
+    return myLogMsg;
+  }
+
+  public String getUri() {
+    return myUri;
+  }
+
+  public int getLine() {
+    return myLine;
+  }
+
+  public boolean isEnabled() {
+    return myEnabled;
+  }
+
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    final BreakpointImpl that = (BreakpointImpl)o;
+
+    if (myLine != that.myLine) return false;
+    return myUri.equals(that.myUri);
+  }
+
+  public int hashCode() {
+    int result;
+    result = myUri.hashCode();
+    result = 31 * result + myLine;
+    return result;
+  }
+
+
+  public String toString() {
+    return "Breakpoint{" +
+           "myUri='" + myUri + '\'' +
+           ", myLine=" + myLine +
+           ", myEnabled=" + myEnabled +
+           '}';
+  }
+}
diff --git a/plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointManagerImpl.java b/plugins/xslt-debugger/rt/src/org/intellij/plugins/xsltDebugger/rt/engine/BreakpointManagerImpl.java
new file mode 100644 (file)
index 0000000..4ce8b6f
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2007 Sascha Weinreuter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.intellij.plugins.xsltDebugger.rt.engine;
+
+import gnu.trove.TIntObjectHashMap;
+import gnu.trove.TIntObjectProcedure;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sweinreuter
+ * Date: 19.05.2007
+ */
+public class BreakpointManagerImpl implements BreakpointManager {
+  private final TIntObjectHashMap<Map<String, Breakpoint>> myBreakpoints =
+    new TIntObjectHashMap<Map<String, Breakpoint>>();
+
+  public Breakpoint setBreakpoint(File file, int line) {
+    return setBreakpoint(file.toURI().toASCIIString(), line);
+  }
+
+  public synchronized void removeBreakpoint(String uri, int line) {
+    final Map<String, Breakpoint> s = myBreakpoints.get(line);
+    if (s != null) {
+      s.remove(normalizeUri(uri));
+    }
+  }
+
+  public synchronized List<Breakpoint> getBreakpoints() {
+    final ArrayList<Breakpoint> breakpoints = new ArrayList<Breakpoint>();
+    myBreakpoints.forEachEntry(new TIntObjectProcedure<Map<String, Breakpoint>>() {
+      public boolean execute(int i, Map<String, Breakpoint> map) {
+        breakpoints.addAll(map.values());
+        return true;
+      }
+    });
+    return breakpoints;
+  }
+
+  public void removeBreakpoint(Breakpoint bp) {
+    removeBreakpoint(bp.getUri(), bp.getLine());
+  }
+
+  public synchronized Breakpoint setBreakpoint(String uri, int line) {
+    assert line > 0 : "No line number for breakpoint in file " + uri;
+
+    uri = normalizeUri(uri);
+    final Map<String, Breakpoint> s = myBreakpoints.get(line);
+    final BreakpointImpl bp = new BreakpointImpl(uri, line);
+    if (s == null) {
+      final HashMap<String, Breakpoint> map = new HashMap<String, Breakpoint>();
+      map.put(uri, bp);
+      myBreakpoints.put(line, map);
+    } else {
+      s.put(uri, bp);
+    }
+    return bp;
+  }
+
+  private static String normalizeUri(String uri) {
+    // hmm, this code sucks, but seems to be a good guess to ensure the same format of
+    // strings (file:/C:/... vs, file:///C:/...) on both sides...
+    try {
+      try {
+        uri = uri.replaceAll(" ", "%20");
+        return new File(new URI(uri)).toURI().toASCIIString();
+      } catch (IllegalArgumentException e) {
+        return new URI(uri).normalize().toASCIIString();
+      }
+    } catch (URISyntaxException e) {
+      System.err.println("Failed to parse <" + uri + ">: " + e);
+      return uri;
+    }
+  }
+
+  public synchronized boolean isBreakpoint(String uri, int lineNumber) {
+    final Breakpoint breakpoint = getBreakpoint(uri, lineNumber);
+    return breakpoint != null && breakpoint.isEnabled();
+  }
+
+  public synchronized Breakpoint getBreakpoint(String uri, int lineNumber) {
+    final Map<String, Breakpoint> s = myBreakpoints.get(lineNumber);
+    if (s != null) {
+      return s.get(normalizeUri(uri));
+    }
+    return null;
+  }
+}
index 275ff940618d2a85a31b4385af5b3d35fb1805f2..d434602cc2efb988240f13b3969b1af671da192c 100644 (file)
@@ -144,22 +144,37 @@ public class XsltDebuggerExtension extends XsltRunnerExtension {
     File rtClasspath = new File(pluginPath, "lib" + c + "xslt-debugger-engine.jar");
     if (rtClasspath.exists()) {
       parameters.getClassPath().addTail(rtClasspath.getAbsolutePath());
+
+      final File rmiStubs = new File(pluginPath, "lib" + c + "rmi-stubs.jar");
+      assert rmiStubs.exists() : rmiStubs.getAbsolutePath();
+      parameters.getClassPath().addTail(rmiStubs.getAbsolutePath());
+
+      final File engineImpl = new File(pluginPath, "lib" + c + "rt" + c + "xslt-debugger-engine-impl.jar");
+      assert engineImpl.exists() : engineImpl.getAbsolutePath();
+      parameters.getClassPath().addTail(engineImpl.getAbsolutePath());
     } else {
       if (!(rtClasspath = new File(pluginPath, "classes")).exists()) {
         if (ApplicationManagerEx.getApplicationEx().isInternal() && new File(pluginPath, "org").exists()) {
           rtClasspath = pluginPath;
+          final File engineImplInternal = new File(pluginPath, ".." + c + "xslt-debugger-engine-impl");
+          assert engineImplInternal.exists() : engineImplInternal.getAbsolutePath();
+          parameters.getClassPath().addTail(engineImplInternal.getAbsolutePath());
         } else {
           throw new CantRunException("Runtime classes not found");
         }
       }
 
       parameters.getClassPath().addTail(rtClasspath.getAbsolutePath());
-      parameters.getClassPath().addTail(new File(rtClasspath, "rmi-stubs.jar").getAbsolutePath());
+
+      final File rmiStubs = new File(rtClasspath, "rmi-stubs.jar");
+      assert rmiStubs.exists() : rmiStubs.getAbsolutePath();
+      parameters.getClassPath().addTail(rmiStubs.getAbsolutePath());
     }
 
     File trove4j = new File(PathManager.getLibPath() + c + "trove4j.jar");
     if (!trove4j.exists()) {
       trove4j = new File(PathManager.getHomePath() + c + "community" + c + "lib" + c + "trove4j.jar");
+      assert trove4j.exists() : trove4j.getAbsolutePath();
     }
     parameters.getClassPath().addTail(trove4j.getAbsolutePath());
 
@@ -247,27 +262,27 @@ public class XsltDebuggerExtension extends XsltRunnerExtension {
   }
 
   private static void addXalan(SimpleJavaParameters parameters, File pluginPath) {
-    final char c = File.separatorChar;
-    File xalan = new File(pluginPath, "lib" + c + "rt" + c + "xalan.jar");
-    if (!xalan.exists()) {
-      if (!(xalan = new File(pluginPath, "lib" + c + "xalan.jar")).exists()) {
-        xalan = new File(pluginPath, "xalan.jar");
-        assert xalan.exists();
-      }
-    }
+    final File xalan = findTransformerJar(pluginPath, "xalan.jar");
     parameters.getClassPath().addTail(xalan.getAbsolutePath());
     parameters.getClassPath().addTail(new File(xalan.getParentFile(), "serializer.jar").getAbsolutePath());
   }
 
   private static void addSaxon(SimpleJavaParameters parameters, File pluginPath, final String saxonJar) {
+    final File saxon = findTransformerJar(pluginPath, saxonJar);
+    parameters.getClassPath().addTail(saxon.getAbsolutePath());
+  }
+
+  private static File findTransformerJar(File pluginPath, String jarFile) {
     final char c = File.separatorChar;
-    File saxon = new File(pluginPath, "lib" + c + "rt" + c + saxonJar);
-    if (!saxon.exists()) {
-      if (!(saxon = new File(pluginPath, "lib" + c + saxonJar)).exists()) {
-        saxon = new File(pluginPath, saxonJar);
-        assert saxon.exists();
+    File transformerFile = new File(pluginPath, "lib" + c + "rt" + c + jarFile);
+    if (!transformerFile.exists()) {
+      if (!(transformerFile = new File(pluginPath, "lib" + c + jarFile)).exists()) {
+        if (!(transformerFile = new File(new File(pluginPath, ".." + c + "xslt-debugger-engine-impl"), jarFile)).exists()) {
+          transformerFile = new File(pluginPath, jarFile);
+          assert transformerFile.exists() : transformerFile.getAbsolutePath();
+        }
       }
     }
-    parameters.getClassPath().addTail(saxon.getAbsolutePath());
+    return transformerFile;
   }
 }
index 5d0c16aa153d4acd4f4a686f055f9e6c10ac8df5..2ac083997dae5de499f0a9925edd267013d6c002 100644 (file)
@@ -20,7 +20,7 @@ import org.intellij.plugins.xsltDebugger.XsltDebuggerSession;
 import org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint;
 import org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager;
 import org.intellij.plugins.xsltDebugger.rt.engine.Debugger;
-import org.intellij.plugins.xsltDebugger.rt.engine.local.BreakpointManagerImpl;
+import org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManagerImpl;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
index 4f5ffabb0fc696922552341fccae01b86234efcb..6809acd95195403e7ac887f1a539bde4f6e33a7d 100644 (file)
@@ -11,7 +11,7 @@
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="module" module-name="xpath" />
-    <orderEntry type="module" module-name="xslt-debugger-rt" />
+    <orderEntry type="module" module-name="xslt-debugger-engine" />
     <orderEntry type="module" module-name="lang-api" />
     <orderEntry type="module" module-name="lang-impl" />
     <orderEntry type="module" module-name="xdebugger-api" />