Skip to content

Commit 50c4d9e

Browse files
author
Max Philip Stachon
committed
fix ref-code-adaptation
1 parent e974f5a commit 50c4d9e

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

ref-code-adaptation/src/main/java/de/monticore/codeAdaption/handler/BasicUpdateHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,19 @@ private String buildConcreteName(CodeMatching codeMatching) {
176176
}
177177

178178
protected ISymbol getConTypeSymbol(CDTypeSymbol symbol) {
179-
return checker.getConElements(symbol.getAstNode()).iterator().next().getSymbol();
179+
return checker
180+
.getIncarnationMapping()
181+
.getIncarnations(symbol.getAstNode())
182+
.iterator()
183+
.next()
184+
.getSymbol();
180185
}
181186

182187
protected ISymbol getConAttributeSymbol(FieldSymbol symbol) {
183188

184189
return checker
185-
.getConElements((ASTCDAttribute) symbol.getAstNode())
190+
.getIncarnationMapping()
191+
.getIncarnations((ASTCDAttribute) symbol.getAstNode())
186192
.iterator()
187193
.next()
188194
.getSymbol();

ref-code-adaptation/src/main/java/de/monticore/codeAdaption/updater/spoonUpdater/SpoonUpdater.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private CtType<?> getSpoonType(ASTTypeDeclaration mcType) {
191191
typeMap.put(mcType, type.get());
192192
return type.get();
193193
}
194-
194+
195195
/***
196196
* Retrieves the spoonMethod from the Spoon Model based on the provided
197197
* mcType and mcMethod. Saves the found spoonMethod in the method map.
@@ -222,30 +222,27 @@ public CtMethod<?> getSpoonMethod(ASTTypeDeclaration mcType, ASTMethodDeclaratio
222222
methodMap.put(mcMethod, method.get());
223223
return method.get();
224224
}
225-
225+
226226
/**
227227
* Compares a mcType and spoonType and returns true if both are identical.
228228
*
229229
* @param type The ASTTypeDeclaration representing the type to be compared.
230230
* @param spoonType The CtType representing the spoon type to be compared.
231-
* @return True if the file name of the mcType ends with the simple name
232-
* of the spoonType followed by ".java"; otherwise false.
231+
* @return True if the file name of the mcType ends with the simple name of the spoonType followed
232+
* by ".java"; otherwise false.
233233
*/
234234
protected boolean compare(ASTTypeDeclaration type, CtType<?> spoonType) {
235235
String fileName = type.get_SourcePositionStart().getFileName().orElse(type.getName());
236236
return fileName.replaceAll("\\\\", ".").endsWith(spoonType.getSimpleName() + ".java");
237237
}
238-
238+
239239
/**
240-
* Compares a spoonMethod and mcMethod and returns true if both are
241-
* identical.
240+
* Compares a spoonMethod and mcMethod and returns true if both are identical.
242241
*
243-
* @param mcMethod The ASTMethodDeclaration representing the method to be
244-
* compared.
245-
* @param spoonMethod The CtMethod representing the spoon method to be
246-
* compared.
247-
* @return True if the names, parameter count, and parameter types of both
248-
* methods match; otherwise false.
242+
* @param mcMethod The ASTMethodDeclaration representing the method to be compared.
243+
* @param spoonMethod The CtMethod representing the spoon method to be compared.
244+
* @return True if the names, parameter count, and parameter types of both methods match;
245+
* otherwise false.
249246
*/
250247
protected boolean compare(ASTMethodDeclaration mcMethod, CtMethod<?> spoonMethod) {
251248
// compare names

ref-code-adaptation/src/main/java/de/monticore/codeAdaption/utils/AdapterUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static String getPosition(SourcePosition pos) {
4747
}
4848
return "";
4949
}
50-
50+
5151
/**
5252
* Reads a Java file and removes multi-line and single-line comments.
5353
*

ref-code-adaptation/src/main/java/de/monticore/codeAdaption/utils/JavaLoader.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,14 @@
3838
import org.junit.jupiter.api.Assertions;
3939

4040
public class JavaLoader {
41-
41+
4242
/**
43-
* Parses a class diagram, builds the symbol table, and checks the
44-
* consistency conditions (CoCos).
43+
* Parses a class diagram, builds the symbol table, and checks the consistency conditions (CoCos).
4544
*
46-
* @param file The class diagram file to be parsed. It must have a .cd
47-
* extension.
48-
* @return The resulting ASTCDCompilationUnit created from the class
49-
* diagram.
50-
* @throws AssertionError if the provided file does not have a .cd
51-
* extension, or if the AST could not be created successfully.
45+
* @param file The class diagram file to be parsed. It must have a .cd extension.
46+
* @return The resulting ASTCDCompilationUnit created from the class diagram.
47+
* @throws AssertionError if the provided file does not have a .cd extension, or if the AST could
48+
* not be created successfully.
5249
*/
5350
public static ASTCDCompilationUnit loadCD(File file) {
5451
// parse the class diagram
@@ -105,13 +102,12 @@ private static void createCDSymTab(ASTCDCompilationUnit ast) {
105102
ast.accept(c.getTraverser());
106103
ast.setEnclosingScope(as);
107104
}
108-
105+
109106
/**
110107
* Loads a Java file, transforms it to an AST, and creates symbol tables.
111108
*
112109
* @param javaFile The Java file to be loaded and processed.
113-
* @return The resulting ASTOrdinaryCompilationUnit created from the
114-
* Java file.
110+
* @return The resulting ASTOrdinaryCompilationUnit created from the Java file.
115111
*/
116112
public static ASTOrdinaryCompilationUnit loadJava(File javaFile) {
117113
assertTrue(javaFile.getName().endsWith(".java"));
@@ -137,7 +133,7 @@ public static ASTOrdinaryCompilationUnit loadJava(File javaFile) {
137133

138134
return (ASTOrdinaryCompilationUnit) ast.get();
139135
}
140-
136+
141137
/**
142138
* Prints a Java ASTNode as a formatted string.
143139
*
@@ -163,7 +159,7 @@ public static void writeFile(Path path, String content) {
163159
Log.error("Exception occur when writing the file " + path);
164160
}
165161
}
166-
162+
167163
/**
168164
* Reads recursively all Java files in a directory and its subdirectories.
169165
*
@@ -175,7 +171,7 @@ public static Set<ASTOrdinaryCompilationUnit> readJavaCode(Path directoryPath) {
175171
readJavaCode(directoryPath, res);
176172
return res.stream().map(JavaLoader::loadJava).collect(Collectors.toSet());
177173
}
178-
174+
179175
/**
180176
* Reads recursively all Java files in a directory and its subdirectories.
181177
*

ref-code-adaptation/src/test/java/de/monticore/codeAdaption/CodeAdapterToolTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
public class CodeAdapterToolTest {
66

7-
@Test
8-
public void test() {
9-
String cmd = "-i University.cd --reference UserRole.cd --rc code" ;
10-
// String cmd = "java -jar AdapterTool.jar -i University.cd --reference UserRole.cd --rc code" ;
11-
}
7+
@Test
8+
public void test() {
9+
String cmd = "-i University.cd --reference UserRole.cd --rc code";
10+
// String cmd = "java -jar AdapterTool.jar -i University.cd --reference UserRole.cd --rc code"
11+
// ;
12+
}
1213
}

0 commit comments

Comments
 (0)