gdscript_workspace.h 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*************************************************************************/
  2. /* gdscript_workspace.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef GDSCRIPT_WORKSPACE_H
  31. #define GDSCRIPT_WORKSPACE_H
  32. #include "../gdscript_parser.h"
  33. #include "core/variant.h"
  34. #include "editor/editor_file_system.h"
  35. #include "gdscript_extend_parser.h"
  36. #include "lsp.hpp"
  37. class GDScriptWorkspace : public Reference {
  38. GDCLASS(GDScriptWorkspace, Reference);
  39. private:
  40. void _get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners);
  41. Node *_get_owner_scene_node(String p_path);
  42. protected:
  43. static void _bind_methods();
  44. void remove_cache_parser(const String &p_path);
  45. bool initialized = false;
  46. Map<StringName, lsp::DocumentSymbol> native_symbols;
  47. const lsp::DocumentSymbol *get_native_symbol(const String &p_class, const String &p_member = "") const;
  48. const lsp::DocumentSymbol *get_script_symbol(const String &p_path) const;
  49. void reload_all_workspace_scripts();
  50. ExtendGDScriptParser *get_parse_successed_script(const String &p_path);
  51. ExtendGDScriptParser *get_parse_result(const String &p_path);
  52. void list_script_files(const String &p_root_dir, List<String> &r_files);
  53. public:
  54. String root;
  55. String root_uri;
  56. Map<String, ExtendGDScriptParser *> scripts;
  57. Map<String, ExtendGDScriptParser *> parse_results;
  58. HashMap<StringName, ClassMembers> native_members;
  59. public:
  60. Array symbol(const Dictionary &p_params);
  61. public:
  62. Error initialize();
  63. Error parse_script(const String &p_path, const String &p_content);
  64. Error parse_local_script(const String &p_path);
  65. String get_file_path(const String &p_uri) const;
  66. String get_file_uri(const String &p_path) const;
  67. void publish_diagnostics(const String &p_path);
  68. void completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options);
  69. const lsp::DocumentSymbol *resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_requred = false);
  70. void resolve_related_symbols(const lsp::TextDocumentPositionParams &p_doc_pos, List<const lsp::DocumentSymbol *> &r_list);
  71. const lsp::DocumentSymbol *resolve_native_symbol(const lsp::NativeSymbolInspectParams &p_params);
  72. void resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list);
  73. Dictionary generate_script_api(const String &p_path);
  74. Error resolve_signature(const lsp::TextDocumentPositionParams &p_doc_pos, lsp::SignatureHelp &r_signature);
  75. GDScriptWorkspace();
  76. ~GDScriptWorkspace();
  77. };
  78. #endif