Skip to content

Commit ee1dbeb

Browse files
committed
Improved visual style of scope inspection inb debugger
1 parent 70f2553 commit ee1dbeb

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

input/39.ql

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@ entity Cat {
66
Cat(name, age, interests)
77

88
fun printInterests() {
9-
// for (interest : interests) {
10-
vars()
11-
print("This should give an error:")
12-
print(beer)
13-
// breakpoint()
14-
// printf("Interest: %s", [interest])
15-
// }
9+
for (interest : interests) {
10+
breakpoint()
11+
printf("Interest: %s", [interest])
12+
}
1613
}
1714
}
1815

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
// This file is only accessible in the debug REPL
22

3+
/**
4+
* Prints out the functions in the current scope and all parents.
5+
*/
36
native fun functions()
47

8+
/**
9+
* Prints out the functions in the given entity's scope and all parents.
10+
*
11+
* @param entityInstance The instance of the entity to get the scope of
12+
*/
513
native fun functions(entityInstance)
614

15+
/**
16+
* Prints out the variables and their values in the current scope and all parents.
17+
*/
718
native fun vars()
819

20+
/**
21+
* Prints out the variables and their values in the given entity's scope and all parents.
22+
*
23+
* @param entityInstance The instance of the entity to get the scope of
24+
*/
925
native fun vars(entityInstance)
1026

1127
// This could be a call to backtrace() not natively,
1228
// however that makes the stack trace look messier
29+
/**
30+
* Prints out the current stacktrace of the program.
31+
*/
1332
native fun bt()
1433

34+
/**
35+
* Prints out the current stacktrace of the program.
36+
*/
1537
native fun backtrace()

qilletni-lib-std/src/main/java/is/yarr/qilletni/lib/core/DebugFunctions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
import java.util.HashSet;
1414
import java.util.Set;
15-
import java.util.stream.Collectors;
1615

1716
public class DebugFunctions {
1817

1918
private static final Logger LOGGER = LoggerFactory.getLogger(DebugFunctions.class);
2019

2120
final String ANSI_GREEN = "\u001B[32m";
21+
final String ANSI_GRAY = "\u001B[90m";
2222
final String ANSI_RESET = "\u001B[0m";
2323

2424
private final DebugSupport debugSupport;
@@ -60,7 +60,7 @@ private void printFunctionsFromScope(Scope scope, int depth, Set<Scope> printedS
6060
}
6161

6262
if (scope.getAllFunctionSymbols().isEmpty()) {
63-
System.out.printf("%s - No functions in scope -%n", spaces);
63+
System.out.printf("%s%s - No functions in scope -%s%n", spaces, ANSI_GRAY, ANSI_RESET);
6464
}
6565

6666
scope.getAllFunctionSymbols().forEach((name, symbols) -> {
@@ -107,7 +107,7 @@ private void printVariablesFromScope(Scope scope, int depth, Set<Scope> printedS
107107
}
108108

109109
if (scope.getAllSymbols().isEmpty()) {
110-
System.out.printf("%s - No variables in scope -%n", spaces);
110+
System.out.printf("%s%s - No variables in scope -%s%n", spaces, ANSI_GRAY, ANSI_RESET);
111111
}
112112

113113
scope.getAllSymbols().forEach((name, symbol) ->

0 commit comments

Comments
 (0)