Skip to content

Commit

Permalink
remove unknown context types
Browse files Browse the repository at this point in the history
  • Loading branch information
yairco1990 committed Dec 12, 2023
1 parent 1c2490a commit da43de1
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ class GetEnrichingContextHandler(gson: Gson) :
val contextTypesSet = payload?.contextTypes?.toSet() ?: return EnrichingContextResponsePayload()
val editor = getEditorFromProject(project) ?: return EnrichingContextResponsePayload()

val enrichingContextData = contextTypesSet.map {
when (it) {
EnrichingContextType.Editor -> EditorContext.createFuture(editor)
EnrichingContextType.Workspace -> WorkspaceContext.createFuture(
editor,
project,
payload.workspaceCommands ?: emptyList()
)

EnrichingContextType.Diagnostics -> DiagnosticsContext.createFuture(editor, project)
val enrichingContextData = contextTypesSet
// remove unknown context types
.filter { it != null }.map {
when (it) {
EnrichingContextType.Editor -> EditorContext.createFuture(editor)
EnrichingContextType.Workspace -> WorkspaceContext.createFuture(
editor,
project,
payload.workspaceCommands ?: emptyList()
)

EnrichingContextType.Diagnostics -> DiagnosticsContext.createFuture(editor, project)
}
}
}

CompletableFuture.allOf(*enrichingContextData.toTypedArray()).get(3, TimeUnit.SECONDS)

Expand Down

0 comments on commit da43de1

Please sign in to comment.