Path: blob/master/modules/gdscript/language_server/gdscript_workspace.h
20849 views
/**************************************************************************/1/* gdscript_workspace.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/error/error_macros.h"33#include "gdscript_extend_parser.h"34#include "godot_lsp.h"3536#include "core/variant/variant.h"3738class GDScriptWorkspace : public RefCounted {39GDCLASS(GDScriptWorkspace, RefCounted);4041private:42#ifndef DISABLE_DEPRECATED43void didDeleteFiles() {}44Error parse_script(const String &p_path, const String &p_content) {45WARN_DEPRECATED;46return Error::FAILED;47}48Error parse_local_script(const String &p_path) {49WARN_DEPRECATED;50return Error::FAILED;51}52#endif // DISABLE_DEPRECATED5354protected:55static void _bind_methods();56bool initialized = false;57HashMap<StringName, LSP::DocumentSymbol> native_symbols;5859// Absolute paths that are known to point to res://60HashSet<String> absolute_res_paths;6162const LSP::DocumentSymbol *get_native_symbol(const String &p_class, const String &p_member = "") const;63const LSP::DocumentSymbol *get_script_symbol(const String &p_path) const;64const LSP::DocumentSymbol *get_parameter_symbol(const LSP::DocumentSymbol *p_parent, const String &symbol_identifier);65const LSP::DocumentSymbol *get_local_symbol_at(const ExtendGDScriptParser *p_parser, const String &p_symbol_identifier, const LSP::Position p_position);6667void reload_all_workspace_scripts();6869void list_script_files(const String &p_root_dir, List<String> &r_files);7071void apply_new_signal(Object *obj, String function, PackedStringArray args);7273public:74String root;75String root_uri;7677HashMap<StringName, ClassMembers> native_members;7879public:80Error initialize();8182String get_file_path(const String &p_uri);83String get_file_uri(const String &p_path) const;8485void publish_diagnostics(const String &p_path);86void completion(const LSP::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options);8788const LSP::DocumentSymbol *resolve_symbol(const LSP::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_required = false);8990const LSP::DocumentSymbol *resolve_native_symbol(const LSP::NativeSymbolInspectParams &p_params);91void resolve_document_links(const String &p_uri, List<LSP::DocumentLink> &r_list);92Dictionary generate_script_api(const String &p_path);93Error resolve_signature(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::SignatureHelp &r_signature);94Dictionary rename(const LSP::TextDocumentPositionParams &p_doc_pos, const String &new_name);95bool can_rename(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::DocumentSymbol &r_symbol, LSP::Range &r_range);96Vector<LSP::Location> find_usages_in_file(const LSP::DocumentSymbol &p_symbol, const String &p_file_path);97Vector<LSP::Location> find_all_usages(const LSP::DocumentSymbol &p_symbol);9899GDScriptWorkspace();100~GDScriptWorkspace();101};102103104