Merge pull request #47553 from Razoric480/lsp-didDelete
Implement LSP didDeleteFiles to clear diagnostics
This commit is contained in:
commit
e6e1f6212d
3 changed files with 127 additions and 0 deletions
|
@ -41,6 +41,7 @@
|
|||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
void GDScriptWorkspace::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("didDeleteFiles"), &GDScriptWorkspace::did_delete_files);
|
||||
ClassDB::bind_method(D_METHOD("symbol"), &GDScriptWorkspace::symbol);
|
||||
ClassDB::bind_method(D_METHOD("parse_script", "path", "content"), &GDScriptWorkspace::parse_script);
|
||||
ClassDB::bind_method(D_METHOD("parse_local_script", "path"), &GDScriptWorkspace::parse_local_script);
|
||||
|
@ -50,6 +51,16 @@ void GDScriptWorkspace::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("generate_script_api", "path"), &GDScriptWorkspace::generate_script_api);
|
||||
}
|
||||
|
||||
void GDScriptWorkspace::did_delete_files(const Dictionary &p_params) {
|
||||
Array files = p_params["files"];
|
||||
for (int i = 0; i < files.size(); ++i) {
|
||||
Dictionary file = files[i];
|
||||
String uri = file["uri"];
|
||||
String path = get_file_path(uri);
|
||||
parse_script(path, "");
|
||||
}
|
||||
}
|
||||
|
||||
void GDScriptWorkspace::remove_cache_parser(const String &p_path) {
|
||||
Map<String, ExtendGDScriptParser *>::Element *parser = parse_results.find(p_path);
|
||||
Map<String, ExtendGDScriptParser *>::Element *script = scripts.find(p_path);
|
||||
|
|
|
@ -90,6 +90,8 @@ public:
|
|||
Dictionary generate_script_api(const String &p_path);
|
||||
Error resolve_signature(const lsp::TextDocumentPositionParams &p_doc_pos, lsp::SignatureHelp &r_signature);
|
||||
|
||||
void did_delete_files(const Dictionary &p_params);
|
||||
|
||||
GDScriptWorkspace();
|
||||
~GDScriptWorkspace();
|
||||
};
|
||||
|
|
|
@ -1514,6 +1514,114 @@ struct SignatureHelp {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A pattern to describe in which file operation requests or notifications
|
||||
* the server is interested in.
|
||||
*/
|
||||
struct FileOperationPattern {
|
||||
/**
|
||||
* The glob pattern to match.
|
||||
*/
|
||||
String glob = "**/*.gd";
|
||||
|
||||
/**
|
||||
* Whether to match `file`s or `folder`s with this pattern.
|
||||
*
|
||||
* Matches both if undefined.
|
||||
*/
|
||||
String matches = "file";
|
||||
|
||||
Dictionary to_json() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["glob"] = glob;
|
||||
dict["matches"] = matches;
|
||||
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A filter to describe in which file operation requests or notifications
|
||||
* the server is interested in.
|
||||
*/
|
||||
struct FileOperationFilter {
|
||||
/**
|
||||
* The actual file operation pattern.
|
||||
*/
|
||||
FileOperationPattern pattern;
|
||||
|
||||
Dictionary to_json() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["pattern"] = pattern.to_json();
|
||||
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The options to register for file operations.
|
||||
*/
|
||||
struct FileOperationRegistrationOptions {
|
||||
/**
|
||||
* The actual filters.
|
||||
*/
|
||||
Vector<FileOperationFilter> filters;
|
||||
|
||||
FileOperationRegistrationOptions() {
|
||||
filters.push_back(FileOperationFilter());
|
||||
}
|
||||
|
||||
Dictionary to_json() const {
|
||||
Dictionary dict;
|
||||
|
||||
Array filts;
|
||||
for (int i = 0; i < filters.size(); i++) {
|
||||
filts.push_back(filters[i].to_json());
|
||||
}
|
||||
dict["filters"] = filts;
|
||||
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The server is interested in file notifications/requests.
|
||||
*/
|
||||
struct FileOperations {
|
||||
/**
|
||||
* The server is interested in receiving didDeleteFiles file notifications.
|
||||
*/
|
||||
FileOperationRegistrationOptions didDelete;
|
||||
|
||||
Dictionary to_json() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["didDelete"] = didDelete.to_json();
|
||||
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Workspace specific server capabilities
|
||||
*/
|
||||
struct Workspace {
|
||||
/**
|
||||
* The server is interested in file notifications/requests.
|
||||
*/
|
||||
FileOperations fileOperations;
|
||||
|
||||
Dictionary to_json() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["fileOperations"] = fileOperations.to_json();
|
||||
|
||||
return dict;
|
||||
}
|
||||
};
|
||||
|
||||
struct ServerCapabilities {
|
||||
/**
|
||||
* Defines how text documents are synced. Is either a detailed structure defining each notification or
|
||||
|
@ -1575,6 +1683,11 @@ struct ServerCapabilities {
|
|||
*/
|
||||
bool workspaceSymbolProvider = true;
|
||||
|
||||
/**
|
||||
* The server supports workspace folder.
|
||||
*/
|
||||
Workspace workspace;
|
||||
|
||||
/**
|
||||
* The server provides code actions. The `CodeActionOptions` return type is only
|
||||
* valid if the client signals code action literal support via the property
|
||||
|
@ -1662,6 +1775,7 @@ struct ServerCapabilities {
|
|||
dict["documentHighlightProvider"] = documentHighlightProvider;
|
||||
dict["documentSymbolProvider"] = documentSymbolProvider;
|
||||
dict["workspaceSymbolProvider"] = workspaceSymbolProvider;
|
||||
dict["workspace"] = workspace.to_json();
|
||||
dict["codeActionProvider"] = codeActionProvider;
|
||||
dict["documentFormattingProvider"] = documentFormattingProvider;
|
||||
dict["documentRangeFormattingProvider"] = documentRangeFormattingProvider;
|
||||
|
|
Loading…
Reference in a new issue