167 { |
167 { |
168 resources => |
168 resources => |
169 |
169 |
170 private val state = Synchronized(Thy_Resources.State()) |
170 private val state = Synchronized(Thy_Resources.State()) |
171 |
171 |
172 def load_thy(node_name: Document.Node.Name): Thy_Resources.Theory = |
|
173 { |
|
174 val path = node_name.path |
|
175 if (!node_name.is_theory) error("Not a theory file: " + path) |
|
176 |
|
177 val text = File.read(path) |
|
178 val node_header = resources.check_thy_reader(node_name, Scan.char_reader(text)) |
|
179 new Thy_Resources.Theory(node_name, node_header, text, true) |
|
180 } |
|
181 |
|
182 def load_theories( |
172 def load_theories( |
183 session: Session, |
173 session: Session, |
184 id: UUID, |
174 id: UUID, |
185 theories: List[(String, Position.T)], |
175 theories: List[(String, Position.T)], |
186 qualifier: String = Sessions.DRAFT, |
176 qualifier: String = Sessions.DRAFT, |
191 for ((thy, pos) <- theories) |
181 for ((thy, pos) <- theories) |
192 yield (import_name(qualifier, master_dir, thy), pos) |
182 yield (import_name(qualifier, master_dir, thy), pos) |
193 |
183 |
194 val dependencies = resources.dependencies(import_names, progress = progress).check_errors |
184 val dependencies = resources.dependencies(import_names, progress = progress).check_errors |
195 val dep_theories = dependencies.theories |
185 val dep_theories = dependencies.theories |
196 val loaded_theories = dep_theories.map(load_thy(_)) |
186 |
|
187 val loaded_theories = |
|
188 for (node_name <- dep_theories) |
|
189 yield { |
|
190 val path = node_name.path |
|
191 if (!node_name.is_theory) error("Not a theory file: " + path) |
|
192 |
|
193 progress.expose_interrupt() |
|
194 val text = File.read(path) |
|
195 val node_header = resources.check_thy_reader(node_name, Scan.char_reader(text)) |
|
196 new Thy_Resources.Theory(node_name, node_header, text, true) |
|
197 } |
197 |
198 |
198 val edits = |
199 val edits = |
199 state.change_result(st => |
200 state.change_result(st => |
200 { |
201 { |
201 val st1 = st.insert_required(id, dep_theories) |
202 val st1 = st.insert_required(id, dep_theories) |