Skip to content

Commit

Permalink
refactor: refactor split line methods
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 23, 2021
1 parent 3f4095e commit fd05b4b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions plugins/coco_struct_analysis/src/cmd_ctags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ mod tests {
.join("main.go");

files.push(format!("{}", code_dir.display()));
println!("{:?}", files);
let outputs = CmdCtags::call(&opt, &files).unwrap();
let out_str = str::from_utf8(&outputs[0].stdout).unwrap();
println!("{}", out_str);
let mut lines = out_str.lines();

let first_line = lines.next().unwrap_or("");
Expand Down
5 changes: 2 additions & 3 deletions plugins/coco_struct_analysis/src/ctags_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ lazy_static! {
impl CtagsParser {
pub fn parse_str(str: &str) -> CtagsParser {
let mut parser = CtagsParser::default();
let split = str.split("\n");
for line in split.clone() {
for line in str.lines() {
parser.parse_class(line);
}

for line in split {
for line in str.lines() {
parser.parse_method_methods(line);
}

Expand Down
17 changes: 9 additions & 8 deletions plugins/coco_struct_analysis/src/struct_analysis_app.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{fs, str};
use structopt::StructOpt;
use walkdir::{DirEntry, WalkDir};

use core_model::url_format::uri_to_path;
use core_model::{url_format, CocoConfig, Settings};
use ignore::Walk;

use std::{fs, str};
use structopt::StructOpt;

use crate::cmd_ctags::CmdCtags;
use crate::ctags_opt::Opt;
Expand All @@ -24,10 +24,11 @@ pub fn execute_struct_analysis(config: CocoConfig) {

let url_str = repo.url.as_str();
let path = uri_to_path(url_str);
for entry in WalkDir::new(path) {
let entry: DirEntry = entry.unwrap();
if entry.file_type().is_file() {
files.push(format!("{}", entry.path().display()));
for result in Walk::new(path) {
if let Ok(entry) = result {
if entry.file_type().unwrap().is_file() {
files.push(format!("{}", entry.path().display()))
}
}
}

Expand Down

0 comments on commit fd05b4b

Please sign in to comment.