-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fe35e6
commit 440ed9a
Showing
9 changed files
with
90 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 20 additions & 4 deletions
24
circular-reference-detector/src/main/java/org/hjug/parser/visitor/JavaNewClassVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
package org.hjug.parser.visitor; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.jgrapht.Graph; | ||
import org.jgrapht.graph.DefaultWeightedEdge; | ||
import org.jgrapht.graph.SimpleDirectedWeightedGraph; | ||
import org.openrewrite.java.JavaIsoVisitor; | ||
import org.openrewrite.java.tree.Expression; | ||
import org.openrewrite.java.tree.J; | ||
|
||
public class JavaNewClassVisitor {//<P> extends JavaIsoVisitor<P> implements TypeProcessor { | ||
@RequiredArgsConstructor | ||
@Getter | ||
public class JavaNewClassVisitor implements TypeProcessor { | ||
|
||
// figure out later | ||
private final Graph<String, DefaultWeightedEdge> classReferencesGraph; | ||
private final Graph<String, DefaultWeightedEdge> packageReferencesGraph; | ||
|
||
public J.NewClass visitNewClass(String invokingFqn, J.NewClass newClass) { | ||
|
||
// getDeclaringType() returns the type that declared the method being invoked | ||
processType(invokingFqn, newClass.getType()); | ||
|
||
for (Expression argument : newClass.getArguments()) { | ||
processType(invokingFqn, argument.getType()); | ||
} | ||
|
||
// TASK: process initializer block | ||
|
||
return newClass; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ular-reference-detector/src/test/java/org/hjug/parser/visitor/testclasses/newClass/A.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.hjug.parser.visitor.testclasses.newClass; | ||
|
||
public class A { | ||
|
||
B newClassMethod() { | ||
D d = null; | ||
new D(); | ||
C c = new C(); | ||
return new B(c, d); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ular-reference-detector/src/test/java/org/hjug/parser/visitor/testclasses/newClass/B.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.hjug.parser.visitor.testclasses.newClass; | ||
|
||
public class B { | ||
|
||
public B(C c, D d) {} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
...ular-reference-detector/src/test/java/org/hjug/parser/visitor/testclasses/newClass/C.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.hjug.parser.visitor.testclasses.newClass; | ||
|
||
public class C { | ||
} |
4 changes: 4 additions & 0 deletions
4
...ular-reference-detector/src/test/java/org/hjug/parser/visitor/testclasses/newClass/D.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.hjug.parser.visitor.testclasses.newClass; | ||
|
||
public class D { | ||
} |