Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

This commit was manufactured by cvs2svn to create tag 'v201109150205'.

  • Loading branch information...
commit 4d6729c6a2310fd7a09f79aeb60d7ab5a7fbc48f 1 parent 78796d4
nitind authored
Showing with 0 additions and 7,506 deletions.
  1. +0 −7 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/.classpath
  2. +0 −28 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/.project
  3. +0 −90 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/.settings/org.eclipse.jdt.core.prefs
  4. +0 −4 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/.settings/org.eclipse.pde.core.prefs
  5. +0 −14 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/META-INF/MANIFEST.MF
  6. +0 −12 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/OSGI-INF/l10n/bundle.properties
  7. +0 −28 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/about.html
  8. +0 −7 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/build.properties
  9. +0 −82 ...clipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/Breakpoint.java
  10. +0 −369 ...lipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ContextData.java
  11. +0 −320 ...t.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/DebugSessionManager.java
  12. +0 −90 ...se.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/FunctionSource.java
  13. +0 −25 ....eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/LineData.java
  14. +0 −454 ...se.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/RequestHandler.java
  15. +0 −532 ...wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/RhinoDebuggerImpl.java
  16. +0 −471 ...ipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ScriptSource.java
  17. +0 −500 ...clipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/StackFrame.java
  18. +0 −180 ...clipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ThreadData.java
  19. +0 −53 ...lipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/Connection.java
  20. +0 −46 ...clipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/Constants.java
  21. +0 −145 ...pse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/DebugSession.java
  22. +0 −34 ...sdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/DisconnectedException.java
  23. +0 −83 ...ipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/EventPacket.java
  24. +0 −132 ...se.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/JSONConstants.java
  25. +0 −462 ...eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/JSONUtil.java
  26. +0 −117 ...g.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/Packet.java
  27. +0 −112 ...se.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PacketManager.java
  28. +0 −277 ...jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PacketReceiveManager.java
  29. +0 −108 ...st.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PacketSendManager.java
  30. +0 −127 ....wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedConnection.java
  31. +0 −159 ...sdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/PipedTransportService.java
  32. +0 −111 ....eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/Request.java
  33. +0 −181 ...eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/Response.java
  34. +0 −122 ...wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/SocketConnection.java
  35. +0 −149 ...dt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/SocketTransportService.java
  36. +0 −29 ...wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/TimeoutException.java
  37. +0 −71 ...wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/TransportService.java
  38. +0 −13 ...e.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/transport/messages.properties
  39. +0 −66 .../org.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/rhino/debugger/RhinoDebugger.java
  40. +0 −60 ...g.eclipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/rhino/debugger/shell/DebugShell.java
  41. +0 −7 bundles/org.eclipse.wst.jsdt.debug.transport/.classpath
  42. +0 −34 bundles/org.eclipse.wst.jsdt.debug.transport/.project
  43. +0 −90 bundles/org.eclipse.wst.jsdt.debug.transport/.settings/org.eclipse.jdt.core.prefs
  44. +0 −11 bundles/org.eclipse.wst.jsdt.debug.transport/META-INF/MANIFEST.MF
  45. +0 −12 bundles/org.eclipse.wst.jsdt.debug.transport/OSGI-INF/l10n/bundle.properties
  46. +0 −87 bundles/org.eclipse.wst.jsdt.debug.transport/about.html
  47. +0 −18 bundles/org.eclipse.wst.jsdt.debug.transport/build.properties
  48. +0 −60 bundles/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/Connection.java
  49. +0 −52 bundles/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/Constants.java
  50. +0 −112 bundles/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/DebugSession.java
  51. +0 −35 bundles/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/ListenerKey.java
  52. +0 −67 bundles/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/TransportService.java
  53. +0 −33 ...ipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/exception/DisconnectedException.java
  54. +0 −33 ...g.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/exception/TimeoutException.java
  55. +0 −39 bundles/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/packet/Event.java
  56. +0 −40 bundles/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/packet/Packet.java
  57. +0 −114 ...les/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/packet/PacketManager.java
  58. +0 −284 ....eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/packet/PacketReceiveManager.java
  59. +0 −112 ...org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/packet/PacketSendManager.java
  60. +0 −47 bundles/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/packet/Request.java
  61. +0 −61 bundles/org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/packet/Response.java
  62. +0 −96 .../org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/socket/SocketConnection.java
  63. +0 −38 ...org.eclipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/socket/SocketListenerKey.java
  64. +0 −154 ...clipse.wst.jsdt.debug.transport/src/org/eclipse/wst/jsdt/debug/transport/socket/SocketTransportService.java
View
7 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/.classpath
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
View
28 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/.project
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.wst.jsdt.debug.rhino.debugger</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
View
90 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/.settings/org.eclipse.jdt.core.prefs
@@ -1,90 +0,0 @@
-#Fri Apr 30 10:04:28 CDT 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.doc.comment.support=enabled
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
-org.eclipse.jdt.core.compiler.problem.deadCode=error
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
-org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
-org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error
-org.eclipse.jdt.core.compiler.problem.nullReference=warning
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=error
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=error
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=error
-org.eclipse.jdt.core.compiler.problem.unusedLocal=error
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=error
-org.eclipse.jdt.core.compiler.problem.unusedParameter=error
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
View
4 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/.settings/org.eclipse.pde.core.prefs
@@ -1,4 +0,0 @@
-#Sun Feb 28 13:50:08 EST 2010
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
View
14 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/META-INF/MANIFEST.MF
@@ -1,14 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %Bundle-Name
-Bundle-Vendor: %Bundle-Vendor
-Bundle-SymbolicName: org.eclipse.wst.jsdt.debug.rhino.debugger
-Bundle-Version: 1.0.1.qualifier
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
-Export-Package: org.eclipse.wst.jsdt.debug.internal.rhino.debugger;x-internal:=true,
- org.eclipse.wst.jsdt.debug.internal.rhino.transport;x-friends:="org.eclipse.wst.jsdt.debug.rhino",
- org.eclipse.wst.jsdt.debug.rhino.debugger,
- org.eclipse.wst.jsdt.debug.rhino.debugger.shell
-Import-Package: org.mozilla.javascript;resolution:=optional,
- org.mozilla.javascript.debug;resolution:=optional,
- org.mozilla.javascript.tools.shell;resolution:=optional
View
12 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/OSGI-INF/l10n/bundle.properties
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2010 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-Bundle-Vendor = Eclipse Web Tools Platform
-Bundle-Name = Rhino Debugger
View
28 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/about.html
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>March 10, 2010</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
-
-</body>
-</html>
View
7 bundles/org.eclipse.wst.jsdt.debug.rhino.debugger/build.properties
@@ -1,7 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- about.html,\
- OSGI-INF/l10n/bundle.properties
-src.includes = about.html
View
82 ...pse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/Breakpoint.java
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
-
-import java.util.HashMap;
-
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.JSONConstants;
-
-
-/**
- * Implementation of a breakpoint wrt Rhino debugging
- *
- * @since 1.0
- */
-public class Breakpoint {
-
- final Long breakpointId;
- final ScriptSource script;
- final Integer lineNumber;
- final Object functionName;
- final String condition;
- final Long threadId;
-
- /**
- * Constructor
- *
- * @param breakpointId the id for the breakpoint
- * @param script the script the breakpoint applies to, <code>null</code> is not accepted
- * @param lineNumber the line number for the breakpoint
- * @param functionName the name of the function the breakpoint is set on, <code>null</code> is accepted
- * @param condition the condition for the breakpoint, <code>null</code> is accepted
- * @param threadId the id of the thread the breakpoint is for
- */
- public Breakpoint(Long breakpointId, ScriptSource script, Integer lineNumber, String functionName, String condition, Long threadId) {
- if (script == null) {
- throw new IllegalArgumentException("The parent script cannot be null"); //$NON-NLS-1$
- }
- this.breakpointId = breakpointId;
- this.script = script;
- this.lineNumber = lineNumber;
- this.functionName = functionName;
- this.condition = condition;
- this.threadId = threadId;
- }
-
- /**
- * @return the breakpoint as a JSON entry
- */
- public Object toJSON() {
- HashMap result = new HashMap();
- result.put(JSONConstants.BREAKPOINT_ID, breakpointId);
- result.put(JSONConstants.SCRIPT_ID, script.getId());
- if (lineNumber != null) {
- result.put(JSONConstants.LINE, lineNumber);
- }
- if (functionName != null) {
- result.put(JSONConstants.FUNCTION, functionName);
- }
- if (condition != null) {
- result.put(JSONConstants.CONDITION, condition);
- }
- if (threadId != null) {
- result.put(JSONConstants.THREAD_ID, threadId);
- }
- return result;
- }
-
- /**
- * Deletes the breakpoint from the script it is associated with. Does
- * not clear any of the handle information so the deleted breakpoint can be
- * returned as an event if required.
- */
- public void delete() {
- this.script.removeBreakpoint(this);
- }
-}
View
369 ...se.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ContextData.java
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.EventPacket;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.JSONConstants;
-
-/**
- * Rhino implementation of {@link ContextData}
- *
- * @since 1.0
- */
-public class ContextData {
- private static final int CONTEXT_RUNNING = 0;
- private static final int CONTEXT_SUSPENDED = 1;
-
- private static final int STEP_CONTINUE = 0;
- private static final int STEP_IN = 1;
- private static final int STEP_NEXT = 2;
- private static final int STEP_OUT = 4;
-
- private final Long threadId;
- private final Long contextId;
- private final RhinoDebuggerImpl debugger;
-
- private final LinkedList frames = new LinkedList();
-
- private int contextState = CONTEXT_RUNNING;
- private int stepState = STEP_CONTINUE;
- private StackFrame stepFrame;
-
- /**
- * Constructor
- *
- * @param threadId
- * @param contextId
- * @param debugger
- */
- public ContextData(Long threadId, Long contextId, RhinoDebuggerImpl debugger) {
- this.threadId = threadId;
- this.contextId = contextId;
- this.debugger = debugger;
- }
-
- /**
- * Returns the unique id of this context data
- *
- * @return the unique id
- */
- public Long getId() {
- return contextId;
- }
-
- /**
- * Returns the live list of {@link DebugFrame}s from this context
- *
- * @return the live list of {@link DebugFrame}s
- */
- public synchronized List getFrameIds() {
- List result = new ArrayList();
- for (Iterator iterator = frames.iterator(); iterator.hasNext();) {
- result.add(((StackFrame) iterator.next()).getId());
- }
- return result;
- }
-
- /**
- * Returns the {@link DebugFrame} with the given id or <code>null</code> if no such {@link DebugFrame} exists
- *
- * @param frameId
- * @return the {@link DebugFrame} with the given id or <code>null</code>
- */
- public synchronized StackFrame getFrame(Long frameId) {
- StackFrame frame = null;
- for (Iterator iterator = frames.iterator(); iterator.hasNext();) {
- frame = (StackFrame) iterator.next();
- if (frame.getId().equals(frameId)) {
- return frame;
- }
- }
- return null;
- }
-
- /**
- * Adds the given frame to the top of the frame stack and sends out a break event as needed
- *
- * @param frame
- * @param script
- * @param lineNumber
- * @param functionName
- */
- public synchronized void pushFrame(StackFrame frame, ScriptSource script, Integer lineNumber, String functionName) {
- frames.addFirst(frame);
- Breakpoint breakpoint = script.getBreakpoint(lineNumber, functionName);
- boolean isStepBreak = stepBreak(STEP_IN);
- if (isStepBreak || breakpoint != null) {
- if (sendBreakEvent(script, frame.getLineNumber(), functionName, breakpoint, isStepBreak, false)) {
- suspendState();
- }
- }
- }
-
- /**
- * Returns if the step operation should cause a break
- *
- * @param step
- * @return true if the operation should break false otherwise
- */
- private boolean stepBreak(int step) {
- return ((0 != (step & stepState)) && (stepFrame == null || stepFrame == frames.getFirst()));
- }
-
- /**
- * Suspends the state via {@link #wait()}
- */
- private void suspendState() {
- contextState = CONTEXT_SUSPENDED;
- while (contextState == CONTEXT_SUSPENDED) {
- try {
- wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Removes the first {@link DebugFrame} from the current stack
- *
- * @param byThrow
- * @param resultOrException
- */
- public synchronized void popFrame(boolean byThrow, Object resultOrException) {
- if(!frames.isEmpty()) {
- StackFrame frame = (StackFrame) frames.removeFirst();
- if (stepFrame == frame) {
- stepFrame = null;
- stepState = STEP_OUT;
- }
-
- boolean isStepBreak = stepBreak(STEP_IN | STEP_OUT);
- if (isStepBreak) {
- frame = getTopFrame();
- if (frame != null && sendBreakEvent(frame.getScript(), frame.getLineNumber(), null, null, isStepBreak, false)) {
- suspendState();
- }
- }
- }
- }
-
- /**
- * Resume the state with the given step type
- *
- * @param stepType
- */
- public synchronized void resume(String stepType) {
- try {
- if (stepType == null) {
- stepState = STEP_CONTINUE;
- stepFrame = null;
- } else if (stepType.equals(JSONConstants.STEP_IN)) {
- stepState = STEP_IN;
- stepFrame = null;
- } else if (stepType.equals(JSONConstants.STEP_NEXT)) {
- stepState = STEP_NEXT;
- stepFrame = getTopFrame();
- } else if (stepType.equals(JSONConstants.STEP_OUT)) {
- if (frames.size() > 1) {
- stepState = STEP_OUT;
- stepFrame = (StackFrame) frames.get(1);
- } else {
- stepState = STEP_CONTINUE;
- stepFrame = null;
- }
- } else if (stepType.equals(JSONConstants.STEP_ANY)) {
- stepState = STEP_IN | STEP_OUT | STEP_NEXT;
- stepFrame = null;
- } else {
- throw new IllegalStateException("bad stepType: " + stepType); //$NON-NLS-1$
- }
- }
- finally {
- contextState = CONTEXT_RUNNING;
- notifyAll();
- }
- }
-
- /**
- * Returns the top stack frame iff there are frames.
- * Delegate method to prevent {@link NoSuchElementException}s
- *
- * @return the top frame or <code>null</code>
- */
- private StackFrame getTopFrame() {
- if(this.frames != null && !this.frames.isEmpty()) {
- return (StackFrame) this.frames.getFirst();
- }
- return null;
- }
-
- /**
- * Set the step state to the suspend equivalent
- */
- public synchronized void suspend() {
- stepState = STEP_IN | STEP_NEXT | STEP_OUT;
- stepFrame = null;
- }
-
- /**
- * Handles a <code>debugger;</code> statement
- *
- * @param script
- * @param lineNumber
- */
- public synchronized void debuggerStatement(ScriptSource script, Integer lineNumber) {
- Breakpoint breakpoint = script.getBreakpoint(lineNumber, null);
- boolean isStepBreak = stepBreak(STEP_IN | STEP_NEXT);
- if (sendBreakEvent(script, lineNumber, null, breakpoint, isStepBreak, true)) {
- suspendState();
- }
- }
-
- /**
- * Handles a line change
- *
- * @param script
- * @param lineNumber
- */
- public synchronized void lineChange(ScriptSource script, Integer lineNumber) {
- Breakpoint breakpoint = script.getBreakpoint(lineNumber, null);
- boolean isStepBreak = stepBreak(STEP_IN | STEP_NEXT);
- if (isStepBreak || breakpoint != null) {
- if (sendBreakEvent(script, lineNumber, null, breakpoint, isStepBreak, false)) {
- suspendState();
- }
- }
- }
-
- /**
- * Handles forwarding an exception event
- *
- * @param ex
- */
- public synchronized void exceptionThrown(Throwable ex) {
- StackFrame frame = getTopFrame();
- if (sendExceptionEvent(frame.getScript(), frame.getLineNumber(), ex)) {
- suspendState();
- }
- }
-
- /**
- * Sends a JSON message for an exception that has occurred
- *
- * @param script
- * @param lineNumber
- * @param ex
- * @return true if the message was sent successfully, false otherwise
- */
- private boolean sendExceptionEvent(ScriptSource script, Integer lineNumber, Throwable ex) {
- EventPacket exceptionEvent = new EventPacket(JSONConstants.EXCEPTION);
- Map body = exceptionEvent.getBody();
- body.put(JSONConstants.CONTEXT_ID, contextId);
- body.put(JSONConstants.THREAD_ID, threadId);
- body.put(JSONConstants.SCRIPT_ID, script.getId());
- body.put(JSONConstants.LINE_NUMBER, lineNumber);
- body.put(JSONConstants.MESSAGE, ex.getMessage());
- return debugger.sendEvent(exceptionEvent);
- }
-
- /**
- * Sends a JSON message for a break event
- *
- * @param script
- * @param lineNumber
- * @param functionName
- * @param breakpoint
- * @param isStepBreak
- * @param isDebuggerStatement
- * @return true if the message was sent successfully, false otherwise
- */
- private boolean sendBreakEvent(ScriptSource script, Integer lineNumber, String functionName, Breakpoint breakpoint, boolean isStepBreak, boolean isDebuggerStatement) {
- EventPacket breakEvent = new EventPacket(JSONConstants.BREAK);
- Map body = breakEvent.getBody();
- body.put(JSONConstants.THREAD_ID, threadId);
- body.put(JSONConstants.CONTEXT_ID, contextId);
- body.put(JSONConstants.SCRIPT_ID, script.getId());
- if (functionName != null) {
- body.put(JSONConstants.FUNCTION_NAME, functionName);
- }
- body.put(JSONConstants.LINE_NUMBER, lineNumber);
- if (breakpoint != null) {
- body.put(JSONConstants.BREAKPOINT, breakpoint.breakpointId);
- }
-
- if (isStepBreak) {
- String stepType;
- if (stepState == STEP_IN) {
- stepType = JSONConstants.STEP_IN;
- } else if (stepState == STEP_NEXT) {
- stepType = JSONConstants.STEP_NEXT;
- } else if (stepState == STEP_OUT) {
- stepType = JSONConstants.STEP_OUT;
- } else {
- stepType = JSONConstants.SUSPEND;
- }
- body.put(JSONConstants.STEP, stepType);
- stepState = 0;
- }
-
- body.put(JSONConstants.DEBUGGER_STATEMENT, Boolean.valueOf(isDebuggerStatement));
- return debugger.sendEvent(breakEvent);
- }
-
- /**
- * Handles a script load event
- *
- * @param script
- */
- public synchronized void scriptLoaded(ScriptSource script) {
- if (sendScriptEvent(script)) {
- suspendState();
- }
- }
-
- /**
- * Send a JSON message for a script event
- *
- * @param script
- * @return
- */
- private boolean sendScriptEvent(ScriptSource script) {
- EventPacket scriptEvent = new EventPacket(JSONConstants.SCRIPT);
- Map body = scriptEvent.getBody();
- body.put(JSONConstants.THREAD_ID, threadId);
- body.put(JSONConstants.CONTEXT_ID, contextId);
- body.put(JSONConstants.SCRIPT_ID, script.getId());
- return debugger.sendEvent(scriptEvent);
- }
-
- /**
- * Returns the string representation of the state
- *
- * @return the state text
- */
- public synchronized String getState() {
- return contextState == CONTEXT_RUNNING ? JSONConstants.RUNNING : JSONConstants.SUSPENDED;
- }
-
- /**
- * Returns the underlying thread id
- *
- * @return the underlying thread id
- */
- public Long getThreadId() {
- return threadId;
- }
-}
View
320 ...sdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/DebugSessionManager.java
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.Connection;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.DebugSession;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.DisconnectedException;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.EventPacket;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.JSONConstants;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.Request;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.Response;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.SocketTransportService;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.TimeoutException;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.TransportService;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.TransportService.ListenerKey;
-
-/**
- * Delegate for {@link DebugSession} communication
- *
- * @since 1.1
- */
-public class DebugSessionManager {
-
- public class DebugSessionThread extends Thread {
-
- private ListenerKey listenerKey;
- private Connection connection;
- private RequestHandler requestHandler;
-
- public DebugSessionThread(String name, RhinoDebuggerImpl debugger) {
- super(name);
- requestHandler = new RequestHandler(debugger);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Runnable#run()
- */
- public void run() {
- try {
- listenerKey = transportService.startListening(address);
- while (!shutdown) {
- try {
- acceptConnection(10000);
- } catch (IOException e) {
- if (connection == null) {
- continue;
- }
- }
- while (!shutdown && connection.isOpen()) {
- try {
- Request request = debugSession.receiveRequest(1000);
- if (DEBUG)
- System.out.println(request);
- Response response = requestHandler.handleRequest(request);
- if (DEBUG)
- System.out.println(response);
- debugSession.sendResponse(response);
- } catch (TimeoutException e) {
- // ignore
- } catch (DisconnectedException e) {
- break;
- }
- }
- closeConnection();
- }
- } catch (IOException e) {
- sendDeathEvent();
- /* e.printStackTrace(); */
- } finally {
- try {
- if (listenerKey != null)
- transportService.stopListening(listenerKey);
- } catch (IOException e) {
- sendDeathEvent();
- /* e.printStackTrace(); */
- }
- }
- }
-
- /**
- * Close the active connection
- *
- * @throws IOException
- */
- private void closeConnection() throws IOException {
- if (connection != null) {
- setDebugSession(null);
- connection.close();
- connection = null;
- }
- }
-
- /**
- * Waits for a connection for the given timeout
- *
- * @param timeout
- * @throws IOException
- */
- private void acceptConnection(long timeout) throws IOException {
- if (connection == null) {
- connection = transportService.accept(listenerKey, timeout, timeout);
- setDebugSession(new DebugSession(connection));
- }
- }
-
- }
-
- private static final boolean DEBUG = false;
-
- private static final String ADDRESS = "address"; //$NON-NLS-1$
- private static final String SOCKET = "socket"; //$NON-NLS-1$
- private static final String TRANSPORT = "transport"; //$NON-NLS-1$
-
- private final TransportService transportService;
- private final String address;
- private final boolean startSuspended;
-
- private DebugSession debugSession;
- private Thread debuggerThread;
- private volatile boolean shutdown = false;
-
- /**
- * Constructor
- *
- * @param transportService
- * @param address
- * @param startSuspended
- */
- public DebugSessionManager(TransportService transportService, String address, boolean startSuspended) {
- this.transportService = transportService;
- this.address = address;
- this.startSuspended = startSuspended;
- prettyPrintHeader();
- }
-
- /**
- * Creates a new session manager
- *
- * @param configString
- * @return
- */
- static DebugSessionManager create(String configString) {
- Map config = parseConfigString(configString);
- String transport = (String) config.get(TRANSPORT);
- if (!SOCKET.equals(transport)) {
- throw new IllegalArgumentException("Transport service must be 'socket': " + transport); //$NON-NLS-1$
- }
- TransportService parsedTransportService = new SocketTransportService();
- String parsedAddress = (String) config.get(ADDRESS);
- String suspend = (String) config.get(JSONConstants.SUSPEND);
- boolean parsedStartSuspended = false;
- if (suspend != null) {
- parsedStartSuspended = (Boolean.valueOf(suspend).booleanValue() || suspend.trim().equalsIgnoreCase("y")); //$NON-NLS-1$
- }
- return new DebugSessionManager(parsedTransportService, parsedAddress, parsedStartSuspended);
- }
-
- /**
- * Parses the command line configuration string
- *
- * @param configString
- * @return the map of command line arguments
- */
- private static Map parseConfigString(String configString) {
- Map config = new HashMap();
- StringTokenizer tokenizer = new StringTokenizer(configString, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- int equalsIndex = token.indexOf('=');
- if (equalsIndex == -1)
- config.put(token, null);
- else
- config.put(token.substring(0, equalsIndex), token.substring(equalsIndex + 1));
- }
- return config;
- }
-
- /**
- * Pretty print the header for the debugger
- *
- * @since 1.1
- */
- private void prettyPrintHeader() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("Rhino attaching debugger\n"); //$NON-NLS-1$
- buffer.append("Start at time: ").append(getStartAtDate()); //$NON-NLS-1$
- buffer.append("\nListening to "); //$NON-NLS-1$
- buffer.append(this.transportService instanceof SocketTransportService ? "socket on " : "transport service on "); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.append("port: ").append(this.address); //$NON-NLS-1$
- if (startSuspended) {
- buffer.append("\nStarted suspended - waiting for client resume..."); //$NON-NLS-1$
- }
- System.out.println(buffer.toString());
- }
-
- /**
- * Returns the formatted date
- *
- * @return the formatted date
- * @see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4981314
- * @since 1.1
- */
- String getStartAtDate() {
- try {
- return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(Calendar.getInstance().getTime());
- } catch (Throwable t) {
- return "<unknown>"; //$NON-NLS-1$
- }
- }
-
- /**
- * @return true if the <code>suspend=true</code> command line argument is
- * set
- */
- public boolean isStartSuspended() {
- return startSuspended;
- }
-
- /**
- * Returns if a {@link DebugSession} has successfully connected to this
- * debugger.
- *
- * @return <code>true</code> if the debugger has a connected
- * {@link DebugSession} <code>false</code> otherwise
- */
- public synchronized boolean isConnected() {
- return debugSession != null;
- }
-
- /**
- * Starts the debugger
- */
- public synchronized void start(RhinoDebuggerImpl debugger) {
- debuggerThread = new DebugSessionThread("RhinoDebugger - Request Handler", debugger); //$NON-NLS-1$
- debuggerThread.start();
- if (startSuspended) {
- try {
- wait(300000);
- } catch (InterruptedException e) {
- /* e.printStackTrace(); */
- }
- // TODO: We might want to check if debugSession is null and if so
- // call "stop" and throw an exception
- }
- }
-
- /**
- * Stops the debugger
- */
- public synchronized void stop() {
- shutdown = true;
- try {
- debuggerThread.interrupt();
- if (debuggerThread.isAlive())
- wait();
- debuggerThread.join();
- } catch (InterruptedException e) {
- /* e.printStackTrace(); */
- }
- }
-
- private synchronized void setDebugSession(DebugSession session) {
- if (debugSession != session) {
- if (debugSession != null) {
- debugSession.dispose();
- }
- debugSession = session;
- notify();
- }
- }
-
- /**
- * Sends the given {@link EventPacket} using the underlying
- * {@link DebugRuntime} and returns if it was sent successfully
- *
- * @param event
- * @return true if the event was sent successfully, false otherwise
- */
- public synchronized boolean sendEvent(EventPacket event) {
- try {
- if (debugSession != null) {
- if (DEBUG)
- System.out.println(event);
- debugSession.sendEvent(event);
- return true;
- }
- } catch (DisconnectedException e) {
- e.printStackTrace();
- }
- return false;
- }
-
- /**
- * Sends out an event that the debugger has died in an unexpected way.
- * Debugger death can result from:
- * <ul>
- * <li>an {@link IOException} while the debugger is running</li>
- * <li>an {@link InterruptedException} processing I/O</li>
- * </ul>
- */
- private void sendDeathEvent() {
- EventPacket event = new EventPacket(JSONConstants.VMDEATH);
- sendEvent(event);
- }
-}
View
90 ...wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/FunctionSource.java
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
-
-
-/**
- * Handle for a {@link DebuggableScript} function
- *
- * @since 1.0
- */
-public class FunctionSource {
-
- final ScriptSource parent;
- final String name;
- String source;
- final int linenumber;
-
- /**
- * Constructor
- *
- * @param script the parent - cannot be <code>null</code>
- * @param name the name of the function - can be <code>null</code>
- * @param source the underlying source for the function - can be <code>null</code>
- */
- public FunctionSource(ScriptSource script, String name, String source, int linenumber) {
- if(script == null) {
- throw new IllegalArgumentException("The parent script cannot be null"); //$NON-NLS-1$
- }
- this.parent = script;
- this.name = name;
- this.source = source;
- this.linenumber = linenumber;
- }
-
- /**
- * @return the parent {@link ScriptSource} this function appears in
- */
- public ScriptSource parent() {
- return this.parent;
- }
-
- /**
- * @return the name of the function
- */
- public String name() {
- return this.name;
- }
-
- /**
- * @return the source for the function
- */
- public String source() {
- return this.source;
- }
-
- /**
- * Sets the underlying source to the given string
- *
- * @param source the new source
- */
- public void setSource(String source) {
- this.source = source;
- }
-
- /**
- * @return the line number this function appears on
- */
- public int linenumber() {
- return this.linenumber;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("FunctionSource: [name - ").append(this.name).append("] [linenumber - ").append(linenumber).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- buffer.append("\tparent: ").append(parent.getLocation()); //$NON-NLS-1$
- buffer.append("\tsource: ").append(this.source).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$
- return buffer.toString();
- }
-}
View
25 ...lipse.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/LineData.java
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
-
-/**
- * Class to hold information about a given line such as:
- * <ul>
- * <li>FunctionSource at the line</li>
- * <li>Breakpoint set on the line</li>
- * </ul>
- * @since 1.0
- */
-public class LineData {
-
- Breakpoint breakpoint = null;
- FunctionSource function = null;
-}
View
454 ...wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/RequestHandler.java
@@ -1,454 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.JSONConstants;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.Request;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.Response;
-
-/**
- * Rhino request handler used to craft response bodies for given JSON requests
- *
- * @since 1.0
- */
-public class RequestHandler {
-
- public static final String VERSION_1_6 = "1.6"; //$NON-NLS-1$
- private RhinoDebuggerImpl debugger;
-
- /**
- * Constructor
- *
- * @param debugger
- */
- public RequestHandler(RhinoDebuggerImpl debugger) {
- this.debugger = debugger;
- }
-
- /**
- * Handles a general request - delegating to the correct command type
- *
- * @param request
- * @return
- */
- public Response handleRequest(Request request) {
- String command = request.getCommand();
- Response response = new Response(request.getSequence(), command);
- try {
- if (command.equals(JSONConstants.VERSION)) {
- handleVersionRequest(request, response);
- } else if (command.equals(JSONConstants.SUSPEND)) {
- handleSuspendRequest(request, response);
- } else if (command.equals(JSONConstants.CONTINUE)) {
- handleContinueRequest(request, response);
- } else if (command.equals(JSONConstants.DISPOSE)) {
- handleDisposeRequest(request, response);
- } else if (command.equals(JSONConstants.THREADS)) {
- handleThreadsRequest(request, response);
- } else if (command.equals(JSONConstants.THREAD)) {
- handleThreadRequest(request, response);
- } else if (command.equals(JSONConstants.FRAMES)) {
- handleFramesRequest(request, response);
- } else if (command.equals(JSONConstants.FRAME)) {
- handleFrameRequest(request, response);
- } else if (command.equals(JSONConstants.SCRIPTS)) {
- handleScriptsRequest(request, response);
- } else if (command.equals(JSONConstants.SCRIPT)) {
- handleScriptRequest(request, response);
- } else if (command.equals(JSONConstants.EVALUATE)) {
- handleEvaluateRequest(request, response);
- } else if (command.equals(JSONConstants.LOOKUP)) {
- handleLookupRequest(request, response);
- } else if (command.equals(JSONConstants.BREAKPOINTS)) {
- handleBreakpointsRequest(request, response);
- } else if (command.equals(JSONConstants.BREAKPOINT)) {
- handleBreakpointRequest(request, response);
- } else if (command.equals(JSONConstants.SETBREAKPOINT)) {
- handleSetBreakpointRequest(request, response);
- } else if (command.equals(JSONConstants.CLEARBREAKPOINT)) {
- handleClearBreakpointRequest(request, response);
- } else {
- response.setSuccess(false);
- response.setMessage("command not supported"); //$NON-NLS-1$
- }
- } catch (Throwable t) {
- response.setSuccess(false);
- response.setMessage(t.getClass().getName() + " - " + t.getMessage()); //$NON-NLS-1$
- t.printStackTrace();
- }
- return response;
- }
-
- /**
- * Handles a clear breakpoint request
- *
- * @param request
- * @param response
- */
- private void handleClearBreakpointRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long breakpointId = numberToLong((Number) arguments.get(JSONConstants.BREAKPOINT_ID));
- if (breakpointId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.BREAKPOINT_ID));
- return;
- }
- Breakpoint breakpoint = debugger.clearBreakpoint(breakpointId);
- if (breakpoint == null) {
- response.setSuccess(false);
- response.setMessage(JSONConstants.NOT_FOUND);
- return;
- }
- response.getBody().put(JSONConstants.BREAKPOINT, breakpoint.toJSON());
- }
-
- /**
- * Handles a set breakpoint request
- *
- * @param request
- * @param response
- */
- private void handleSetBreakpointRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long scriptId = numberToLong((Number) arguments.get(JSONConstants.SCRIPT_ID));
- Integer line = numberToInteger((Number) arguments.get(JSONConstants.LINE));
- String function = (String) arguments.get(JSONConstants.FUNCTION);
- Long threadId = numberToLong((Number) arguments.get(JSONConstants.THREAD_ID));
- String condition = (String) arguments.get(JSONConstants.CONDITION);
- Breakpoint breakpoint = debugger.setBreakpoint(scriptId, line, function, condition, threadId);
- if(breakpoint != null) {
- response.getBody().put(JSONConstants.BREAKPOINT, breakpoint.toJSON());
- }
- }
-
- /**
- * Handles a breakpoint request
- *
- * @param request
- * @param response
- */
- private void handleBreakpointRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long breakpointId = numberToLong((Number) arguments.get(JSONConstants.BREAKPOINT_ID));
- if (breakpointId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.BREAKPOINT_ID));
- return;
- }
- Breakpoint breakpoint = debugger.getBreakpoint(breakpointId);
- if (breakpoint == null) {
- response.setSuccess(false);
- response.setMessage(JSONConstants.NOT_FOUND);
- return;
- }
- response.getBody().put(JSONConstants.BREAKPOINT, breakpoint.toJSON());
- }
-
- /**
- * Handles a breakpoints request
- *
- * @param request
- * @param response
- */
- private void handleBreakpointsRequest(Request request, Response response) {
- Collection breakpoints = debugger.getBreakpoints();
- response.getBody().put(JSONConstants.BREAKPOINTS, breakpoints);
- }
-
- /**
- * Handles an evaluate request
- *
- * @param request
- * @param response
- */
- private void handleEvaluateRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long threadId = numberToLong((Number) arguments.get(JSONConstants.THREAD_ID));
- if (threadId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.THREAD_ID));
- return;
- }
- Long frameId = numberToLong((Number) arguments.get(JSONConstants.FRAME_ID));
- if (frameId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.FRAME_ID));
- return;
- }
- String evaluate = (String) arguments.get(JSONConstants.EXPRESSION);
- if (evaluate == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.EXPRESSION));
- return;
- }
- StackFrame frame = debugger.getFrame(threadId, frameId);
- if (frame == null) {
- response.setSuccess(false);
- response.setMessage(JSONConstants.NOT_FOUND);
- return;
- }
- Object result = frame.evaluate(evaluate);
- response.getBody().put(JSONConstants.EVALUATE, result);
- }
-
- /**
- * Handles a lookup request
- *
- * @param request
- * @param response
- */
- private void handleLookupRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long threadId = numberToLong((Number) arguments.get(JSONConstants.THREAD_ID));
- if (threadId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.THREAD_ID));
- return;
- }
- Long frameId = numberToLong((Number) arguments.get(JSONConstants.FRAME_ID));
- if (frameId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.FRAME_ID));
- return;
- }
- Long handle = numberToLong((Number) arguments.get(JSONConstants.HANDLE));
- if (handle == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.HANDLE));
- return;
- }
- StackFrame frame = debugger.getFrame(threadId, frameId);
- if (frame == null) {
- response.setSuccess(false);
- response.setMessage(JSONConstants.NOT_FOUND);
- return;
- }
- Object result = frame.lookup(handle);
- response.getBody().put(JSONConstants.LOOKUP, result);
- }
-
- /**
- * Handles a script request
- *
- * @param request
- * @param response
- */
- private void handleScriptRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long scriptId = numberToLong((Number) arguments.get(JSONConstants.SCRIPT_ID));
- if (scriptId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.SCRIPT_ID));
- return;
- }
- ScriptSource script = debugger.getScript(scriptId);
- if (script == null) {
- response.setSuccess(false);
- response.setMessage(JSONConstants.NOT_FOUND);
- return;
- }
- response.getBody().put(JSONConstants.SCRIPT, script.toJSON());
- }
-
- /**
- * Handles a scripts request
- *
- * @param request
- * @param response
- */
- private void handleScriptsRequest(Request request, Response response) {
- List scriptIds = debugger.getScriptIds();
- response.getBody().put(JSONConstants.SCRIPTS, scriptIds);
- }
-
- /**
- * Handles a frame request
- *
- * @param request
- * @param response
- */
- private void handleFrameRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long threadId = numberToLong((Number) arguments.get(JSONConstants.THREAD_ID));
- if (threadId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.THREAD_ID));
- return;
- }
- Long frameId = numberToLong((Number) arguments.get(JSONConstants.FRAME_ID));
- if (frameId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.FRAME_ID));
- return;
- }
- StackFrame frame = debugger.getFrame(threadId, frameId);
- if (frame == null) {
- response.setSuccess(false);
- response.setMessage(JSONConstants.NOT_FOUND);
- return;
- }
- response.getBody().put(JSONConstants.FRAME, frame.toJSON());
- }
-
- /**
- * Handles a frames request
- *
- * @param request
- * @param response
- */
- private void handleFramesRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long threadId = numberToLong((Number) arguments.get(JSONConstants.THREAD_ID));
- if (threadId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.THREAD_ID));
- return;
- }
- List frameIds = debugger.getFrameIds(threadId);
- response.getBody().put(JSONConstants.FRAMES, frameIds);
- }
-
- /**
- * Handles a thread request
- *
- * @param request
- * @param response
- */
- private void handleThreadRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long threadId = numberToLong((Number) arguments.get(JSONConstants.THREAD_ID));
- if (threadId == null) {
- response.setSuccess(false);
- response.setMessage(missingArgument(JSONConstants.THREAD_ID));
- return;
- }
- ThreadData threadData = debugger.getThreadData(threadId);
- if (threadData == null) {
- response.setSuccess(false);
- response.setMessage(JSONConstants.NOT_FOUND);
- return;
- }
- response.getBody().put(JSONConstants.THREAD, threadData.toJSON());
- }
-
- /**
- * Reports a missing argument
- *
- * @param key
- * @return
- */
- private String missingArgument(String key) {
- // TODO NLS this
- return "Missing Argument: "+key; //$NON-NLS-1$
- }
-
- /**
- * Handles a threads request
- *
- * @param request
- * @param response
- */
- private void handleThreadsRequest(Request request, Response response) {
- List threadIds = debugger.getThreadIds();
- response.getBody().put(JSONConstants.THREADS, threadIds);
- }
-
- /**
- * Handles a dispose request by disconnecting the underlying {@link RhinoDebuggerImpl}
- *
- * @param request
- * @param response
- */
- private void handleDisposeRequest(Request request, Response response) {
- debugger.disconnect();
- }
-
- /**
- * Handles a continue request
- *
- * @param request
- * @param response
- */
- private void handleContinueRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long threadId = numberToLong((Number) arguments.get(JSONConstants.THREAD_ID));
- if (threadId == null) {
- debugger.resumeAll();
- return;
- }
- String stepType = (String) arguments.get(JSONConstants.STEP);
- debugger.resume(threadId, stepType);
- }
-
- /**
- * Handles a suspend request
- *
- * @param request
- * @param response
- */
- private void handleSuspendRequest(Request request, Response response) {
- Map arguments = request.getArguments();
- Long threadId = numberToLong((Number) arguments.get(JSONConstants.THREAD_ID));
- if (threadId == null) {
- debugger.suspendAll();
- return;
- }
- debugger.suspend(threadId);
- }
-
- /**
- * Wrappers the given {@link Number} as a {@link Long}
- *
- * @param number
- * @return a new {@link Long}
- */
- private static Long numberToLong(Number number) {
- if (number == null)
- return null;
- return new Long(number.longValue());
- }
-
- /**
- * Wrappers the given {@link Number} as an {@link Integer}
- *
- * @param number
- * @return a new {@link Integer}
- */
- private Integer numberToInteger(Number number) {
- if (number == null) {
- return null;
- }
- return new Integer(number.intValue());
- }
-
- /**
- * Appends version infos to the given response body
- *
- * @param request
- * @param response
- *
- * @see JSONConstants#ECMASCRIPT_VERSION
- * @see JSONConstants#JAVASCRIPT_VERSION
- * @see JSONConstants#VM_NAME
- * @see JSONConstants#VM_VENDOR
- * @see JSONConstants#VM_VERSION
- */
- private void handleVersionRequest(Request request, Response response) {
- Map body = response.getBody();
- body.put(JSONConstants.JAVASCRIPT_VERSION, VERSION_1_6);
- body.put(JSONConstants.ECMASCRIPT_VERSION, "3"); //$NON-NLS-1$
- body.put(JSONConstants.VM_NAME, "Rhino"); //$NON-NLS-1$
- body.put(JSONConstants.VM_VERSION, VERSION_1_6);
- body.put(JSONConstants.VM_VENDOR, "Mozilla"); //$NON-NLS-1$
- }
-}
View
532 ....jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/RhinoDebuggerImpl.java
@@ -1,532 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.EventPacket;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.JSONConstants;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.JSONUtil;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.TransportService;
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.ContextFactory;
-import org.mozilla.javascript.debug.DebugFrame;
-import org.mozilla.javascript.debug.DebuggableScript;
-import org.mozilla.javascript.debug.Debugger;
-
-/**
- * Rhino implementation of {@link Debugger}
- * <br><br>
- * Events fired:
- * <ul>
- * <li><b>Thread enter event</b> - when a new context is created see: {@link #contextCreated(Context)}</li>
- * <li><b>Thread exit event</b> - when a context is exited see: {@link #contextReleased(Context)}</li>
- * <li><b>VM death event</b> - if the debugger dies: this event can only be received if the underlying communication channel has not been interrupted</li>
- * </ul>
- * @since 1.0
- */
-public class RhinoDebuggerImpl implements Debugger, ContextFactory.Listener {
-
- public static final DebuggableScript[] NO_SCRIPTS = new DebuggableScript[0];
- private static final String RHINO_SCHEME = "rhino"; //$NON-NLS-1$
-
- private final Map threadToThreadId = new HashMap();
- private final Map threadIdToData = new HashMap();
- private final Map breakpoints = new HashMap();
-
- private long currentThreadId = 0L;
- private long currentBreakpointId = 0L;
- private long currentScriptId = 0L;
- private ArrayList disabledThreads = new ArrayList();
-
- /**
- * Mapping of the URI string to the {@link ScriptSource}
- */
- private HashMap/*<String, ScriptSource>*/ uriToScript = new HashMap();
- /**
- * Mapping of the id to the {@link ScriptSource}
- */
- private HashMap/*<Long, ScriptSource>*/ idToScript = new HashMap();
-
- private final DebugSessionManager sessionManager;
-
- /**
- * This constructor will only accept a <code>transport</code> argument
- * of <code>socket</code>. I.e. <code>transport=socket</code>.<br><br>
- *
- * To use a differing {@link TransportService} pleas use the other constructor:
- * {@link #RhinoDebugger(TransportService, String, boolean)}
- *
- * @param configString the configuration string, for example: <code>transport=socket,suspend=y,address=9000</code>
- */
- public RhinoDebuggerImpl(String configString) {
- sessionManager = DebugSessionManager.create(configString);
- }
-
- /**
- * This constructor allows you to specify a custom {@link TransportService} to use other than <code>socket</code>.
- *
- * @param transportService the {@link TransportService} to use for debugger communication
- * @param address the address to communicate on
- * @param startSuspended if the debugger should wait while accepting a connection. The wait time for stating suspended is not indefinite,
- * and is equal to 300000ms.
- */
- public RhinoDebuggerImpl(TransportService transportService, String address, boolean startSuspended) {
- sessionManager = new DebugSessionManager( transportService, address, startSuspended);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.mozilla.javascript.debug.Debugger#getFrame(org.mozilla.javascript.Context, org.mozilla.javascript.debug.DebuggableScript)
- */
- public synchronized DebugFrame getFrame(Context context, DebuggableScript debuggableScript) {
- ScriptSource script = getScript(debuggableScript);
- if(script != null && !script.isStdIn()) {
- ContextData contextData = (ContextData) context.getDebuggerContextData();
- ThreadData thread = (ThreadData) threadIdToData.get(contextData.getThreadId());
- FunctionSource function = script.getFunction(debuggableScript);
- return thread.getFrame(context, function, script);
- }
- return null;
- }
-
- /**
- * Returns the root {@link ScriptSource} context
- *
- * @param script
- * @return the root {@link ScriptSource} context
- */
- private ScriptSource getScript(DebuggableScript script) {
- synchronized (uriToScript) {
- DebuggableScript root = script;
- while (!root.isTopLevel()) {
- root = root.getParent();
- }
- URI uri = getSourceUri(root, parseSourceProperties(root.getSourceName()));
- if(uri != null) {
- return (ScriptSource) uriToScript.get(uri);
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.mozilla.javascript.debug.Debugger#handleCompilationDone(org.mozilla.javascript.Context, org.mozilla.javascript.debug.DebuggableScript, java.lang.String)
- */
- public void handleCompilationDone(Context context, DebuggableScript script, String source) {
- if (!script.isTopLevel()) {
- return;
- }
- Map properties = parseSourceProperties(script.getSourceName());
- URI uri = getSourceUri(script, properties);
- if(uri == null) {
- //if the source cannot be located don't load or notify
- return;
- }
- final ScriptSource newscript = new ScriptSource(script, source, uri, script.isGeneratedScript(), properties);
- synchronized (uriToScript) {
- ScriptSource old = (ScriptSource) uriToScript.remove(uri);
- Long id = null;
- if(old != null) {
- //recycle the id for a re-loaded script
- //https://bugs.eclipse.org/bugs/show_bug.cgi?id=306832
- id = old.getId();
- idToScript.remove(old.getId());
- newscript.clone(old);
- }
- else {
- //a totally new script is loaded
- id = scriptId();
- newscript.setId(id);
- }
- uriToScript.put(uri, newscript);
- idToScript.put(id, newscript);
- }
- ContextData contextData = (ContextData) context.getDebuggerContextData();
- contextData.scriptLoaded(newscript);
- }
-
- /**
- * Composes a {@link URI} representing the path to the source of the given script
- *
- * @param script the script to create a {@link URI} for
- * @param properties any special properties @see {@link #parseSourceProperties(String)}
- * @return the {@link URI} for the source or <code>null</code>
- */
- private URI getSourceUri(DebuggableScript script, Map properties) {
- String sourceName = script.getSourceName();
- if(properties != null) {
- String jsonName = (String) properties.get(JSONConstants.NAME);
- if (jsonName != null)
- sourceName = jsonName;
- }
-
- // handle null sourceName
- if (sourceName == null)
- return null;
-
- // handle input from the Rhino Shell
- if (sourceName.equals("<stdin>")) { //$NON-NLS-1$
- sourceName = "stdin"; //$NON-NLS-1$
- } else {
- // try to parse it as a file
- File sourceFile = new File(sourceName);
- if (sourceFile.exists())
- return sourceFile.toURI();
-
- //try to just create a URI from the name
- try {
- return new URI(sourceName);
- } catch(URISyntaxException e) {
- //do nothing and fall through
- }
- }
-
- //fall back to creating a rhino specific URI from the script source name as a path
- try {
- if (! (sourceName.charAt(0) == '/'))
- sourceName = "/" + sourceName; //$NON-NLS-1$
- return new URI(RHINO_SCHEME, null, sourceName, null);
- } catch (URISyntaxException e) {
- return null;
- }
- }
-
- /**
- * Returns any special properties specified in the source name or <code>null</code>
- *
- * @param sourceName
- * @return any special properties specified in the source name or <code>null</code>
- */
- Map parseSourceProperties(String sourceName) {
- if (sourceName != null && sourceName.charAt(0) == '{') {
- try {
- Object json = JSONUtil.read(sourceName);
- if (json instanceof Map) {
- return (Map) json;
- }
- } catch (RuntimeException e) {
- // ignore
- }
- }
- return null;
- }
-
- /**
- * Returns the next script id to use
- *
- * @return the next id
- */
- synchronized Long scriptId() {
- return new Long(currentScriptId++);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.mozilla.javascript.ContextFactory.Listener#contextCreated(org.mozilla.javascript.Context)
- */
- public synchronized void contextCreated(Context context) {
- Thread thread = Thread.currentThread();
- if (disabledThreads.contains(thread)) {
- return;
- }
- Long threadId = (Long) threadToThreadId.get(thread);
- if (threadId == null) {
- threadId = new Long(currentThreadId++);
- threadToThreadId.put(thread, threadId);
- }
- ThreadData threadData = (ThreadData) threadIdToData.get(threadId);
- if (threadData == null) {
- threadData = new ThreadData(threadId, this);
- threadIdToData.put(threadId, threadData);
- sendThreadEvent(JSONConstants.ENTER, threadId);
- }
- threadData.contextCreated(context);
- }
-
- /**
- * Sends a thread event for the given type
- *
- * @param type the type of event to send
- * @param threadId the id of the thread the even is for
- *
- * @see JSONConstants#ENTER
- * @see JSONConstants#EXIT
- */
- private void sendThreadEvent(String type, Long threadId) {
- EventPacket threadEvent = new EventPacket(JSONConstants.THREAD);
- Map body = threadEvent.getBody();
- body.put(JSONConstants.TYPE, type);
- body.put(JSONConstants.THREAD_ID, threadId);
- sendEvent(threadEvent);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.mozilla.javascript.ContextFactory.Listener#contextReleased(org.mozilla.javascript.Context)
- */
- public synchronized void contextReleased(Context context) {
- Thread thread = Thread.currentThread();
- if (disabledThreads.contains(thread)) {
- return;
- }
- Long threadId = (Long) threadToThreadId.get(thread);
- if (threadId == null) {
- return;
- }
- ThreadData threadData = (ThreadData) threadIdToData.get(threadId);
- threadData.contextReleased(context);
- if (!threadData.hasContext()) {
- threadToThreadId.remove(thread);
- threadIdToData.remove(threadId);
- sendThreadEvent(JSONConstants.EXIT, threadId);
- }
- }
-
- /**
- * Resumes a thread with the given id for the given step type. Has no effect if no such thread exists
- *
- * @param threadId
- * @param stepType
- */
- public synchronized void resume(Long threadId, String stepType) {
- ThreadData threadData = (ThreadData) threadIdToData.get(threadId);
- if (threadData != null) {
- threadData.resume(stepType);
- }
- }
-
- /**
- * Resumes all threads currently in the debugger
- */
- public synchronized void resumeAll() {
- for (Iterator it = threadIdToData.keySet().iterator(); it.hasNext();) {
- Long threadId = (Long) it.next();
- resume(threadId, null);
- }
- }
-
- /**
- * Suspend the thread with the given id. Has no effect if no such thread exists
- *
- * @param threadId
- */
- public synchronized void suspend(Long threadId) {
- ThreadData threadData = (ThreadData) threadIdToData.get(threadId);
- if (threadData != null) {
- threadData.suspend();
- }
- }
-
- /**
- * Suspend all threads currently in the debugger
- */
- public synchronized void suspendAll() {
- for (Iterator it = threadIdToData.keySet().iterator(); it.hasNext();) {
- Long threadId = (Long) it.next();
- suspend(threadId);
- }
- }
-
- /**
- * Disconnects the debugger
- */
- public void disconnect() {
- }
-
- /**
- * Returns all of the stack frame ids for the thread with the given id. Returns an empty list if no such thread exists, never <code>null</code>
- *
- * @param threadId
- * @return the complete list of stack frame ids from the thread with the given id
- */
- public synchronized List getFrameIds(Long threadId) {
- ThreadData threadData = (ThreadData) threadIdToData.get(threadId);
- if (threadData == null) {
- return Collections.EMPTY_LIST;
- }
- return threadData.getFrameIds();
- }
-
- /**
- * Returns a {@link DebugFrame} with the given id from the thread with the given thread id. Returns <code>null</code> if the no such thread exists with the given id and / or no such {@link DebugFrame} exists with the given id
- *
- * @param threadId
- * @param frameId
- * @return the {@link DebugFrame} with the given id from the thread with the given id
- */
- public synchronized StackFrame getFrame(Long threadId, Long frameId) {
- ThreadData threadData = (ThreadData) threadIdToData.get(threadId);
- if (threadData != null) {
- return threadData.getFrame(frameId);
- }
- return null;
- }
-
- /**
- * @return the ids of all of the scripts currently known to the debugger
- */
- public synchronized List getScriptIds() {
- return new ArrayList(idToScript.keySet());
- }
-
- /**
- * Returns the script with the given id or <code>null</code> if no such script exists with the given id
- *
- * @param scriptId
- * @return the script with the given id or <code>null</code>
- */
- public synchronized ScriptSource getScript(Long scriptId) {
- return (ScriptSource) idToScript.get(scriptId);
- }
-
- /**
- * @return the complete collection of breakpoints currently known to the debugger
- */
- public synchronized Collection getBreakpoints() {
- return breakpoints.keySet();
- }
-
- /**
- * Creates a breakpoint in the script with the given id and the given breakpoint attributes.
- * Returns the new breakpoint or <code>null</code> if:
- * <ul>
- * <li>no such script exists with the given id</li>
- * <li>the given line number is not a valid line number</li>
- * </ul>
- * <p>
- * If a breakpoint already exists at the given location it is removed and the new breakpoint is set.
- * </p>
- * @param scriptId
- * @param lineNumber
- * @param functionName
- * @param condition
- * @param threadId
- * @return the new breakpoint or <code>null</code> if no script exists with the given id
- */
- public synchronized Breakpoint setBreakpoint(Long scriptId, Integer lineNumber, String functionName, String condition, Long threadId) {
- ScriptSource script = (ScriptSource) idToScript.get(scriptId);
- if (script == null || !script.isValid(lineNumber, functionName)) {
- return null;
- }
-
-
- Breakpoint newbreakpoint = new Breakpoint(nextBreakpointId(), script, lineNumber, functionName, condition, threadId);
- Breakpoint oldbp = script.getBreakpoint(lineNumber, functionName);
- if(oldbp != null) {
- breakpoints.remove(oldbp.breakpointId);
- }
- breakpoints.put(newbreakpoint.breakpointId, newbreakpoint);
- script.addBreakpoint(newbreakpoint);
- return newbreakpoint;
- }
-
- /**
- * @return the next unique breakpoint id to use
- */
- private synchronized Long nextBreakpointId() {
- return new Long(currentBreakpointId++);
- }
-
- /**
- * Clears the breakpoint out of the cache with the given id and returns it. Returns <code>null</code> if no breakpoint exists with the given id.
- *
- * @param breakpointId
- * @return the removed breakpoint or <code>null</code>
- */
- public synchronized Breakpoint clearBreakpoint(Long breakpointId) {
- Breakpoint breakpoint = (Breakpoint) breakpoints.remove(breakpointId);
- if (breakpoint != null) {
- breakpoint.delete();
- }
- return breakpoint;
- }
-
- /**
- * Sends the given {@link EventPacket} using the underlying {@link DebugRuntime} and returns if it was sent successfully
- *
- * @param event
- * @return true if the event was sent successfully, false otherwise
- */
- public boolean sendEvent(EventPacket event) {
- return sessionManager.sendEvent(event);
- }
-
- /**
- * Gets a breakpoint with the given id, returns <code>null</code> if no such breakpoint exists with the given id
- *
- * @param breakpointId
- * @return the breakpoint with the given id or <code>null</code>
- */
- public Breakpoint getBreakpoint(Long breakpointId) {
- return (Breakpoint) breakpoints.get(breakpointId);
- }
-
- /**
- * Gets the thread for the thread with the given id, returns <code>null</code> if no such thread exists with the goven id
- *
- * @param threadId
- * @return the thread data for the thread with the given id or <code>null</code>
- */
- public synchronized ThreadData getThreadData(Long threadId) {
- return (ThreadData) threadIdToData.get(threadId);
- }
-
- /**
- * @return the complete list of thread ids known to the debugger
- */
- public synchronized List getThreadIds() {
- return new ArrayList(threadIdToData.keySet());
- }
-
- /**
- * Caches the current thread as disabled
- */
- public synchronized void disableThread() {
- disabledThreads.add(Thread.currentThread());
- }
-
- /**
- * Removes the current thread as being disabled
- */
- public synchronized void enableThread() {
- disabledThreads.remove(Thread.currentThread());
- }
-
- public void start() {
- sessionManager.start(this);
- }
-
- public void stop() {
- sessionManager.stop();
- }
-
- /**
- * Returns if a {@link DebugSession} has successfully connected to this debugger.
- *
- * @return <code>true</code> if the debugger has a connected {@link DebugSession} <code>false</code> otherwise
- */
- public boolean isConnected() {
- return sessionManager.isConnected();
- }
-}
View
471 ...e.wst.jsdt.debug.rhino.debugger/src/org/eclipse/wst/jsdt/debug/internal/rhino/debugger/ScriptSource.java
@@ -1,471 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.jsdt.debug.internal.rhino.debugger;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.Constants;
-import org.eclipse.wst.jsdt.debug.internal.rhino.transport.JSONConstants;
-import org.mozilla.javascript.debug.DebuggableScript;
-
-/**
- * Rhino script implementation
- *
- * @since 1.0
- */
-public class ScriptSource {
-
- /**
- * No line information
- */
- static final LineData[] NO_LINES = new LineData[0];
-
- /**
- * The id of the script
- */
- private Long scriptId;
- /**
- * Any special source properties to consider
- */
- private final Map properties;
- /**
- * The backing source String that was compiled to give us this proxy
- */
- private final String source;
- /**
- * If this {@link ScriptSource} was generated
- */
- private final boolean generated;
- /**
- * The ordered list of function names
- */
- private ArrayList functionNames = null;
-
- private Integer firstLine = null;
-
- /**
- * The location of the script
- */
- private URI uri = null;
- /**
- * The array of cached {@link FunctionSource}s
- */
- private FunctionSource[] functionSources = null;
- /**
- * Sparse array of line information. This array only has entries present for
- * lines that are returned
- */
- private LineData[] lines = null;
- /**
- * Mapping of the {@link DebuggableScript} backing the FunctionSource to the FunctionSource handle
- */
- private HashMap/*<DebuggableScript, FunctionSource>*/ scriptToFunction = new HashMap();
-
- /**
- * Constructor
- *
- * @param scriptId
- * @param debuggableScript
- * @param source
- */
- public ScriptSource(DebuggableScript script, String source, URI uri, boolean generated, Map properties) {
- this.uri = uri;
- this.source = source;
- this.properties = properties;
- this.generated = generated;
-
- if(isStdIn()) {
- //do not compute line data
- return;
- }
- int[] rootlines = script.getLineNumbers();
- DebuggableScript[] functions = collectFunctions(script);
- int flength = functions.length;
- int max = 0;
- int min = Integer.MAX_VALUE;
- HashSet lineNumbers = new HashSet(flength+rootlines.length+1);
- //dump in the line #'s from the root script
- for (int i = 0; i < rootlines.length; i++) {
- int line = rootlines[i];
- if(line > max) {
- max = line;
- }
- if(line < min) {
- min = line;
- }
- lineNumbers.add(new Integer(line));
- }
- //dump in the line numbers from the expanded set of functions
- if(flength > 0) {
- functionSources = new FunctionSource[flength];
- functionNames = new ArrayList(flength);
-
- int start = 0, end = 0;;
- for (int i = 0; i < functions.length; i++) {
- int[] lines = functions[i].getLineNumbers();
- if(lines != null && lines.length > 0) {
- start = lines[0] + 1;
- for (int j = 0; j < lines.length; j++) {
- int currentLine = lines[j];
- if(currentLine > max) {
- max = currentLine;
- }
- if(currentLine < min) {
- min = currentLine;
- }
- if (currentLine < start) {
- start = currentLine;
- }
- else if(currentLine > end) {
- end = currentLine;
- }
- lineNumbers.add(new Integer(currentLine));
- }
- }
- String name = functions[i].getFunctionName();
- name = (name == null ? Constants.EMPTY_STRING : name);
- functionSources[i] = new FunctionSource(this, name, computeFunctionSource(0, 0, source), start);
- functionNames.add(name);
- scriptToFunction.put(functions[i], functionSources[i]);
- start = 0;
- }
- }
- //create the sparse array and populate the valid line numbers
- if(max == 0) {
- this.lines = NO_LINES;
- }
- else {
- this.lines = new LineData[max+1];
- for (Iterator iter = lineNumbers.iterator(); iter.hasNext();) {
- Integer value = (Integer) iter.next();
- this.lines[value.intValue()] = new LineData();
- iter.remove();
- }
- lineNumbers = null;
- }
- this.firstLine = new Integer(min);
- }
-
- /**
- * Returns the first executable line in the script
- *
- * @return the first executable line in the script
- */
- public Integer firstLine() {
- return this.firstLine;
- }
-
- /**
- * @return if this script represents the stdin script
- */
- public boolean isStdIn() {
- return this.uri.toString().endsWith("stdin"); //$NON-NLS-1$
- }
-
- /**
- * Collects all of the {@link DebuggableScript} objects for the functions
- * @param root the root script
- * @return the collected array of functions - {@link DebuggableScript} - objects or an empty array
- */
- DebuggableScript[] collectFunctions(DebuggableScript root) {
- ArrayList functions = new ArrayList();
- collectFunctions(root, functions);
- int size = functions.size();
- if(size < 1) {
- return RhinoDebuggerImpl.NO_SCRIPTS;
- }
- DebuggableScript[] funcs = new DebuggableScript[size];
- functions.toArray(funcs);
- return funcs;
- }
-
- /**
- * Recursively collects function {@link DebuggableScript}s
- *
- * @param root
- * @param collector
- */
- void collectFunctions(DebuggableScript root, List collector) {
- if(root.isFunction()) {
- collector.add(root);
- }
- for (int i = 0; i < root.getFunctionCount(); i++) {
- collectFunctions(root.getFunction(i), collector);
- }
- }
-
- /**
- * Computes the functions' source from the given compiled buffer
- *
- * @param start
- * @param end
- * @param source
- * @return the string for the source or <code>null</code> if it could not be computed
- */
- String computeFunctionSource(int start, int end, String source) {
- if(start > -1 && end <= source.length()) {
- return source.substring(start, end);
- }
- return null;
- }
-
- /**
- * Sets the id for the script, <code>null</code> will throw and {@link IllegalArgumentException}
- * @param id
- * @throws IllegalArgumentException if <code>null</code> is specified as the new id
- */
- public void setId(Long id) throws IllegalArgumentException {
- if(id == null) {
- throw new IllegalArgumentException();
- }
- this.scriptId = id;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if(obj instanceof ScriptSource) {
- return this.uri.toString().equals(((ScriptSource)obj).uri.toString());
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return this.uri.toString().hashCode();
- }
-
- /**
- * @return a new JSON map
- */
- public Object toJSON() {
- HashMap result = new HashMap();
- result.put(JSONConstants.SCRIPT_ID, this.scriptId);
- result.put(JSONConstants.LOCATION, this.uri.toString());
- result.put(JSONConstants.PROPERTIES, properties);
- result.put(JSONConstants.SOURCE, source);
- result.put(JSONConstants.GENERATED, Boolean.valueOf(generated));
- if(lines != null) {
- HashSet lineNumbers = new HashSet();
- for (int i = 0; i < lines.length; i++) {
- if(lines[i] != null) {
- lineNumbers.add(new Integer(i));
- }
- }
- result.put(JSONConstants.LINES, (lineNumbers == null ? Collections.EMPTY_SET : lineNumbers));
- }
- else {
- result.put(JSONConstants.LINES, Collections.EMPTY_SET);
- }
- result.put(JSONConstants.FUNCTIONS, (functionNames == null ? Collections.EMPTY_LIST : functionNames));
- return result;
- }
-
- /**
- * @return the id for this script object
- */
- public Long getId() {
- return scriptId;
- }
-
- /**
- * Returns the {@link Breakpoint} at the given line number or <code>null</code>
- * if there isn't one
- * @param lineNumber
- * @return
- */
- public Breakpoint getBreakpoint(Integer line, String functionName) {
- synchronized (lines) {
- if(line != null) {
- int value = line.intValue();
- if (value > -1 && value < lines.length && lines[value] != null) {
- return lines[value].breakpoint;
- }
- }
- if(functionNames != null) {
- int index = functionNames.indexOf(functionName);
- FunctionSource func = functionAt(index);
- if(func != null && lines[func.linenumber()] != null) {
- return lines[func.linenumber()].breakpoint;
- }
- }
- return null;
- }
- }
-
- /**
- * Returns if the line number is valid wrt this script
- *
- * @param lineNumber
- * @param functionName
- * @return true if the line number is valid wrt this script
- */
- public boolean isValid(Integer line, String functionName) {
- synchronized (lines) {
- if(line != null) {
- int value = line.intValue();
- if (value > -1 && value < lines.length) {
- return lines[value] != null;
- }
- }
- if(functionNames != null) {
- int index = functionNames.indexOf(functionName);
- FunctionSource func = functionAt(index);
- if(func != null) {
- return lines[func.linenumber()] != null;
- }
- }
- }
- return false;
- }
-
- /**
- * Copies items from the given object to this one
- * @param script
- */
- public void clone(ScriptSource script) {
- this.scriptId = script.scriptId;
- this.lines = script.lines;
- }
-
- /**
- * Adds a breakpoint to this script
- *
- * @param breakpoint
- */
- public void addBreakpoint(Breakpoint breakpoint) {
- synchronized (lines) {
- Integer lineNumber = breakpoint.lineNumber;
- if(lineNumber != null) {
- int value = lineNumber.intValue();
- if(lines[value] != null) {
- lines[value].breakpoint = breakpoint;
- }
- }
- else if(functionNames != null) {
- int index = functionNames.indexOf(breakpoint.functionName);
- FunctionSource func = functionAt(index);
- if(func != null) {
- if(lines[func.linenumber] != null) {
- lines[func.linenumber].breakpoint = breakpoint;
- }
- }
- }
- }
- }
-
- /**
- * Removes a breakpoint from this script
- *
- * @param breakpoint
- */
- public void removeBreakpoint(Breakpoint breakpoint) {
- synchronized (lines) {
- Integer lineNumber = breakpoint.lineNumber;
- if(lineNumber != null) {
- int value = lineNumber.intValue();
- if(lines[value] != null) {