You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "stricklandrbls (via GitHub)" <gi...@apache.org> on 2023/02/14 20:28:57 UTC

[GitHub] [daffodil-vscode] stricklandrbls opened a new pull request, #452: Revised Data Editor Integration

stricklandrbls opened a new pull request, #452:
URL: https://github.com/apache/daffodil-vscode/pull/452

   Revised Omega Edit data editor integration to target 1.3.0 release. 
   
   ### Issues Addressed
   - https://github.com/apache/daffodil-vscode/issues/130
   - https://github.com/apache/daffodil-vscode/issues/131
   - https://github.com/apache/daffodil-vscode/issues/132
   - https://github.com/apache/daffodil-vscode/issues/137
   - https://github.com/apache/daffodil-vscode/issues/138
   - https://github.com/apache/daffodil-vscode/issues/139
   - https://github.com/apache/daffodil-vscode/issues/140
   - https://github.com/apache/daffodil-vscode/issues/141
   - https://github.com/apache/daffodil-vscode/issues/143
   - https://github.com/apache/daffodil-vscode/issues/145
   - https://github.com/apache/daffodil-vscode/issues/311
   - https://github.com/apache/daffodil-vscode/issues/430


-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] Shanedell commented on pull request #452: Revised Data Editor Integration

Posted by "Shanedell (via GitHub)" <gi...@apache.org>.
Shanedell commented on PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#issuecomment-1468345284

   @stricklandrbls Are you able to resolve the conflicts? We will want the CI to run so we can check if windows is still having issues. Currently on the `omega-edit` there still seems to be an issue with getting the classpath jar added.


-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1123137518


##########
src/omega_edit/dataEditWebView.ts:
##########
@@ -0,0 +1,366 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import * as vscode from 'vscode'
+import { SvelteWebviewInitializer } from './svelteWebviewInitializer'
+import {
+  logicalDisplay,
+  DisplayState,
+  fillRequestData,
+  dataToEncodedStr,
+  viewportSubscribe,
+  checkMimeType,
+  encodedStrToData,
+  ViewportReference,
+  hashData,
+  hashViewport,
+  hashCommitedSelection,
+  getOnDiskFileSize,
+} from './utils'
+import { EditorMessage, MessageCommand } from '../svelte/src/utilities/message'
+import * as omegaEditSession from 'omega-edit/session'
+import * as omegaEditViewport from 'omega-edit/viewport'
+import * as omegaEditChange from 'omega-edit/change'
+import { OmegaEdit } from './omega_edit'
+
+const VIEWPORT_CAPACITY_MAX = 1048576 // Maximum viewport size in Ωedit is 1048576 (1024 * 1024)
+
+export class DataEditWebView implements vscode.Disposable {
+  public panel: vscode.WebviewPanel
+  private svelteWebviewInitializer: SvelteWebviewInitializer
+  private displayState = new DisplayState()
+  private omegaViewports: Map<string, ViewportReference> = new Map()
+  private currentOmegaViewport: ViewportReference
+  private fileToEdit: string = ''
+  private omegaSessionId = ''
+  constructor(
+    protected context: vscode.ExtensionContext,
+    private view: string,
+    title: string
+  ) {
+    this.panel = this.createPanel(title)
+    this.panel.webview.onDidReceiveMessage(this.messageReceiver, this)
+
+    this.svelteWebviewInitializer = new SvelteWebviewInitializer(context)
+    this.svelteWebviewInitializer.initialize(this.view, this.panel.webview)
+    this.currentOmegaViewport = {
+      label: '',
+      vpid: '',
+      hash: '',
+    }
+  }
+
+  dispose(): void {
+    ;async () => {
+      this.omegaViewports.forEach(async (vpo) => {
+        await omegaEditViewport.destroyViewport(vpo.vpid)
+      })
+      await omegaEditSession.destroySession(this.omegaSessionId)
+    }
+    this.panel.dispose()
+  }
+
+  show(): void {
+    this.panel.reveal()
+  }
+
+  setTitle(title: string): void {
+    this.panel.title = title
+  }
+
+  public async initialize() {
+    vscode.window
+      .showOpenDialog({
+        canSelectMany: false,
+        openLabel: 'Select',
+        canSelectFiles: true,
+        canSelectFolders: false,
+      })
+      .then(async (fileUri) => {
+        if (fileUri && fileUri[0]) {
+          this.fileToEdit = fileUri[0].fsPath
+          this.sendDiskFileSize()
+        }
+
+        this.omegaSessionId = await omegaEditSession.createSession(
+          this.fileToEdit,
+          undefined
+        )
+        let currentVpid = await omegaEditViewport.createViewport(
+          undefined,
+          this.omegaSessionId,
+          0,
+          VIEWPORT_CAPACITY_MAX,
+          false
+        )
+        this.setCurrentViewport(currentVpid, 'vpAll')
+      })
+  }
+
+  private createPanel(title: string): vscode.WebviewPanel {
+    const column =
+      vscode.window.activeTextEditor &&
+      vscode.window.activeTextEditor.viewColumn
+        ? vscode.window.activeTextEditor?.viewColumn
+        : vscode.ViewColumn.Active
+    return vscode.window.createWebviewPanel(this.view, title, column, {
+      enableScripts: true,
+      retainContextWhenHidden: true,
+    })
+  }
+
+  private async sendDiskFileSize() {
+    return this.panel.webview.postMessage({
+      command: MessageCommand.fileInfo,
+      data: {
+        diskFileSize: await getOnDiskFileSize(this.fileToEdit),
+      },
+    })
+  }
+
+  private async sendChangesInfo() {
+    this.panel.webview.postMessage({
+      command: MessageCommand.fileInfo,
+      data: {
+        computedFilesize: await omegaEditSession.getComputedFileSize(
+          this.omegaSessionId
+        ),
+        commitHash: await hashViewport(this.currentOmegaViewport.vpid),
+        changeCount: await omegaEditChange.getChangeCount(this.omegaSessionId),
+        undoCount: await omegaEditChange.getUndoCount(this.omegaSessionId),
+      },
+    })
+  }
+
+  // handle messages from the webview
+  private async messageReceiver(message: EditorMessage) {
+    switch (message.command) {
+      case MessageCommand.updateLogicalDisplay:
+        this.displayState.bytesPerRow = message.data.bytesPerRow
+        const logicalDisplayText = logicalDisplay(
+          message.data.viewportData,
+          this.displayState.bytesPerRow
+        )
+        this.panel.webview.postMessage({
+          command: MessageCommand.updateLogicalDisplay,
+          data: {
+            logicalDisplay: logicalDisplayText,
+          },
+        })
+        break
+      case MessageCommand.editorOnChange:
+        this.displayState.editorEncoding = message.data.encoding
+
+        if (message.data.selectionData.length > 0) {
+          const bufSlice = Buffer.from(message.data.selectionData)
+          this.panel.webview.postMessage({
+            command: MessageCommand.editorOnChange,
+            selectionHash: await hashCommitedSelection(
+              this.currentOmegaViewport.vpid,
+              message.data.fileOffset,
+              bufSlice.byteLength
+            ),
+            display: dataToEncodedStr(
+              bufSlice,
+              this.displayState.editorEncoding
+            ),
+          })
+        }
+
+        break
+      case MessageCommand.commit: {
+        const fileOffset = message.data.selectionStart
+        const data = message.data.selectionData
+        const originalSelectionLen = message.data.selectionDataLen + 1
+
+        const omegaEdit = new OmegaEdit(
+          this.omegaSessionId,
+          fileOffset,
+          data,
+          originalSelectionLen,
+          this.panel
+        )
+        await omegaEdit.replace(
+          this.omegaSessionId,
+          fileOffset,
+          originalSelectionLen,
+          data
+        )
+        this.sendChangesInfo()
+        break
+      }
+      case MessageCommand.undo:
+        await omegaEditChange.undo(this.omegaSessionId)
+        this.sendChangesInfo()
+        break
+      case MessageCommand.redo:
+        await omegaEditChange.redo(this.omegaSessionId)
+        this.sendChangesInfo()
+        break
+      case MessageCommand.clear:
+        await omegaEditChange.clear(this.omegaSessionId)
+        this.sendChangesInfo()
+        break
+      case MessageCommand.save:
+        {
+          const vpData = await omegaEditViewport.getViewportData(
+            this.currentOmegaViewport.vpid
+          )
+          const omegaEdit = new OmegaEdit(
+            this.omegaSessionId,
+            vpData.getOffset(),
+            vpData.getData() as string,
+            vpData.getLength(),
+            this.panel
+          )

Review Comment:
   This OmegaEdit class was nuked a while ago.  I suspect the merge is bad.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1123105512


##########
src/svelte/src/utilities/display.ts:
##########
@@ -0,0 +1,260 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+const binary_regex = /^[0-1]*$/
+const decimal_regex = /^[0-9]*$/
+const octal_regex = /^[0-7]*$/
+const hex_regex = /^[0-9a-fA-F]*$/
+// const base64_regex =
+//   /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/

Review Comment:
   Remove commented code.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1123135503


##########
src/omega_edit/dataEditWebView.ts:
##########
@@ -0,0 +1,366 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import * as vscode from 'vscode'
+import { SvelteWebviewInitializer } from './svelteWebviewInitializer'
+import {
+  logicalDisplay,
+  DisplayState,
+  fillRequestData,
+  dataToEncodedStr,
+  viewportSubscribe,
+  checkMimeType,
+  encodedStrToData,
+  ViewportReference,
+  hashData,
+  hashViewport,
+  hashCommitedSelection,
+  getOnDiskFileSize,
+} from './utils'
+import { EditorMessage, MessageCommand } from '../svelte/src/utilities/message'
+import * as omegaEditSession from 'omega-edit/session'
+import * as omegaEditViewport from 'omega-edit/viewport'
+import * as omegaEditChange from 'omega-edit/change'
+import { OmegaEdit } from './omega_edit'
+
+const VIEWPORT_CAPACITY_MAX = 1048576 // Maximum viewport size in Ωedit is 1048576 (1024 * 1024)
+
+export class DataEditWebView implements vscode.Disposable {
+  public panel: vscode.WebviewPanel
+  private svelteWebviewInitializer: SvelteWebviewInitializer
+  private displayState = new DisplayState()
+  private omegaViewports: Map<string, ViewportReference> = new Map()
+  private currentOmegaViewport: ViewportReference
+  private fileToEdit: string = ''
+  private omegaSessionId = ''
+  constructor(
+    protected context: vscode.ExtensionContext,
+    private view: string,
+    title: string
+  ) {
+    this.panel = this.createPanel(title)
+    this.panel.webview.onDidReceiveMessage(this.messageReceiver, this)
+
+    this.svelteWebviewInitializer = new SvelteWebviewInitializer(context)
+    this.svelteWebviewInitializer.initialize(this.view, this.panel.webview)
+    this.currentOmegaViewport = {
+      label: '',
+      vpid: '',
+      hash: '',
+    }
+  }
+
+  dispose(): void {
+    ;async () => {
+      this.omegaViewports.forEach(async (vpo) => {
+        await omegaEditViewport.destroyViewport(vpo.vpid)
+      })
+      await omegaEditSession.destroySession(this.omegaSessionId)
+    }
+    this.panel.dispose()
+  }
+
+  show(): void {
+    this.panel.reveal()
+  }
+
+  setTitle(title: string): void {
+    this.panel.title = title
+  }
+
+  public async initialize() {
+    vscode.window
+      .showOpenDialog({
+        canSelectMany: false,
+        openLabel: 'Select',
+        canSelectFiles: true,
+        canSelectFolders: false,
+      })
+      .then(async (fileUri) => {
+        if (fileUri && fileUri[0]) {
+          this.fileToEdit = fileUri[0].fsPath
+          this.sendDiskFileSize()
+        }
+
+        this.omegaSessionId = await omegaEditSession.createSession(
+          this.fileToEdit,
+          undefined
+        )
+        let currentVpid = await omegaEditViewport.createViewport(
+          undefined,
+          this.omegaSessionId,
+          0,
+          VIEWPORT_CAPACITY_MAX,
+          false
+        )
+        this.setCurrentViewport(currentVpid, 'vpAll')
+      })
+  }
+
+  private createPanel(title: string): vscode.WebviewPanel {
+    const column =
+      vscode.window.activeTextEditor &&
+      vscode.window.activeTextEditor.viewColumn
+        ? vscode.window.activeTextEditor?.viewColumn
+        : vscode.ViewColumn.Active
+    return vscode.window.createWebviewPanel(this.view, title, column, {
+      enableScripts: true,
+      retainContextWhenHidden: true,
+    })
+  }
+
+  private async sendDiskFileSize() {
+    return this.panel.webview.postMessage({
+      command: MessageCommand.fileInfo,
+      data: {
+        diskFileSize: await getOnDiskFileSize(this.fileToEdit),
+      },
+    })
+  }
+
+  private async sendChangesInfo() {
+    this.panel.webview.postMessage({
+      command: MessageCommand.fileInfo,
+      data: {
+        computedFilesize: await omegaEditSession.getComputedFileSize(
+          this.omegaSessionId
+        ),
+        commitHash: await hashViewport(this.currentOmegaViewport.vpid),
+        changeCount: await omegaEditChange.getChangeCount(this.omegaSessionId),
+        undoCount: await omegaEditChange.getUndoCount(this.omegaSessionId),
+      },
+    })
+  }
+
+  // handle messages from the webview
+  private async messageReceiver(message: EditorMessage) {
+    switch (message.command) {
+      case MessageCommand.updateLogicalDisplay:
+        this.displayState.bytesPerRow = message.data.bytesPerRow
+        const logicalDisplayText = logicalDisplay(
+          message.data.viewportData,
+          this.displayState.bytesPerRow
+        )
+        this.panel.webview.postMessage({
+          command: MessageCommand.updateLogicalDisplay,
+          data: {
+            logicalDisplay: logicalDisplayText,
+          },
+        })
+        break
+      case MessageCommand.editorOnChange:
+        this.displayState.editorEncoding = message.data.encoding
+
+        if (message.data.selectionData.length > 0) {
+          const bufSlice = Buffer.from(message.data.selectionData)
+          this.panel.webview.postMessage({
+            command: MessageCommand.editorOnChange,
+            selectionHash: await hashCommitedSelection(
+              this.currentOmegaViewport.vpid,
+              message.data.fileOffset,
+              bufSlice.byteLength
+            ),
+            display: dataToEncodedStr(
+              bufSlice,
+              this.displayState.editorEncoding
+            ),
+          })
+        }
+
+        break
+      case MessageCommand.commit: {
+        const fileOffset = message.data.selectionStart
+        const data = message.data.selectionData
+        const originalSelectionLen = message.data.selectionDataLen + 1
+
+        const omegaEdit = new OmegaEdit(

Review Comment:
   This definitely isn't right.  Some wires were crossed somewhere.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1123108026


##########
src/svelte/src/utilities/display.ts:
##########
@@ -0,0 +1,260 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+
+//     http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+const binary_regex = /^[0-1]*$/
+const decimal_regex = /^[0-9]*$/
+const octal_regex = /^[0-7]*$/
+const hex_regex = /^[0-9a-fA-F]*$/
+// const base64_regex =
+//   /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/

Review Comment:
   BASE64 provides a convenient way to insert binary data/files into a session, in which case we would want to validate that data with this regex.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#issuecomment-1464514560

   @Shanedell, will you look into the failing tests?  Thanks.


-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] Shanedell commented on pull request #452: Revised Data Editor Integration

Posted by "Shanedell (via GitHub)" <gi...@apache.org>.
Shanedell commented on PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#issuecomment-1466891897

   @stricklandrbls Add some white space in the code. Don't have everything all compacted, having some extra white space makes the code easier to read and to see whats going on.
   
   Also please fix the merge conflict.
   
   I am currently working on a fix for `omega-edit` so that it doesn't fail in windows because of that line too long thing anymore. Will comment here when you will need to update that version.


-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] Shanedell commented on pull request #452: Revised Data Editor Integration

Posted by "Shanedell (via GitHub)" <gi...@apache.org>.
Shanedell commented on PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#issuecomment-1433918712

   @stricklandrbls In your git commit you need to add more details as to what is being changed. Also you need to address what issues this PR closes/fixes, each issue should have its own line. So for example:
   
   ```bash
   Data Editor Integration:
   
   - Remake UI for omega-edit data editor.
   - Add svelte to code to allow us to make more dynamic UIs.
   - No longer mark data editor as experimental.
   
   Closes #130 
   Closes #131 
   ```
   
   In this repo usually we do more of generally stating what major or important updates are going on in the PR.


-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1123100269


##########
src/tests/suite/utils.test.ts:
##########
@@ -45,7 +45,7 @@ suite('Utils Test Suite', () => {
   }
 
   test('Default config', async () => {
-    var config = await utils.getConfig(name, request, type)

Review Comment:
   `var` should be `const`.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1123127342


##########
src/omega_edit/omega_edit.ts:
##########
@@ -17,13 +17,13 @@
 

Review Comment:
   I thought we got rid of this whole file?!



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1123119195


##########
src/omega_edit/utils.ts:
##########
@@ -127,19 +102,18 @@ export async function viewportSubscribe(
   panel: vscode.WebviewPanel,
   vp1: string,
   vp2: string,
-  commandViewport: string,
-  commandHex: string | null
+  commandViewport: string
 ) {
-  var request = new EventSubscriptionRequest()
+  let request = new EventSubscriptionRequest()

Review Comment:
   Should be `const`.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1123103241


##########
src/svelte/src/utilities/message.ts:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// import * as vscode from 'vscode'

Review Comment:
   Remove commented code.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] Shanedell merged pull request #452: Revised Data Editor Integration

Posted by "Shanedell (via GitHub)" <gi...@apache.org>.
Shanedell merged PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452


-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1134520648


##########
package.json:
##########
@@ -509,15 +503,31 @@
               "type": "string"
             },
             "default": {}
+          },
+          "dataEditor.defaultServerPort": {
+            "type": "integer",
+            "description": "Editor server default port",
+            "default": 9000
+          },
+          "dataEditor.logFile": {
+            "type": "string",
+            "description": "Path to log file for data editor",
+            "default": "${workspaceFolder}/dataEditor-${serverPort}.log"
+          },
+          "dataEditor.logLevel": {
+            "type": "string",
+            "description": "Log level for data editor",
+            "enum": [
+              "error",
+              "warn",
+              "info",
+              "debug",
+              "trace"
+            ],
+            "default": "info"
           }
         }
       }
     ]
-  },
-  "__metadata": {
-    "id": "4f1304da-7e65-48f1-9126-0a143e2e5ef2",
-    "publisherDisplayName": "Apache Software Foundation",
-    "publisherId": "4dbc1d1a-d64b-46f8-8756-1c234855f645",
-    "isPreReleaseVersion": false

Review Comment:
   This seems like something we should keep.



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] stricklandrbls commented on pull request #452: Revised Data Editor Integration

Posted by "stricklandrbls (via GitHub)" <gi...@apache.org>.
stricklandrbls commented on PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#issuecomment-1467218130

   > @stricklandrbls Add some white space in the code. Don't have everything all compacted, having some extra white space makes the code easier to read and to see whats going on.
   
   Do we have a style guide established for things like this that `prettier` doesn't resolve? If no, should we establish one?


-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] Shanedell commented on a diff in pull request #452: Revised Data Editor Integration

Posted by "Shanedell (via GitHub)" <gi...@apache.org>.
Shanedell commented on code in PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#discussion_r1134563787


##########
src/omega_edit/client.ts:
##########
@@ -41,217 +37,174 @@ export function getOmegaEditPackageVersion(filePath: fs.PathLike) {
   ]
 }
 
-async function cleanupViewportSession(
-  sessionId: string,
-  viewportIds: Array<string>
-) {
-  viewportIds.forEach(async (vid) => {
-    await omegaEditViewport.destroyViewport(vid)
-  })
-  await omegaEditSession.destroySession(sessionId)
-}
-
-async function commonOmegaEdit(
-  ctx: vscode.ExtensionContext,
-  startServer: boolean,
-  omegaEditPackageVersion: string,
-  port: number
-) {
-  if (!serverRunning && startServer) {
-    ;[serverTerminal, serverRunning] = await startOmegaEditServer(
-      ctx,
-      rootPath,
-      omegaEditPackageVersion,
-      port
-    )
-  }
+function getServerPidFile() {
+  return path.join(appDataPath, `serv-${serverPort}.pid`)
 }
 
-async function getOmegaEditPort(
-  port: number | undefined = undefined
-): Promise<number> {
+async function getOmegaEditPort(port: number | undefined = undefined) {
   if (!port) {
+    const defaultServerPort = vscode.workspace
+      .getConfiguration('dataEditor')
+      .get<number>('defaultServerPort', serverPort)
     const portEntered = await vscode.window.showInputBox({
       prompt: 'Enter port number to run omega-edit server on',
-      value: '9000',
+      value: defaultServerPort.toString(),
     })
 
     if (portEntered) {
-      port = +portEntered
+      serverPort = parseInt(portEntered)
     } else {
+      serverPort = 0
       throw Error('Bad port entered')
     }
+  } else {
+    serverPort = port
+  }
+}
+
+function setupLogging() {
+  const config = vscode.workspace.getConfiguration('dataEditor')
+  const logFile = config
+    .get<string>('logFile', '${workspaceFolder}/dataEditor-${serverPort}.log')
+    ?.replace('${workspaceFolder}', appDataPath)
+    .replace('${serverPort}', serverPort.toString())
+  const logLevel =
+    process.env.OMEGA_EDIT_CLIENT_LOG_LEVEL ||
+    config.get<string>('logLevel', 'info')
+  fs.writeFileSync('/tmp/test75.txt', 'HERE 1')

Review Comment:
   Remove this line



-- 
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: commits-unsubscribe@daffodil.apache.org

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


[GitHub] [daffodil-vscode] Shanedell commented on pull request #452: Revised Data Editor Integration

Posted by "Shanedell (via GitHub)" <gi...@apache.org>.
Shanedell commented on PR #452:
URL: https://github.com/apache/daffodil-vscode/pull/452#issuecomment-1467268204

   I don't think so. I am not aware of things to check for too much run on code or anything like that. I am also not sure if the whole adding extra white space thing is a common practice or not for Typescript. Its just with how much code lives in this repository sometimes having a lot of code condensed together can make it harder to read and understand what is going on. Not necessary required but definitely nice to have


-- 
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: commits-unsubscribe@daffodil.apache.org

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