104 rendering = model.rendering() |
104 rendering = model.rendering() |
105 offset <- model.doc.offset(node_pos.pos) |
105 offset <- model.doc.offset(node_pos.pos) |
106 } yield (rendering, offset) |
106 } yield (rendering, offset) |
107 |
107 |
108 |
108 |
|
109 /* document content */ |
|
110 |
|
111 private def update_document(uri: String, text: String) |
|
112 { |
|
113 resources.update_model(session, uri, text) |
|
114 delay_input.invoke() |
|
115 } |
|
116 |
|
117 private def close_document(uri: String) |
|
118 { |
|
119 resources.close_model(uri) match { |
|
120 case Some(model) => |
|
121 model.register(watcher) |
|
122 sync_external(Set(model.file)) |
|
123 case None => |
|
124 } |
|
125 } |
|
126 |
|
127 private def sync_external(changed: Set[JFile]): Unit = |
|
128 if (resources.sync_external(changed)) delay_input.invoke() |
|
129 |
|
130 private val watcher = File_Watcher(sync_external(_)) |
|
131 |
|
132 |
109 /* input from client */ |
133 /* input from client */ |
110 |
134 |
111 private val delay_input = |
135 private val delay_input = |
112 Standard_Thread.delay_last(options.seconds("vscode_input_delay")) |
136 Standard_Thread.delay_last(options.seconds("vscode_input_delay")) |
113 { resources.flush_input(session) } |
137 { resources.flush_input(session) } |
114 |
|
115 private def update_document(uri: String, text: String) |
|
116 { |
|
117 resources.update_model(session, uri, text) |
|
118 delay_input.invoke() |
|
119 } |
|
120 |
138 |
121 |
139 |
122 /* output to client */ |
140 /* output to client */ |
123 |
141 |
124 private val commands_changed = |
142 private val commands_changed = |
278 case Protocol.Exit(()) => exit() |
300 case Protocol.Exit(()) => exit() |
279 case Protocol.DidOpenTextDocument(uri, lang, version, text) => |
301 case Protocol.DidOpenTextDocument(uri, lang, version, text) => |
280 update_document(uri, text) |
302 update_document(uri, text) |
281 case Protocol.DidChangeTextDocument(uri, version, List(Protocol.TextDocumentContent(text))) => |
303 case Protocol.DidChangeTextDocument(uri, version, List(Protocol.TextDocumentContent(text))) => |
282 update_document(uri, text) |
304 update_document(uri, text) |
283 case Protocol.DidCloseTextDocument(uri) => channel.log("CLOSE " + uri) |
305 case Protocol.DidCloseTextDocument(uri) => |
|
306 close_document(uri) |
284 case Protocol.DidSaveTextDocument(uri) => channel.log("SAVE " + uri) |
307 case Protocol.DidSaveTextDocument(uri) => channel.log("SAVE " + uri) |
285 case Protocol.Hover(id, node_pos) => hover(id, node_pos) |
308 case Protocol.Hover(id, node_pos) => hover(id, node_pos) |
286 case Protocol.GotoDefinition(id, node_pos) => goto_definition(id, node_pos) |
309 case Protocol.GotoDefinition(id, node_pos) => goto_definition(id, node_pos) |
287 case _ => channel.log("### IGNORED") |
310 case _ => channel.log("### IGNORED") |
288 } |
311 } |