gdscript_workspace.h 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*************************************************************************/
  2. /* gdscript_workspace.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 "gdscript_extend_parser.h"
  35. #include "lsp.hpp"
  36. class GDScriptWorkspace : public Reference {
  37. GDCLASS(GDScriptWorkspace, Reference);
  38. protected:
  39. static void _bind_methods();
  40. void remove_cache_parser(const String &p_path);
  41. bool initialized = false;
  42. Map<StringName, lsp::DocumentSymbol> native_symbols;
  43. const lsp::DocumentSymbol *get_native_symbol(const String &p_class, const String &p_member = "") const;
  44. const lsp::DocumentSymbol *get_script_symbol(const String &p_path) const;
  45. void reload_all_workspace_scripts();
  46. ExtendGDScriptParser *get_parse_successed_script(const String &p_path);
  47. ExtendGDScriptParser *get_parse_result(const String &p_path);
  48. void list_script_files(const String &p_root_dir, List<String> &r_files);
  49. public:
  50. String root;
  51. String root_uri;
  52. Map<String, ExtendGDScriptParser *> scripts;
  53. Map<String, ExtendGDScriptParser *> parse_results;
  54. HashMap<StringName, ClassMembers> native_members;
  55. public:
  56. Array symbol(const Dictionary &p_params);
  57. public:
  58. Error initialize();
  59. Error parse_script(const String &p_path, const String &p_content);
  60. Error parse_local_script(const String &p_path);
  61. String get_file_path(const String &p_uri) const;
  62. String get_file_uri(const String &p_path) const;
  63. void publish_diagnostics(const String &p_path);
  64. void completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options);
  65. const lsp::DocumentSymbol *resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_requred = false);
  66. void resolve_related_symbols(const lsp::TextDocumentPositionParams &p_doc_pos, List<const lsp::DocumentSymbol *> &r_list);
  67. const lsp::DocumentSymbol *resolve_native_symbol(const lsp::NativeSymbolInspectParams &p_params);
  68. void resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list);
  69. Dictionary generate_script_api(const String &p_path);
  70. GDScriptWorkspace();
  71. ~GDScriptWorkspace();
  72. };
  73. #endif