Path: blob/master/modules/gdscript/language_server/gdscript_workspace.h
10278 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 "../gdscript_parser.h"33#include "gdscript_extend_parser.h"34#include "godot_lsp.h"3536#include "core/variant/variant.h"37#include "editor/file_system/editor_file_system.h"3839class GDScriptWorkspace : public RefCounted {40GDCLASS(GDScriptWorkspace, RefCounted);4142private:43void _get_owners(EditorFileSystemDirectory *efsd, String p_path, List<String> &owners);44Node *_get_owner_scene_node(String p_path);4546protected:47static void _bind_methods();48void remove_cache_parser(const String &p_path);49bool initialized = false;50HashMap<StringName, LSP::DocumentSymbol> native_symbols;5152// Absolute paths that are known to point to res://53HashSet<String> absolute_res_paths;5455const LSP::DocumentSymbol *get_native_symbol(const String &p_class, const String &p_member = "") const;56const LSP::DocumentSymbol *get_script_symbol(const String &p_path) const;57const LSP::DocumentSymbol *get_parameter_symbol(const LSP::DocumentSymbol *p_parent, const String &symbol_identifier);58const LSP::DocumentSymbol *get_local_symbol_at(const ExtendGDScriptParser *p_parser, const String &p_symbol_identifier, const LSP::Position p_position);5960void reload_all_workspace_scripts();6162ExtendGDScriptParser *get_parse_successed_script(const String &p_path);63ExtendGDScriptParser *get_parse_result(const String &p_path);6465void list_script_files(const String &p_root_dir, List<String> &r_files);6667void apply_new_signal(Object *obj, String function, PackedStringArray args);6869public:70String root;71String root_uri;7273HashMap<String, ExtendGDScriptParser *> scripts;74HashMap<String, ExtendGDScriptParser *> parse_results;75HashMap<StringName, ClassMembers> native_members;7677public:78Error initialize();7980Error parse_script(const String &p_path, const String &p_content);81Error parse_local_script(const String &p_path);8283String get_file_path(const String &p_uri);84String get_file_uri(const String &p_path) const;8586void publish_diagnostics(const String &p_path);87void completion(const LSP::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options);8889const LSP::DocumentSymbol *resolve_symbol(const LSP::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_required = false);90void resolve_related_symbols(const LSP::TextDocumentPositionParams &p_doc_pos, List<const LSP::DocumentSymbol *> &r_list);91const LSP::DocumentSymbol *resolve_native_symbol(const LSP::NativeSymbolInspectParams &p_params);92void resolve_document_links(const String &p_uri, List<LSP::DocumentLink> &r_list);93Dictionary generate_script_api(const String &p_path);94Error resolve_signature(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::SignatureHelp &r_signature);95void didDeleteFiles(const Dictionary &p_params);96Dictionary rename(const LSP::TextDocumentPositionParams &p_doc_pos, const String &new_name);97bool can_rename(const LSP::TextDocumentPositionParams &p_doc_pos, LSP::DocumentSymbol &r_symbol, LSP::Range &r_range);98Vector<LSP::Location> find_usages_in_file(const LSP::DocumentSymbol &p_symbol, const String &p_file_path);99Vector<LSP::Location> find_all_usages(const LSP::DocumentSymbol &p_symbol);100101GDScriptWorkspace();102~GDScriptWorkspace();103};104105106