1
/*******************************************************************************
2
* Copyright (c) 2007 Wind River Systems, Inc. and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Markus Schorn - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.rewrite;
13
import java.util.HashMap;
16
* Collects modifications to an AST in a hierarchical manner. The store gives access to
17
* the root modifications and for each modification you can obtain the nested modifications here.
20
public class ASTModificationStore {
21
private HashMap<ASTModification,ASTModificationMap> fNestedModMaps;
23
public ASTModificationStore() {
24
fNestedModMaps= new HashMap<ASTModification, ASTModificationMap>();
28
* Adds a potentially nested modification to the store.
29
* @param parentMod the parent for a nested modification, or <code>null</code>
30
* @param mod a modification
32
public void storeModification(ASTModification parentMod, ASTModification mod) {
33
ASTModificationMap modMap = createNestedModificationMap(parentMod);
34
modMap.addModification(mod);
37
private ASTModificationMap createNestedModificationMap(ASTModification parentMod) {
38
ASTModificationMap modMap= fNestedModMaps.get(parentMod);
40
modMap= new ASTModificationMap();
41
fNestedModMaps.put(parentMod, modMap);
47
* Returns the modifications that are performed directly on the AST, or <code>null</code> if there
48
* are no modifications.
49
* @return the root modifications or <code>null</code>.
51
public ASTModificationMap getRootModifications() {
52
return fNestedModMaps.get(null);
56
* Returns the modifications that are performed on the node that has been introduced by the
57
* given modification. If there are no nested modifications, <code>null</code> is returned.
58
* @return the nested modifications or <code>null</code>.
60
public ASTModificationMap getNestedModifications(ASTModification mod) {
61
return fNestedModMaps.get(mod);