mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2025-12-31 13:48:24 +03:00
Improve for speed
This commit is contained in:
212
configrations/GDScript.full.tmLanguage.json
Normal file
212
configrations/GDScript.full.tmLanguage.json
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -35,37 +35,13 @@ class GDScriptCompletionItemProvider implements CompletionItemProvider {
|
||||
}
|
||||
|
||||
provideCompletionItems(document : TextDocument, position : Position, token : CancellationToken) : CompletionItem[] | Thenable < CompletionItem[] > | CompletionList | Thenable < CompletionList > {
|
||||
// console.log("[GodotTools]:provideCompletionItems");
|
||||
// const request: CompleteRequest = {
|
||||
// path: config.normalizePath(document.fileName),
|
||||
// text: document.getText(),
|
||||
// cursor: {
|
||||
// row: position.line + 1,
|
||||
// column: position.character + 1
|
||||
// }
|
||||
// };
|
||||
// return new Promise((resolve, reject) => {
|
||||
// requestGodot({
|
||||
// action: "codecomplete",
|
||||
// request
|
||||
// }).then((data: any)=>{
|
||||
// const result: CompletionResult = data.result;
|
||||
// if(result && result.suggestions && result.suggestions.length > 0) {
|
||||
// const items:CompletionItem[] = [];
|
||||
// result.suggestions.map((label, i)=>{
|
||||
// items.push(new CompletionItem(label, CompletionItemKind.Field));
|
||||
// });
|
||||
// resolve(items);
|
||||
// }
|
||||
// else
|
||||
// reject("Nothing to complete");
|
||||
// }).catch(e=>{
|
||||
// reject(e);
|
||||
// });
|
||||
// });
|
||||
let items:CompletionItem[] = config.getWorkspaceCompletionItems();
|
||||
items = [...items, ...config.bintinSybmolInfoList];
|
||||
return items;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let items:CompletionItem[] = config.getWorkspaceCompletionItems();
|
||||
items = [...items, ...config.bintinSybmolInfoList];
|
||||
resolve(items);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
resolveCompletionItem(item : CompletionItem, token : CancellationToken) : CompletionItem | Thenable < CompletionItem > {
|
||||
|
||||
@@ -63,18 +63,21 @@ class GDScriptDefinitionProivder implements DefinitionProvider {
|
||||
}
|
||||
};
|
||||
|
||||
let selStr = getSelectedContent(document, position);
|
||||
if(selStr) {
|
||||
// For strings
|
||||
if(isStr(selStr)) {
|
||||
selStr = getStrContent(selStr);
|
||||
let fpath = path.join(path.dirname(document.uri.fsPath), selStr)
|
||||
if(fs.existsSync(fpath) && fs.statSync(fpath).isFile())
|
||||
selStr = fpath
|
||||
return new Promise((resolve, reject) => {
|
||||
let selStr = getSelectedContent(document, position);
|
||||
if(selStr) {
|
||||
// For strings
|
||||
if(isStr(selStr)) {
|
||||
selStr = getStrContent(selStr);
|
||||
let fpath = path.join(path.dirname(document.uri.fsPath), selStr)
|
||||
if(fs.existsSync(fpath) && fs.statSync(fpath).isFile())
|
||||
selStr = fpath
|
||||
}
|
||||
resolve(getDefinitions(selStr));
|
||||
}
|
||||
return getDefinitions(selStr);
|
||||
}
|
||||
return null;
|
||||
else
|
||||
reject(new Error("Empty selection"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,17 +41,18 @@ class GDScriptDiagnosticSeverity {
|
||||
this._subscription.dispose()
|
||||
}
|
||||
|
||||
validateScript(doc: vscode.TextDocument, script: any) {
|
||||
async validateScript(doc: vscode.TextDocument, script: any) {
|
||||
if(doc.languageId == 'gdscript') {
|
||||
if(script) {
|
||||
|
||||
let diagnostics = [
|
||||
...(this.validateExpression(doc)),
|
||||
...(this.validateUnusedSymbols(doc, script)),
|
||||
];
|
||||
this._subscription.set(doc.uri, diagnostics);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private validateUnusedSymbols(doc: vscode.TextDocument,script) {
|
||||
|
||||
@@ -35,29 +35,30 @@ class GDScriptDocumentContentProvider implements TextDocumentContentProvider{
|
||||
const request = uri.authority;
|
||||
let classname = request;
|
||||
let membername = null;
|
||||
|
||||
if(request.indexOf(".") != -1) {
|
||||
classname = request.substring(0, request.indexOf("."));
|
||||
if(!request.endsWith("."))
|
||||
membername = request.substring(request.indexOf(".")+1, request.length);
|
||||
}
|
||||
if(classname.length >= 1) {
|
||||
for(let key of config.getBuiltinClassNameList()) {
|
||||
if(key.toLowerCase() == classname) {
|
||||
classname = key;
|
||||
break;
|
||||
const self = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
if(request.indexOf(".") != -1) {
|
||||
classname = request.substring(0, request.indexOf("."));
|
||||
if(!request.endsWith("."))
|
||||
membername = request.substring(request.indexOf(".")+1, request.length);
|
||||
}
|
||||
if(classname.length >= 1) {
|
||||
for(let key of config.getBuiltinClassNameList()) {
|
||||
if(key.toLowerCase() == classname) {
|
||||
classname = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(classname, membername);
|
||||
if(classname && classname.length > 0) {
|
||||
if(membername && membername.length >0 )
|
||||
return this.genMemberDoc(classname, membername);
|
||||
else
|
||||
return this.genClassDoc(config.getClass(classname));
|
||||
}
|
||||
return null;
|
||||
if(classname && classname.length > 0) {
|
||||
if(membername && membername.length >0 )
|
||||
resolve(self.genMemberDoc(classname, membername)) ;
|
||||
else
|
||||
resolve(self.genClassDoc(config.getClass(classname)));
|
||||
}
|
||||
reject(new Error("Open Documentation Failed!"));
|
||||
});
|
||||
}
|
||||
|
||||
genMethodDoc(mDoc:any):string {
|
||||
|
||||
@@ -40,7 +40,7 @@ class WindowWatcher {
|
||||
if(window.activeTextEditor != undefined) {
|
||||
const doc = window.activeTextEditor.document;
|
||||
const script = config.loadSymbolsFromFile(doc.fileName);
|
||||
this._diagnosticSeverity.validateScript(doc, script);
|
||||
this._diagnosticSeverity.validateScript(doc, script).then(()=>{});
|
||||
this._lastText = {path: doc.fileName, version: doc.version};
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class WindowWatcher {
|
||||
// Check content changed
|
||||
if(this._lastText.path != curText.path || this._lastText.version != curText.version) {
|
||||
const script = config.loadSymbolsFromFile(doc.fileName);
|
||||
this._diagnosticSeverity.validateScript(doc, script);
|
||||
this._diagnosticSeverity.validateScript(doc, script).then(()=>{});
|
||||
this._lastText = curText;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user