gdscript_workspace.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. void list_script_files(const String &p_root_dir, List<String> &r_files);
  47. ExtendGDScriptParser *get_parse_successed_script(const String &p_path);
  48. ExtendGDScriptParser *get_parse_result(const String &p_path);
  49. public:
  50. String root;
  51. Map<String, ExtendGDScriptParser *> scripts;
  52. Map<String, ExtendGDScriptParser *> parse_results;
  53. public:
  54. Array symbol(const Dictionary &p_params);
  55. public:
  56. Error initialize();
  57. Error parse_script(const String &p_path, const String &p_content);
  58. Error parse_local_script(const String &p_path);
  59. String get_file_path(const String &p_uri) const;
  60. String get_file_uri(const String &p_path) const;
  61. void publish_diagnostics(const String &p_path);
  62. void completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options);
  63. const lsp::DocumentSymbol *resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_requred = false);
  64. static String marked_documentation(const String &p_bbcode);
  65. GDScriptWorkspace();
  66. ~GDScriptWorkspace();
  67. };
  68. #endif