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
8c334682
Commit
8c334682
authored
5 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
work in progress
parent
62207526
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
scope4j/src/main/jastadd/ProgramToScopeTree.jrag
+6
-0
6 additions, 0 deletions
scope4j/src/main/jastadd/ProgramToScopeTree.jrag
testprograms/simpleScope/A.java
+26
-9
26 additions, 9 deletions
testprograms/simpleScope/A.java
with
32 additions
and
9 deletions
scope4j/src/main/jastadd/ProgramToScopeTree.jrag
+
6
−
0
View file @
8c334682
...
@@ -18,7 +18,9 @@ aspect ProgramToScopeTree {
...
@@ -18,7 +18,9 @@ aspect ProgramToScopeTree {
Block contributes scope() to ASTNode.scope() for containingScope();
Block contributes scope() to ASTNode.scope() for containingScope();
// collect all elements
// collect all elements
// TODO exclude declarators not in statements (for, enhancedfor, try)
Declarator contributes asDeclaration() to ASTNode.scope() for containingScope();
Declarator contributes asDeclaration() to ASTNode.scope() for containingScope();
ResourceDeclaration contributes asDeclaration() to ASTNode.scope() for succeedingScope();
ParameterDeclaration contributes asDeclaration() to ASTNode.scope() for succeedingScope();
ParameterDeclaration contributes asDeclaration() to ASTNode.scope() for succeedingScope();
/** fallback attribute to ensure every AST element could pontentially be a scope */
/** fallback attribute to ensure every AST element could pontentially be a scope */
...
@@ -66,4 +68,8 @@ aspect ScopeGenerationAttributes {
...
@@ -66,4 +68,8 @@ aspect ScopeGenerationAttributes {
eq BasicCatch.getParameter().succeedingScope() = getBlock();
eq BasicCatch.getParameter().succeedingScope() = getBlock();
eq MethodDecl.getParameter().succeedingScope() = getBlock();
eq MethodDecl.getParameter().succeedingScope() = getBlock();
eq ConstructorDecl.getParameter().succeedingScope() = getBlock();
eq ConstructorDecl.getParameter().succeedingScope() = getBlock();
inh ASTNode ResourceDeclaration.succeedingScope();
eq TryWithResources.getResource().succeedingScope() = getBlock();
eq EnhancedForStmt.getVariableDecl().succeedingScope() = (getStmt() instanceof Block) ? getStmt() : null;
eq VarDeclStmt.getDeclarator().succeedingScope() = null;
}
}
This diff is collapsed.
Click to expand it.
testprograms/simpleScope/A.java
+
26
−
9
View file @
8c334682
...
@@ -2,26 +2,43 @@ package p1;
...
@@ -2,26 +2,43 @@ package p1;
public
abstract
class
ClassA
{
public
abstract
class
ClassA
{
A
fieldA
;
int
fieldA
;
int
fieldB
;
public
ClassA
(
int
constructorParameterA
)
{
public
ClassA
(
int
constructorParameterA
)
{
A
localConstructorVarA
=
new
A
()
;
int
localConstructorVarA
=
0
;
}
}
public
void
methodNameA
(
int
parameterA
)
{
public
void
methodNameA
(
int
parameterA
)
{
A
localVarA
=
new
A
();
int
localVarA
=
1
;
int
localVarB
=
1
;
{
{
A
localVarInBlockA
=
new
A
()
;
int
localVarInBlockA
=
2
;
// this is shadowed
:
// this is shadowed
(and forbidden)
A
localVarA
=
new
A
()
;
int
localVarA
=
3
;
}
}
// this is shadowed (over two levels)
// this is shadowed (over two levels, not forbidden)
A
fieldA
;
int
fieldA
;
try
(
// this is forbidden
java
.
util
.
zip
.
ZipFile
localVarB
=
new
java
.
util
.
zip
.
ZipFile
(
"zipFileName"
);
// this is okay
java
.
io
.
BufferedWriter
fieldB
=
java
.
nio
.
file
.
Files
.
newBufferedWriter
(
null
)
)
{
/* do stuff */
}
catch
(
java
.
io
.
IOException
e
)
{
/* do stuff */
}
}
int
i
;
class
Local
{
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
System
.
out
.
println
(
i
);
}
}
}
// this does not appear as a scope (and, more importantly, the parameters are not added anywhere else)
// this does not appear as a scope (and, more importantly, the parameters are not added anywhere else)
public
void
methodNameB
(
int
parameterForAbstractMethodB
);
public
abstract
void
methodNameB
(
int
parameterForAbstractMethodB
);
}
}
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