44import java .util .List ;
55import liquidjava .api .CommandLineLauncher ;
66import liquidjava .processor .VCImplication ;
7+ import liquidjava .processor .context .Context ;
8+ import liquidjava .processor .context .ContextHistory ;
79import liquidjava .rj_language .Predicate ;
810import liquidjava .rj_language .ast .BinaryExpression ;
911import liquidjava .rj_language .ast .Expression ;
1012import liquidjava .rj_language .ast .GroupExpression ;
1113import liquidjava .utils .Utils ;
1214import spoon .reflect .cu .SourcePosition ;
15+ import spoon .reflect .declaration .CtElement ;
1316import spoon .reflect .reference .CtTypeReference ;
1417
1518/**
@@ -29,6 +32,7 @@ public final class DebugLog {
2932 private static final String SMT_TAG = Colors .BLUE + "[SMT]" + Colors .RESET ;
3033 private static final String SMT_CHECK = Colors .SALMON + "[SMT CHECK]" + Colors .RESET ;
3134 private static final String SMP_TAG = Colors .YELLOW + "[SMP]" + Colors .RESET ;
35+ private static final String CTX_TAG = Colors .BRIGHT_MAGENTA + "[CTX]" + Colors .RESET ;
3236
3337 private DebugLog () {
3438 }
@@ -37,6 +41,11 @@ public static boolean enabled() {
3741 return CommandLineLauncher .cmdArgs .debugMode ;
3842 }
3943
44+ /** Gate for the full-context dump, driven by the {@code -a} / {@code --all-context} flag (independent of debug). */
45+ public static boolean contextEnabled () {
46+ return CommandLineLauncher .cmdArgs .printContext ;
47+ }
48+
4049 /**
4150 * One-line header for a verification check: emits the absolute file path + line so terminals (iTerm2, VS Code,
4251 * WezTerm, …) make it ⌘/Ctrl-clickable. Replaces the older two-line {@code info()} prints.
@@ -445,4 +454,31 @@ public static void smtError(String message) {
445454 System .out .println (SMT_TAG + " Result: " + Colors .RED + "ERROR" + Colors .RESET + " — "
446455 + (message == null ? "(no message)" : message ));
447456 }
457+
458+ public static void contextAtElement (CtElement element , String contextInfo ) {
459+ if (!contextEnabled ()) {
460+ return ;
461+ }
462+ SourcePosition position = element .getPosition ();
463+ String header ;
464+ if (position != null && position .getFile () != null ) {
465+ // file:line so terminals make it ⌘/Ctrl-clickable (same form as smtVerifying), plus the source line itself.
466+ String where = position .getFile ().getAbsolutePath () + ":" + position .getLine ();
467+ String code = Utils .getExpressionFromPosition (position );
468+ header = CTX_TAG + " Context at " + Colors .CYAN + where + Colors .RESET
469+ + (code != null ? " \n " + Colors .BOLD_YELLOW + code + Colors .RESET : ":" );
470+ } else {
471+ header = CTX_TAG + " Context at " + position + ":" ;
472+ }
473+ System .out .println (header );
474+ System .out .println (contextInfo );
475+ }
476+
477+ public static void log (String string ) {
478+ if (!enabled ()) {
479+ return ;
480+ }
481+ System .out .println (string );
482+
483+ }
448484}
0 commit comments