You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "sdedic (via GitHub)" <gi...@apache.org> on 2024/12/10 14:56:22 UTC

Re: [PR] Create new output channel for every LspIO [netbeans]

sdedic commented on code in PR #8000:
URL: https://github.com/apache/netbeans/pull/8000#discussion_r1878217321


##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java:
##########
@@ -1358,6 +1358,27 @@ public CompletableFuture<Boolean> requestDocumentSave(SaveDocumentRequestParams
             logWarning(Arrays.asList(documentUris));
             return CompletableFuture.completedFuture(false);
         }
+
+        @Override
+        public CompletableFuture<Void> writeOutput(OutputMessage lm) {
+            logWarning(lm.message);
+            return CompletableFuture.completedFuture(null);
+        }
+
+        @Override
+        public CompletableFuture<Void> showOutput(String outputName) {
+            return CompletableFuture.completedFuture(null);

Review Comment:
   Maybe add logWarning to all the new outgoing call stubs.



##########
java/java.lsp.server/vscode/src/extension.ts:
##########
@@ -377,6 +377,107 @@ function getValueAfterPrefix(input: string | undefined, prefix: string): string
     return '';
 }
 
+class LineBufferingPseudoterminal implements vscode.Pseudoterminal {
+    private static instances = new Map<string, LineBufferingPseudoterminal>();
+
+    private writeEmitter = new vscode.EventEmitter<string>();
+    onDidWrite: vscode.Event<string> = this.writeEmitter.event;
+
+    private closeEmitter = new vscode.EventEmitter<void>();
+    onDidClose?: vscode.Event<void> = this.closeEmitter.event;
+
+    private buffer: string = ''; 
+    private isOpen = false;
+    private readonly name: string;
+    private terminal: vscode.Terminal | undefined;
+
+    private constructor(name: string) {
+        this.name = name;
+    }
+
+    open(): void {
+        this.isOpen = true;
+    }
+
+    close(): void {
+        this.isOpen = false;
+        this.closeEmitter.fire();
+    }
+
+    /**
+     * Accepts partial input strings and logs complete lines when they are formed.
+     * Also processes carriage returns (\r) to overwrite the current line.
+     * @param input The string input to the pseudoterminal.
+     */
+    public acceptInput(input: string): void {
+        if (!this.isOpen) {
+            return;
+        }
+
+        for (const char of input) {
+            if (char === '\n') {
+                // Process a newline: log the current buffer and reset it
+                this.logLine(this.buffer.trim());
+                this.buffer = '';
+            } else if (char === '\r') {
+                // Process a carriage return: log the current buffer on the same line
+                this.logInline(this.buffer.trim());
+                this.buffer = '';
+            } else {
+                // Append characters to the buffer
+                this.buffer += char;
+            }
+        }
+    }
+
+    private logLine(line: string): void {
+        console.log('[Gradle Debug]', line.toString());

Review Comment:
   Gradle debug here ?



##########
java/java.lsp.server/vscode/src/extension.ts:
##########
@@ -377,6 +377,107 @@ function getValueAfterPrefix(input: string | undefined, prefix: string): string
     return '';
 }
 
+class LineBufferingPseudoterminal implements vscode.Pseudoterminal {
+    private static instances = new Map<string, LineBufferingPseudoterminal>();
+
+    private writeEmitter = new vscode.EventEmitter<string>();
+    onDidWrite: vscode.Event<string> = this.writeEmitter.event;
+
+    private closeEmitter = new vscode.EventEmitter<void>();
+    onDidClose?: vscode.Event<void> = this.closeEmitter.event;
+
+    private buffer: string = ''; 
+    private isOpen = false;
+    private readonly name: string;
+    private terminal: vscode.Terminal | undefined;
+
+    private constructor(name: string) {
+        this.name = name;
+    }
+
+    open(): void {
+        this.isOpen = true;
+    }
+
+    close(): void {
+        this.isOpen = false;
+        this.closeEmitter.fire();
+    }
+
+    /**
+     * Accepts partial input strings and logs complete lines when they are formed.
+     * Also processes carriage returns (\r) to overwrite the current line.
+     * @param input The string input to the pseudoterminal.
+     */
+    public acceptInput(input: string): void {
+        if (!this.isOpen) {
+            return;
+        }
+
+        for (const char of input) {
+            if (char === '\n') {
+                // Process a newline: log the current buffer and reset it
+                this.logLine(this.buffer.trim());
+                this.buffer = '';
+            } else if (char === '\r') {
+                // Process a carriage return: log the current buffer on the same line
+                this.logInline(this.buffer.trim());

Review Comment:
   Not sure about this: we have buffered content + instruction not to leave the line. So the result should be printed content from whenever the caret is at the moment + return at the start of line. 
    According to logInline comment, it will actially clear the current line + print the buffered content, leaving the caret at the end -- a reverse of the original instructions (content + CR)
   
   Did I understand wrong ?



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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