public override void Initialize(Response response, Table args)
		{
#if DOTNET_CORE
			SendText("Connected to MoonSharp {0} [{1}]",
					 Script.VERSION,
					 Script.GlobalOptions.Platform.GetPlatformName());
#else
			SendText("Connected to MoonSharp {0} [{1}] on process {2} (PID {3})",
					 Script.VERSION,
					 Script.GlobalOptions.Platform.GetPlatformName(),
					 System.Diagnostics.Process.GetCurrentProcess().ProcessName,
					 System.Diagnostics.Process.GetCurrentProcess().Id);
#endif

			SendText("Debugging script '{0}'; use the debug console to debug another script.", m_Debug.Name);

			SendText("Type '!help' in the Debug Console for available commands.");

			SendResponse(response, new Capabilities()
			{
				// This debug adapter does not need the configurationDoneRequest.
				supportsConfigurationDoneRequest = false,

				// This debug adapter does not support function breakpoints.
				supportsFunctionBreakpoints = false,

				// This debug adapter doesn't support conditional breakpoints.
				supportsConditionalBreakpoints = false,

				// This debug adapter does not support a side effect free evaluate request for data hovers.
				supportsEvaluateForHovers = false,

				// This debug adapter does not support exception breakpoint filters
				exceptionBreakpointFilters = new object[0]
			});

			// Debugger is ready to accept breakpoints immediately
			SendEvent(new InitializedEvent());

			m_Debug.Client = this;
		}
		public void SendErrorResponse(Response response, int id, string format, object arguments = null, bool user = true, bool telemetry = false)
		{
			var msg = new Message(id, format, arguments, user, telemetry);
			var message = Utilities.ExpandVariables(msg.format, msg.variables);
			response.SetErrorBody(message, new ErrorResponseBody(msg));
			SendMessage(response);
		}
Ejemplo n.º 3
0
		protected abstract void DispatchRequest(string command, Table args, Response response);
		public override void Continue(Response response, Table arguments)
		{
			SendList();
			SendResponse(response);
		}
		public override void Variables(Response response, Table arguments)
		{
			SendResponse(response);
		}
		public override void StepOut(Response response, Table arguments)
		{
			SendList();
			SendResponse(response);
		}
		public override void SetBreakpoints(Response response, Table args)
		{
			SendResponse(response);
		}
		public abstract void Evaluate(Response response, Table arguments);
		public abstract void SetBreakpoints(Response response, Table arguments);
		public virtual void SetExceptionBreakpoints(Response response, Table arguments)
		{
		}
		public abstract void Disconnect(Response response, Table arguments);
		public abstract void Attach(Response response, Table arguments);
		public abstract void Launch(Response response, Table arguments);
		public abstract void Initialize(Response response, Table args);
		protected override void DispatchRequest(string command, Table args, Response response)
		{
			if (args == null)
			{
				args = new Table(null);
			}

			try
			{
				switch (command)
				{

					case "initialize":

						if (args["linesStartAt1"] != null)
						_clientLinesStartAt1 = args.Get("linesStartAt1").ToObject<bool>();

						var pathFormat = args.Get("pathFormat").ToObject<string>();
						if (pathFormat != null)
						{
							switch (pathFormat)
							{
								case "uri":
									_clientPathsAreURI = true;
									break;
								case "path":
									_clientPathsAreURI = false;
									break;
								default:
									SendErrorResponse(response, 1015, "initialize: bad value '{_format}' for pathFormat", new { _format = pathFormat });
									return;
							}
						}
						Initialize(response, args);
						break;

					case "launch":
						Launch(response, args);
						break;

					case "attach":
						Attach(response, args);
						break;

					case "disconnect":
						Disconnect(response, args);
						break;

					case "next":
						Next(response, args);
						break;

					case "continue":
						Continue(response, args);
						break;

					case "stepIn":
						StepIn(response, args);
						break;

					case "stepOut":
						StepOut(response, args);
						break;

					case "pause":
						Pause(response, args);
						break;

					case "stackTrace":
						StackTrace(response, args);
						break;

					case "scopes":
						Scopes(response, args);
						break;

					case "variables":
						Variables(response, args);
						break;

					case "source":
						Source(response, args);
						break;

					case "threads":
						Threads(response, args);
						break;

					case "setBreakpoints":
						SetBreakpoints(response, args);
						break;

					case "setFunctionBreakpoints":
						SetFunctionBreakpoints(response, args);
						break;

					case "setExceptionBreakpoints":
						SetExceptionBreakpoints(response, args);
						break;

					case "evaluate":
						Evaluate(response, args);
						break;

					default:
						SendErrorResponse(response, 1014, "unrecognized request: {_request}", new { _request = command });
						break;
				}
			}
			catch (Exception e)
			{
				SendErrorResponse(response, 1104, "error while processing request '{_request}' (exception: {_exception})", new { _request = command, _exception = e.Message });
			}

			if (command == "disconnect")
			{
				Stop();
			}
		}
		public virtual void Source(Response response, Table arguments)
		{
			SendErrorResponse(response, 1020, "Source not supported");
		}
		public abstract void Threads(Response response, Table arguments);
		public abstract void Continue(Response response, Table arguments);
		public override void Evaluate(Response response, Table args)
		{
			var expression = getString(args, "expression");
			var context = getString(args, "context") ?? "hover";

			if (context == "repl")
				ExecuteRepl(expression);

			SendResponse(response);
		}
		public abstract void Next(Response response, Table arguments);
		public override void StackTrace(Response response, Table args)
		{
			SendResponse(response);
		}
		public abstract void StepOut(Response response, Table arguments);
		public override void Threads(Response response, Table arguments)
		{
			var threads = new List<Thread>() { new Thread(0, "Main Thread") };
			SendResponse(response, new ThreadsResponseBody(threads));
		}
		public abstract void Pause(Response response, Table arguments);
		public override void Attach(Response response, Table arguments)
		{
			SendResponse(response);
		}
		public abstract void StackTrace(Response response, Table arguments);
		public override void Disconnect(Response response, Table arguments)
		{
			SendResponse(response);
		}
		public abstract void Scopes(Response response, Table arguments);
Ejemplo n.º 29
0
		private void Dispatch(string req)
		{
			try
			{
				Table request = JsonTableConverter.JsonToTable(req);
				if (request != null && request["type"].ToString() == "request")
				{
					if (TRACE)
						Console.Error.WriteLine(string.Format("C {0}: {1}", request["command"], req));

					var response = new Response(request);

					DispatchRequest(request.Get("command").String, request.Get("arguments").Table, response);

					SendMessage(response);
				}
			}
			catch
			{
			}
		}
		public abstract void Variables(Response response, Table arguments);