Giter Site home page Giter Site logo

Comments (6)

afonsonf avatar afonsonf commented on May 28, 2024 1

@afonsonf Do you have plans to re-add the functionality that shows deleted set elements in the error trace view?

if (value.deletedItems) {
value.deletedItems.forEach((dit) => displayValue(elSubList, dit, showUnmodified));
}

Hi, true I missed that part in the migration of the ui, I will add it back

from vscode-tlaplus.

lemmy avatar lemmy commented on May 28, 2024

Perhaps it's TLC that should provide annotations in its textual error trace to free IDEs from parsing and evaluating values.

from vscode-tlaplus.

lemmy avatar lemmy commented on May 28, 2024

The Toolbox's set difference algorithm:

https://github.com/tlaplus/tlaplus/blob/baf6f1b4000ba72cd4ac2704d07c60ea2ae8343b/toolbox/org.lamport.tla.toolbox.tool.tlc.ui/src/org/lamport/tla/toolbox/tool/tlc/output/data/TLCSetVariableValue.java#L69-L107

from vscode-tlaplus.

lemmy avatar lemmy commented on May 28, 2024

@afonsonf Do you have plans to re-add the functionality that shows deleted set elements in the error trace view?

if (value.deletedItems) {
value.deletedItems.forEach((dit) => displayValue(elSubList, dit, showUnmodified));
}

from vscode-tlaplus.

lemmy avatar lemmy commented on May 28, 2024

Incomplete attempt to bring the rest of the Toolbox diffing over:

diff --git a/src/model/check.ts b/src/model/check.ts
index 79c015a..bf60526 100644
--- a/src/model/check.ts
+++ b/src/model/check.ts
@@ -178,6 +178,14 @@ export class Value {
     format(indent: string): string {
         return `${this.str}`;
     }
+
+    diff(other: Value): boolean {
+        if (this.str !== other.str) {
+            other.setModified();
+            return true;
+        }
+        return false;
+    }
 }
 
 /**
@@ -257,6 +265,63 @@ export abstract class CollectionValue extends Value {
     formatKey(indent: string, value: Value): string {
         return `${indent}${value.key}: `;
     }
+
+    // diff(other: Value): boolean {
+    //     return false;
+    // }
+    setElementArrayDiffInfo(
+        t: CollectionValue,
+        o: CollectionValue,
+        firstElts: Value[],
+        firstLHKeys: ValueKey[],
+        secondElts: Value[],
+        secondLHKeys: ValueKey[]
+    ): void {
+        const deletedItems = [];
+        for (let i = 0; i < firstElts.length; i++) {
+            let notfound = true;
+            let j = 0;
+            while (notfound && j < secondElts.length) {
+                if (firstLHKeys[i] === secondLHKeys[j]) {
+                    notfound = false;
+                    const first = firstElts[i];
+                    const second = secondElts[j];
+                    if (first.str !== second.str) {
+                        secondElts[i].setModified();
+                        second.setModified();
+                        if (first.constructor === second.constructor) {
+                            // Only diff objects of identical types
+                            first.diff(second);
+                        }
+                    }
+                }
+                j++;
+            }
+            if (notfound) {
+                deletedItems.push(firstElts[i]);
+            }
+        }
+        if (deletedItems.length > 0) {
+            o.addDeletedItems(deletedItems);
+            o.setModified();
+        }
+
+        for (let i = 0; i < secondElts.length; i++) {
+            const s = secondElts[i].str;
+            let notfound = true;
+            let j = 0;
+            while (notfound && j < firstElts.length) {
+                const f = firstElts[j].str;
+                if (f === s) {
+                    notfound = false;
+                }
+                j++;
+            }
+            if (notfound) {
+                secondElts[i].setAdded();
+            }
+        }
+    }
 }
 
 /**
@@ -381,6 +446,33 @@ export class StructureValue extends CollectionValue {
     formatKey(indent: string, value: Value): string {
         return `${indent}${value.key}` + this.itemSep;
     }
+
+    diff(other: Value): boolean {
+        /*
+         * RECORDS We mark a record element as added or deleted if its label
+         * does not appear in one of the elements of the other record. We
+         * mark the element as changed, and call setInnerDiffInfo on the
+         * elements' values if elements with the same label but different values
+         * appear in the two records.
+         */
+        if (!(other instanceof StructureValue)) {
+            return false;
+        }
+
+        const secondElts: StructureValue = (other as StructureValue);
+
+        const firstLHStrings: ValueKey[] = [];
+        for (let i = 0; i < this.items.length; i++) {
+            firstLHStrings[i] = this.items[i].key;
+        }
+        const secondLHStrings: ValueKey[] = [];
+        for (let i = 0; i < other.items.length; i++) {
+            secondLHStrings[i] = secondElts.items[i].key;
+        }
+
+        this.setElementArrayDiffInfo(this, other, this.items, firstLHStrings, secondElts.items, secondLHStrings);
+        return true;
+    }
 }
 
 /**
@@ -538,6 +630,15 @@ export function getStatusName(status: CheckStatus): string {
 /**
  * Recursively finds and marks all the changes between two collections.
  */
+export function findChangesOff(prev: CollectionValue, state: CollectionValue): boolean {
+    let i = 0;
+    while (i < prev.items.length && i < state.items.length) {
+        prev.items[i].diff(state.items[i]);
+        i++;
+    }
+    return true;
+}
+
 export function findChanges(prev: CollectionValue, state: CollectionValue): boolean {
     let pi = 0;
     let si = 0;

from vscode-tlaplus.

lemmy avatar lemmy commented on May 28, 2024

@afonsonf Do you have plans to re-add the functionality that shows deleted set elements in the error trace view?

if (value.deletedItems) {
value.deletedItems.forEach((dit) => displayValue(elSubList, dit, showUnmodified));
}

A set will only be marked modified M until the webview shows deleted set elements again.

image

from vscode-tlaplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.