@@ -116,6 +116,16 @@ use move_symbol_pool::Symbol;
116
116
/// go-to-references to the IDE.
117
117
pub const DEFS_AND_REFS_SUPPORT : bool = true ;
118
118
119
+ const MANIFEST_FILE_NAME : & str = "Move.toml" ;
120
+
121
+ #[ derive( Clone ) ]
122
+ pub struct PrecompiledPkgDeps {
123
+ /// Hash of the manifest file for a given package
124
+ manifest_hash : Option < FileHash > ,
125
+ /// Precompiled deps
126
+ deps : Arc < FullyCompiledProgram > ,
127
+ }
128
+
119
129
#[ derive( Debug , Clone , Eq , PartialEq , Ord , PartialOrd , Copy ) ]
120
130
/// Location of a definition's identifier
121
131
pub struct DefLoc {
@@ -731,7 +741,7 @@ impl SymbolicatorRunner {
731
741
pub fn new (
732
742
ide_files_root : VfsPath ,
733
743
symbols : Arc < Mutex < Symbols > > ,
734
- pkg_deps : Arc < Mutex < BTreeMap < PathBuf , Arc < FullyCompiledProgram > > > > ,
744
+ pkg_deps : Arc < Mutex < BTreeMap < PathBuf , PrecompiledPkgDeps > > > ,
735
745
sender : Sender < Result < BTreeMap < PathBuf , Vec < Diagnostic > > > > ,
736
746
lint : LintLevel ,
737
747
) -> Self {
@@ -851,7 +861,7 @@ impl SymbolicatorRunner {
851
861
let mut current_path_opt = Some ( starting_path) ;
852
862
while current_path_opt. is_some ( ) {
853
863
let current_path = current_path_opt. unwrap ( ) ;
854
- let manifest_path = current_path. join ( "Move.toml" ) ;
864
+ let manifest_path = current_path. join ( MANIFEST_FILE_NAME ) ;
855
865
if manifest_path. is_file ( ) {
856
866
return Some ( current_path. to_path_buf ( ) ) ;
857
867
}
@@ -1051,7 +1061,7 @@ impl Symbols {
1051
1061
/// actually (re)computed and the diagnostics are returned, the old symbolic information should
1052
1062
/// be retained even if it's getting out-of-date.
1053
1063
pub fn get_symbols (
1054
- pkg_dependencies : Arc < Mutex < BTreeMap < PathBuf , Arc < FullyCompiledProgram > > > > ,
1064
+ pkg_dependencies : Arc < Mutex < BTreeMap < PathBuf , PrecompiledPkgDeps > > > ,
1055
1065
ide_files_root : VfsPath ,
1056
1066
pkg_path : & Path ,
1057
1067
lint : LintLevel ,
@@ -1077,6 +1087,19 @@ pub fn get_symbols(
1077
1087
VfsPath :: new ( PhysicalFS :: new ( "/" ) ) ,
1078
1088
] ) ) ;
1079
1089
1090
+ let manifest_file = overlay_fs_root
1091
+ . join ( pkg_path. to_string_lossy ( ) )
1092
+ . and_then ( |p| p. join ( MANIFEST_FILE_NAME ) )
1093
+ . and_then ( |p| p. open_file ( ) ) ;
1094
+
1095
+ let manifest_hash = if let Ok ( mut f) = manifest_file {
1096
+ let mut contents = String :: new ( ) ;
1097
+ let _ = f. read_to_string ( & mut contents) ;
1098
+ Some ( FileHash :: new ( & contents) )
1099
+ } else {
1100
+ None
1101
+ } ;
1102
+
1080
1103
// get source files to be able to correlate positions (in terms of byte offsets) with actual
1081
1104
// file locations (in terms of line/column numbers)
1082
1105
let source_files = file_sources ( & resolution_graph, overlay_fs_root. clone ( ) ) ;
@@ -1120,18 +1143,24 @@ pub fn get_symbols(
1120
1143
1121
1144
let mut pkg_deps = pkg_dependencies. lock ( ) . unwrap ( ) ;
1122
1145
let compiled_deps = match pkg_deps. get ( pkg_path) {
1123
- Some ( d) => {
1146
+ Some ( d) if manifest_hash . is_some ( ) && manifest_hash == d . manifest_hash => {
1124
1147
eprintln ! ( "found pre-compiled libs for {:?}" , pkg_path) ;
1125
- Some ( d. clone ( ) )
1148
+ Some ( d. deps . clone ( ) )
1126
1149
}
1127
- None => construct_pre_compiled_lib ( src_deps, None , compiler_flags)
1150
+ _ => construct_pre_compiled_lib ( src_deps, None , compiler_flags)
1128
1151
. ok ( )
1129
1152
. and_then ( |pprog_and_comments_res| pprog_and_comments_res. ok ( ) )
1130
- . map ( |lib | {
1153
+ . map ( |libs | {
1131
1154
eprintln ! ( "created pre-compiled libs for {:?}" , pkg_path) ;
1132
- let res = Arc :: new ( lib) ;
1133
- pkg_deps. insert ( pkg_path. to_path_buf ( ) , res. clone ( ) ) ;
1134
- res
1155
+ let deps = Arc :: new ( libs) ;
1156
+ pkg_deps. insert (
1157
+ pkg_path. to_path_buf ( ) ,
1158
+ PrecompiledPkgDeps {
1159
+ manifest_hash,
1160
+ deps : deps. clone ( ) ,
1161
+ } ,
1162
+ ) ;
1163
+ deps
1135
1164
} ) ,
1136
1165
} ;
1137
1166
if compiled_deps. is_some ( ) {
0 commit comments