Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASTDiff: BugFix #847

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ private Tree makeFakeTree(Tree tree, CompositeStatementObject fragment, Map<Tree
cpyMap.put(cpy,tree);
for (AbstractExpression abstractExpression : fragment.getExpressions()) {
Tree expTree = TreeUtilFunctions.findByLocationInfo(tree,abstractExpression.getLocationInfo());
if (expTree == null) continue;
Tree expCopy = TreeUtilFunctions.deepCopyWithMap(expTree,cpyMap);
cpy.addChild(expCopy);
}
if (tree.getType().name.equals(Constants.FOR_STATEMENT)) return cpy;
for (VariableDeclaration variableDeclaration : fragment.getVariableDeclarations()) {
Tree varTree = TreeUtilFunctions.findByLocationInfo(tree, variableDeclaration.getLocationInfo());
if (varTree == null) continue;
Tree varCopy = TreeUtilFunctions.deepCopyWithMap(varTree, cpyMap);
cpy.addChild(varCopy);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ private void processFieldDeclaration(Tree srcTree, Tree dstTree, UMLAttribute sr
new JavaDocMatcher(optimizationData, srcUMLAttribute.getJavadoc(), dstUMLAttribute.getJavadoc(), umlJavadocDiff)
.match(srcTree, dstTree, mappingStore);
if (srcVarDeclaration != null && dstVarDeclaration != null)
mappingStore.addMapping(srcVarDeclaration.getChild(0),dstVarDeclaration.getChild(0));
if (!srcVarDeclaration.getChildren().isEmpty() && !dstVarDeclaration.getChildren().isEmpty())
mappingStore.addMapping(srcVarDeclaration.getChild(0),dstVarDeclaration.getChild(0));
}

private void matchFieldAllModifiers(Tree srcFieldDeclaration, Tree dstFieldDeclaration, UMLAttribute srcUMLAttribute, UMLAttribute dstUMLAttribute, ExtendedMultiMappingStore mappingStore) {
if (srcFieldDeclaration == null || dstFieldDeclaration == null) return;
matchModifiersForField(srcFieldDeclaration,dstFieldDeclaration,srcUMLAttribute.getVisibility().toString(),dstUMLAttribute.getVisibility().toString(),mappingStore);
if (srcUMLAttribute.isFinal() && dstUMLAttribute.isFinal())
matchModifierForField(srcFieldDeclaration,dstFieldDeclaration,Constants.FINAL,mappingStore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,10 @@ public static boolean isFromType(Tree t1, String type) {
return t1.getType().name.equals(type);
}

public static Tree findFirstByType(Tree srcFieldDeclaration, String typeName) {
public static Tree findFirstByType(Tree inputTree, String typeName) {
if (inputTree == null) return null;
Tree fieldAnnotation = null;
for (Tree child : srcFieldDeclaration.getChildren()) {
for (Tree child : inputTree.getChildren()) {
if (isFromType(child, typeName)) {
fieldAnnotation = child;
break;
Expand Down
Loading