void renameProperties ( ) { int propsRenamed = 0 ; int propsSkipped = 0 ; int instancesRenamed = 0 ; int instancesSkipped = 0 ; int singleTypeProps = 0 ; Set < String > reported = new HashSet <> ( ) ; for ( Property prop : properties . values ( ) ) { if ( prop . shouldRename ( ) ) { UnionFind < JSType > pTypes = prop . getTypes ( ) ; Map < JSType , String > propNames = buildPropNames ( prop ) ; ++ propsRenamed ; prop . expandTypesToSkip ( ) ; // This loop has poor locality, because instead of walking the AST, // we iterate over all accesses of a property, which can be in very // different places in the code. for ( Map . Entry < Node , JSType > entry : prop . rootTypesByNode . entrySet ( ) ) { Node node = entry . getKey ( ) ; JSType rootType = entry . getValue ( ) ; if ( prop . shouldRename ( rootType ) ) { String newName = propNames . get ( pTypes . find ( rootType ) ) ; node . setString ( newName ) ; compiler . reportChangeToEnclosingScope ( node ) ; ++ instancesRenamed ; } else { ++ instancesSkipped ; CheckLevel checkLevelForProp = propertiesToErrorFor . get ( prop . name ) ; if ( checkLevelForProp != null && checkLevelForProp != CheckLevel . OFF && ! reported . contains ( prop . name ) ) { reported . add ( prop . name ) ; compiler . report ( JSError . make ( node , checkLevelForProp , Warnings . INVALIDATION_ON_TYPE , prop . name , rootType . toString ( ) , "" ) ) ; } } } } else { if ( prop . skipRenaming ) { ++ propsSkipped ; } else { ++ singleTypeProps ; } } } if ( logger . isLoggable ( Level . FINE ) ) { logger . fine ( "Renamed " + instancesRenamed + " instances of " + propsRenamed + " properties." ) ; logger . fine ( "Skipped renaming " + instancesSkipped + " invalidated " + "properties, " + propsSkipped + " instances of properties " + "that were skipped for specific types and " + singleTypeProps + " properties that were referenced from only one type." ) ; } }
Renames all properties with references on more than one type .