ref-code-adaptation: Initial merge request - #15
Conversation
…aptationConflictDetector now uses strategies
…bugs in other classes
…ey for mappings and reduce complexity
…ncarnation mapping, only one class for single- and multi-incarnations
… remove thread-local storage; add unit tests for lifecycle behavior
…eld addition; remove deprecated methods
…onstructor overloads and remove unused methods
…s and streamline method renaming processes
…s rebuilt too often; fixes bugs that remained hidden; made the test oracle for the completer cases stricter
MaxStachon
left a comment
There was a problem hiding this comment.
Initial Review für den verbesserten Reference Code Adapter
@PresiProdanov Bitte Kommentare anschauen und bearbeiten/antworten.
|
|
||
| Last updated: 13.07.2026 | ||
|
|
||
| ## Requirements |
There was a problem hiding this comment.
Nach GitLab verschieben bevor gemerged wird.
There was a problem hiding this comment.
Die Requirements sind übertragen.
| public final class GroupingMappingService { | ||
|
|
||
| /** Computes replacements for one mapping only, preventing one mapping from leaking into another. */ | ||
| public Map<String, String> compute(IncarnationContext context) { |
There was a problem hiding this comment.
Was wird in der Map gespeichert? JavaDoc?
There was a problem hiding this comment.
JavaDoc vorhanden - die Map bildetr den einfachen Namen eines konkreten Typs auf den einfachen Namen seines Gruppierungstyps ab.
There was a problem hiding this comment.
Vielleicht konsistenter, wenn du hier von Inkarnationen oder Inkarnations-Gruppe sprichst?
Schau auch mal an anderen Stellen nach.
There was a problem hiding this comment.
Oder gleich Map<String, Set<String>>?
| String lowerName = name.toLowerCase(Locale.ROOT); | ||
| Map<Integer, List<ISymbol>> refsByPosition = new TreeMap<>(); | ||
| List<ISymbol> longestFirst = new ArrayList<>(infixList); | ||
| longestFirst.sort( | ||
| Comparator.comparingInt((ISymbol symbol) -> symbol.getName().length()).reversed()); | ||
| boolean[] occupied = new boolean[name.length()]; | ||
| for (ISymbol reference : longestFirst) { | ||
| String infix = reference.getName().toLowerCase(Locale.ROOT); | ||
| if (infix.isEmpty()) { | ||
| continue; | ||
| } | ||
| int from = 0; | ||
| while (from <= lowerName.length() - infix.length()) { | ||
| int index = lowerName.indexOf(infix, from); | ||
| if (index < 0) { | ||
| break; | ||
| } | ||
| boolean overlaps = false; | ||
| for (int i = index; i < index + infix.length(); i++) { | ||
| overlaps |= occupied[i]; | ||
| } | ||
| if (!overlaps) { | ||
| refsByPosition.computeIfAbsent(index, ignored -> new ArrayList<>()).add(reference); | ||
| Arrays.fill(occupied, index, index + infix.length(), true); | ||
| } | ||
| from = index + infix.length(); | ||
| } | ||
| } | ||
| List<ISymbol> result = new ArrayList<>(); | ||
| refsByPosition.values().forEach(result::addAll); | ||
| return result; | ||
| } |
There was a problem hiding this comment.
Gibt es dafür nicht Library-Methoden, z.B. in String oder Strings?
There was a problem hiding this comment.
Ich habe nach einer passenden Library-Methode gesucht. String#indexOf hilft zwar beim Finden einzelner Vorkommen, aber längere Referenznamen müssen Vorrang haben, Treffer dürfen sich nicht überschneidenn und das Ergebnis muss nach der Position im Bezeichner sortiert sein.
| @@ -135,38 +160,40 @@ public static Optional<ASTAnnotation> getInfoAnnotation(List<ASTMCModifier> mods | |||
| * @return the generated String. | |||
| */ | |||
| public static String fillTemplate(String template, List<ISymbol> refSymbol) { | |||
There was a problem hiding this comment.
Was ist denn das Template in diesem Kontext?
There was a problem hiding this comment.
Doku ist jetzt da.
| for (ISymbol symbol1 : temps) { | ||
| if (!symbol.equals(symbol1) && (matchInfix(symbol.getName(), symbol1.getName()))) { | ||
| references.remove(symbol1); | ||
| List<ISymbol> result = new ArrayList<>(new LinkedHashSet<>(references)); |
There was a problem hiding this comment.
Vielleicht hier noch ein Kommentar.
There was a problem hiding this comment.
Doku ist da. Duplikate werden entfernt, anschließend werden kürzere Referenznamen verworfen, wenn sie vollständig in einer längeren Referenz enthalten sind.
| enforceInterfaceMethodBodies(); | ||
| } | ||
|
|
||
| private boolean invokesMethodOn( |
There was a problem hiding this comment.
Bitte kommentieren, was diese Methode machen soll.
There was a problem hiding this comment.
Kommentiert.
| } | ||
|
|
||
| @SuppressWarnings({"rawtypes", "unchecked"}) | ||
| private CtExpression<?> missingArgument(CtInvocation<?> invocation, String parameterType) { |
| import spoon.refactoring.Refactoring; | ||
|
|
||
| /** Generates, clones and removes Spoon declarations. */ | ||
| final class SpoonGenerationService { |
There was a problem hiding this comment.
Ggf. Mit SpoonTransformationService kombinieren zu SpoonCRUDUtil (o.ä.).
There was a problem hiding this comment.
Im Meeting habe ich dir selber vorgeschalgen, beide zu mergen, da keine Doku vorhanden war. Das habe ich jedoch nicht gemacht. SpoonGenerationService : Elemente werden erzeugt, geklont, entfernt oder mit Bodies versehen. SpoonTransformationService verändert dagegen bestehende Deklarationen und Referenzen und besitzt dafür lazy aufgebaute Referenzindizes. Beide Bereiche haben unterschiedliche Zustände und Ausführungsreihenfolgen.
| import spoon.reflect.visitor.filter.TypeFilter; | ||
|
|
||
| /** Applies all mutations to declarations and references in an already loaded Spoon model. */ | ||
| final class SpoonTransformationService { |
There was a problem hiding this comment.
Ggf. Mit SpoonGenerationService kombinieren zu SpoonCRUDUtil (o.ä.).
There was a problem hiding this comment.
Wie erwähnt, das ist eine schlechte Idee. Code ist jetzt besser dokumentiert.
| } | ||
| } | ||
|
|
||
| void rewriteTypeReferenceName(CtTypeReference<?> reference, String newName) { |
There was a problem hiding this comment.
Muss das nichtr logisch woanders hin?
There was a problem hiding this comment.
Ja, die Methode wurde verschoben.
…documentation across multiple classes
…or symbol resolution
…ports; preserve abstractness during merges; add more comments
…ts in various cases
No description provided.