Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsp: added more synchronization while accessing the view context and syntheses. #131

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ class KGraphDiagramUpdater extends DiagramUpdater {
(diagramServers as List<KGraphDiagramServer>).forEach [ KGraphDiagramServer server |
// Only update an erroneous model if there was no diagram shown before.
if (!hasErrors || server.currentRoot.type == "NONE") {
prepareModel(server, model_, uri)
updateLayout(server)
synchronized (diagramState) {
prepareModel(server, model_, uri)
updateLayout(server)
}
}
]
return null as Void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,19 @@ class KGraphLanguageServerExtension extends SyncDiagramLanguageServer
* @return A list of the IDs and displayable names of all available syntheses.
*/
def List<SetSynthesesActionData> getAvailableSynthesesData(Class<?> currentModelClass) {
val KlighdDataManager kdm = KlighdDataManager.instance
return kdm.getAvailableSyntheses(currentModelClass).map [
val synthesisId = kdm.getSynthesisID(it)
var displayedName = ""
if (it instanceof ReinitializingDiagramSynthesisProxy) {
displayedName = it.delegate.class.simpleName
} else {
displayedName = it.class.simpleName
}
return new SetSynthesesActionData(synthesisId, displayedName)
].toList
synchronized (diagramState) {
val KlighdDataManager kdm = KlighdDataManager.instance
return kdm.getAvailableSyntheses(currentModelClass).map [
val synthesisId = kdm.getSynthesisID(it)
var displayedName = ""
if (it instanceof ReinitializingDiagramSynthesisProxy) {
displayedName = it.delegate.class.simpleName
} else {
displayedName = it.class.simpleName
}
return new SetSynthesesActionData(synthesisId, displayedName)
].toList
}
}

override setSynthesisOptions(SetSynthesisOptionsParam param) {
Expand Down Expand Up @@ -436,10 +438,12 @@ class KGraphLanguageServerExtension extends SyncDiagramLanguageServer
// With that new diagram server, do a similar procedure to generate a diagram as for usual diagrams (except,
// use the 'model' as its model.
if (diagramUpdater instanceof KGraphDiagramUpdater) {
(diagramUpdater as KGraphDiagramUpdater).prepareModel(diagramServer, model, uri)
AbstractLanguageServer.addToMainThreadQueue([
(diagramUpdater as KGraphDiagramUpdater).updateLayout(diagramServer)
])
synchronized (diagramState) {
(diagramUpdater as KGraphDiagramUpdater).prepareModel(diagramServer, model, uri)
AbstractLanguageServer.addToMainThreadQueue([
(diagramUpdater as KGraphDiagramUpdater).updateLayout(diagramServer)
])
}
// Also, update the syntheses available for the given diagram.
if (!update) {
val availableSynthesesData = getAvailableSynthesesData(model.class)
Expand Down