Skip to content

Commit

Permalink
Replacing with modifiable collections
Browse files Browse the repository at this point in the history
  • Loading branch information
tsantalis committed Dec 13, 2024
1 parent cc49fcc commit 69d6071
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/main/java/gr/uom/java/xmi/UMLAnnotation.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gr.uom.java.xmi;

import java.io.Serializable;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -27,13 +26,13 @@ public UMLAnnotation(CompilationUnit cu, String sourceFolder, String filePath, A
this.locationInfo = new LocationInfo(cu, sourceFolder, filePath, annotation, CodeElementType.ANNOTATION);
if(annotation instanceof SingleMemberAnnotation) {
SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation)annotation;
this.value = new AbstractExpression(cu, sourceFolder, filePath, singleMemberAnnotation.getValue(), CodeElementType.SINGLE_MEMBER_ANNOTATION_VALUE, null, Collections.emptyMap(), javaFileContent);
this.value = new AbstractExpression(cu, sourceFolder, filePath, singleMemberAnnotation.getValue(), CodeElementType.SINGLE_MEMBER_ANNOTATION_VALUE, null, new LinkedHashMap<>(), javaFileContent);
}
else if(annotation instanceof NormalAnnotation) {
NormalAnnotation normalAnnotation = (NormalAnnotation)annotation;
List<MemberValuePair> pairs = normalAnnotation.values();
for(MemberValuePair pair : pairs) {
AbstractExpression value = new AbstractExpression(cu, sourceFolder, filePath, pair.getValue(), CodeElementType.NORMAL_ANNOTATION_MEMBER_VALUE_PAIR, null, Collections.emptyMap(), javaFileContent);
AbstractExpression value = new AbstractExpression(cu, sourceFolder, filePath, pair.getValue(), CodeElementType.NORMAL_ANNOTATION_MEMBER_VALUE_PAIR, null, new LinkedHashMap<>(), javaFileContent);
memberValuePairs.put(pair.getName().getIdentifier(), value);
}
}
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/gr/uom/java/xmi/UMLModelASTReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static org.eclipse.jdt.core.JavaCore.VERSION_21;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -70,7 +69,6 @@
import gr.uom.java.xmi.decomposition.AbstractExpression;
import gr.uom.java.xmi.decomposition.OperationBody;
import gr.uom.java.xmi.decomposition.VariableDeclaration;
import org.refactoringminer.astDiff.visitors.JdtVisitor;
import org.refactoringminer.astDiff.visitors.JdtWithCommentsVisitor;

public class UMLModelASTReader {
Expand Down Expand Up @@ -142,7 +140,6 @@ private void processJavaFileContents(Map<String, String> javaFileContents, boole
AbstractJdtVisitor visitor = (VISIT_JDT_COMMENTS) ?
new JdtWithCommentsVisitor(scanner) :
new com.github.gumtreediff.gen.jdt.JdtVisitor(scanner);
// JdtVisitor visitor = new JdtWithCommentsVisitor(scanner);
compilationUnit.accept(visitor);
TreeContext treeContext = visitor.getTreeContext();
this.umlModel.getTreeContextMap().put(filePath, treeContext);
Expand Down Expand Up @@ -426,7 +423,7 @@ private void processRecordDeclaration(CompilationUnit cu, RecordDeclaration reco
}
LocationInfo recordComponentLocationInfo = generateLocationInfo(cu, sourceFolder, sourceFile, recordComponent, CodeElementType.RECORD_COMPONENT);
UMLRecordComponent umlRecordComponent = new UMLRecordComponent(parameterName, type, recordComponentLocationInfo);
VariableDeclaration variableDeclaration = new VariableDeclaration(cu, sourceFolder, sourceFile, recordComponent, umlRecordComponent, recordComponent.isVarargs(), Collections.emptyMap(), javaFileContent);
VariableDeclaration variableDeclaration = new VariableDeclaration(cu, sourceFolder, sourceFile, recordComponent, umlRecordComponent, recordComponent.isVarargs(), new LinkedHashMap<>(), javaFileContent);
variableDeclaration.setAttribute(true);
umlRecordComponent.setVariableDeclaration(variableDeclaration);
umlRecordComponent.setClassName(umlClass.getName());
Expand Down Expand Up @@ -1072,7 +1069,7 @@ else if(extendedModifier.isModifier()) {
}

if(annotationTypeMemberDeclatation.getDefault() != null) {
AbstractExpression defaultExpression = new AbstractExpression(cu, sourceFolder, sourceFile, annotationTypeMemberDeclatation.getDefault(), CodeElementType.ANNOTATION_TYPE_MEMBER_DEFAULT_EXPRESSION, umlOperation, Collections.emptyMap(), javaFileContent);
AbstractExpression defaultExpression = new AbstractExpression(cu, sourceFolder, sourceFile, annotationTypeMemberDeclatation.getDefault(), CodeElementType.ANNOTATION_TYPE_MEMBER_DEFAULT_EXPRESSION, umlOperation, new LinkedHashMap<>(), javaFileContent);
umlOperation.setDefaultExpression(defaultExpression);
}
return umlOperation;
Expand Down Expand Up @@ -1177,7 +1174,7 @@ else if(extendedModifier.isModifier()) {
type.setVarargs();
}
UMLParameter umlParameter = new UMLParameter(parameterName, type, "in", parameter.isVarargs());
VariableDeclaration variableDeclaration = new VariableDeclaration(cu, sourceFolder, sourceFile, parameter, umlOperation, parameter.isVarargs(), Collections.emptyMap(), javaFileContent);
VariableDeclaration variableDeclaration = new VariableDeclaration(cu, sourceFolder, sourceFile, parameter, umlOperation, parameter.isVarargs(), new LinkedHashMap<>(), javaFileContent);
variableDeclaration.setParameter(true);
umlParameter.setVariableDeclaration(variableDeclaration);
umlOperation.addParameter(umlParameter);
Expand All @@ -1199,7 +1196,7 @@ private void processEnumConstantDeclaration(CompilationUnit cu, EnumConstantDecl
UMLJavadoc javadoc = generateJavadoc(cu, enumConstantDeclaration, sourceFolder, sourceFile, javaFileContent);
LocationInfo locationInfo = generateLocationInfo(cu, sourceFolder, sourceFile, enumConstantDeclaration, CodeElementType.ENUM_CONSTANT_DECLARATION);
UMLEnumConstant enumConstant = new UMLEnumConstant(enumConstantDeclaration.getName().getIdentifier(), UMLType.extractTypeObject(umlClass.getName()), locationInfo);
VariableDeclaration variableDeclaration = new VariableDeclaration(cu, sourceFolder, sourceFile, enumConstantDeclaration, Collections.emptyMap(), javaFileContent);
VariableDeclaration variableDeclaration = new VariableDeclaration(cu, sourceFolder, sourceFile, enumConstantDeclaration, new LinkedHashMap<>(), javaFileContent);
enumConstant.setVariableDeclaration(variableDeclaration);
enumConstant.setJavadoc(javadoc);
distributeComments(comments, locationInfo, enumConstant.getComments());
Expand All @@ -1225,7 +1222,7 @@ private List<UMLAttribute> processFieldDeclaration(CompilationUnit cu, FieldDecl
LocationInfo locationInfo = generateLocationInfo(cu, sourceFolder, sourceFile, fragment, CodeElementType.FIELD_DECLARATION);
UMLAttribute umlAttribute = new UMLAttribute(fieldName, type, locationInfo);
umlAttribute.setFieldDeclarationLocationInfo(generateLocationInfo(cu, sourceFolder, sourceFile, fieldDeclaration, CodeElementType.FIELD_DECLARATION));
VariableDeclaration variableDeclaration = new VariableDeclaration(cu, sourceFolder, sourceFile, fragment, umlAttribute, Collections.emptyMap(), javaFileContent);
VariableDeclaration variableDeclaration = new VariableDeclaration(cu, sourceFolder, sourceFile, fragment, umlAttribute, new LinkedHashMap<>(), javaFileContent);
variableDeclaration.setAttribute(true);
umlAttribute.setVariableDeclaration(variableDeclaration);
umlAttribute.setJavadoc(javadoc);
Expand Down

0 comments on commit 69d6071

Please sign in to comment.