dbalek commented on code in PR #4203:
URL: https://github.com/apache/netbeans/pull/4203#discussion_r899991800


##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/input/LspInputServiceImpl.java:
##########
@@ -32,32 +32,42 @@
 @JsonSegment("input")
 public class LspInputServiceImpl implements InputService {
 
-    private final Map<String, Function<InputCallbackParams, 
CompletableFuture<Either<QuickPickStep, InputBoxStep>>>> stepCallbacks = new 
HashMap<>();
-    private final Map<String, Function<InputCallbackParams, 
CompletableFuture<String>>> validateCallbacks = new HashMap<>();
+    private final RegistryImpl registry = new RegistryImpl();
 
-    public String registerInput(Function<InputCallbackParams, 
CompletableFuture<Either<QuickPickStep, InputBoxStep>>> stepCallback, 
Function<InputCallbackParams, CompletableFuture<String>> validateCallback) {
-        String id = "ID:" + System.identityHashCode(stepCallback);
-        stepCallbacks.put(id, stepCallback);
-        if (validateCallback != null) {
-            validateCallbacks.put(id, validateCallback);
+    @Override
+    public CompletableFuture<Either<QuickPickStep, InputBoxStep>> 
step(InputCallbackParams params) {
+        Callback callback = registry.callbacks.get(params.getInputId());
+        if (callback == null) {
+            return CompletableFuture.completedFuture(null);
         }
-        return id;
+        return callback.step(params).handle((step, ex) -> {
+            if (ex != null || step == null)  {
+                registry.callbacks.remove(params.getInputId());
+            }
+            return step;

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to