<s> package org . eclipse . jdt . internal . core . dom . rewrite ; import java . util . HashSet ; import java . util . IdentityHashMap ; import java . util . Map ; import java . util . Set ; import org . eclipse . jdt . core . dom . AST ; import org . eclipse . jdt . core . dom . ASTNode ; import org . eclipse . jdt . core . dom . Block ; import org . eclipse . jdt . core . dom . FieldDeclaration ; import org . eclipse . jdt . core . dom . Modifier ; import org . eclipse . jdt . core . dom . ParameterizedType ; import org . eclipse . jdt . core . dom . TryStatement ; import org . eclipse . jdt . core . dom . VariableDeclarationExpression ; import org . eclipse . jdt . core . dom . VariableDeclarationStatement ; import org . eclipse . jdt . internal . core . dom . rewrite . RewriteEventStore . CopySourceInfo ; public final class NodeInfoStore { private AST ast ; private Map placeholderNodes ; private Set collapsedNodes ; public NodeInfoStore ( AST ast ) { super ( ) ; this . ast = ast ; this . placeholderNodes = null ; this . collapsedNodes = null ; } public final void markAsStringPlaceholder ( ASTNode placeholder , String code ) { StringPlaceholderData data = new StringPlaceholderData ( ) ; data . code = code ; setPlaceholderData ( placeholder , data ) ; } public final void markAsCopyTarget ( ASTNode target , CopySourceInfo copySource ) { CopyPlaceholderData data = new CopyPlaceholderData ( ) ; data . copySource = copySource ; setPlaceholderData ( target , data ) ; } public final ASTNode newPlaceholderNode ( int nodeType ) { try { ASTNode node = this . ast . createInstance ( nodeType ) ; switch ( node . getNodeType ( ) ) { case ASTNode . FIELD_DECLARATION : ( ( FieldDeclaration ) node ) . fragments ( ) . add ( this . ast . newVariableDeclarationFragment ( ) ) ; break ; case ASTNode . MODIFIER : ( ( Modifier ) node ) . setKeyword ( Modifier . ModifierKeyword . ABSTRACT_KEYWORD ) ; break ; case ASTNode . TRY_STATEMENT : ( ( TryStatement ) node ) . setFinally ( this . ast . newBlock ( ) ) ; break ; case ASTNode . VARIABLE_DECLARATION_EXPRESSION : ( ( VariableDeclarationExpression ) node ) . fragments ( ) . add ( this . ast . newVariableDeclarationFragment ( ) ) ; break ; case ASTNode . VARIABLE_DECLARATION_STATEMENT : ( ( VariableDeclarationStatement ) node ) . fragments ( ) . add ( this . ast . newVariableDeclarationFragment ( ) ) ; break ; case ASTNode . PARAMETERIZED_TYPE : ( ( ParameterizedType ) node ) . typeArguments ( ) . add ( this . ast . newWildcardType ( ) ) ; break ; } return node ; } catch ( IllegalArgumentException e ) { return null ; } } public Block createCollapsePlaceholder ( ) { Block placeHolder = this . ast . newBlock ( ) ; if ( this . collapsedNodes == null ) { this . collapsedNodes = new HashSet ( ) ; } this . collapsedNodes . add ( placeHolder ) ; return placeHolder ; } public boolean isCollapsed ( ASTNode node ) { if ( this . collapsedNodes != null ) { return this . collapsedNodes . contains ( node ) ; } return false ; } public Object getPlaceholderData ( ASTNode node ) { if ( this . placeholderNodes != null ) { return this . placeholderNodes . get ( node ) ; } return null ; } private void setPlaceholderData ( ASTNode node , PlaceholderData data ) { if ( this . placeholderNodes == null ) { this . placeholderNodes = new IdentityHashMap ( ) ; } this . placeholderNodes . put ( node , data ) ; } static class PlaceholderData { } protected static final class CopyPlaceholderData extends PlaceholderData { public CopySourceInfo copySource ; public String toString ( ) { return "" + this . copySource + "]" ; } } protected static final class StringPlaceholderData extends PlaceholderData { public String code ; public String toString ( ) { return "" + this . code + "]" ; } } public void clear ( ) { this . placeholderNodes = null ; this . collapsedNodes = null ; } } </s>