Skip to content

Commit

Permalink
Add dummy classes for xtext @pure and ToStringBuilder to prevent
Browse files Browse the repository at this point in the history
ClassNotFoundExceptions while debugging.  See
eclipse-lsp4j/lsp4j#494 for context.

[Bug]
  • Loading branch information
lemmy committed Jan 20, 2021
1 parent f88a2a2 commit 9dd6fa8
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.eclipse.xtext.xbase.lib;

import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

@Documented
@Retention(RUNTIME)
@Target({ METHOD, CONSTRUCTOR })
public @interface Pure {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.eclipse.xtext.xbase.lib.util;

public class ToStringBuilder {

public ToStringBuilder(Object instance) {
}

public ToStringBuilder add(Object value) {
return this;
}

public ToStringBuilder add(String fieldName, Object value) {
return this;
}
}
4 changes: 4 additions & 0 deletions tlatools/org.lamport.tlatools/src/tlc2/tool/ITool.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public interface ITool extends TraceApp {

boolean getNextStates(final INextStateFunctor functor, final TLCState state);

IValue eval(SemanticNode expr);

IValue eval(SemanticNode expr, Context c);

IValue eval(SemanticNode expr, Context c, TLCState s0);

IValue eval(SemanticNode expr, Context c, TLCState s0, TLCState s1, int control);
Expand Down
29 changes: 25 additions & 4 deletions tlatools/org.lamport.tlatools/src/tlc2/tool/impl/DebugTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import tlc2.tool.INextStateFunctor;
import tlc2.tool.IStateFunctor;
import tlc2.tool.TLCState;
import tlc2.tool.TLCStateFun;
import tlc2.tool.coverage.CostModel;
import tlc2.util.Context;
import tlc2.value.IValue;
Expand All @@ -66,15 +67,21 @@ public DebugTool(String mainFile, String configFile, FilenameToStream resolver,
}

// 88888888888888888888888888888888888888888888888888888888888888888888888888 //

@Override
public final IValue eval(SemanticNode expr, Context ctxt) {
mode = EvalMode.Const;
return this.evalImpl(expr, Context.Empty, TLCState.Empty, TLCState.Empty, EvalControl.Clear,
CostModel.DO_NOT_RECORD);
}

@Override
public final IValue eval(SemanticNode expr, Context c, TLCState s0) {
mode = EvalMode.Const;
return this.evalImpl(expr, c, s0, TLCState.Empty, EvalControl.Clear, CostModel.DO_NOT_RECORD);
return this.eval(expr, c, s0, CostModel.DO_NOT_RECORD);
}

@Override
public IValue eval(SemanticNode expr, Context c, TLCState s0, CostModel cm) {
public final IValue eval(SemanticNode expr, Context c, TLCState s0, CostModel cm) {
mode = EvalMode.State;
return this.evalImpl(expr, c, s0, TLCState.Empty, EvalControl.Clear, cm);
}
Expand All @@ -100,13 +107,27 @@ public final Value eval(final SemanticNode expr, final Context c, final TLCState
}

@Override
protected Value evalImpl(final SemanticNode expr, final Context c, final TLCState s0, final TLCState s1,
protected final Value evalImpl(final SemanticNode expr, final Context c, final TLCState s0, final TLCState s1,
final int control, CostModel cm) {
if (target == null) {
// target is null during instantiation of super, ie. eager evaluation of
// operators in SpecProcessor.
return super.evalImpl(expr, c, s0, s1, control, cm);
}
if (EvalControl.isEnabled(control) || EvalControl.isPrimed(control)) {
// If EvalControl is set to primed or enabled, TLC is evaluating an ENABLED expr.
// TLCStateFun are passed in when enabled is evaluated. However, it is also
// possible for enabled to be replaced with primed. At any rate, there is no
// point evaluating ENABLED expr.
return super.evalImpl(expr, c, s0, s1, control, cm);
}
if (s0 instanceof TLCStateFun || s1 instanceof TLCStateFun) {
// If EvalControl is set to primed or enabled, TLC is evaluating an ENABLED expr.
// (see previous if branch). However, if expr is built from an operator with a
// Java module override, control is cleared/reset and the only indicator that
// evaluation is in the scope of enabled, is TLCStateFunc.
return super.evalImpl(expr, c, s0, s1, control, cm);
}
if (KINDS.contains(expr.getKind())) {
// These nodes don't seem interesting to users. They are leaves and we don't
// care to see how TLC figures out that then token 1 evaluates to the IntValue 1.
Expand Down
10 changes: 8 additions & 2 deletions tlatools/org.lamport.tlatools/src/tlc2/tool/impl/Tool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,14 @@ public IValue eval(SemanticNode expr, Context c, TLCState s0) {
return this.eval(expr, c, s0, TLCState.Empty, EvalControl.Clear, CostModel.DO_NOT_RECORD);
}

public final IValue eval(SemanticNode expr) {
return this.eval(expr, Context.Empty, TLCState.Empty);
@Override
public IValue eval(SemanticNode expr, Context c) {
return this.eval(expr, c, TLCState.Empty);
}

@Override
public IValue eval(SemanticNode expr) {
return this.eval(expr, Context.Empty);
}

@ExpectInlined
Expand Down
2 changes: 1 addition & 1 deletion tlatools/org.lamport.tlatools/test-model/EWD840/EWD840.tla
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ vars == <<active, color, tpos, tcolor>>

Fairness == WF_vars(System)

Spec == Init /\ [][Next]_vars (*/\ Fairness*)
Spec == Init /\ [][Next]_vars /\ Fairness

LInv == [][Next]_vars => WF_vars(System)

Expand Down
2 changes: 2 additions & 0 deletions tlatools/org.lamport.tlatools/test-model/EWD840/MC02.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ CONSTRAINT
StateConstraint
ACTION_CONSTRAINT
ActionConstraint
PROPERTIES
Liveness
2 changes: 1 addition & 1 deletion tlatools/org.lamport.tlatools/test-model/EWD840/MC02.tla
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const_143073460396411000 ==
2

spec_143073460397412000 ==
Spec
Spec /\ ENABLED Next /\ ENABLED (SelectSeq([i \in 1..N+1 |-> i - 1], LAMBDA node: node = tpos ) = <<tpos>>)

StateConstraint ==
\* For the tests to be interesting, this triggers the evaluation
Expand Down

0 comments on commit 9dd6fa8

Please sign in to comment.