Skip to content

Commit

Permalink
Modify statement signature in case of anonymous class declaration within
Browse files Browse the repository at this point in the history
the statement
  • Loading branch information
tsantalis committed Oct 23, 2024
1 parent b1d526e commit 35a9df1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/gr/uom/java/xmi/decomposition/StatementObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ public StatementObject(CompilationUnit cu, String filePath, Statement statement,
this.locationInfo = new LocationInfo(cu, filePath, statement, codeElementType);
Visitor visitor = new Visitor(cu, filePath, container, javaFileContent);
statement.accept(visitor);
int start = statement.getStartPosition();
int end = start + statement.getLength();
this.actualSignature = javaFileContent.substring(start, end);
this.variables = visitor.getVariables();
this.types = visitor.getTypes();
this.variableDeclarations = visitor.getVariableDeclarations();
Expand All @@ -84,6 +81,15 @@ public StatementObject(CompilationUnit cu, String filePath, Statement statement,
this.castExpressions = visitor.getCastExpressions();
this.ternaryOperatorExpressions = visitor.getTernaryOperatorExpressions();
this.lambdas = visitor.getLambdas();
int start = statement.getStartPosition();
int end = start + statement.getLength();
if(this.anonymousClassDeclarations.isEmpty()) {
this.actualSignature = javaFileContent.substring(start, end);
}
else {
int endOffset = this.anonymousClassDeclarations.get(0).getLocationInfo().getStartOffset() + 1;
this.actualSignature = javaFileContent.substring(start, endOffset);
}
setDepth(depth);
String statementAsString = stringify(statement);
if(Visitor.METHOD_INVOCATION_PATTERN.matcher(statementAsString).matches()) {
Expand Down

0 comments on commit 35a9df1

Please sign in to comment.