Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic functionalities for LSP Server #31937

Closed
wants to merge 11 commits into from

Conversation

ankitpriyarup
Copy link
Contributor

This PR provides functionality for: Function Signature, Markdown documentation & Document Link. I will create another PR later on covering rename functionality very soon.

Copy link
Contributor

@Geequlim Geequlim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signatureHelper looks ok.
The documentLink should not resolve more than one files.


For documentations of builtin symbols

I'm not sure this is a good way to implement the builtin documentation support.

You dumping the documentaions of builtin symbols to markdown files from the DocData on the server side and display them in the client side. There would be a lot of markdown files in the output folders so we have to manage the versions and make sure they are not deleted by users. That is not so reliable IMO.

I suggest you send documentations in realtime from the server side every time the client request the documentation display (maybe format them to markdown before send). The the client decide how to display the recived data (may caching and open them as markdown file like you did or something else).


You'd better seperate the signatureHelp and documentLink from the markdown documentation code to different PRs.

@@ -75,9 +75,12 @@ class GDScriptWorkspace : public Reference {

String get_file_path(const String &p_uri) const;
String get_file_uri(const String &p_path) const;
String simplify_file_uri(const String &p_path) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seems only called in get_file_uri so you can put the implementation inside get_file_uri

String value = lines[i].substr(start_pos + 1, end_pos - start_pos - 1);

if (!value.begins_with("res://")) {
value = "res://" + value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right way to handle relative file paths.

How about this situation:
res://enermys/wolf.gd

extends 'enermy.gd'

'enermy.gd' should link to res://enermys/enermy.gd instead of res://enermy.gd.


value = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_uri(value);
// File is not outside project scope && exists
if (value.find(root_uri) != -1 && FileAccess::exists(value.replace(root_uri + "/", "res://"))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call workspace->get_file_path here ?


void publish_diagnostics(const String &p_path);
void completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options);
Error get_signature_help(const lsp::TextDocumentPositionParams &p_params, String *r_signature_name, String *r_signature_doc, List<String> *r_signature_parameter, int *r_cur_active_parameter);
Error get_document_link(const lsp::DocumentLinkParams &p_params, List<lsp::DocumentLink> *r_links_parameter);
Copy link
Contributor

@Geequlim Geequlim Sep 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think a path can link to more than one file so why need this function returns multi-values?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm wrong.
The LSP require us to return a DocumentLink[] so we have to search all the strings in scripts.

@@ -1467,7 +1621,7 @@ struct ServerCapabilities {
dict["signatureHelpProvider"] = signatureHelpProvider.to_json();
dict["codeLensProvider"] = false; // codeLensProvider.to_json();
dict["documentOnTypeFormattingProvider"] = documentOnTypeFormattingProvider.to_json();
dict["renameProvider"] = renameProvider.to_json();
// dict["renameProvider"] = renameProvider.to_json();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do't commit unused code

@@ -1161,6 +1161,267 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
return OK;
}

String DocData::parse_description(String p_description) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a more explicit name, like convert_description_to_markdown.

@@ -284,7 +283,7 @@ void Main::print_help(const char *p_binary) {
#ifdef TOOLS_ENABLED
OS::get_singleton()->print(" --export <target> Export the project using the given export target. Export only main pack if path ends with .pck or .zip.\n");
OS::get_singleton()->print(" --export-debug <target> Like --export, but use debug template.\n");
OS::get_singleton()->print(" --doctool <path> Dump the engine API reference to the given <path> in XML format, merging if existing files are found.\n");
OS::get_singleton()->print(" --doctool <path> Dump the engine API reference to the given <bool: inMarkdown> <path> in XML format, merging if existing files are found.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't change doctool, just add a new option, e.g. --dump-markdown-docs.

@akien-mga
Copy link
Member

Commits should be squashed together eventually (with an appropriate description for the squashed commits to describe the overall changes).

@Geequlim
Copy link
Contributor

Geequlim commented Jan 3, 2020

@ankitpriyarup Are you going to continue the work for the signature implementation ?

@ankitpriyarup
Copy link
Contributor Author

@ankitpriyarup Are you going to continue the work for the signature implementation ?

No I won't be able to continue

@aaronfranke
Copy link
Member

The documentation part of this PR is superceded by #39359, the rest may still be relevant but I'm not sure. In any case, this PR is not good as-is, since it's still incomplete, has conflicts, and needs squashing. Therefore, I'm closing and adding "salvageable".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants