Skip to content

Commit

Permalink
[70_17] Fix some root node cannot find
Browse files Browse the repository at this point in the history
## What
Fix some root node cannot find
  • Loading branch information
UnbSky authored Sep 22, 2024
1 parent 08b977d commit 9fdf670
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/Plugins/Treesitter/lang_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
******************************************************************************/

#include "lang_parser.hpp"
#include "boxes.hpp"
#include "converter.hpp"
#include "list.hpp"
#include "observers.hpp"
Expand Down Expand Up @@ -86,17 +87,18 @@ lang_parser::get_root_node (tree t, int& start_index, int& hash_code) {
father_ip = father_ip->next;
tree_index= reverse (last_ip)[N (father_ip)];
if (tree_index < 0) {
// cout << "tree_index < 0: " << tree_index << LF;
tree_index= 0;
tree_index= reverse (descend_decode (last_ip, 0))[N (father_ip)];
}
last_ip= father_ip;
root = tree (subtree (the_et, reverse (father_ip)));
// cout << "Father: " << father_ip << " Root:" << root << LF;
if (!is_atomic (root)) {
tree env_child= the_drd->get_env_child (root, tree_index, MODE, "");
// tree prog_lan=
// the_drd->get_env_child (root, tree_index, "prog-language", "");
if (env_child == "prog") {
// Fix some root node cannot find
tree env_child_mode= the_drd->get_env_child (root, tree_index, MODE, "");

tree env_child_pl=
the_drd->get_env_child (root, tree_index, moebius::PROG_LANGUAGE, "");
if (env_child_mode == "prog" || N (env_child_pl) > 0) {
root= root[tree_index];
// cout << "Tree Index: " << tree_index << " Root: " << root << LF;
break;
Expand All @@ -105,10 +107,16 @@ lang_parser::get_root_node (tree t, int& start_index, int& hash_code) {
}
if (N (father_ip) == 0) {
// cout << "Can not meet Prog " << t << " IP:" << obtain_ip(t) << LF;
root= root[tree_index]; // Set Root To Self as Fallback
root= root[tree_index];
}
hash_code= hash (root);
get_data_from_root (root, t, start_index);

// //Add this to avoid wrong hash code
// if(N(change_line_pos) > 0){
// hash_code += change_line_pos[N(change_line_pos) - 1];
// //cout << "last " << change_line_pos[N(change_line_pos) - 1] << LF;
// }
return root;
}

Expand Down Expand Up @@ -189,6 +197,7 @@ lang_parser::get_code_from_root (tree root, string& code, string_u8& code_u8) {

bool
lang_parser::check_to_compile (int hash_code) {
// cout << "current " << current_code_hash << " hash " << hash_code << LF;
if (hash_code != current_code_hash) {
current_code_hash= hash_code;
return true;
Expand Down

0 comments on commit 9fdf670

Please sign in to comment.