Browse Source

Add command to list godot native classes

Geequlim 5 years ago
parent
commit
3645e431d3
2 changed files with 20 additions and 0 deletions
  1. 4 0
      package.json
  2. 16 0
      src/lsp/NativeDocumentManager.ts

+ 4 - 0
package.json

@@ -34,6 +34,10 @@
 			{
 				"command": "godot-tool.run_project",
 				"title": "Godot Tools: Run workspace as Godot project"
+			},
+			{
+				"command": "godot-tool.list_native_classes",
+				"title": "Godot Tools: List native classes of godot"
 			}
 		],
 		"configuration": {

+ 16 - 0
src/lsp/NativeDocumentManager.ts

@@ -14,6 +14,7 @@ marked.setOptions({
 const enum WebViewMessageType {
 	INSPECT_NATIVE_SYMBOL = 'INSPECT_NATIVE_SYMBOL',
 };
+const LIST_NATIVE_CLASS_COMMAND = 'godot-tool.list_native_classes';
 
 export default class NativeDocumentManager extends EventEmitter {
 	
@@ -39,6 +40,21 @@ export default class NativeDocumentManager extends EventEmitter {
 				}
 			}
 		});
+		
+		vscode.commands.registerCommand(LIST_NATIVE_CLASS_COMMAND, this.list_native_classes.bind(this));
+	}
+	
+	private async list_native_classes() {
+		let classname = await vscode.window.showQuickPick(
+			Object.keys(this.native_classes).sort(),
+			{
+				placeHolder: 'Type godot class name here',
+				canPickMany: false
+			}
+		);
+		if (classname) {
+			this.inspect_native_symbol({native_class: classname, symbol_name: classname});
+		}
 	}
 	
 	private inspect_native_symbol(params: NativeSymbolInspectParams) {