소스 검색

Run game within terminal
Remove Debugger

geequlim 8 년 전
부모
커밋
590f9e51e7
3개의 변경된 파일186개의 추가작업 그리고 224개의 파일을 삭제
  1. 18 58
      package.json
  2. 160 160
      src/debug/godotDebugger.ts
  3. 8 6
      src/tool_manager.ts

+ 18 - 58
package.json

@@ -79,6 +79,14 @@
           ".gd"
         ],
         "configuration": "./configurations/gdscript-configuration.json"
+      },
+      {
+        "id": "properties",
+        "extensions": [
+          ".cfg",
+          "tres",
+          "tscn"
+        ]
       }
     ],
     "grammars": [
@@ -94,63 +102,16 @@
         "path": "./configurations/snippets.json"
       }
     ],
-    "breakpoints": [
-			{
-				"language": "gdscript"
-			}
-		],
-    "debuggers": [
-			{
-				"type": "godot",
-				"label": "Godot Game",
-				"program": "./out/src/debug/godotDebugger.js",
-				"runtime": "node",
-				"configurationSnippets": [
-					{
-						"label": "Godot Game: Launch",
-						"description": "A new configuration for launching a godot game",
-						"body": {
-							"type": "godot",
-							"request": "launch",
-              "name": "Godot Game",
-							"godot": "${1:The abusolut path of your godot binary}",
-              "projectDir": "^\"\\${workspaceRoot}\"",
-              "params": [],
-              "runWithEditor": false
-						}
-					}
-				],
-
-				"configurationAttributes": {
-					"launch": {
-						"required": [ "godot", "runWithEditor", "projectDir" ],
-						"properties": {
-							"godot": {
-								"type": "string",
-								"description": "The dirctory of your godot project",
-								"default": ""
-							},
-							"runWithEditor": {
-								"type": "boolean",
-								"description": "Launch the game with godot editor.",
-								"default": false
-							},
-              "projectDir": {
-								"type": "string",
-								"description": "The dirctory of your godot project",
-								"default": "${workspaceRoot}"
-							},
-              "params": {
-								"type": "array",
-								"description": "Addtional params passed to godot",
-								"default": []
-							}
-						}
-					}
-				},
-				"initialConfigurations": "godot.provideInitialDebugConfigurations"
-			}
-		]
+    "keybindings": [
+      {
+        "command": "godot.runWorkspace",
+        "key": "F5"
+      },
+      {
+        "command": "godot.runCurrentScene",
+        "key": "F6"
+      }
+    ]
   },
   "scripts": {
     "vscode:prepublish": "tsc -p ./",
@@ -167,7 +128,6 @@
   },
   "dependencies": {
     "glob": "^7.1.1",
-    "node-cmd": "1.2.0",
     "vscode-debugprotocol": "^1.17.0",
 		"vscode-debugadapter": "^1.17.0"
   }

+ 160 - 160
src/debug/godotDebugger.ts

@@ -1,162 +1,162 @@
-import {
-	DebugSession,
-	InitializedEvent, TerminatedEvent, StoppedEvent, BreakpointEvent, OutputEvent, Event,
-	Thread, StackFrame, Scope, Source, Handles, Breakpoint
-} from 'vscode-debugadapter';
-import {DebugProtocol} from 'vscode-debugprotocol';
-import * as fs from 'fs';
-import * as path from 'path';
-const cmd = require('node-cmd');
-
-export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
-	godot: string;
-	projectDir: string;
-	runWithEditor: boolean;
-	params: string[];
-}
-
-class GodotDebugSession extends DebugSession {
-
-	// we don't support multiple threads, so we can use a hardcoded ID for the default thread
-	private static THREAD_ID = 1;
-
-	/**
-	 * Creates a new debug adapter that is used for one debug session.
-	 * We configure the default implementation of a debug adapter here.
-	 */
-	public constructor() {
-		super();
-	}
-
-	/**
-	 * The 'initialize' request is the first request called by the frontend
-	 * to interrogate the features the debug adapter provides.
-	 */
-	protected initializeRequest(response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments): void {
-
-		// since this debug adapter can accept configuration requests like 'setBreakpoint' at any time,
-		// we request them early by sending an 'initializeRequest' to the frontend.
-		// The frontend will end the configuration sequence by calling 'configurationDone' request.
-		this.sendEvent(new InitializedEvent());
-
-		// This debug adapter implements the configurationDoneRequest.
-		response.body.supportsConfigurationDoneRequest = true;
-
-		// make VS Code to use 'evaluate' when hovering over source
-		response.body.supportsEvaluateForHovers = true;
-
-		// make VS Code to show a 'step back' button
-		response.body.supportsStepBack = true;
-
-		this.log("initializeRequest");
-		this.log_err("initializeRequest");
-		this.log_console("initializeRequest");
-		this.sendResponse(response);
-	}
-
-	protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
-		for(let key of Object.keys(args))
-			this.log(`${key} : ${args[key]}`);
-		let workspaceValid = false
-        if(args.godot && fs.existsSync(args.godot) && fs.statSync(args.godot).isFile() ) {
-			if(args.projectDir && fs.existsSync(args.projectDir) && fs.statSync(args.projectDir).isDirectory() ) {
-				let cfg = path.join(args.projectDir, "engine.cfg");
-				if( fs.existsSync(cfg) && fs.statSync(cfg).isFile())
-					workspaceValid = true;
-			}
-		}
-		if(workspaceValid) {
-			let params = `-path ${args.projectDir} `;
-			if(args.runWithEditor)
-				params += "-e";
-			if(args.params) {
-				for(let p of args.params)
-					params += " " + p;
-			}
-			let cmdcontent = `${args.godot} ${params}`;
-			this.log(cmdcontent)
-			//  TODO: print outputs in terminal console
-			cmd.run(cmdcontent);
-			this.sendEvent(new TerminatedEvent());
-		}
-		else {
-			this.log_err("Invalidate path of projectDir or godot:");
-			this.log_err(JSON.stringify(args, null, '\t'));
-			this.sendEvent(new TerminatedEvent());
-		}
-	}
+// import {
+// 	DebugSession,
+// 	InitializedEvent, TerminatedEvent, StoppedEvent, BreakpointEvent, OutputEvent, Event,
+// 	Thread, StackFrame, Scope, Source, Handles, Breakpoint
+// } from 'vscode-debugadapter';
+// import {DebugProtocol} from 'vscode-debugprotocol';
+// import * as fs from 'fs';
+// import * as path from 'path';
+// const cmd = require('node-cmd');
+
+// export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
+// 	godot: string;
+// 	projectDir: string;
+// 	runWithEditor: boolean;
+// 	params: string[];
+// }
+
+// class GodotDebugSession extends DebugSession {
+
+// 	// we don't support multiple threads, so we can use a hardcoded ID for the default thread
+// 	private static THREAD_ID = 1;
+
+// 	/**
+// 	 * Creates a new debug adapter that is used for one debug session.
+// 	 * We configure the default implementation of a debug adapter here.
+// 	 */
+// 	public constructor() {
+// 		super();
+// 	}
+
+// 	/**
+// 	 * The 'initialize' request is the first request called by the frontend
+// 	 * to interrogate the features the debug adapter provides.
+// 	 */
+// 	protected initializeRequest(response: DebugProtocol.InitializeResponse, args: DebugProtocol.InitializeRequestArguments): void {
+
+// 		// since this debug adapter can accept configuration requests like 'setBreakpoint' at any time,
+// 		// we request them early by sending an 'initializeRequest' to the frontend.
+// 		// The frontend will end the configuration sequence by calling 'configurationDone' request.
+// 		this.sendEvent(new InitializedEvent());
+
+// 		// This debug adapter implements the configurationDoneRequest.
+// 		response.body.supportsConfigurationDoneRequest = true;
+
+// 		// make VS Code to use 'evaluate' when hovering over source
+// 		response.body.supportsEvaluateForHovers = true;
+
+// 		// make VS Code to show a 'step back' button
+// 		response.body.supportsStepBack = true;
+
+// 		this.log("initializeRequest");
+// 		this.log_err("initializeRequest");
+// 		this.log_console("initializeRequest");
+// 		this.sendResponse(response);
+// 	}
+
+// 	protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
+// 		for(let key of Object.keys(args))
+// 			this.log(`${key} : ${args[key]}`);
+// 		let workspaceValid = false
+//         if(args.godot && fs.existsSync(args.godot) && fs.statSync(args.godot).isFile() ) {
+// 			if(args.projectDir && fs.existsSync(args.projectDir) && fs.statSync(args.projectDir).isDirectory() ) {
+// 				let cfg = path.join(args.projectDir, "engine.cfg");
+// 				if( fs.existsSync(cfg) && fs.statSync(cfg).isFile())
+// 					workspaceValid = true;
+// 			}
+// 		}
+// 		if(workspaceValid) {
+// 			let params = `-path ${args.projectDir} `;
+// 			if(args.runWithEditor)
+// 				params += "-e";
+// 			if(args.params) {
+// 				for(let p of args.params)
+// 					params += " " + p;
+// 			}
+// 			let cmdcontent = `${args.godot} ${params}`;
+// 			this.log(cmdcontent)
+// 			//  TODO: print outputs in terminal console
+// 			cmd.run(cmdcontent);
+// 			this.sendEvent(new TerminatedEvent());
+// 		}
+// 		else {
+// 			this.log_err("Invalidate path of projectDir or godot:");
+// 			this.log_err(JSON.stringify(args, null, '\t'));
+// 			this.sendEvent(new TerminatedEvent());
+// 		}
+// 	}
 	
 
-	protected setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments): void {
-
-		this.sendResponse(response);
-	}
-
-	protected threadsRequest(response: DebugProtocol.ThreadsResponse): void {
-
-		// return the default thread
-		response.body = {
-			threads: [
-				new Thread(GodotDebugSession.THREAD_ID, "thread 1")
-			]
-		};
-		this.sendResponse(response);
-	}
-
-	/**
-	 * Returns a fake 'stacktrace' where every 'stackframe' is a word from the current line.
-	 */
-	protected stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments): void {
-		this.sendResponse(response);
-	}
-
-	protected scopesRequest(response: DebugProtocol.ScopesResponse, args: DebugProtocol.ScopesArguments): void {
-		this.sendResponse(response);
-	}
-
-	protected variablesRequest(response: DebugProtocol.VariablesResponse, args: DebugProtocol.VariablesArguments): void {
-		this.sendResponse(response);
-	}
-
-	protected continueRequest(response: DebugProtocol.ContinueResponse, args: DebugProtocol.ContinueArguments): void {
-		this.sendEvent(new TerminatedEvent());
-	}
-
-	protected reverseContinueRequest(response: DebugProtocol.ReverseContinueResponse, args: DebugProtocol.ReverseContinueArguments) : void {
-		this.sendResponse(response);
- 	}
-
-	protected nextRequest(response: DebugProtocol.NextResponse, args: DebugProtocol.NextArguments): void {
-		this.sendResponse(response);
-	}
-
-	protected stepBackRequest(response: DebugProtocol.StepBackResponse, args: DebugProtocol.StepBackArguments): void {
-		this.sendResponse(response);
-	}
-
-	protected evaluateRequest(response: DebugProtocol.EvaluateResponse, args: DebugProtocol.EvaluateArguments): void {
-		this.sendResponse(response);
-	}
-
-	/**
-	 * Fire StoppedEvent if line is not empty.
-	 */
-	private fireStepEvent(response: DebugProtocol.Response, ln: number): boolean {
-		return false;
-	}
-
-	private log(msg: string) {
-		const e = new OutputEvent(msg, "stdout");
-		this.sendEvent(e);
-	}
-	private log_err(msg: string) {
-		const e = new OutputEvent(msg, "stderr");
-		this.sendEvent(e);
-	}
-	private log_console(msg: string) {
-		const e = new OutputEvent(msg, "console");
-		this.sendEvent(e);
-	}
-}
-
-DebugSession.run(GodotDebugSession);
+// 	protected setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments): void {
+
+// 		this.sendResponse(response);
+// 	}
+
+// 	protected threadsRequest(response: DebugProtocol.ThreadsResponse): void {
+
+// 		// return the default thread
+// 		response.body = {
+// 			threads: [
+// 				new Thread(GodotDebugSession.THREAD_ID, "thread 1")
+// 			]
+// 		};
+// 		this.sendResponse(response);
+// 	}
+
+// 	/**
+// 	 * Returns a fake 'stacktrace' where every 'stackframe' is a word from the current line.
+// 	 */
+// 	protected stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments): void {
+// 		this.sendResponse(response);
+// 	}
+
+// 	protected scopesRequest(response: DebugProtocol.ScopesResponse, args: DebugProtocol.ScopesArguments): void {
+// 		this.sendResponse(response);
+// 	}
+
+// 	protected variablesRequest(response: DebugProtocol.VariablesResponse, args: DebugProtocol.VariablesArguments): void {
+// 		this.sendResponse(response);
+// 	}
+
+// 	protected continueRequest(response: DebugProtocol.ContinueResponse, args: DebugProtocol.ContinueArguments): void {
+// 		this.sendEvent(new TerminatedEvent());
+// 	}
+
+// 	protected reverseContinueRequest(response: DebugProtocol.ReverseContinueResponse, args: DebugProtocol.ReverseContinueArguments) : void {
+// 		this.sendResponse(response);
+//  	}
+
+// 	protected nextRequest(response: DebugProtocol.NextResponse, args: DebugProtocol.NextArguments): void {
+// 		this.sendResponse(response);
+// 	}
+
+// 	protected stepBackRequest(response: DebugProtocol.StepBackResponse, args: DebugProtocol.StepBackArguments): void {
+// 		this.sendResponse(response);
+// 	}
+
+// 	protected evaluateRequest(response: DebugProtocol.EvaluateResponse, args: DebugProtocol.EvaluateArguments): void {
+// 		this.sendResponse(response);
+// 	}
+
+// 	/**
+// 	 * Fire StoppedEvent if line is not empty.
+// 	 */
+// 	private fireStepEvent(response: DebugProtocol.Response, ln: number): boolean {
+// 		return false;
+// 	}
+
+// 	private log(msg: string) {
+// 		const e = new OutputEvent(msg, "stdout");
+// 		this.sendEvent(e);
+// 	}
+// 	private log_err(msg: string) {
+// 		const e = new OutputEvent(msg, "stderr");
+// 		this.sendEvent(e);
+// 	}
+// 	private log_console(msg: string) {
+// 		const e = new OutputEvent(msg, "console");
+// 		this.sendEvent(e);
+// 	}
+// }
+
+// DebugSession.run(GodotDebugSession);

+ 8 - 6
src/tool_manager.ts

@@ -11,7 +11,6 @@ var glob = require("glob")
 import config from './config';
 import * as path from 'path';
 import * as fs from 'fs';
-const cmd = require('node-cmd');
 class ToolManager {
 
   private workspaceDir: string = "";
@@ -51,7 +50,7 @@ class ToolManager {
       vscode.commands.registerCommand('godot.updateWorkspaceSymbols', this.loadWorkspaceSymbols.bind(this)),
       vscode.commands.registerCommand('godot.runWorkspace', ()=>{this.openWorkspaceWithEditor()}),
       vscode.commands.registerCommand('godot.openWithEditor', ()=>{this.openWorkspaceWithEditor("-e")}),
-      vscode.commands.registerCommand('godot.runCurrentScene', this.runCurrentScenr.bind(this)),
+      vscode.commands.registerCommand('godot.runCurrentScene', this.runCurrentScene.bind(this)),
       vscode.commands.registerCommand('godot.provideInitialDebugConfigurations', this.getDefaultDebugConfig.bind(this))
     );
   }
@@ -134,10 +133,10 @@ class ToolManager {
   private loadWorkspaceSymbols() {
     this.loadAllNodesInWorkspace();
     this.loadAllSymbols().then(symbols=>{
-        vscode.window. setStatusBarMessage("$(check) Workspace symbols", 5000);
+        vscode.window.setStatusBarMessage("$(check) Workspace symbols", 5000);
         config.setAllSymbols(symbols);
     }).catch(e=>{
-        vscode.window. setStatusBarMessage("$(x) Workspace symbols", 5000);
+        vscode.window.setStatusBarMessage("$(x) Workspace symbols", 5000);
     });
   }
 
@@ -160,11 +159,14 @@ class ToolManager {
       vscode.window.showErrorMessage("Invalid editor path to run the project");
     }
     else {
-      cmd.run(`${editorPath} ${params}`);
+      let terminal = vscode.window.createTerminal("Godot");
+      let cmmand = `${editorPath} ${params}`;
+      terminal.sendText(cmmand, true);
+      terminal.show();
     }
   }
 
-  private runCurrentScenr() {
+  private runCurrentScene() {
     let scenePath = null
     if(vscode.window.activeTextEditor)
       scenePath = vscode.workspace.asRelativePath(vscode.window.activeTextEditor.document.uri);