Skip to content

Commit

Permalink
Refactoring addChanges / detectChanges
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Aug 11, 2020
1 parent 3d9f511 commit 2d3ebea
Showing 1 changed file with 7 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ class WollokRemoteContextStateListener implements XInterpreterListener {
override started() {}

override terminated() {
if (forRepl) {
this.detectChanges
} else {
this.addChanges
}
this.detectChanges(!forRepl)
variables.notifyPossibleStateChanged
}

Expand All @@ -49,36 +45,21 @@ class WollokRemoteContextStateListener implements XInterpreterListener {

override evaluated(EObject element) {
if (!forRepl) {
this.detectChanges
}
}

def void detectChanges() {
try {
XDebugStackFrame.initAllVariables()
this.variables = #[]
val currentStack = interpreter.currentThread.stack
if (!currentStack.isEmpty) {
this.variables = new XDebugStackFrame(currentStack.peek).variables
}
} catch (Exception e) {
val realCause = e.realCause
println("ERROR: " + realCause.class.name + ", " + realCause.message)
realCause.stackTrace.forEach [ ste |
println('''«ste.methodName» («ste.fileName»:«ste.lineNumber»)''')
]
this.detectChanges(false)
}
}

def void addChanges() {
def void detectChanges(boolean preserveVariables) {
try {
XDebugStackFrame.initAllVariables()
val Collection<XDebugStackFrameVariable> variables = newArrayList(this.variables)
val Collection<XDebugStackFrameVariable> variables = if (preserveVariables) newArrayList(this.variables) else newArrayList
this.variables = #[]
val currentStack = interpreter.currentThread.stack
if (!currentStack.isEmpty) {
this.variables = new XDebugStackFrame(currentStack.peek).variables
this.variables.addAll(variables)
if (preserveVariables) {
this.variables.addAll(variables)
}
}
} catch (Exception e) {
val realCause = e.realCause
Expand Down

0 comments on commit 2d3ebea

Please sign in to comment.