lsp: re-analyze IR2 files when they change (#1841)

* lsp: re-analyze IR2 files when they change

* tests: update ref tests
This commit is contained in:
Tyler Wilding 2022-09-05 17:45:41 -04:00 committed by GitHub
parent 9f90a7c2db
commit 71871595da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 19 additions and 23 deletions

View file

@ -552,7 +552,7 @@ void ObjectFileDB::ir2_type_analysis_pass(int seg, const Config& config, ObjectF
func.ir2.env.set_types(out.block_init_types, out.op_end_types, *func.ir2.atomic_ops,
ts);
} catch (const std::exception& e) {
func.warnings.warning("Type analysis failed: {}", e.what());
func.warnings.error("Type analysis failed: {}", e.what());
}
func.ir2.env.types_succeeded = out.succeeded;
} else {
@ -560,7 +560,7 @@ void ObjectFileDB::ir2_type_analysis_pass(int seg, const Config& config, ObjectF
if (run_type_analysis_ir2(ts, dts, func)) {
func.ir2.env.types_succeeded = true;
} else {
func.warnings.warning("Type analysis failed");
func.warnings.error("Type analysis failed");
}
}
} else {

View file

@ -108,7 +108,6 @@ std::optional<std::vector<std::string>> LSPRouter::route_message(
if (route.m_post_notification_publish) {
auto resp = route.m_post_notification_publish.value()(appstate.workspace, body["params"]);
if (resp) {
lg::info("adding publish resp");
resp_bodies.push_back(resp.value());
}
}

View file

@ -92,7 +92,7 @@ int main(int argc, char** argv) {
for (const auto& response : responses.value()) {
std::cout << response.c_str() << std::flush;
if (appstate.verbose) {
lg::debug("<<< Sending message: {}", response);
lg::trace("<<< Sending message: {}", response);
} else {
lg::info("<<< Sending message of method '{}'", method_name);
}

View file

@ -17,11 +17,12 @@ void LSPSpec::from_json(const json& j, TextDocumentContentChangeEvent& obj) {
}
void LSPSpec::to_json(json& j, const DidChangeTextDocumentParams& obj) {
j = json{{"textDocument", obj.m_textDocument}};
j = json{{"textDocument", obj.m_textDocument}, {"contentChanges", obj.m_contentChanges}};
}
void LSPSpec::from_json(const json& j, DidChangeTextDocumentParams& obj) {
j.at("textDocument").get_to(obj.m_textDocument);
j.at("contentChanges").get_to(obj.m_contentChanges);
}
void LSPSpec::to_json(json& j, const DidCloseTextDocumentParams& obj) {

View file

@ -50,13 +50,12 @@ void Workspace::start_tracking_file(const LSPSpec::DocumentUri& file_uri,
const std::string& language_id,
const std::string& content) {
if (language_id == "opengoal-ir") {
lg::debug("new ir file");
lg::debug("new ir file - {}", file_uri);
WorkspaceIRFile file(content);
lg::debug("parsed!");
m_tracked_ir_files[file_uri] = file;
if (!file.m_all_types_uri.empty()) {
if (m_tracked_all_types_files.count(file.m_all_types_uri) == 0) {
lg::debug("new all-types file");
lg::debug("new all-types file - {}", file_uri);
m_tracked_all_types_files[file.m_all_types_uri] = WorkspaceAllTypesFile(
file.m_all_types_uri, file.m_game_version, file.m_all_types_file_path);
m_tracked_all_types_files[file.m_all_types_uri].parse_type_system();
@ -68,9 +67,11 @@ void Workspace::start_tracking_file(const LSPSpec::DocumentUri& file_uri,
void Workspace::update_tracked_file(const LSPSpec::DocumentUri& file_uri,
const std::string& content) {
lg::debug("potentially updating - {}", file_uri);
// Check if the file is already tracked or not, this is done because change events don't give
// language details it's assumed you are keeping track of that!
if (m_tracked_ir_files.count(file_uri) != 0) {
lg::debug("updating tracked IR file - {}", file_uri);
WorkspaceIRFile file(content);
m_tracked_ir_files[file_uri] = file;
// There is the potential for the all-types to have changed, albeit this is probably never going
@ -86,6 +87,7 @@ void Workspace::update_tracked_file(const LSPSpec::DocumentUri& file_uri,
}
if (m_tracked_all_types_files.count(file_uri) != 0) {
lg::debug("updating tracked all types file - {}", file_uri);
// If the all-types file has changed, re-parse it
// NOTE - this assumes its still for the same game version!
m_tracked_all_types_files[file_uri].update_type_system();
@ -140,9 +142,7 @@ void WorkspaceIRFile::find_all_types_path(const std::string& line) {
lg::debug("DTS URI - {}", all_types_uri);
if (valid_game_version(game_version.str())) {
lg::debug("a");
m_game_version = game_name_to_version(game_version.str());
lg::debug("b");
m_all_types_uri = all_types_uri;
m_all_types_file_path = fs::path(all_types_path.str());
} else {
@ -181,7 +181,7 @@ void WorkspaceIRFile::find_function_symbol(const uint32_t line_num_zero_based,
std::regex end_function("^;; \\.endfunction\\s*$");
if (std::regex_match(line, end_function)) {
lg::info("Found end of previous function on line - {}", line);
lg::debug("Found end of previous function on line - {}", line);
// Set the previous symbols end-line
if (!m_symbols.empty()) {
m_symbols[m_symbols.size() - 1].m_range.m_end.m_line = line_num_zero_based - 1;

View file

@ -41,7 +41,7 @@ void MessageBuffer::handle_char(char c) {
// If so, add it to our known headers.
// We'll also reset our string then.
if (!header_name.empty()) {
lg::debug("found header!");
lg::trace("found header!");
m_headers[header_name] = header_value;
m_raw_message.clear();
}
@ -53,7 +53,7 @@ void MessageBuffer::handle_char(char c) {
m_raw_message.clear();
m_is_header_done = true;
m_reading_content = true;
lg::debug("Header complete, content length: {}", m_headers["Content-Length"]);
lg::trace("Header complete, content length: {}", m_headers["Content-Length"]);
}
if (m_is_header_done) {

View file

@ -541,7 +541,7 @@
;; definition for method 9 of type art-mesh-geo
;; ERROR: Type Propagation failed: Failed type prop at op 20 ((set! v1 (l.h (+ s4 6)))): Could not get type of load: (set! v1 (l.h (+ s4 6))).
;; WARN: Type analysis failed
;; ERROR: Type analysis failed
(defmethod login art-mesh-geo ((a0-0 art-mesh-geo))
(local-vars
(v0-0 none)

View file

@ -134,7 +134,7 @@
;; definition for function vis-cull
;; ERROR: Type Propagation failed: Failed type prop at op 3 ((set! v1 (l.b (+ v1 #x38b0)))): Could not get type of load: (set! v1 (l.b (+ v1 #x38b0))).
;; WARN: Type analysis failed
;; ERROR: Type analysis failed
;; ERROR: Unsupported inline assembly instruction kind - [addiu a0, a0, 56]
(defun vis-cull ((a0-0 int))
(local-vars (v0-0 none) (v1-0 int) (v1-1 int) (v1-2 none) (v1-3 none) (a0-1 none) (a0-2 none) (a1-0 int))

View file

@ -139,7 +139,7 @@
;; definition for function sky-draw
;; ERROR: Type Propagation failed: Failed type prop at op 12 ((set! a0 (+ a0 16))): Cannot get_type_int2: (+ a0 16), args float and <integer 16>
;; WARN: Type analysis failed
;; ERROR: Type analysis failed
(defun sky-draw ((a0-0 sky-parms))
(local-vars
(v0-0 none)

View file

@ -112,7 +112,7 @@
;; definition for function glst-find-node-by-name
;; ERROR: Type Propagation failed: Failed type prop at op 7 ((set! a0 (l.wu (+ v1 8)))): Could not get type of load: (set! a0 (l.wu (+ v1 8))).
;; WARN: Type analysis failed
;; ERROR: Type analysis failed
(defun glst-find-node-by-name ((a0-0 glst-list) (a1-0 string))
(local-vars
(v0-0 none)
@ -173,7 +173,7 @@
;; definition for function glst-length-of-longest-name
;; ERROR: Type Propagation failed: Failed type prop at op 6 ((set! a0 (l.wu (+ v1 8)))): Could not get type of load: (set! a0 (l.wu (+ v1 8))).
;; WARN: Type analysis failed
;; ERROR: Type analysis failed
(defun glst-length-of-longest-name ((a0-0 glst-list))
(local-vars
(v0-0 none)

View file

@ -872,7 +872,7 @@
;; definition for function race-time-save
;; ERROR: Type Propagation failed: Failed type prop at op 6 ((set! v1 (l.wu (+ a0 -4)))): Could not get type of load: (set! v1 (l.wu (+ a0 -4))).
;; WARN: Type analysis failed
;; ERROR: Type analysis failed
;; ERROR: Function may read a register that is not set: a2
(defun race-time-save ((a0-0 race-time) (a1-0 task-control))
(local-vars

View file

@ -2160,7 +2160,3 @@
;; failed to figure out what this is:
(kmemclose)