Skip to content

Commit 9a1696d

Browse files
committed
fix: align uniast struct between go and rust
1 parent f7fdc17 commit 9a1696d

File tree

8 files changed

+180
-278
lines changed

8 files changed

+180
-278
lines changed

src/compress/compress.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright 2025 CloudWeGo Authors
2-
//
2+
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// https://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,7 +40,11 @@ pub fn from_json(id: &str, json: &str) -> Result<Repository, Box<dyn Error>> {
4040
f.id = id.to_string();
4141
}
4242
if f.graph.is_none() {
43-
f.build_graph();
43+
//return err
44+
return Err(Box::new(std::io::Error::new(
45+
std::io::ErrorKind::Other,
46+
"graph is None",
47+
)));
4448
}
4549
f.save_to_cache();
4650
Ok(f)
@@ -171,18 +175,20 @@ pub async fn cascade_compress_variable(
171175
return;
172176
}
173177
let var_node = var_node.unwrap();
174-
for (i, v) in var_node.references.iter().enumerate() {
175-
if i >= MAX_REFERS {
176-
eprintln!("too many references for {:?}", id);
177-
break;
178-
}
179-
let c = repo.get_id_content(v);
180-
if c.is_none() {
181-
eprintln!("{:?} node is not found", v);
182-
continue;
178+
if let Some(nfs) = &var_node.references {
179+
for (i, v) in nfs.iter().enumerate() {
180+
if i >= MAX_REFERS {
181+
eprintln!("too many references for {:?}", id);
182+
break;
183+
}
184+
let c = repo.get_id_content(&v.id());
185+
if c.is_none() {
186+
eprintln!("{:?} node is not found", v);
187+
continue;
188+
}
189+
let elem = c.unwrap();
190+
refs.push(elem);
183191
}
184-
let elem = c.unwrap();
185-
refs.push(elem);
186192
}
187193

188194
// compress type if any

0 commit comments

Comments
 (0)