Skip to content

Commit

Permalink
Add ability to open docs for builtin functions
Browse files Browse the repository at this point in the history
  • Loading branch information
DaelonSuzuka committed Oct 13, 2023
1 parent 5bfe853 commit c50f096
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
},
{
"command": "godotTools.openTypeDocumentation",
"title": "Godot Tools: Open Type Documentation"
"title": "Godot Tools: Open Documentation"
},
{
"command": "godotTools.debugger.inspectNode",
Expand Down
7 changes: 7 additions & 0 deletions src/lsp/GDScriptLanguageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ export default class GDScriptLanguageClient extends LanguageClient {
let decl: string = message.result["contents"].value;
decl = decl.split('\n')[0].trim();

const match = decl.match(/func (@?\w+)\.(\w+)\(/);
if (match) {
this.lastSymbolHovered = `${match[1]}.${match[2]}`;
set_context("typeFound", true);
return;
}

// strip off the value
if (decl.includes("=")) {
decl = decl.split("=")[0];
Expand Down
18 changes: 14 additions & 4 deletions src/lsp/NativeDocumentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,22 @@ export default class NativeDocumentManager extends EventEmitter {
register_command("listNativeClasses", this.list_native_classes.bind(this));
}

public request_documentation(symbolName: string) {
if (symbolName in this.native_classes) {
public request_documentation(symbol: string) {
if (symbol in this.native_classes) {
this.inspect_native_symbol({
native_class: symbolName,
symbol_name: symbolName,
native_class: symbol,
symbol_name: symbol,
});
return;
}

if (symbol.includes(".")) {
const parts = symbol.split(".");
this.inspect_native_symbol({
native_class: parts[0],
symbol_name: parts[1],
});
return;
}
}

Expand Down

0 comments on commit c50f096

Please sign in to comment.