mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2025-12-31 13:48:24 +03:00
stop crash when open single gdscriot
This commit is contained in:
66075
doc/classes.json
Normal file
66075
doc/classes.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,8 @@
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"workspaceContains:engine.cfg"
|
||||
"workspaceContains:engine.cfg",
|
||||
"onLanguage:gdscript"
|
||||
],
|
||||
"main": "./out/src/extension",
|
||||
"contributes": {
|
||||
|
||||
@@ -121,7 +121,6 @@ class Config {
|
||||
let items: CompletionItem[] = [];
|
||||
for (let path of Object.keys(this.symbols)) {
|
||||
const script = this.symbols[path];
|
||||
console.log(script);
|
||||
const addScriptItems = (items, kind: CompletionItemKind, kindName:string = "Symbol")=>{
|
||||
const _items: CompletionItem[] = [];
|
||||
for (let name of Object.keys(items)) {
|
||||
@@ -130,7 +129,6 @@ class Config {
|
||||
item.documentation = `${kindName} defined in ${item.detail}`;
|
||||
_items.push(item);
|
||||
}
|
||||
console.log(_items);
|
||||
return _items;
|
||||
}
|
||||
items = [...items, ...addScriptItems(script.classes, CompletionItemKind.Class, "Class")];
|
||||
|
||||
@@ -7,8 +7,7 @@ let tool: ToolManager = null;
|
||||
|
||||
export function activate(context: ExtensionContext) {
|
||||
tool = new ToolManager(context);
|
||||
// context.subscriptions.push(tool);
|
||||
context.subscriptions.push(new WindowWatch());
|
||||
context.subscriptions.push(tool);
|
||||
context.subscriptions.push(new WindowWatch());
|
||||
console.log("[GodotTools]: Extension Activated");
|
||||
}
|
||||
|
||||
@@ -12,14 +12,23 @@ class ToolManager {
|
||||
private symbolprovider: GDScriptSymbolProvider = null;
|
||||
private workspacesymbolprovider: GDScriptWorkspaceSymbolProvider = null;
|
||||
private _disposable: vscode.Disposable;
|
||||
private _context: vscode.ExtensionContext;
|
||||
|
||||
constructor(context: vscode.ExtensionContext) {
|
||||
this.workspaceDir = vscode.workspace.rootPath.replace(/\\/g, "/");
|
||||
this.validate();
|
||||
this.loadWorkspaceSymbols();
|
||||
this._context = context;
|
||||
this.workspaceDir = vscode.workspace.rootPath;
|
||||
if(this.workspaceDir) {
|
||||
this.workspaceDir = this.workspaceDir.replace(/\\/g, "/");
|
||||
this.loadWorkspaceSymbols();
|
||||
}
|
||||
if(0) { // TODO: EditorServer validate
|
||||
this.validate();
|
||||
}
|
||||
this.loadClasses();
|
||||
|
||||
this.symbolprovider = new GDScriptSymbolProvider();
|
||||
vscode.languages.registerDocumentSymbolProvider('gdscript', this.symbolprovider);
|
||||
|
||||
this.workspacesymbolprovider = new GDScriptWorkspaceSymbolProvider();
|
||||
vscode.languages.registerWorkspaceSymbolProvider(this.workspacesymbolprovider);
|
||||
|
||||
@@ -71,12 +80,13 @@ class ToolManager {
|
||||
}
|
||||
|
||||
loadClasses() {
|
||||
if(config.loadClasses(path.join(this.workspaceDir, ".vscode", "classes.json"))) {
|
||||
vscode.window.showInformationMessage("Update GDScript documentations done");
|
||||
}
|
||||
else {
|
||||
vscode.window.showWarningMessage("Update GDScript documentations failed");
|
||||
}
|
||||
let done :boolean = false;
|
||||
if(this.workspaceDir)
|
||||
done = config.loadClasses(path.join(this.workspaceDir, ".vscode", "classes.json"));
|
||||
if(!done)
|
||||
done = config.loadClasses(path.join(this._context.extensionPath, "doc", "classes.json"));
|
||||
if(!done)
|
||||
vscode.window.showErrorMessage("Load GDScript documentations failed");
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
Reference in New Issue
Block a user