Skip to content

Commit

Permalink
fix: fix thread issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 23, 2021
1 parent fd05b4b commit 49fd82e
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions plugins/coco_struct_analysis/src/struct_analysis_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ use crate::ctags_opt::Opt;
use crate::ctags_parser::CtagsParser;

pub fn execute_struct_analysis(config: CocoConfig) {
let args = vec![
"ptags",
"-t",
"1",
// "--bin-ctags=/usr/local/bin/ctags",
"--verbose=true",
"--fields=+latinK",
];

for repo in config.repo {
let mut files = vec![];

Expand All @@ -27,16 +18,35 @@ pub fn execute_struct_analysis(config: CocoConfig) {
for result in Walk::new(path) {
if let Ok(entry) = result {
if entry.file_type().unwrap().is_file() {
files.push(format!("{}", entry.path().display()))
files.push(format!(
"{}",
fs::canonicalize(entry.path()).unwrap().display()
))
}
}
}

let mut thread = files.len();
if thread >= 8 {
thread = 8;
}
let string = thread.to_string();
let thread: &str = string.as_str();
let args = vec![
"ptags",
"-t",
thread,
// "--bin-ctags=/usr/local/bin/ctags",
"--verbose=true",
"--fields=+latinK",
];
let opt = Opt::from_iter(args.iter());

let outputs = CmdCtags::call(&opt, &files).unwrap();
let out_str = str::from_utf8(&outputs[0].stdout).unwrap();

println!("{}", out_str);

let parser = CtagsParser::parse_str(out_str);
let classes = parser.classes();

Expand Down

0 comments on commit 49fd82e

Please sign in to comment.