Compare commits

..

24 Commits
1.1.3 ... 1.2.0

Author SHA1 Message Date
Hugo Locurcio
d404eaedc6 Bump to version 1.2.0 2022-04-05 22:52:09 +02:00
Adam Chyb
854ec42027 Fix some $ node path shorthand regex bugs in syntax highlighting (#340) 2022-04-05 16:57:49 +02:00
dependabot[bot]
281c78f133 Bump actions/setup-node from 3.0.0 to 3.1.0 (#339)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-01 19:44:48 +02:00
dependabot[bot]
a254b55aa5 Bump minimist from 1.2.5 to 1.2.6 (#333)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-27 20:21:01 +02:00
Brian Bugh
1be4ccaaad Add macOS editor location to README since it's not obvious (#332)
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2022-03-20 17:20:25 +01:00
Rémi Verschelde
1755e2f3c3 Merge pull request #264 from Razoric480/master
Update client to v7.0.0 to use 3.16.0 spec
2022-03-19 23:41:06 +01:00
Francois Belair
f9a5204dcf Update client to v7.0.0 to use of 3.16.0 spec 2022-03-19 15:32:40 -04:00
Rémi Verschelde
62cb49e506 Merge pull request #303 from kagof/master 2022-03-19 17:38:53 +01:00
johnjdonna
c347a522a3 Add support for setting language-server-host (#297) 2022-03-19 17:36:48 +01:00
Quan
293cc8c1fb Fix "static func" indent error (#279) 2022-03-19 17:32:57 +01:00
Rémi Verschelde
f21d7517c4 Merge pull request #331 from godotengine/dependabot/npm_and_yarn/simple-get-3.1.1 2022-03-19 17:30:26 +01:00
dependabot[bot]
314288b592 Bump simple-get from 3.1.0 to 3.1.1
Bumps [simple-get](https://github.com/feross/simple-get) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/feross/simple-get/releases)
- [Commits](https://github.com/feross/simple-get/compare/v3.1.0...v3.1.1)

---
updated-dependencies:
- dependency-name: simple-get
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-19 16:29:20 +00:00
Rémi Verschelde
c3c615825d Merge pull request #316 from Calinou/update-extension-metadata 2022-03-19 17:29:19 +01:00
Rémi Verschelde
6ebc866ce1 Merge pull request #313 from Calinou/update-dependencies 2022-03-19 17:28:57 +01:00
Hugo Locurcio
fb498a7502 Add GitHub issue templates (#326) 2022-03-19 17:02:34 +01:00
oidro
ee80ea914b Improve syntax highlighting (#330)
This pull request makes the syntax highlighting of GDScript more closely match
the built-in Godot editor's, as well as VSCode's Python syntax highlighting.
2022-03-19 17:02:10 +01:00
dependabot[bot]
158c0c38bf Bump actions/checkout from 2 to 3 (#329)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-02 18:39:46 +01:00
kurtlachmann
f1e57e5443 Fix restart of debugging sessions (#327) 2022-02-26 00:28:29 +01:00
dependabot[bot]
e78a8b8f86 Bump actions/setup-node from 2.5.1 to 3.0.0 (#322)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-24 18:17:34 +01:00
kurtlachmann
c03ab7e3f5 Fix "Continue" for multiple breakpoints in the same script (#324) 2022-02-24 17:56:11 +01:00
Raul Santos
12858a2e05 Use the LSP defined SymbolKind enum and fix marked (#325) 2022-02-24 17:25:43 +01:00
Hugo Locurcio
355c0f8614 Update dependencies, recommend local TypeScript and vsce
Local package installations should be favored over global installations
to avoid conflicts when working on multiple projects on the same system.

Only dependencies that did not cause the build to break were updated.

- Add `package` npm script to run local vsce installation.
2022-02-18 19:35:19 +01:00
Hugo Locurcio
650170ce13 Update extension metadata for better presentation on VS Marketplace
This also updates copyright statements to 2022.
2022-01-27 14:52:16 +01:00
Karl Goffin
9fa3031699 fixes #302 handling of Windows terminals determined by profiles 2021-10-10 10:44:05 +01:00
19 changed files with 1075 additions and 287 deletions

71
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,71 @@
name: Bug report
description: Report a bug in Godot Tools VS Code add-on
labels:
- bug
body:
- type: markdown
attributes:
value: |
- Write a descriptive issue title above.
- Search [open](https://github.com/godotengine/godot-vscode-plugin/issues) and [closed](https://github.com/godotengine/godot-vscode-plugin/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
- This repository only contains the LSP *client*. Issues pertaining to the Godot editor itself or the LSP's *server* side should be reported on the [main Godot repository](https://github.com/godotengine/godot/issues).
- type: input
attributes:
label: Godot version
description: >
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: 3.3.stable, 4.0.dev (3041becc6)
validations:
required: true
- type: input
attributes:
label: VS Code version
description: >
Use the **Help > About** menu to see your current version.
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: "1.64.2"
validations:
required: true
- type: input
attributes:
label: Godot Tools VS Code extension version
description: >
Open the **Extensions** side panel and click on the **godot-tools** extension to see your current version.
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: "1.2.0"
validations:
required: true
- type: input
attributes:
label: System information
description: |
Specify the OS version, and when relevant hardware information.
placeholder: Windows 10
validations:
required: true
- type: textarea
attributes:
label: Issue description
description: |
Describe your issue briefly. What doesn't work, and how do you expect it to work instead?
You can include images or videos with drag and drop, and format code blocks or logs with <code>```</code> tags.
validations:
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: |
List of steps or sample code that reproduces the issue. Having reproducible issues is a prerequisite for contributors to be able to solve them.
validations:
required: true

6
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
blank_issues_enabled: false
contact_links:
- name: Godot community channels
url: https://godotengine.org/community
about: Please ask for technical support on one of the other community channels, not here.

View File

@@ -0,0 +1,71 @@
name: Feature request
description: Request a new feature to be added or improved in Godot Tools VS Code add-on
labels:
- enhancement
body:
- type: markdown
attributes:
value: |
- Write a descriptive issue title above.
- Search [open](https://github.com/godotengine/godot-vscode-plugin/issues) and [closed](https://github.com/godotengine/godot-vscode-plugin/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
- This repository only contains the LSP *client*. Issues pertaining to the Godot editor itself or the LSP's *server* side should be reported on the [main Godot repository](https://github.com/godotengine/godot/issues).
- type: input
attributes:
label: Godot version
description: >
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: 3.3.stable, 4.0.dev (3041becc6)
validations:
required: true
- type: input
attributes:
label: VS Code version
description: >
Use the **Help > About** menu to see your current version.
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: "1.64.2"
validations:
required: true
- type: input
attributes:
label: Godot Tools VS Code extension version
description: >
Open the **Extensions** side panel and click on the **godot-tools** extension to see your current version.
Specify the Git commit hash if using a development or non-official build.
If you use a custom build, please test if your issue is reproducible in official builds too.
placeholder: "1.2.0"
validations:
required: true
- type: input
attributes:
label: System information
description: |
Specify the OS version, and when relevant hardware information.
placeholder: Windows 10
validations:
required: true
- type: textarea
attributes:
label: Problem statement
description: |
Describe the problem or limitation you're currently facing with the Godot Tools extension.
validations:
required: true
- type: textarea
attributes:
label: Proposed solution
description: |
Describe your proposed solution and how it resolves the problem or limitation mentioned above.
You can include images or videos with drag and drop, and format code blocks or logs with <code>```</code> tags.
validations:
required: true

View File

@@ -6,18 +6,19 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v2.5.1
uses: actions/setup-node@v3.1.0
with:
node-version: 12.x
node-version: 16.x
- name: Lint and build extension
run: |
npm install
npm run lint
node_modules/.bin/vsce package --out godot-tools.vsix
npm run package -- --out godot-tools.vsix
ls -l godot-tools.vsix
- name: Upload extension VSIX
uses: actions/upload-artifact@v2

View File

@@ -1,5 +1,16 @@
# Change Log
### 1.2.0
* [Add support for setting language-server-host](https://github.com/godotengine/godot-vscode-plugin/pull/297)
* [Improve syntax highlighting](https://github.com/godotengine/godot-vscode-plugin/pull/330)
* [Update LSP client to 7.0.0 to use the 3.16.0 specification](https://github.com/godotengine/godot-vscode-plugin/pull/264)
* [Fix some `$` node path shorthand regex bugs in syntax highlighting](https://github.com/godotengine/godot-vscode-plugin/pull/340)
* [Fix handling of Windows terminals determined by profiles](https://github.com/godotengine/godot-vscode-plugin/pull/303)
* [Fix "static func" indent error](https://github.com/godotengine/godot-vscode-plugin/pull/279)
* [Fix restart of debugging sessions](https://github.com/godotengine/godot-vscode-plugin/pull/327)
* [Use the LSP defined SymbolKind enum and fix marked](https://github.com/godotengine/godot-vscode-plugin/pull/325)
* [Fix "Continue" for multiple breakpoints in the same script](https://github.com/godotengine/godot-vscode-plugin/pull/324)
### 1.1.3
* [Fix conditional breakpoints being parsed as regular breakpoints](https://github.com/godotengine/godot-vscode-plugin/pull/278)
- [Add `in` to the list of keywords and add rule for `$` shorthand](https://github.com/godotengine/godot-vscode-plugin/pull/274)

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2016-2019 The Godot Engine community
Copyright (c) 2016-2022 The Godot Engine community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -44,6 +44,7 @@ for Godot by following these steps:
2. Select **Text Editor > External**
3. Make sure the **Use External Editor** box is checked
4. Fill **Exec Path** with the path to your VS Code executable
* On macOS, this executable is typically located at: `/Applications/Visual Studio Code.app/Contents/MacOS/Electron`
5. Fill **Exec Flags** with `{project} --goto {file}:{line}:{col}`
### VS Code
@@ -103,14 +104,12 @@ for the latest changes.
#### Requirements
- [npm](https://www.npmjs.com/get-npm)
- Typescript to compile, installed using npm with `npm install -g typescript`
- VSCE to create a VSIX file, installed using npm with `npm install -g vsce`
#### Process
1. Open a command prompt/terminal and browse to the location of this repository on your local filesystem.
2. Download dependencies by using the command `npm install`
3. When done, package a VSIX file by using the command `vsce package`.
3. When done, package a VSIX file by using the command `npm run package`.
4. Install it by opening Visual Studio Code, opening the Extensions tab, clicking on the More actions (**...**) button in the top right, and choose **Install from VSIX...** and find the compiled VSIX file.
When developing for the extension, you can open this project in Visual Studio Code and debug the extension by using the **Run Extension** launch configuration instead of going through steps 3 and 4. It will launch a new instance of Visual Studio Code that has the extension running. You can then open a Godot project folder and debug the extension or GDScript debugger.

View File

@@ -23,7 +23,7 @@
["{", "}"]
],
"indentationRules": {
"increaseIndentPattern": "^\\s*((class|func|else|elif|for|if|match|while|enum)|(.*\\sdo\\b))\\b[^\\{;]*$",
"increaseIndentPattern": "^\\s*((class|static func|func|else|elif|for|if|match|while|enum)|(.*\\sdo\\b))\\b[^\\{;]*$",
"decreaseIndentPattern": "^\\s*([}\\]]([,)]?\\s*(#|$)|\\.[a-zA-Z_]\\w*\\b)|(else|elif)\\b)"
},
"folding": {

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

973
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,20 +2,27 @@
"name": "godot-tools",
"displayName": "godot-tools",
"icon": "icon.png",
"version": "1.1.3",
"description": "Tools for game development with godot game engine",
"version": "1.2.0",
"description": "Tools for game development with Godot Engine and GDScript",
"repository": {
"type": "git",
"url": "https://github.com/godotengine/godot-vscode-plugin"
},
"bugs": {
"url": "https://github.com/godotengine/godot-vscode-plugin/issues"
},
"license": "MIT",
"author": "The Godot Engine community",
"publisher": "geequlim",
"engines": {
"vscode": "^1.33.0"
},
"categories": [
"Other",
"Debuggers"
"Programming Languages",
"Linters",
"Snippets",
"Debuggers",
"Other"
],
"activationEvents": [
"workspaceContains:project.godot",
@@ -27,7 +34,8 @@
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"lint": "tslint -p ./",
"watch": "tsc -watch -p ./"
"watch": "tsc -watch -p ./",
"package": "vsce package"
},
"contributes": {
"commands": [
@@ -99,6 +107,11 @@
],
"description": "The server protocol of the GDScript language server.\nYou have restart VSCode editor after change this value."
},
"godot_tools.gdscript_lsp_server_host": {
"type": "string",
"default": "127.0.0.1",
"description": "The server host of the GDScript language server"
},
"godot_tools.gdscript_lsp_server_port": {
"type": "number",
"default": 6008,
@@ -289,23 +302,23 @@
},
"devDependencies": {
"@types/marked": "^0.6.5",
"@types/mocha": "^2.2.42",
"@types/mocha": "^9.1.0",
"@types/node": "^10.12.21",
"@types/prismjs": "^1.16.0",
"@types/prismjs": "^1.16.8",
"@types/vscode": "^1.33.0",
"@types/ws": "^6.0.1",
"tslint": "^5.16.0",
"@types/ws": "^8.2.2",
"tslint": "^5.20.1",
"typescript": "^3.5.1",
"vsce": "^1.76.1"
"vsce": "^2.6.4"
},
"dependencies": {
"await-notify": "^1.0.1",
"global": "^4.4.0",
"marked": "^4.0.10",
"marked": "^4.0.11",
"net": "^1.0.2",
"terminate": "^2.1.2",
"terminate": "^2.5.0",
"vscode-debugadapter": "^1.38.0",
"vscode-languageclient": "^5.2.1",
"ws": "^7.4.6"
"vscode-languageclient": "^7.0.0",
"ws": "^8.4.2"
}
}

View File

@@ -82,8 +82,9 @@ export class GodotDebugData {
bps.push(bp);
let out_file = `res://${path.relative(this.project_path, bp.file)}`;
Mediator.notify("set_breakpoint", [out_file.replace(/\\/g, "/"), line]);
if (this.project_path) {
let out_file = `res://${path.relative(this.project_path, bp.file)}`;
Mediator.notify("set_breakpoint", [out_file.replace(/\\/g, "/"), line]);
}
}
}

View File

@@ -89,6 +89,7 @@ export class GodotDebugSession extends LoggingDebugSession {
args: DebugProtocol.ConfigurationDoneArguments
) {
this.configuration_done.notify();
this.sendResponse(response);
}
public set_scopes(
@@ -236,7 +237,7 @@ export class GodotDebugSession extends LoggingDebugSession {
args.launch_scene,
get_configuration("scene_file_config", "") || args.scene_file,
]);
this.sendResponse(response);
}

View File

@@ -47,7 +47,7 @@ export class GodotTools {
private open_workspace_with_editor(params = "") {
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
let valid = false;
if (this.workspace_dir) {
let cfg = path.join(this.workspace_dir, this.project_file);
@@ -79,18 +79,51 @@ export class GodotTools {
private run_editor(params = "") {
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
const run_godot = (path: string, params: string) => {
const is_powershell_path = (path?: string) => {
const POWERSHELL = "powershell.exe";
const POWERSHELL_CORE = "pwsh.exe";
return path && (path.endsWith(POWERSHELL) || path.endsWith(POWERSHELL_CORE));
};
const escape_command = (cmd: string) => {
let cmdEsc = `"${cmd}"`;
const cmdEsc = `"${cmd}"`;
if (process.platform === "win32") {
const POWERSHELL = "powershell.exe";
const POWERSHELL_CORE = "pwsh.exe";
const shell_plugin = vscode.workspace.getConfiguration("terminal.integrated.shell");
let shell = (shell_plugin ? shell_plugin.get("windows", POWERSHELL) : POWERSHELL) || POWERSHELL;
if (shell.endsWith(POWERSHELL) || shell.endsWith(POWERSHELL_CORE)) {
cmdEsc = `&${cmdEsc}`;
if (shell_plugin) {
const shell = shell_plugin.get<string>("windows");
if (shell) {
if (is_powershell_path(shell)) {
return `&${cmdEsc}`;
} else {
return cmdEsc;
}
}
}
const POWERSHELL_SOURCE = "PowerShell"
const default_profile = vscode.workspace.getConfiguration("terminal.integrated.defaultProfile");
if (default_profile) {
const profile_name = default_profile.get<string>("windows");
if (profile_name) {
if (POWERSHELL_SOURCE === profile_name) {
return `&${cmdEsc}`;
}
const profiles = vscode.workspace.getConfiguration("terminal.integrated.profiles.windows");
const profile = profiles.get<{source?: string, path?: string}>(profile_name);
if (profile) {
if (POWERSHELL_SOURCE === profile.source || is_powershell_path(profile.path)) {
return `&${cmdEsc}`;
} else {
return cmdEsc;
}
}
}
}
// default for Windows if nothing is set is PowerShell
return `&${cmdEsc}`
}
return cmdEsc;
};
@@ -131,9 +164,11 @@ export class GodotTools {
}
private check_client_status() {
let host = get_configuration("gdscript_lsp_server_host", "localhost");
let port = get_configuration("gdscript_lsp_server_port", 6008);
switch (this.client.status) {
case ClientStatus.PENDING:
vscode.window.showInformationMessage("Connecting to the GDScript language server...");
vscode.window.showInformationMessage(`Connecting to the GDScript language server at ${host}:${port}`);
break;
case ClientStatus.CONNECTED:
vscode.window.showInformationMessage("Connected to the GDScript language server.");
@@ -145,10 +180,12 @@ export class GodotTools {
}
private on_client_status_changed(status: ClientStatus) {
let host = get_configuration("gdscript_lsp_server_host", "localhost");
let port = get_configuration("gdscript_lsp_server_port", 6008);
switch (status) {
case ClientStatus.PENDING:
this.connection_status.text = `$(sync) Connecting`;
this.connection_status.tooltip = `Connecting to the GDScript language server...`;
this.connection_status.tooltip = `Connecting to the GDScript language server at ${host}:${port}`;
break;
case ClientStatus.CONNECTED:
this.connection_status.text = `$(check) Connected`;
@@ -169,7 +206,9 @@ export class GodotTools {
}
private retry_connect_client() {
vscode.window.showErrorMessage(`Couldn't connect to the GDScript language server.`, 'Open Godot Editor', 'Retry', 'Ignore').then(item=>{
let host = get_configuration("gdscript_lsp_server_host", "localhost");
let port = get_configuration("gdscript_lsp_server_port", 6008);
vscode.window.showErrorMessage(`Couldn't connect to the GDScript language server at ${host}:${port}`, 'Open Godot Editor', 'Retry', 'Ignore').then(item=>{
if (item == 'Retry') {
this.client.connect_to_server();
} else if (item == 'Open Godot Editor') {

View File

@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, RequestMessage } from "vscode-languageclient";
import { LanguageClient, LanguageClientOptions, ServerOptions, RequestMessage } from "vscode-languageclient/node";
import { is_debug_mode, get_configuration } from "../utils";
import { MessageIO, MessageIOReader, MessageIOWriter, Message, WebsocktMessageIO, TCPMessageIO } from "./MessageIO";
import logger from "../loggger";
@@ -74,8 +74,9 @@ export default class GDScriptLanguageClient extends LanguageClient {
connect_to_server() {
this.status = ClientStatus.PENDING;
let host = get_configuration("gdscript_lsp_server_host", "127.0.0.1");
let port = get_configuration("gdscript_lsp_server_port", 6008);
this.io.connect_to_language_server(port);
this.io.connect_to_language_server(host, port);
}
start(): vscode.Disposable {

View File

@@ -1,11 +1,11 @@
import { AbstractMessageReader, MessageReader, DataCallback } from "vscode-jsonrpc/lib/messageReader";
import { AbstractMessageReader, MessageReader, DataCallback, Disposable } from "vscode-jsonrpc";
import { EventEmitter } from "events";
import * as WebSocket from 'ws';
import { Socket } from 'net';
import MessageBuffer from "./MessageBuffer";
import { AbstractMessageWriter, MessageWriter } from "vscode-jsonrpc/lib/messageWriter";
import { RequestMessage, ResponseMessage, NotificationMessage } from "vscode-jsonrpc/lib/messages";
import { AbstractMessageWriter, MessageWriter } from "vscode-jsonrpc";
import { RequestMessage, ResponseMessage, NotificationMessage } from "vscode-jsonrpc";
export type Message = RequestMessage | ResponseMessage | NotificationMessage;
export class MessageIO extends EventEmitter {
@@ -30,7 +30,7 @@ export class MessageIO extends EventEmitter {
this.emit("message", message);
}
async connect_to_language_server(port: number): Promise<void> {
async connect_to_language_server(host: string, port: number): Promise<void> {
// virtual
}
}
@@ -46,10 +46,10 @@ export class WebsocktMessageIO extends MessageIO {
}
}
async connect_to_language_server(port: number): Promise<void> {
async connect_to_language_server(host:string, port: number): Promise<void> {
return new Promise((resolve, reject) => {
this.socket = null;
const ws = new WebSocket(`ws://localhost:${port}`);
const ws = new WebSocket(`ws://${host}:${port}`);
ws.on('open', ()=>{ this.on_connected(ws); resolve(); });
ws.on('message', this.on_message.bind(this));
ws.on('error', this.on_disconnected.bind(this));
@@ -77,11 +77,11 @@ export class TCPMessageIO extends MessageIO {
}
}
async connect_to_language_server(port: number):Promise<void> {
async connect_to_language_server(host:string, port: number):Promise<void> {
return new Promise((resolve, reject) => {
this.socket = null;
const socket = new Socket();
socket.connect(port);
socket.connect(port, host);
socket.on('connect', ()=>{ this.on_connected(socket); resolve(); });
socket.on('data', this.on_message.bind(this));
socket.on('end', this.on_disconnected.bind(this));
@@ -127,7 +127,7 @@ export class MessageIOReader extends AbstractMessageReader implements MessageRea
return this._partialMessageTimeout;
}
public listen(callback: DataCallback): void {
public listen(callback: DataCallback): Disposable {
this.nextMessageLength = -1;
this.messageToken = 0;
this.partialMessageTimer = undefined;
@@ -137,6 +137,8 @@ export class MessageIOReader extends AbstractMessageReader implements MessageRea
});
this.io.on('error', (error: any) => this.fireError(error));
this.io.on('close', () => this.fireClose());
return;
}
private onData(data: Buffer | String): void {
@@ -214,8 +216,12 @@ export class MessageIOWriter extends AbstractMessageWriter implements MessageWri
this.io.on('error', (error: any) => this.fireError(error));
this.io.on('close', () => this.fireClose());
}
public end(): void {
}
public write(msg: Message): void {
public write(msg: Message): Promise<void> {
let json = JSON.stringify(msg);
let contentLength = Buffer.byteLength(json, this.encoding);
@@ -235,5 +241,7 @@ export class MessageIOWriter extends AbstractMessageWriter implements MessageWri
this.errorCount++;
this.fireError(error, msg, this.errorCount);
}
return;
}
}

View File

@@ -1,4 +1,5 @@
import * as vscode from "vscode";
import * as ls from "vscode-languageclient";
import { EventEmitter } from "events";
import { MessageIO } from "./MessageIO";
import { NotificationMessage } from "vscode-jsonrpc";
@@ -32,7 +33,7 @@ export default class NativeDocumentManager extends EventEmitter {
this.io = io;
io.on("message", (message: NotificationMessage) => {
if (message.method == Methods.SHOW_NATIVE_SYMBOL) {
this.show_native_symbol(message.params);
this.show_native_symbol(message.params as GodotNativeSymbol);
} else if (message.method == Methods.GDSCRIPT_CAPABILITIES) {
for (const gdclass of (message.params as GodotCapabilities)
.native_classes) {
@@ -190,8 +191,8 @@ export default class NativeDocumentManager extends EventEmitter {
with_class = false
): { index?: string; body: string } {
switch (s.kind) {
case vscode.SymbolKind.Property:
case vscode.SymbolKind.Variable:
case ls.SymbolKind.Property:
case ls.SymbolKind.Variable:
{
// var Control.anchor_left: float
const parts = /\.([A-z_0-9]+)\:\s(.*)$/.exec(s.detail);
@@ -215,7 +216,7 @@ export default class NativeDocumentManager extends EventEmitter {
};
}
break;
case vscode.SymbolKind.Constant:
case ls.SymbolKind.Constant:
{
// const Control.FOCUS_ALL: FocusMode = 2
// const Control.NOTIFICATION_RESIZED = 40
@@ -243,7 +244,7 @@ export default class NativeDocumentManager extends EventEmitter {
};
}
break;
case vscode.SymbolKind.Event:
case ls.SymbolKind.Event:
{
const parts = /\.([A-z0-9]+)\((.*)?\)/.exec(s.detail);
if (!parts) {
@@ -269,8 +270,8 @@ export default class NativeDocumentManager extends EventEmitter {
};
}
break;
case vscode.SymbolKind.Method:
case vscode.SymbolKind.Function:
case ls.SymbolKind.Method:
case ls.SymbolKind.Function:
{
const signature = make_function_signature(s, with_class);
const title = element("h4", signature);
@@ -290,7 +291,7 @@ export default class NativeDocumentManager extends EventEmitter {
}
}
if (symbol.kind == vscode.SymbolKind.Class) {
if (symbol.kind == ls.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] : "";
@@ -326,19 +327,19 @@ export default class NativeDocumentManager extends EventEmitter {
for (let s of symbol.children as GodotNativeSymbol[]) {
const elements = make_symbol_elements(s);
switch (s.kind) {
case vscode.SymbolKind.Property:
case vscode.SymbolKind.Variable:
case ls.SymbolKind.Property:
case ls.SymbolKind.Variable:
properties_index += element("li", elements.index);
propertyies += element("li", elements.body, { id: s.name });
break;
case vscode.SymbolKind.Constant:
case ls.SymbolKind.Constant:
constants += element("li", elements.body, { id: s.name });
break;
case vscode.SymbolKind.Event:
case ls.SymbolKind.Event:
signals += element("li", elements.body, { id: s.name });
break;
case vscode.SymbolKind.Method:
case vscode.SymbolKind.Function:
case ls.SymbolKind.Method:
case ls.SymbolKind.Function:
methods_index += element("li", elements.index);
methods += element("li", elements.body, { id: s.name });
break;
@@ -373,11 +374,8 @@ export default class NativeDocumentManager extends EventEmitter {
let doc = "";
const elements = make_symbol_elements(symbol, true);
if (elements.index) {
if (
[vscode.SymbolKind.Function, vscode.SymbolKind.Method].indexOf(
symbol.kind
) == -1
) {
const symbols: ls.SymbolKind[] = [ls.SymbolKind.Function, ls.SymbolKind.Method];
if (!symbols.includes(symbol.kind)) {
doc += element("h2", elements.index);
}
}
@@ -419,7 +417,7 @@ function make_link(classname: string, symbol: string) {
}
function make_codeblock(code: string) {
const md = marked("```gdscript\n" + code + "\n```");
const md = marked.parse("```gdscript\n" + code + "\n```");
return `<div class="codeblock">${md}</div>`;
}

View File

@@ -1,4 +1,5 @@
import { DocumentSymbol } from "vscode";
import { DocumentSymbol, Range, SymbolKind } from "vscode-languageclient";
export const enum Methods {
GDSCRIPT_CAPABILITIES = 'gdscript/capabilities',
@@ -11,7 +12,15 @@ export interface NativeSymbolInspectParams {
symbol_name: string;
}
export class GodotNativeSymbol extends DocumentSymbol {
export class GodotNativeSymbol implements DocumentSymbol {
name: string;
detail?: string;
kind: SymbolKind;
tags?: 1[];
deprecated?: boolean;
range: Range;
selectionRange: Range;
children?: DocumentSymbol[];
documentation: string;
native_class: string;
}

View File

@@ -88,7 +88,7 @@
},
"logic_op": {
"match": "\\b(and|or|not)\\b",
"name": "keyword.operator.logical.gdscript"
"name": "keyword.operator.wordlike.gdscript"
},
"compare_op": {
"match": "<=|>=|==|<|>|!=",
@@ -104,8 +104,16 @@
},
"keywords": {
"match": "\\b(?i:if|elif|else|for|while|break|continue|pass|return|match|func|class|class_name|extends|is|in|onready|tool|static|export|setget|const|var|as|void|enum|preload|assert|yield|signal|breakpoint|rpc|sync|remote|master|puppet|slave|remotesync|mastersync|puppetsync|in)\\b",
"name": "keyword.language.gdscript"
"patterns": [
{
"match": "\\b(?i:func|class|class_name|extends|is|in|onready|tool|static|export|setget|const|var|as|void|enum|preload|assert|yield|signal|breakpoint|rpc|sync|remote|master|puppet|slave|remotesync|mastersync|puppetsync|in)\\b",
"name": "keyword.language.gdscript"
},
{
"match": "\\b(?i:if|elif|else|for|while|break|continue|pass|return|match)\\b",
"name": "keyword.control"
}
]
},
"letter": {
"match": "\\b(?i:true|false|null)\\b",
@@ -204,7 +212,7 @@
"name": "support.function.builtin.gdscript"
},
"builtin_get_node_shorthand": {
"match": "\\$((\\\"(\\.\\.\\/)+|\\\"\\/|\\\"[0-9]+|\\\")([0-9A-Za-z\\_]+\\/)*[A-Za-z0-9\\_]+\\\"|[A-Za-z\\_]+(\\/[A-Za-z\\_]+)*)",
"match": "\\$(((?<quote>\"|')((\\.\\.\\/)+|\\/)?)[0-9A-Za-z_ ]+(\\/[0-9A-Za-z_ ]+)*\\k<quote>|[0-9A-Za-z_]+(\\/[0-9A-Za-z_]+)*)",
"name": "support.function.builtin.shorthand.gdscript"
},
"builtin_classes": {