Browse Source

fix: VSCode extension cleanup

Matthias Ladkau 3 years ago
parent
commit
e2b396579d

+ 56 - 27
ecal-support/README.md

@@ -1,16 +1,18 @@
 # VSCode extension for ECAL
 
-## Folder content
+The extension adds support for the Event Condition Action Language (ECAL) to VS Code. The extension requires VSCode 1.50 or higher.
 
-- `package.json` - manifest file
-- `syntaxes/ecal.tmLanguage.json` - Text mate grammar file
-- `language-configuration.json` - language configuration for VSCode
+<p align="center">
+  <img height="600px" style="height:600px;" src="https://devt.de/krotik/ecal/raw/master/ecal-support/images/screenshot.png">
+</p>
 
-## Build the extention
-
-To build the extention you need `npm` installed.
-
-VSIX file can be build with `npm run package`
+The extension supports the following features:
+- Syntax highlighting
+- Debugger support:
+  - Setting / Removing of break points
+  - Stepping support (step-in, step-out and step-over)
+  - Stack trace inspection of suspended threads
+  - Variable inspection of suspended threads
 
 ## Install the extension
 
@@ -18,31 +20,58 @@ The extention can be installed using a precompiled VSIX file which can be downlo
 
 https://devt.de/krotik/ecal/releases
 
-## Launch config for ecal projects
+Alternatively you can build the extension yourself. To build the extension you need `npm` installed. Download the source code from the [repository](https://devt.de/krotik/ecal). First install all required dependencies with `npm -i`. Then compile and package the extension with `npm run compile` and `npm run package`. The folder should now contain a VSIX file.
+
+## Using the extension
 
+The extension can connect to a running ECAL debug server. The ECAL interpreter which can run the debug server needs to be downloaded separately [here](https://devt.de/krotik/ecal/releases). The debug server has to run first and needs the VSCode project directory as its root directory. An ECAL debug server can be started with the following command line:
+```
+ecal debug -server -dir myproj myproj/entry.ecal
+```
+
+The `ecal` interpreter starts in debug mode and starts a debug server on the default address `localhost:33274`.
+
+After opening the project directory VSCode needs a launch configuration (located in `.vscode/launch.json`) to be able to connect to the debug server:
 ```
 {
-	"version": "0.2.0",
-	"configurations": [
-		{
-			"type": "ecaldebug",
-			"request": "launch",
-			"name": "Debug ECAL script with ECAL Debug Server",
-
-			"serverURL": "localhost:43806",
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "type": "ecaldebug",
+            "request": "launch",
+            "name": "Debug ECAL script with ECAL Debug Server",
+            "host": "localhost",
+            "port": 33274,
             "dir": "${workspaceFolder}",
-			"executeOnEntry": true,
-			"trace": false,
-		}
-	]
+            "executeOnEntry": true
+        }
+    ]
 }
 ```
+- host / port: Connection information for the ECAL debug server.
+- dir: Root directory of the ECAL debug server.
+- executeOnEntry: Restart the interpreter when connecting to the server. If this is set to false then the code needs to be manually started from the ECAL debug server console.
 
-- serverURL: URL of the ECAL debug server.
-- dir: Root directory for ECAL debug server.
-- executeOnEntry: (optional) Execute the ECAL script on entry. If this is set to false then code needs to be manually started from the ECAL debug server console.
-- trace: (optional) Enable tracing messages for debug adapter (useful when debugging the debugger).
+Advanced debugging commands can be issued via the `Debug Console`. Type `?` there to get more information.
 
 ## Developing the extension
 
-In VSCode the extention can be launched and debugged using the included launch configuration. Press F5 to start a VS Code instance with ECAL support extention form the development code.
+In VSCode the extension can be launched and debugged using the included launch configuration. Press F5 to start a VSCode instance with the ECAL extension from the development code.
+
+The usual `npm run` commands for development are available:
+```
+$ npm run
+Scripts available in ecal-support via `npm run-script`:
+  compile
+    tsc
+  watch
+    tsc -w
+  package
+    vsce package
+  lint
+    eslint 'src/**/*.{js,ts,tsx}' --quiet
+  pretty
+    prettier --write .
+```
+
+For more in-depth information about VSCode debug extensions have a look at the extensive extension documentation: https://code.visualstudio.com/api/extension-guides/debugger-extension

BIN
ecal-support/images/screenshot.png


+ 0 - 24
ecal-support/notes.txt

@@ -1,24 +0,0 @@
-debug extension - how to declare it - must have a bin file
-https://code.visualstudio.com/api/extension-guides/debugger-extension
-
-https://github.com/Microsoft/vscode-mock-debug/blob/d33d6057c2d7d7f0495e26d6fa8844c8336b2408/src/extension.ts#L79
-
-
-https://microsoft.github.io/debug-adapter-protocol/overview
-
-https://github.com/google/go-dap
-
-https://github.com/golang/vscode-go/blob/master/package.json
-
-
-Firefox vscode extension
-https://github.com/firefox-devtools/vscode-firefox-debug
-
-
-Blog:
-https://code.visualstudio.com/blogs/2018/07/12/introducing-logpoints-and-auto-attach
-
-
-BUG:
-https://github.com/Microsoft/vscode/issues/63896
-

+ 1 - 2
ecal-support/package.json

@@ -129,8 +129,7 @@
             "host": "localhost",
             "port": 33274,
             "dir": "${workspaceFolder}",
-            "executeOnEntry": true,
-            "trace": false
+            "executeOnEntry": true
           }
         ]
       }

+ 3 - 31
ecal-support/src/ecalDebugAdapter.ts

@@ -68,6 +68,8 @@ export class ECALDebugSession extends LoggingDebugSession {
   private config: ECALDebugArguments = {} as ECALDebugArguments;
 
   private unconfirmedBreakpoints: DebugProtocol.Breakpoint[] = [];
+  private frameVariableScopes: Record<number, Record<string, any>> = {};
+  private frameVariableGlobalScopes: Record<number, Record<string, any>> = {};
 
   private bpCount: number = 1;
   private sfCount: number = 1;
@@ -89,7 +91,6 @@ export class ECALDebugSession extends LoggingDebugSession {
     // Add event handlers
 
     this.client.on("pauseOnBreakpoint", (e: ClientBreakEvent) => {
-      console.log("#### send StoppedEvent event:", e.tid, typeof e.tid);
       this.sendEvent(new StoppedEvent("breakpoint", e.tid));
     });
 
@@ -106,7 +107,6 @@ export class ECALDebugSession extends LoggingDebugSession {
                   toConfirm.line === line &&
                   toConfirm.source?.name === breakpointString
                 ) {
-                  console.log("Confirmed breakpoint:", breakpointString);
                   toConfirm.verified = true;
                   this.sendEvent(new BreakpointEvent("changed", toConfirm));
                 }
@@ -133,11 +133,8 @@ export class ECALDebugSession extends LoggingDebugSession {
    * interrogates the debug adapter on the features which it provides.
    */
   protected initializeRequest(
-    response: DebugProtocol.InitializeResponse,
-    args: DebugProtocol.InitializeRequestArguments
+    response: DebugProtocol.InitializeResponse
   ): void {
-    console.log("##### initializeRequest:", args);
-
     response.body = response.body || {};
 
     // The adapter implements the configurationDoneRequest.
@@ -162,8 +159,6 @@ export class ECALDebugSession extends LoggingDebugSession {
     response: DebugProtocol.ConfigurationDoneResponse,
     args: DebugProtocol.ConfigurationDoneArguments
   ): void {
-    console.log("##### configurationDoneRequest");
-
     super.configurationDoneRequest(response, args);
     this.wgConfig.done();
   }
@@ -175,8 +170,6 @@ export class ECALDebugSession extends LoggingDebugSession {
     response: DebugProtocol.LaunchResponse,
     args: ECALDebugArguments
   ) {
-    console.log("##### launchRequest:", args);
-
     this.config = args; // Store the configuration
 
     // Setup logging either verbose or just on errors
@@ -196,8 +189,6 @@ export class ECALDebugSession extends LoggingDebugSession {
       this.client.reload();
     }
 
-    console.log("##### launchRequest result:", response.body);
-
     this.sendResponse(response);
   }
 
@@ -205,8 +196,6 @@ export class ECALDebugSession extends LoggingDebugSession {
     response: DebugProtocol.SetBreakpointsResponse,
     args: DebugProtocol.SetBreakpointsArguments
   ): Promise<void> {
-    console.log("##### setBreakPointsRequest:", args);
-
     let breakpoints: DebugProtocol.Breakpoint[] = [];
 
     if (args.source.path?.indexOf(this.config.dir) === 0) {
@@ -263,8 +252,6 @@ export class ECALDebugSession extends LoggingDebugSession {
       breakpoints,
     };
 
-    console.error("##### setBreakPointsRequest result:", response.body);
-
     this.sendResponse(response);
   }
 
@@ -303,8 +290,6 @@ export class ECALDebugSession extends LoggingDebugSession {
   protected async threadsRequest(
     response: DebugProtocol.ThreadsResponse
   ): Promise<void> {
-    console.log("##### threadsRequest");
-
     const status = await this.client.status();
     const threads = [];
 
@@ -320,21 +305,14 @@ export class ECALDebugSession extends LoggingDebugSession {
       threads,
     };
 
-    console.log("##### threadsRequest result:", response.body);
-
     this.sendResponse(response);
   }
 
-  private frameVariableScopes: Record<number, Record<string, any>> = {};
-  private frameVariableGlobalScopes: Record<number, Record<string, any>> = {};
-
   protected async stackTraceRequest(
     response: DebugProtocol.StackTraceResponse,
     args: DebugProtocol.StackTraceArguments
   ) {
     const stackFrames: StackFrame[] = [];
-    console.log("##### stackTraceRequest:", args);
-
     const status = await this.client.status();
     const threadStatus = status?.threads[String(args.threadId)];
 
@@ -397,8 +375,6 @@ export class ECALDebugSession extends LoggingDebugSession {
     response: DebugProtocol.ScopesResponse,
     args: DebugProtocol.ScopesArguments
   ): void {
-    console.error("##### scopesRequest:", args);
-
     response.body = {
       scopes: [
         new Scope("Local", this.getVariableScopeId(args.frameId, "local")),
@@ -413,8 +389,6 @@ export class ECALDebugSession extends LoggingDebugSession {
     response: DebugProtocol.VariablesResponse,
     args: DebugProtocol.VariablesArguments
   ) {
-    console.error("##### variablesRequest", args);
-
     let vs: Record<string, any> = {};
     let variables: Variable[] = [];
 
@@ -442,8 +416,6 @@ export class ECALDebugSession extends LoggingDebugSession {
       }
     }
 
-    console.log("##### variablesRequest response", variables);
-
     response.body = {
       variables,
     };

+ 0 - 2
ecal-support/src/ecalDebugClient.ts

@@ -118,8 +118,6 @@ export class ECALDebugClient extends EventEmitter {
         const tid = parseInt(tidString);
 
         if (thread.threadRunning === false && !this.threadInspection[tid]) {
-          console.log("#### Thread was stopped!!");
-
           // A thread was stopped inspect it
 
           let inspection: ThreadInspection = {

+ 2 - 3
examples/fib/.vscode/launch.json

@@ -8,8 +8,7 @@
             "host": "localhost",
             "port": 33274,
             "dir": "${workspaceFolder}",
-            "executeOnEntry": true,
-            "trace": true
+            "executeOnEntry": true
         }
     ]
-}
+}