Lines 284-289
public class FakedTrackingVariable extends LocalDeclaration {
Link Here
|
284 |
/** |
284 |
/** |
285 |
* Check if the rhs of an assignment or local declaration is an (Auto)Closeable. |
285 |
* Check if the rhs of an assignment or local declaration is an (Auto)Closeable. |
286 |
* If so create or re-use a tracking variable, and wire and initialize everything. |
286 |
* If so create or re-use a tracking variable, and wire and initialize everything. |
|
|
287 |
* @param scope scope containing the assignment |
287 |
* @param upstreamInfo info without analysis of the rhs, use this to determine the status of a resource being disconnected |
288 |
* @param upstreamInfo info without analysis of the rhs, use this to determine the status of a resource being disconnected |
288 |
* @param flowInfo info with analysis of the rhs, use this for recording resource status because this will be passed downstream |
289 |
* @param flowInfo info with analysis of the rhs, use this for recording resource status because this will be passed downstream |
289 |
* @param location where to report warnigs/errors against |
290 |
* @param location where to report warnigs/errors against |
Lines 291-297
public class FakedTrackingVariable extends LocalDeclaration {
Link Here
|
291 |
* The caller has already checked that the rhs is either of a closeable type or null. |
292 |
* The caller has already checked that the rhs is either of a closeable type or null. |
292 |
* @param local the local variable into which the rhs is being assigned |
293 |
* @param local the local variable into which the rhs is being assigned |
293 |
*/ |
294 |
*/ |
294 |
public static void handleResourceAssignment(FlowInfo upstreamInfo, FlowInfo flowInfo, ASTNode location, Expression rhs, LocalVariableBinding local) |
295 |
public static void handleResourceAssignment(BlockScope scope, FlowInfo upstreamInfo, FlowInfo flowInfo, ASTNode location, Expression rhs, LocalVariableBinding local) |
295 |
{ |
296 |
{ |
296 |
// does the LHS (local) already have a tracker, indicating we may leak a resource by the assignment? |
297 |
// does the LHS (local) already have a tracker, indicating we may leak a resource by the assignment? |
297 |
FakedTrackingVariable previousTracker = null; |
298 |
FakedTrackingVariable previousTracker = null; |
Lines 338-346
public class FakedTrackingVariable extends LocalDeclaration {
Link Here
|
338 |
} |
339 |
} |
339 |
|
340 |
|
340 |
if (disconnectedTracker != null) { |
341 |
if (disconnectedTracker != null) { |
341 |
int upstreamStatus = upstreamInfo.nullStatus(disconnectedTracker.binding); |
342 |
if (disconnectedTracker.innerTracker != null && disconnectedTracker.innerTracker.binding.declaringScope == scope) { |
342 |
if (upstreamStatus != FlowInfo.NON_NULL) |
343 |
disconnectedTracker.innerTracker.outerTracker = null; |
343 |
disconnectedTracker.recordErrorLocation(location, upstreamStatus); |
344 |
scope.pruneWrapperTrackingVar(disconnectedTracker); |
|
|
345 |
} else { |
346 |
int upstreamStatus = upstreamInfo.nullStatus(disconnectedTracker.binding); |
347 |
if (upstreamStatus != FlowInfo.NON_NULL) |
348 |
disconnectedTracker.recordErrorLocation(location, upstreamStatus); |
349 |
} |
344 |
} |
350 |
} |
345 |
} |
351 |
} |
346 |
/** |
352 |
/** |