mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2026-01-04 10:09:58 +03:00
Set up continuous integration using GitHub Actions (#197)
The extension will be built and uploaded to artifacts so it can be tested easily by users. This also fixes warnings reported by TSLint.
This commit is contained in:
@@ -47,7 +47,7 @@ export class GodotTools {
|
||||
private open_workspace_with_editor(params = "") {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let valid = false
|
||||
let valid = false;
|
||||
if (this.workspace_dir) {
|
||||
let cfg = path.join(this.workspace_dir, this.project_file);
|
||||
valid = (fs.existsSync(cfg) && fs.statSync(cfg).isFile());
|
||||
@@ -78,9 +78,9 @@ export class GodotTools {
|
||||
}
|
||||
return cmdEsc;
|
||||
};
|
||||
let existingTerminal = vscode.window.terminals.find(t => t.name === TOOL_NAME)
|
||||
let existingTerminal = vscode.window.terminals.find(t => t.name === TOOL_NAME);
|
||||
if (existingTerminal) {
|
||||
existingTerminal.dispose()
|
||||
existingTerminal.dispose();
|
||||
}
|
||||
let terminal = vscode.window.createTerminal(TOOL_NAME);
|
||||
let editorPath = escape_command(path);
|
||||
@@ -90,14 +90,16 @@ export class GodotTools {
|
||||
resolve();
|
||||
};
|
||||
|
||||
let editorPath = get_configuration("editor_path", "")
|
||||
let editorPath = get_configuration("editor_path", "");
|
||||
editorPath = editorPath.replace("${workspaceRoot}", this.workspace_dir);
|
||||
if (!fs.existsSync(editorPath) || !fs.statSync(editorPath).isFile()) {
|
||||
vscode.window.showOpenDialog({
|
||||
openLabel: "Run",
|
||||
filters: process.platform === "win32" ? {"Godot Editor Binary": ["exe", "EXE"]} : undefined
|
||||
}).then((uris: vscode.Uri[])=> {
|
||||
if (!uris) return;
|
||||
if (!uris) {
|
||||
return;
|
||||
}
|
||||
let path = uris[0].fsPath;
|
||||
if (!fs.existsSync(path) || !fs.statSync(path).isFile()) {
|
||||
reject("Invalid editor path to run the project");
|
||||
@@ -164,4 +166,4 @@ export class GodotTools {
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -84,14 +84,18 @@ export default class GDScriptLanguageClient extends LanguageClient {
|
||||
}
|
||||
|
||||
private on_send_message(message: Message) {
|
||||
if (is_debug_mode()) logger.log("[client]", JSON.stringify(message));
|
||||
if (is_debug_mode()) {
|
||||
logger.log("[client]", JSON.stringify(message));
|
||||
}
|
||||
if ((message as RequestMessage).method == "initialize") {
|
||||
this._initialize_request = message;
|
||||
}
|
||||
}
|
||||
|
||||
private on_message(message: Message) {
|
||||
if (is_debug_mode()) logger.log("[server]", JSON.stringify(message));
|
||||
if (is_debug_mode()) {
|
||||
logger.log("[server]", JSON.stringify(message));
|
||||
}
|
||||
this.message_handler.on_message(message);
|
||||
}
|
||||
|
||||
@@ -105,7 +109,7 @@ export default class GDScriptLanguageClient extends LanguageClient {
|
||||
private on_disconnected() {
|
||||
this.status = ClientStatus.DISCONNECTED;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -128,12 +132,12 @@ class MessageHandler extends EventEmitter {
|
||||
}
|
||||
|
||||
on_message(message: any) {
|
||||
|
||||
|
||||
// FIXME: Hot fix VSCode 1.42 hover position
|
||||
if (message && message.result && message.result.range && message.result.contents) {
|
||||
if (message && message.result && message.result.range && message.result.contents) {
|
||||
message.result.range = undefined;
|
||||
}
|
||||
|
||||
|
||||
if (message && message.method && (message.method as string).startsWith(CUSTOM_MESSAGE)) {
|
||||
const method = (message.method as string).substring(CUSTOM_MESSAGE.length, message.method.length);
|
||||
if (this[method]) {
|
||||
|
||||
@@ -62,7 +62,7 @@ export default class MessageBuffer {
|
||||
let key = header.substr(0, index);
|
||||
let value = header.substr(index + 1).trim();
|
||||
result![key] = value;
|
||||
})
|
||||
});
|
||||
|
||||
let nextStart = current + 4;
|
||||
this.buffer = this.buffer.slice(nextStart);
|
||||
@@ -84,4 +84,4 @@ export default class MessageBuffer {
|
||||
public get numberOfBytes(): number {
|
||||
return this.index;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,31 +9,31 @@ import { RequestMessage, ResponseMessage, NotificationMessage } from "vscode-jso
|
||||
export type Message = RequestMessage | ResponseMessage | NotificationMessage;
|
||||
|
||||
export class MessageIO extends EventEmitter {
|
||||
|
||||
|
||||
reader: MessageIOReader = null;
|
||||
writer: MessageIOWriter = null;
|
||||
|
||||
public send_message(message: string) {
|
||||
// virtual
|
||||
}
|
||||
|
||||
|
||||
protected on_message(chunk: WebSocket.Data) {
|
||||
let message = chunk.toString();
|
||||
this.emit('data', message);
|
||||
}
|
||||
|
||||
|
||||
on_send_message(message: any) {
|
||||
this.emit("send_message", message);
|
||||
}
|
||||
|
||||
|
||||
on_message_callback(message: any) {
|
||||
this.emit("message", message);
|
||||
}
|
||||
|
||||
|
||||
async connect_to_language_server(port: number): Promise<void> {
|
||||
// virtual
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export class WebsocktMessageIO extends MessageIO {
|
||||
@@ -61,7 +61,7 @@ export class WebsocktMessageIO extends MessageIO {
|
||||
this.socket = socket;
|
||||
this.emit("connected");
|
||||
}
|
||||
|
||||
|
||||
protected on_disconnected() {
|
||||
this.socket = null;
|
||||
this.emit('disconnected');
|
||||
@@ -93,7 +93,7 @@ export class TCPMessageIO extends MessageIO {
|
||||
this.socket = socket;
|
||||
this.emit("connected");
|
||||
}
|
||||
|
||||
|
||||
protected on_disconnected() {
|
||||
this.socket = null;
|
||||
this.emit('disconnected');
|
||||
|
||||
@@ -13,14 +13,14 @@ 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 {
|
||||
|
||||
|
||||
private io: MessageIO = null;
|
||||
private native_classes: {[key: string]: GodotNativeClassInfo } = {};
|
||||
|
||||
|
||||
constructor(io: MessageIO) {
|
||||
super();
|
||||
this.io = io;
|
||||
@@ -40,10 +40,10 @@ 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(),
|
||||
@@ -56,7 +56,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
this.inspect_native_symbol({native_class: classname, symbol_name: classname});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private inspect_native_symbol(params: NativeSymbolInspectParams) {
|
||||
this.io.send_message(JSON.stringify({
|
||||
id: -1,
|
||||
@@ -66,7 +66,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private show_native_symbol(symbol: GodotNativeSymbol) {
|
||||
// 创建webview
|
||||
const panel = vscode.window.createWebviewPanel(
|
||||
@@ -82,7 +82,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
panel.webview.html = this.make_html_content(symbol);
|
||||
panel.webview.onDidReceiveMessage(this.on_webview_message.bind(this));
|
||||
}
|
||||
|
||||
|
||||
private on_webview_message(msg: any) {
|
||||
switch (msg.type) {
|
||||
case WebViewMessageType.INSPECT_NATIVE_SYMBOL:
|
||||
@@ -92,7 +92,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private make_html_content(symbol: GodotNativeSymbol): string {
|
||||
return `
|
||||
<html>
|
||||
@@ -130,28 +130,32 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
</script>
|
||||
</html>`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private make_symbol_document(symbol: GodotNativeSymbol): string {
|
||||
const classlink = make_link(symbol.native_class, undefined);
|
||||
const classinfo = this.native_classes[symbol.native_class];
|
||||
|
||||
|
||||
function make_function_signature(s: GodotNativeSymbol, with_class = false) {
|
||||
let parts = /\((.*)?\)\s*\-\>\s*(([A-z0-9]+)?)$/.exec(s.detail);
|
||||
if (!parts) return "";
|
||||
if (!parts) {
|
||||
return "";
|
||||
}
|
||||
const ret_type = make_link(parts[2] || "void", undefined);
|
||||
let args = (parts[1] || "").replace(/\:\s([A-z0-9_]+)(\,\s*)?/g, `: <a href="" onclick="inspect('$1', '$1')">$1</a>$2`);
|
||||
args = args.replace(/\s=\s(.*?)[\,\)]/g, "")
|
||||
args = args.replace(/\s=\s(.*?)[\,\)]/g, "");
|
||||
return `${ret_type} ${with_class?`${classlink}.`:''}${element("a", s.name, {href: `#${s.name}`})}( ${args} )`;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
function make_symbol_elements(s: GodotNativeSymbol, with_class = false): {index?: string, body: string} {
|
||||
switch (s.kind) {
|
||||
case vscode.SymbolKind.Property:
|
||||
case vscode.SymbolKind.Variable: {
|
||||
// var Control.anchor_left: float
|
||||
const parts = /\.([A-z_0-9]+)\:\s(.*)$/.exec(s.detail);
|
||||
if (!parts) return;
|
||||
if (!parts) {
|
||||
return;
|
||||
}
|
||||
let type = make_link(parts[2], undefined);
|
||||
let name = element("a", s.name, {href: `#${s.name}`});
|
||||
const title = element('h4', `${type} ${with_class?`${classlink}.`:''}${s.name}`);
|
||||
@@ -166,11 +170,13 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
// const Control.FOCUS_ALL: FocusMode = 2
|
||||
// const Control.NOTIFICATION_RESIZED = 40
|
||||
const parts = /\.([A-Za-z_0-9]+)(\:\s*)?([A-z0-9_\.]+)?\s*=\s*(.*)$/.exec(s.detail);
|
||||
if (!parts) return;
|
||||
if (!parts) {
|
||||
return;
|
||||
}
|
||||
let type = make_link(parts[3] || 'int', undefined);
|
||||
let name = parts[1];
|
||||
let value = element('code', parts[4]);
|
||||
|
||||
|
||||
const title = element('p', `${type} ${with_class?`${classlink}.`:''}${name} = ${value}`);
|
||||
const doc = element("p", format_documentation(s.documentation, symbol.native_class));
|
||||
const div = element("div", title + doc);
|
||||
@@ -180,7 +186,9 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
} break;
|
||||
case vscode.SymbolKind.Event: {
|
||||
const parts = /\.([A-z0-9]+)\((.*)?\)/.exec(s.detail);
|
||||
if (!parts) return;
|
||||
if (!parts) {
|
||||
return;
|
||||
}
|
||||
const args = (parts[2] || "").replace(/\:\s([A-z0-9_]+)(\,\s*)?/g, `: <a href="" onclick="inspect('$1', '$1')">$1</a>$2`);
|
||||
const title = element('p', `${with_class?`signal ${with_class?`${classlink}.`:''}`:''}${s.name}( ${args} )`);
|
||||
const doc = element("p", format_documentation(s.documentation, symbol.native_class));
|
||||
@@ -203,10 +211,10 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (symbol.kind == vscode.SymbolKind.Class) {
|
||||
|
||||
|
||||
let doc = element("h2", `Native class ${symbol.name}`);
|
||||
const parts = /extends\s+([A-z0-9]+)/.exec(symbol.detail);
|
||||
let inherits = parts && parts.length > 1 ? parts[1] : '';
|
||||
@@ -227,7 +235,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
}
|
||||
doc += element("p", `Inherited by:${inherited}`);
|
||||
}
|
||||
|
||||
|
||||
let constants = "";
|
||||
let signals = "";
|
||||
let methods_index = "";
|
||||
@@ -235,7 +243,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
let properties_index = "";
|
||||
let propertyies = "";
|
||||
let others = "";
|
||||
|
||||
|
||||
for (let s of symbol.children as GodotNativeSymbol[]) {
|
||||
const elements = make_symbol_elements(s);
|
||||
switch (s.kind) {
|
||||
@@ -260,14 +268,14 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function add_group(title: string, block: string) {
|
||||
if (block) {
|
||||
doc += element('h3', title);
|
||||
doc += element('ul', block);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
doc += element("p", format_documentation(symbol.documentation, symbol.native_class));
|
||||
add_group("Properties", properties_index);
|
||||
add_group("Constants", constants);
|
||||
@@ -277,7 +285,7 @@ export default class NativeDocumentManager extends EventEmitter {
|
||||
add_group("Method Descriptions", methods);
|
||||
add_group("Other Members", others);
|
||||
doc += element("script", `var godot_class = "${symbol.native_class}";`);
|
||||
|
||||
|
||||
return doc;
|
||||
} else {
|
||||
let doc = "";
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface NativeSymbolInspectParams {
|
||||
export class GodotNativeSymbol extends DocumentSymbol {
|
||||
documentation: string;
|
||||
native_class: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface GodotNativeClassInfo {
|
||||
name: string;
|
||||
|
||||
Reference in New Issue
Block a user