Add Java-cpg language module with cpg version 8.3.0#2767
Add Java-cpg language module with cpg version 8.3.0#2767LundiNord wants to merge 32 commits intojplag:developfrom
Conversation
Content: - A new CPG language frontend for JPlag - An interface to transform submissions into CPGs - An interface to transform CPGs into token lists - A Graph Transformation Engine (to be extended) . interfaces representing node and graph patterns, matches of these patterns, transformations . an isomorphism detector . a transformation algorithm - Some graph transformations (to be extended)
- implemented multi-root graph patterns - implemented searching for "all matches at once" - GraphOperations should leave EOG intact - implemented new kinds of edges and properties for graph patterns - tokenization works well - implemented DFG sort pass -- this requires specialized treatment for all kinds of language features. Surely the considered feature set is incomplete.
It was designed for local use.
Add many comments and put a file in the 'passes' package. When JavaDoc cannot find a Java file in there, it quits.
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Java-cpg language module that uses CPG (Code Property Graph) version 8.3.0 for enhanced Java code analysis. The implementation includes comprehensive graph transformation capabilities, pattern matching, and visitor-based token extraction.
Key Changes:
- Added new
java-cpglanguage module with CPG integration - Implemented graph transformation framework for code normalization
- Added comprehensive test resources covering various Java patterns
- Updated UI components to recognize the new language variant
Reviewed changes
Copilot reviewed 103 out of 104 changed files in this pull request and generated 59 comments.
Show a summary per file
| File | Description |
|---|---|
report-viewer/model/src/Language.ts |
Added JAVA_CPG enum value for new language support |
report-viewer/ui-components/widget/fileDisplaying/CodeHighlighter.ts |
Added case for JAVA_CPG to use Java syntax highlighting |
pom.xml |
Formatted maven-surefire-plugin argLine for readability |
languages/pom.xml |
Added java-cpg module to language modules list |
languages/java-cpg/src/test/resources/** |
Added comprehensive Java test files for various transformations |
languages/java-cpg/src/test/java/** |
Added test infrastructure and transformation tests |
languages/java-cpg/src/main/java/** |
Core implementation: visitors, transformations, pattern matching, operations |
.gitignore |
Added .factorypath and website to ignored files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| newSource = (NodePattern<T2>) source; | ||
| } else { | ||
|
|
||
| boolean disconnectEog = this.phase.disconnectEog && incomingEdge.isAst(); |
There was a problem hiding this comment.
Variable incomingEdge may be null at this access because of this null argument.
| // empty dummy implementation | ||
| } | ||
|
|
||
| void exit(TupleDeclaration tupleDeclaration) { |
There was a problem hiding this comment.
| void exit(ShortCircuitOperator shortCircuitOperator) { | ||
| // empty dummy implementation | ||
| } | ||
|
|
There was a problem hiding this comment.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
Method ACpgNodeListener.exit(..) could be confused with overloaded method exit, since dispatch depends on static types.
| @SuppressWarnings("java/confusing-overload") |
| return this.multiEdge; | ||
| } | ||
|
|
||
| public List<R> getTarget(T from) { |
There was a problem hiding this comment.
This method overrides Relation<T,R,List>.getTarget; it is advisable to add an Override annotation.
| return cpgEdge.getRelated(from); | ||
| } | ||
|
|
||
| public <C extends T> void recursiveMatch(NodePattern<C> pattern, T parent, List<Match> openMatches) { |
There was a problem hiding this comment.
This method overrides Relation<T,R,R>.recursiveMatch; it is advisable to add an Override annotation.
| return cpgEdge; | ||
| } | ||
|
|
||
| public R getTarget(T from) { |
There was a problem hiding this comment.
This method overrides Relation<T,R,R>.getTarget; it is advisable to add an Override annotation.
|
|
||
| } | ||
|
|
||
| public <T2 extends Node> RemoveOperation<T2, R> fromWildcardMatch(NodePattern<? extends T2> pattern, CpgEdge<T2, R> edge) { |
There was a problem hiding this comment.
This method overrides GraphOperationImpl<T,R>.fromWildcardMatch; it is advisable to add an Override annotation.
| return match.instantiateGraphOperation(wcParent, this); | ||
| } | ||
|
|
||
| public <T2 extends Node> ReplaceOperation<T2, R> fromWildcardMatch(NodePattern<? extends T2> pattern, CpgEdge<T2, R> edge) { |
There was a problem hiding this comment.
This method overrides GraphOperationImpl<T,R>.fromWildcardMatch; it is advisable to add an Override annotation.
JPlag currently is vulnerable to attacks like changing for loops to while loops.
The Java CPG language module in this PR solves this by using a Code Property Graph (CPG) and normalizing/standardizing the resulting code graph. The graph is then converted into tokens.