diff --git a/crates/erlang_service/src/lib.rs b/crates/erlang_service/src/lib.rs index e217c8b35..b9f5009c1 100644 --- a/crates/erlang_service/src/lib.rs +++ b/crates/erlang_service/src/lib.rs @@ -246,7 +246,6 @@ impl Response { pub struct ParseResult { pub ast: Arc>, pub stub: Arc>, - pub files: Arc>, pub errors: Vec, pub warnings: Vec, } @@ -256,7 +255,6 @@ impl ParseResult { Self { ast: Arc::default(), stub: Arc::default(), - files: Arc::default(), errors: vec![error], warnings: Vec::default(), } @@ -377,7 +375,6 @@ impl Connection { ) -> Option { let mut ast = vec![]; let mut stub = vec![]; - let mut files = vec![]; let mut warnings = vec![]; let mut errors = vec![]; let mut opens = vec![]; @@ -388,7 +385,6 @@ impl Connection { match tag { b"AST" => ast = data, b"STU" => stub = data, - b"FIL" => files = data, b"WAR" => warnings = data, b"ERR" => errors = data, b"OPN" => opens = data, @@ -400,7 +396,6 @@ impl Connection { Ok(ParseResult { ast: Arc::new(ast), stub: Arc::new(stub), - files: Arc::new(files), warnings: decode_errors(&warnings).context("decoding warnings")?, errors: decode_errors(&errors).context("decoding errors")?, }) diff --git a/crates/ide_db/src/erl_ast.rs b/crates/ide_db/src/erl_ast.rs index ef5d10a37..a8ae20b20 100644 --- a/crates/ide_db/src/erl_ast.rs +++ b/crates/ide_db/src/erl_ast.rs @@ -19,7 +19,6 @@ use elp_base_db::FileId; use elp_base_db::IncludeCtx; use elp_base_db::ProjectId; use elp_base_db::SourceDatabase; -use elp_base_db::VfsPath; use elp_erlang_service::Format; use elp_erlang_service::IncludeType; use elp_erlang_service::ParseError; @@ -30,7 +29,6 @@ use crate::erlang_service::ParseRequest; use crate::metadata; use crate::metadata::Metadata; use crate::LineIndexDatabase; -use crate::RootDatabase; pub trait AstLoader { fn load_ast( @@ -92,28 +90,6 @@ impl AstLoader for crate::RootDatabase { || self.unwind_if_cancelled(), &move |include_type, path| resolve_include(self, file_id, include_type, &path), ); - let included_files = files_from_bytes(&r.files); - for file in included_files { - let file_path = PathBuf::from(file.clone()); - let file = if file_path.is_absolute() { - file - } else { - match path.parent() { - None => file, - Some(file) => file - .to_path_buf() - .join(file) - .as_os_str() - .to_string_lossy() - .to_string(), - } - }; - let file_path = VfsPath::new_real_path(file); - if let Some(file_id) = find_path_in_project(self, project_id, &file_path) { - // Dummy read of file revision to make DB track changes - let _ = self.file_revision(file_id); - } - } r } } @@ -191,20 +167,3 @@ fn elp_metadata(db: &dyn ErlAstDatabase, file_id: FileId) -> Metadata { let source = db.parse(file_id); metadata::collect_metadata(&line_index, &file_text, &source) } - -pub fn files_from_bytes(bytes: &[u8]) -> Vec { - let str = String::from_utf8_lossy(bytes); - str.split('\n').map(|s| s.to_string()).collect::>() -} - -fn find_path_in_project( - db: &RootDatabase, - project_id: ProjectId, - path: &VfsPath, -) -> Option { - let project = db.project_data(project_id); - project - .source_roots - .iter() - .find_map(|&source_root_id| db.source_root(source_root_id).file_for_path(path)) -} diff --git a/erlang_service/src/erlang_service_lint.erl b/erlang_service/src/erlang_service_lint.erl index 95e13c85b..99700d5f3 100644 --- a/erlang_service/src/erlang_service_lint.erl +++ b/erlang_service/src/erlang_service_lint.erl @@ -45,32 +45,27 @@ run(Id, [FileName, Options0, OverrideOptions, PostProcess, Deterministic]) -> end, case lint_file(Forms3, FileName, Options3, OverrideOptions) of {ok, []} -> - {Stub, AST, FILES} = partition_stub(Forms3), + {Stub, AST} = partition_stub(Forms3), ResultStub = PostProcess(Stub, FileName), ResultAST = PostProcess(AST, FileName), - ResultFILES = unicode:characters_to_binary(FILES), - {ok, [{<<"AST">>, ResultAST}, {<<"STU">>, ResultStub}, {<<"FIL">>, ResultFILES}]}; + {ok, [{<<"AST">>, ResultAST}, {<<"STU">>, ResultStub}]}; {ok, Warnings} -> - {Stub, AST, FILES} = partition_stub(Forms3), + {Stub, AST} = partition_stub(Forms3), ResultStub = PostProcess(Stub, FileName), ResultAST = PostProcess(AST, FileName), - ResultFILES = unicode:characters_to_binary(FILES), FormattedWarnings = format_errors(Forms3, FileName, Warnings), {ok, [{<<"AST">>, ResultAST}, {<<"STU">>, ResultStub}, - {<<"FIL">>, ResultFILES}, {<<"WAR">>, FormattedWarnings}]}; {error, Errors, Warnings} -> - {Stub, AST, FILES} = partition_stub(Forms3), + {Stub, AST} = partition_stub(Forms3), ResultStub = PostProcess(Stub, FileName), ResultAST = PostProcess(AST, FileName), - ResultFILES = unicode:characters_to_binary(FILES), FormattedErrors = format_errors(Forms3, FileName, Errors), FormattedWarnings = format_errors(Forms3, FileName, Warnings), {ok, [ {<<"AST">>, ResultAST}, {<<"STU">>, ResultStub}, - {<<"FIL">>, ResultFILES}, {<<"ERR">>, FormattedErrors}, {<<"WAR">>, FormattedWarnings} ]} @@ -160,11 +155,9 @@ vararg_transform(Atomic) -> Atomic. -spec partition_stub([elp_parse:abstract_form()]) -> - {Stub :: [elp_parse:abstract_form()], AST :: [elp_parse:abstract_form()], FILES :: string()}. + {Stub :: [elp_parse:abstract_form()], AST :: [elp_parse:abstract_form()]}. partition_stub(Forms) -> {[Attr || {attribute, _, _, _} = Attr <- Forms], - Forms, - % eqwalizer:ignore - We know that the Name is a string, from matching the abstract form - string:join([Name || {attribute, _, file, {Name,_}} = _Attr <- Forms],"\n")}. + Forms}. format_errors(Forms, OriginalPath, Warnings) ->