Skip to content

Commit

Permalink
Renaming: process Aspects before EPackages
Browse files Browse the repository at this point in the history
  • Loading branch information
fcoulon committed Oct 18, 2016
1 parent 37de93c commit a137625
Showing 1 changed file with 9 additions and 6 deletions.
Expand Up @@ -135,9 +135,16 @@ class AspectRenamer {
*/
private def void applyRenaming(ICompilationUnit sourceUnit, ASTVisitor renamer, List<Pair<String,String>> k3pattern, Set<String> allAspectNamespaces, String targetAspectNamespace){
try {
//Pre-process: rename aspects
var String newSource = sourceUnit.getSource()
newSource = newSource.replacePatterns(k3pattern)
newSource = newSource.replaceNamespace(allAspectNamespaces,targetAspectNamespace)
sourceUnit.getBuffer().setContents(newSource)
sourceUnit.getBuffer().save(null,true)

// textual document
val String source = sourceUnit.getSource();
val Document document= new Document(source);
val Document document = new Document(source);

// get the AST
val ASTParser parser = ASTParser.newParser(AST.JLS8)
Expand All @@ -147,20 +154,16 @@ class AspectRenamer {

// start record of the modifications
astRoot.recordModifications()

astRoot.accept(renamer)

// computation of the text edits
val TextEdit edits = astRoot.rewrite(document, sourceUnit.getJavaProject().getOptions(true))

// computation of the new source code
edits.apply(document);
var String newSource = document.get()
newSource = newSource.replacePatterns(k3pattern)
newSource = newSource.replaceNamespace(allAspectNamespaces,targetAspectNamespace)

// update of the compilation unit
sourceUnit.getBuffer().setContents(newSource)
sourceUnit.getBuffer().setContents(document.get)
sourceUnit.getBuffer().save(null,true)
} catch (Exception e) {
log.error("Couldn't apply renaming rules", e)
Expand Down

0 comments on commit a137625

Please sign in to comment.