@@ -54,10 +54,10 @@ public final class SimpleCodeCoverageInstrument extends TruffleInstrument {
54
54
* but not yet executed {@link SourceSection}s. This is used to calculate
55
55
* the coverage for each {@link Source}.
56
56
*/
57
- private final Map <Source , Set <SourceSection >> sourceToUncoveredSections = new HashMap <>();
57
+ private final Map <Source , Set <SourceSection >> sourceToNotYetCoveredSections = new HashMap <>();
58
58
59
- public Map <Source , Set <SourceSection >> getSourceToUncoveredSections () {
60
- return sourceToUncoveredSections ;
59
+ public Map <Source , Set <SourceSection >> getSourceToNotYetCoveredSections () {
60
+ return sourceToNotYetCoveredSections ;
61
61
}
62
62
63
63
/**
@@ -123,7 +123,7 @@ protected void onCreate(final Env env) {
123
123
* factory produces {@link Node Truffle Nodes} that will be inserted into
124
124
* the AST at positions specified by the filter. Each of the inserted nodes
125
125
* will, once executed, remove the corresponding source section from the
126
- * {@link #sourceToUncoveredSections set of unexecuted source sections}.
126
+ * {@link #sourceToNotYetCoveredSections set of unexecuted source sections}.
127
127
*
128
128
* @param env The environment, used to get the {@link Instrumenter}
129
129
*/
@@ -163,28 +163,28 @@ private void ensurePrintCoverage(final Env env) {
163
163
*/
164
164
private void printResults (final Env env ) {
165
165
final PrintStream printStream = new PrintStream (env .out ());
166
- for (Source source : sourceToUncoveredSections .keySet ()) {
166
+ for (Source source : sourceToNotYetCoveredSections .keySet ()) {
167
167
final String path = source .getPath ();
168
168
final int lineCount = source .getLineCount ();
169
- final List <Integer > uncoveredLineNumbers = uncoveredLineNumbers (source );
170
- final int uncoveredLineCount = uncoveredLineNumbers .size ();
171
- double coveredPercentage = 100 * ((double ) lineCount - uncoveredLineCount ) / lineCount ;
169
+ final List <Integer > notYetCoveredLineNumbers = notYetCoveredLineNumbers (source );
170
+ final int notYetCoveredSize = notYetCoveredLineNumbers .size ();
171
+ double coveredPercentage = 100 * ((double ) lineCount - notYetCoveredSize ) / lineCount ;
172
172
printStream .println ("==" );
173
173
printStream .println ("Coverage of " + path + " is " + String .format ("%.2f%%" , coveredPercentage ));
174
174
printStream .println ("Lines not covered by execution:" );
175
- for (Integer uncoveredLineNumber : uncoveredLineNumbers ) {
176
- printStream .println (uncoveredLineNumber + " " + source .getCharacters (uncoveredLineNumber ));
175
+ for (Integer notYetCoveredLineNumber : notYetCoveredLineNumbers ) {
176
+ printStream .println (notYetCoveredLineNumber + " " + source .getCharacters (notYetCoveredLineNumber ));
177
177
}
178
178
}
179
179
}
180
180
181
181
/**
182
182
* @param source
183
- * @return A sorted list of line numers for uncovered lines of source code
184
- * in the given {@link Source}
183
+ * @return A sorted list of line numbers for not-yet-covered lines of source
184
+ * code in the given {@link Source}
185
185
*/
186
- public List <Integer > uncoveredLineNumbers (final Source source ) {
187
- Set <SourceSection > sections = sourceToUncoveredSections .get (source );
186
+ public List <Integer > notYetCoveredLineNumbers (final Source source ) {
187
+ Set <SourceSection > sections = sourceToNotYetCoveredSections .get (source );
188
188
Set <Integer > linesNotCovered = new HashSet <>();
189
189
for (SourceSection ss : sections ) {
190
190
for (int i = ss .getStartLine (); i <= ss .getEndLine (); i ++) {
@@ -229,7 +229,7 @@ private class GatherSourceSectionsListener implements LoadSourceSectionListener
229
229
*
230
230
* @param event information about the event. We use this information to
231
231
* keep our
232
- * {@link #sourceToUncoveredSections set of uncovered } {@link SourceSection}s
232
+ * {@link #sourceToNotYetCoveredSections set of not-yet-covered } {@link SourceSection}s
233
233
* up to date.
234
234
*/
235
235
@ Override
@@ -238,7 +238,7 @@ public void onLoad(LoadSourceSectionEvent event) {
238
238
final Source source = sourceSection .getSource ();
239
239
// TODO: This should not be necesery becuase of the filter. Bug!
240
240
if (!source .isInternal ()) {
241
- sourceToUncoveredSections .computeIfAbsent (source , (Source s ) -> {
241
+ sourceToNotYetCoveredSections .computeIfAbsent (source , (Source s ) -> {
242
242
return new HashSet <>();
243
243
}).add (sourceSection );
244
244
}
@@ -270,7 +270,7 @@ public ExecutionEventNode create(final EventContext ec) {
270
270
* expressions in our case as defined by the filter given to the
271
271
* {@link Instrumenter} in {@link #onCreate(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env)
272
272
* }), and removes the "wrapped" {@link SourceSection} from the set
273
- * {@link #sourceToUncoveredSections uncovered } {@link SourceSection}.
273
+ * {@link #sourceToNotYetCoveredSections not-yet-covered } {@link SourceSection}.
274
274
*/
275
275
class CoverageNode extends ExecutionEventNode {
276
276
@@ -290,7 +290,8 @@ private CoverageNode(SourceSection instrumentedSourceSection) {
290
290
* The {@link ExecutionEventNode} class let's us define several events
291
291
* that we can intercept. The one of interest to us is {@link ExecutionEventNode#onReturnValue(com.oracle.truffle.api.frame.VirtualFrame, java.lang.Object)
292
292
* } as we wish to remove this nodes {@link #instrumentedSourceSection}
293
- * from the {@link #sourceToUncoveredSections set of uncovered nodes}
293
+ * from the
294
+ * {@link #sourceToNotYetCoveredSections set of not-yet-covered nodes}
294
295
* only once the node is successfully executed (as oppose to, for
295
296
* example, {@link ExecutionEventNode#onReturnExceptional(com.oracle.truffle.api.frame.VirtualFrame, java.lang.Throwable)
296
297
* }).
@@ -333,7 +334,7 @@ public void onReturnValue(VirtualFrame vFrame, Object result) {
333
334
final Source source = instrumentedSourceSection .getSource ();
334
335
// TODO: This should not be necesery becuase of the filter. Bug!
335
336
if (!source .isInternal ()) {
336
- sourceToUncoveredSections .get (source ).remove (instrumentedSourceSection );
337
+ sourceToNotYetCoveredSections .get (source ).remove (instrumentedSourceSection );
337
338
}
338
339
}
339
340
}
0 commit comments