You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
GDScript LSP: Implement signatureHelp
Enable smart resolve default to true as it is required for script symbol lookup
This commit is contained in:
@@ -1402,6 +1402,120 @@ struct Hover {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a parameter of a callable-signature. A parameter can
|
||||
* have a label and a doc-comment.
|
||||
*/
|
||||
struct ParameterInformation {
|
||||
|
||||
/**
|
||||
* The label of this parameter information.
|
||||
*
|
||||
* Either a string or an inclusive start and exclusive end offsets within its containing
|
||||
* signature label. (see SignatureInformation.label). The offsets are based on a UTF-16
|
||||
* string representation as `Position` and `Range` does.
|
||||
*
|
||||
* *Note*: a label of type string should be a substring of its containing signature label.
|
||||
* Its intended use case is to highlight the parameter label part in the `SignatureInformation.label`.
|
||||
*/
|
||||
String label;
|
||||
|
||||
/**
|
||||
* The human-readable doc-comment of this parameter. Will be shown
|
||||
* in the UI but can be omitted.
|
||||
*/
|
||||
MarkupContent documentation;
|
||||
|
||||
Dictionary to_json() const {
|
||||
Dictionary dict;
|
||||
dict["label"] = label;
|
||||
dict["documentation"] = documentation.to_json();
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents the signature of something callable. A signature
|
||||
* can have a label, like a function-name, a doc-comment, and
|
||||
* a set of parameters.
|
||||
*/
|
||||
struct SignatureInformation {
|
||||
/**
|
||||
* The label of this signature. Will be shown in
|
||||
* the UI.
|
||||
*/
|
||||
String label;
|
||||
|
||||
/**
|
||||
* The human-readable doc-comment of this signature. Will be shown
|
||||
* in the UI but can be omitted.
|
||||
*/
|
||||
MarkupContent documentation;
|
||||
|
||||
/**
|
||||
* The parameters of this signature.
|
||||
*/
|
||||
Vector<ParameterInformation> parameters;
|
||||
|
||||
Dictionary to_json() const {
|
||||
Dictionary dict;
|
||||
dict["label"] = label;
|
||||
dict["documentation"] = documentation.to_json();
|
||||
Array args;
|
||||
for (int i = 0; i < parameters.size(); i++) {
|
||||
args.push_back(parameters[i].to_json());
|
||||
}
|
||||
dict["parameters"] = args;
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Signature help represents the signature of something
|
||||
* callable. There can be multiple signature but only one
|
||||
* active and only one active parameter.
|
||||
*/
|
||||
struct SignatureHelp {
|
||||
/**
|
||||
* One or more signatures.
|
||||
*/
|
||||
Vector<SignatureInformation> signatures;
|
||||
|
||||
/**
|
||||
* The active signature. If omitted or the value lies outside the
|
||||
* range of `signatures` the value defaults to zero or is ignored if
|
||||
* `signatures.length === 0`. Whenever possible implementors should
|
||||
* make an active decision about the active signature and shouldn't
|
||||
* rely on a default value.
|
||||
* In future version of the protocol this property might become
|
||||
* mandatory to better express this.
|
||||
*/
|
||||
int activeSignature = 0;
|
||||
|
||||
/**
|
||||
* The active parameter of the active signature. If omitted or the value
|
||||
* lies outside the range of `signatures[activeSignature].parameters`
|
||||
* defaults to 0 if the active signature has parameters. If
|
||||
* the active signature has no parameters it is ignored.
|
||||
* In future version of the protocol this property might become
|
||||
* mandatory to better express the active parameter if the
|
||||
* active signature does have any.
|
||||
*/
|
||||
int activeParameter = 0;
|
||||
|
||||
Dictionary to_json() const {
|
||||
Dictionary dict;
|
||||
Array sigs;
|
||||
for (int i = 0; i < signatures.size(); i++) {
|
||||
sigs.push_back(signatures[i].to_json());
|
||||
}
|
||||
dict["signatures"] = sigs;
|
||||
dict["activeSignature"] = activeSignature;
|
||||
dict["activeParameter"] = activeParameter;
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
||||
struct ServerCapabilities {
|
||||
/**
|
||||
* Defines how text documents are synced. Is either a detailed structure defining each notification or
|
||||
@@ -1532,6 +1646,8 @@ struct ServerCapabilities {
|
||||
Dictionary dict;
|
||||
dict["textDocumentSync"] = (int)textDocumentSync.change;
|
||||
dict["completionProvider"] = completionProvider.to_json();
|
||||
signatureHelpProvider.triggerCharacters.push_back(",");
|
||||
signatureHelpProvider.triggerCharacters.push_back("(");
|
||||
dict["signatureHelpProvider"] = signatureHelpProvider.to_json();
|
||||
dict["codeLensProvider"] = false; // codeLensProvider.to_json();
|
||||
dict["documentOnTypeFormattingProvider"] = documentOnTypeFormattingProvider.to_json();
|
||||
|
||||
Reference in New Issue
Block a user