Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b58fc7
commit 0ea3ea4
Showing
19 changed files
with
738 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/spoon/experimental/modelobs/SourceFragmentsTreeCreatingChangeCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (C) 2006-2017 INRIA and contributors | ||
* Spoon - http://spoon.gforge.inria.fr/ | ||
* | ||
* This software is governed by the CeCILL-C License under French law and | ||
* abiding by the rules of distribution of free software. You can use, modify | ||
* and/or redistribute the software under the terms of the CeCILL-C license as | ||
* circulated by CEA, CNRS and INRIA at http://www.cecill.info. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details. | ||
* | ||
* The fact that you are presently reading this means that you have had | ||
* knowledge of the CeCILL-C license and that you accept its terms. | ||
*/ | ||
package spoon.experimental.modelobs; | ||
|
||
import spoon.reflect.cu.CompilationUnit; | ||
import spoon.reflect.declaration.CtElement; | ||
import spoon.reflect.path.CtRole; | ||
import spoon.reflect.visitor.printer.change.SourceFragment; | ||
|
||
/** | ||
* Listens on changes on the spoon model and remembers them | ||
* It builds a tree of {@link SourceFragment}s of {@link CompilationUnit} of the modified element | ||
* lazily before the element is changed | ||
*/ | ||
public class SourceFragmentsTreeCreatingChangeCollector extends ChangeCollector { | ||
@Override | ||
protected void onChange(CtElement currentElement, CtRole role) { | ||
CompilationUnit cu = currentElement.getPosition().getCompilationUnit(); | ||
if (cu != null) { | ||
//build a tree of SourceFragments of compilation unit of the modified element before the first change | ||
cu.getRootSourceFragment(); | ||
} | ||
super.onChange(currentElement, role); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.