Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dap/implement #52

Closed
wants to merge 104 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
bd1f510
grrr
X39 Feb 18, 2021
0584556
submodules
X39 Feb 27, 2021
a522e78
Shelved everything and started from scratch
X39 Feb 27, 2021
a4c1d3d
stuff
X39 Feb 27, 2021
c6dc2ae
Fixed warnings
X39 Feb 27, 2021
4ed2418
Merge branch 'dap/implement' of https://github.com/SQFvm/vscode into …
X39 Feb 27, 2021
9d9af67
Implemented further changes
X39 Feb 28, 2021
5dcc03f
further code structuring
X39 Feb 28, 2021
c290a18
Implemented variables_visitor
X39 Mar 3, 2021
01cb318
added drop file
X39 Mar 3, 2021
bf093a6
cleanup
X39 Nov 14, 2022
da8a75b
adding reference db
X39 Nov 14, 2022
158045b
state
X39 Nov 15, 2022
660222b
removing build files
X39 Dec 9, 2022
b5bc83c
adding build files to gitignore
X39 Dec 9, 2022
45c5b42
garbage
X39 Dec 26, 2022
d20c1b9
tiny steps to success
X39 Jun 6, 2023
0e2fcd0
rewrite progress
X39 Jun 6, 2023
454357c
fixing orm macro
X39 Jun 7, 2023
8f7a301
state
X39 Jun 9, 2023
284f8af
state
X39 Jul 31, 2023
6a14738
more progress on reimplementation (yes ... still no real commit message)
X39 Aug 5, 2023
9198b17
progress
X39 Aug 9, 2023
ea3b4b0
progress
X39 Aug 9, 2023
33e3176
progress
X39 Aug 10, 2023
e26d4e7
progress and #19
X39 Aug 11, 2023
8cbe929
catch and findIf magic variable recognition
X39 Aug 11, 2023
1b29dcf
fixing .gitignore
X39 Aug 11, 2023
2d4210c
fixing sample data warning
X39 Aug 11, 2023
b2ed6ef
removing obsolete options (#18)
X39 Aug 11, 2023
d2131b7
fixed #21
X39 Aug 11, 2023
5559e72
fixed #25
X39 Aug 11, 2023
644bf65
fixed #24
X39 Aug 11, 2023
beabc7b
remove garbage
X39 Aug 11, 2023
e2a8fd0
adding private _xyz = nil being declaration
X39 Aug 11, 2023
5ad83cd
Create cmake-multi-platform.yml
X39 Aug 11, 2023
3a663c0
Update cmake-multi-platform.yml
X39 Aug 11, 2023
1c1164b
Update cmake-multi-platform.yml
X39 Aug 11, 2023
36328bf
Update cmake-multi-platform.yml
X39 Aug 11, 2023
9d51f78
Update cmake-multi-platform.yml
X39 Aug 11, 2023
ac542be
Update cmake-multi-platform.yml
X39 Aug 11, 2023
d7ae6e7
Update cmake-multi-platform.yml
X39 Aug 11, 2023
80d3b2c
Update cmake-multi-platform.yml
X39 Aug 11, 2023
16d3e81
Update cmake-multi-platform.yml
X39 Aug 11, 2023
eb1b304
Update cmake-multi-platform.yml
X39 Aug 11, 2023
d17dd67
Update cmake-multi-platform.yml
X39 Aug 11, 2023
df7f0a0
Update cmake-multi-platform.yml
X39 Aug 11, 2023
028c7ac
Update cmake-multi-platform.yml
X39 Aug 11, 2023
8d7b5a7
Update cmake-multi-platform.yml
X39 Aug 11, 2023
4cccb07
Update cmake-multi-platform.yml
X39 Aug 11, 2023
f2df2b1
Update language_server.cpp
X39 Aug 11, 2023
97a622b
adding &&, and, ||, or to the list of non-detach code blocks
X39 Aug 13, 2023
ee92e52
now watching every directory instead of only top-level one
X39 Aug 14, 2023
3e50c53
Update cmake-multi-platform.yml
X39 Aug 14, 2023
d4da9e1
Update cmake-multi-platform.yml
X39 Aug 14, 2023
fcc7e69
Update cmake-multi-platform.yml
X39 Aug 16, 2023
a439fbe
Update cmake-multi-platform.yml
X39 Aug 16, 2023
a2aba9f
Update cmake-multi-platform.yml
X39 Aug 16, 2023
d58486f
Update cmake-multi-platform.yml
X39 Aug 16, 2023
e1c67c4
Update cmake-multi-platform.yml
X39 Aug 16, 2023
1348943
Update cmake-multi-platform.yml
X39 Aug 16, 2023
58f115f
Update cmake-multi-platform.yml
X39 Aug 16, 2023
9191ca5
Update cmake-multi-platform.yml
X39 Aug 16, 2023
6fb81b8
Update cmake-multi-platform.yml
X39 Aug 16, 2023
78df16f
Update cmake-multi-platform.yml
X39 Aug 16, 2023
13bc049
Update cmake-multi-platform.yml
X39 Aug 16, 2023
127638b
Update cmake-multi-platform.yml
X39 Aug 16, 2023
b26ad7e
adding dynamic exlanguage server executable resolution
X39 Aug 16, 2023
2024d1b
Update cmake-multi-platform.yml
X39 Aug 16, 2023
78b7895
Update cmake-multi-platform.yml
X39 Aug 16, 2023
0b29233
implementing additional features
X39 Aug 17, 2023
316e27d
Update cmake-multi-platform.yml
X39 Aug 17, 2023
1c4badd
merge
X39 Aug 17, 2023
5fddd70
Update cmake-multi-platform.yml
X39 Aug 17, 2023
a30f410
.................
X39 Aug 17, 2023
2a61ffa
Update cmake-multi-platform.yml
X39 Aug 17, 2023
37d64ec
Update cmake-multi-platform.yml
X39 Aug 17, 2023
d263ef0
sqfvm fix
X39 Aug 17, 2023
688deaf
Merge branch 'dap/cd' of https://github.com/SQFvm/language-server int…
X39 Aug 17, 2023
c3e3b27
fixed #42
X39 Aug 17, 2023
8447243
data
X39 Aug 17, 2023
a42a738
adding sqf based visitor
X39 Aug 18, 2023
726b200
Update cmake-multi-platform.yml
X39 Aug 19, 2023
c02ae07
Update cmake-multi-platform.yml
X39 Aug 19, 2023
f0902a3
Update cmake-multi-platform.yml
X39 Aug 19, 2023
28736c7
documented scripted_visitor.cpp
X39 Aug 20, 2023
87224ed
Merge remote-tracking branch 'origin/dap/cd' into dap/cd
X39 Aug 20, 2023
22838b4
Update cmake-multi-platform.yml
X39 Aug 20, 2023
cbc03b5
adding exitWith to non-detach scopes
X39 Aug 20, 2023
2fb3983
moving implementation to source file
X39 Aug 20, 2023
6c6c7f0
[LSP] Implement code action support #40
X39 Aug 20, 2023
0b501fd
Update cmake-multi-platform.yml
X39 Aug 20, 2023
faf2303
Update cmake-multi-platform.yml
X39 Aug 20, 2023
0d3cf4c
Merge pull request #27 from SQFvm/dap/cd
X39 Aug 20, 2023
1905e87
[LSP] Implement code action support #40 & better $PBOPREFIX$ support
X39 Aug 28, 2023
745f9ff
updating submodule
X39 Aug 28, 2023
c37bf7d
begining of code action support
X39 Aug 28, 2023
e6882f5
code action support
X39 Aug 29, 2023
d5664f6
adding configuration to extension to configure additional path mappings
X39 Aug 29, 2023
52c1f46
Merge branch 'dap/cd' into dap/implement
X39 Aug 29, 2023
5b71c9f
adding macro hover resolve
X39 Aug 29, 2023
2ff2f1a
Update cmake-multi-platform.yml
X39 Aug 29, 2023
666a4b1
fixing PBOPREFIX
X39 Aug 29, 2023
1897cce
adding shadowing check
X39 Sep 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
begining of code action support
X39 committed Aug 28, 2023

Verified

This commit was signed with the committer’s verified signature.
X39 Marco Silipo
commit c37bf7ddb57a2bc2cbcb448c5927175825f9d617
4 changes: 4 additions & 0 deletions clients/vscode/sample/get_after_nested_set.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if (true) then {
private _var = false;
};
_var
2 changes: 1 addition & 1 deletion clients/vscode/sample/sample.sqf
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ testvalue = "";



systemChat CONCAT(test,value);
systemChat CONCAT(test test,value);

private _something = [];
private _input = _this select 0;
2 changes: 1 addition & 1 deletion server/extern/runtime
8 changes: 6 additions & 2 deletions server/sqfvm_language_server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ add_executable(sqfvm_language_server
analysis/sqf_ast/ast_visitor.hpp
analysis/sqf_ast/sqf_ast_analyzer.cpp
analysis/sqf_ast/sqf_ast_analyzer.hpp
analysis/sqf_ast/visitors/variables_visitor.hpp
analysis/sqf_ast/visitors/general_visitor.hpp
analysis/analyzer.hpp
database/tables/t_diagnostic.h
database/tables/t_file.h
@@ -27,7 +27,7 @@ add_executable(sqfvm_language_server
database/orm_mappings.hpp
database/orm_mappings.hpp
util.hpp
analysis/sqf_ast/visitors/variables_visitor.cpp
analysis/sqf_ast/visitors/general_visitor.cpp
sqfvm_factory.cpp
sqfvm_factory.hpp
runtime_logger.hpp
@@ -45,6 +45,10 @@ add_executable(sqfvm_language_server
lsp/server.cpp
lsp/server.hpp
lsp/data/enums.hpp
analysis/sqfvm_analyzer.hpp
analysis/sqfvm_analyzer.cpp
analysis/file_analyzer.hpp
analysis/db_analyzer.hpp
)

# Set C++ Version
21 changes: 21 additions & 0 deletions server/sqfvm_language_server/analysis/db_analyzer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Created by marco.silipo on 28.08.2023.
//

#ifndef SQFVM_LANGUAGE_SERVER_DB_ANALYZER_HPP
#define SQFVM_LANGUAGE_SERVER_DB_ANALYZER_HPP

#include "analyzer.hpp"

namespace sqfvm::language_server::analysis {
class db_analyzer : public analyzer {
protected:
database::context m_context;
public:
db_analyzer(
const std::filesystem::path &db_path)
: m_context(db_path) {};
};
}

#endif //SQFVM_LANGUAGE_SERVER_DB_ANALYZER_HPP
25 changes: 25 additions & 0 deletions server/sqfvm_language_server/analysis/file_analyzer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Created by marco.silipo on 28.08.2023.
//

#ifndef SQFVM_LANGUAGE_SERVER_FILE_ANALYZER_HPP
#define SQFVM_LANGUAGE_SERVER_FILE_ANALYZER_HPP

#include "db_analyzer.hpp"

namespace sqfvm::language_server::analysis {
class file_analyzer : public db_analyzer {
protected:
database::tables::t_file m_file;

public:
file_analyzer(
const std::filesystem::path &db_path,
database::tables::t_file file)
: db_analyzer(db_path),
m_file(std::move(file)) {};
};

}

#endif //SQFVM_LANGUAGE_SERVER_FILE_ANALYZER_HPP
7 changes: 7 additions & 0 deletions server/sqfvm_language_server/analysis/sqf_ast/ast_visitor.hpp
Original file line number Diff line number Diff line change
@@ -28,6 +28,13 @@ namespace sqfvm::language_server::analysis::sqf_ast {
return a.m_ls_path;
}

auto is_offset_in_macro(sqf_ast_analyzer &a, size_t offset) const {
return a.is_offset_in_macro(offset);
}
auto decode_preprocessed_offset(sqf_ast_analyzer &a, size_t offset) const {
return a.decode_preprocessed_offset(offset);
}

std::shared_ptr<sqf::runtime::runtime> runtime_of(sqf_ast_analyzer &a) {
return a.m_runtime;
}
80 changes: 43 additions & 37 deletions server/sqfvm_language_server/analysis/sqf_ast/sqf_ast_analyzer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "sqf_ast_analyzer.hpp"
#include "ast_visitor.hpp"
#include "../../util.hpp"
#include "visitors/variables_visitor.hpp"
#include "visitors/general_visitor.hpp"
#include "visitors/scripted_visitor.hpp"
#include "../../runtime_logger.hpp"
#include <functional>
@@ -13,18 +13,6 @@
#include <parser/preprocessor/default.h>
#include <parser/config/config_parser.hpp>

void sqfvm::language_server::analysis::sqf_ast::sqf_ast_analyzer::analyze() {
auto path_info = m_runtime->fileio().get_info(m_file.path, {m_file.path, {}, {}});
if (!path_info.has_value()) {
m_diagnostics.push_back({
.file_fk = m_file.id_pk,
.severity = database::tables::t_diagnostic::severity_level::error,
.message = "Failed to get path info for file: " + m_file.path,
});
return;
}
analyze_ast(*m_runtime);
}

namespace {

@@ -176,6 +164,31 @@ void sqfvm::language_server::analysis::sqf_ast::sqf_ast_analyzer::commit() {
#pragma endregion


#pragma region Code Actions
// Remove old code actions
for (auto &it: storage.get_all<database::tables::t_code_action>(
where(c(&database::tables::t_code_action::file_fk) == m_file.id_pk))) {
storage.remove_all<database::tables::t_code_action_change>(
where(c(&database::tables::t_code_action_change::code_action_fk) == it.id_pk));
}
storage.remove_all<database::tables::t_code_action>(
where(c(&database::tables::t_code_action::file_fk) == m_file.id_pk));

// Add new code actions
for (auto &visitor: m_visitors) {
for (auto &it: visitor->m_code_actions) {
if (it.code_action.file_fk == 0)
it.code_action.file_fk = m_file.id_pk;
auto code_action_id = storage.insert(it.code_action);
for (auto &change: it.changes) {
change.code_action_fk = code_action_id;
}
storage.insert_range(it.changes.begin(), it.changes.end());
}
}
#pragma endregion


#pragma region Diagnostics
// Remove old diagnostics
storage.remove_all<database::tables::t_diagnostic>(
@@ -260,16 +273,10 @@ void sqfvm::language_server::analysis::sqf_ast::sqf_ast_analyzer::recurse(

#pragma clang diagnostic pop

void sqfvm::language_server::analysis::sqf_ast::sqf_ast_analyzer::analyze_ast(
sqf::runtime::runtime &runtime) {
void sqfvm::language_server::analysis::sqf_ast::sqf_ast_analyzer::analyze(sqf::runtime::runtime &runtime) {
for (auto &visitor: m_visitors) {
visitor->start(*this);
}
auto preprocessed_opt = runtime.parser_preprocessor().preprocess(runtime, m_text, {m_file.path, {}, {}});
if (!preprocessed_opt.has_value()) {
return;
}
m_preprocessed_text = preprocessed_opt.value();
auto parser = sqf::parser::sqf::parser(runtime.get_logger());
auto tokenizer = sqf::parser::sqf::tokenizer(m_preprocessed_text.begin(), m_preprocessed_text.end(), m_file.path);
sqf::parser::sqf::bison::astnode root;
@@ -284,29 +291,28 @@ void sqfvm::language_server::analysis::sqf_ast::sqf_ast_analyzer::analyze_ast(
}

sqfvm::language_server::analysis::sqf_ast::sqf_ast_analyzer::sqf_ast_analyzer(
std::filesystem::path ls_path,
const std::filesystem::path &db_path,
database::tables::t_file file,
sqfvm_factory &factory,
sqfvm::language_server::database::tables::t_file file,
std::string &text)
: m_file(std::move(file)),
m_text(text),
m_preprocessed_text(text),
m_runtime(),
m_context(db_path),
m_ls_path(std::move(ls_path)),
m_slspp_context(std::make_shared<slspp_context>()) {
m_runtime = factory.create([&](auto &msg) {
auto copy = msg;
copy.source_file_fk = m_file.id_pk;
m_diagnostics.push_back(copy);
}, m_context, m_slspp_context);
m_visitors.push_back(new visitors::variables_visitor());
std::string text,
std::filesystem::path ls_path)
: sqfvm_analyzer(db_path, std::move(file), factory, std::move(text)),
m_ls_path(std::move(ls_path)) {
m_visitors.push_back(new visitors::general_visitor());
m_visitors.push_back(new visitors::scripted_visitor());
}

sqfvm::language_server::analysis::sqf_ast::sqf_ast_analyzer::~sqf_ast_analyzer() {
for (auto v: m_visitors) {
delete v;
}
}
}

void sqfvm::language_server::analysis::sqf_ast::sqf_ast_analyzer::macro_resolved(
::sqf::parser::preprocessor::impl_default::macro_resolved_data orig_start,
::sqf::parser::preprocessor::impl_default::macro_resolved_data orig_end, size_t pp_start, size_t pp_end,
sqf::runtime::runtime &runtime, sqf::runtime::parser::preprocessor::context &local_fileinfo,
sqf::runtime::parser::preprocessor::context &original_fileinfo, const sqf::runtime::parser::macro &m,
const std::unordered_map<std::string, std::string> &param_map) {

}
44 changes: 28 additions & 16 deletions server/sqfvm_language_server/analysis/sqf_ast/sqf_ast_analyzer.hpp
Original file line number Diff line number Diff line change
@@ -2,29 +2,25 @@
#define SQFVM_LANGUAGE_SERVER_ANALYSIS_SQF_AST_SQF_AST_ANALYZER_HPP

#include "../slspp_context.hpp"
#include "../analyzer.hpp"
#include "../sqfvm_analyzer.hpp"
#include "../../sqfvm_factory.hpp"
#include <string_view>
#include <utility>
#include <parser/sqf/astnode.hpp>

namespace sqfvm::language_server::analysis::sqf_ast {
class ast_visitor;
class sqf_ast_analyzer : public analyzer {

class sqf_ast_analyzer : public sqfvm_analyzer {
friend class ast_visitor;
database::tables::t_file m_file;
std::string m_text;
std::string m_preprocessed_text;

std::vector<database::tables::t_diagnostic> m_diagnostics;
std::vector<ast_visitor*> m_visitors;
std::vector<ast_visitor *> m_visitors;
std::vector<const ::sqf::parser::sqf::bison::astnode *> m_descend_ast_nodes;
std::shared_ptr<sqf::runtime::runtime> m_runtime;
std::shared_ptr<slspp_context> m_slspp_context;
database::context m_context;
std::filesystem::path m_ls_path;

void recurse(const sqf::parser::sqf::bison::astnode &parent);
void analyze_ast(sqf::runtime::runtime &runtime);

[[nodiscard]] std::string scope_name() const {
std::string scope{};
auto id = std::to_string(m_file.id_pk);
@@ -34,22 +30,38 @@ namespace sqfvm::language_server::analysis::sqf_ast {
scope.append("://"sv);
return scope;
}

void insert(
database::context::storage_t &storage,
const database::tables::t_reference& copy) const;
const database::tables::t_reference &copy) const;

protected:
void report_diagnostic(const database::tables::t_diagnostic &diagnostic) override {
m_diagnostics.push_back(diagnostic);
}

void macro_resolved(
::sqf::parser::preprocessor::impl_default::macro_resolved_data orig_start,
::sqf::parser::preprocessor::impl_default::macro_resolved_data orig_end, size_t pp_start,
size_t pp_end, ::sqf::runtime::runtime &runtime,
::sqf::runtime::parser::preprocessor::context &local_fileinfo,
::sqf::runtime::parser::preprocessor::context &original_fileinfo,
const ::sqf::runtime::parser::macro &m,
const std::unordered_map<std::string, std::string> &param_map) override;

public:
sqf_ast_analyzer(
std::filesystem::path ls_path,
const std::filesystem::path& db_path,
sqfvm_factory &factory,
const std::filesystem::path &db_path,
database::tables::t_file file,
std::string &text);
sqfvm_factory &factory,
std::string text,
std::filesystem::path ls_path);

~sqf_ast_analyzer() override;

// Perform an abstract analysis of the document, gathering references of variables, functions, etc.
// to be committed to the database in the next step.
void analyze() override;
void analyze(sqf::runtime::runtime &runtime) override;

// Commit the analysis to the database.
void commit() override;
Loading