Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Reusable Analysis
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
Reusable Analysis
Commits
81d41c23
Commit
81d41c23
authored
5 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
extract java-specific part from analysis (not all parts, though)
parent
2aa86825
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
reusablecfg/src/main/jastadd/AlreadyClosedAnalysis.jrag
+14
-10
14 additions, 10 deletions
reusablecfg/src/main/jastadd/AlreadyClosedAnalysis.jrag
with
14 additions
and
10 deletions
reusablecfg/src/main/jastadd/AlreadyClosedAnalysis.jrag
+
14
−
10
View file @
81d41c23
...
@@ -40,16 +40,8 @@ aspect AlreadyClosedAnalysis {
...
@@ -40,16 +40,8 @@ aspect AlreadyClosedAnalysis {
/** Check if the reciever of this method access was already closed. */
/** Check if the reciever of this method access was already closed. */
syn boolean MethodAccess.alreadyClosedStream() {
syn boolean MethodAccess.alreadyClosedStream() {
// The receiver must be an effectively final local variable (or parameter).
if (!isCloseableAccess()) return false;
if (name().equals("close") // Don't check for repeated close() calls.
|| name().equals("toString") || name().equals("toByteArray")
|| !hasPrevExpr() // Does not have a variable or parameter receiver.
|| prevExpr().varDecl() == null // Receiver is not a variable/parameter.
|| !(prevExpr().varDecl().isFinal()
|| prevExpr().varDecl().isEffectivelyFinal()) // Receiver might have changed.
|| !prevExpr().type().isCloseable()) { // Receiver is not instance of java.io.Closeable.
return false;
}
final Variable receiver = prevExpr().varDecl();
final Variable receiver = prevExpr().varDecl();
return null != call().reverseBfs(new CfgVisitor() {
return null != call().reverseBfs(new CfgVisitor() {
@Override
@Override
...
@@ -75,6 +67,18 @@ aspect AlreadyClosedAnalysis {
...
@@ -75,6 +67,18 @@ aspect AlreadyClosedAnalysis {
});
});
}
}
/**
* Determines if a MethodAccess is an access of a Closable and its expression is an effectively final local variable (or parameter).
*/
syn boolean MethodAccess.isCloseableAccess() = !(
name().equals("close") // Don't check for repeated close() calls.
|| name().equals("toString") || name().equals("toByteArray")
|| !hasPrevExpr() // Does not have a variable or parameter receiver.
|| prevExpr().varDecl() == null // Receiver is not a variable/parameter.
|| !(prevExpr().varDecl().isFinal()
|| prevExpr().varDecl().isEffectivelyFinal()) // Receiver might have changed.
|| !prevExpr().type().isCloseable());
/** Test if the CFG node is a call node with the given variable as receiver. */
/** Test if the CFG node is a call node with the given variable as receiver. */
syn boolean CfgNode.isCall(Variable receiver) = false;
syn boolean CfgNode.isCall(Variable receiver) = false;
eq CfgMethodCall.isCall(Variable receiver) = methodAccess().hasReceiver(receiver);
eq CfgMethodCall.isCall(Variable receiver) = methodAccess().hasReceiver(receiver);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment