fca4f13be6/org.scala-refactoring.library/src/main/scala/scala/tools/refactoring/implementations/MoveClass.scala

799e54613b3a098cb99a0ecbbd544c44faebfe7afca4f13be6a79d9efa6228576a8d231680ac6346
115
            
115
            
116
        val oi = new OrganizeImports {
116
        val oi = new OrganizeImports {
117
          val global: MoveClass.this.global.type = MoveClass.this.global
117
          val global: MoveClass.this.global.type = MoveClass.this.global
118
            
119
          object NeededImports extends Participant {
120
            def apply(trees: List[Import]) = {
121
              
122
              val imps = neededImports(toMove) filterNot { imp =>
123
                // We don't want to add imports for types that are
124
                // declared in `toMove`.
125
                val declaration = index.declaration(imp.symbol)
126
                declaration map (toMove.pos includes _.pos) getOrElse false
127
              }
128
              mkImportTrees(imps, targetPackageName)
129
            }
130
          }
118
        }
131
        }
119
        
132
        // TODO: Use IDE settings
120
        val imports = scala.Function.chain(new oi.FindNeededImports(toMove, targetPackageName) :: oi.SortImports :: Nil)(existingImports)         
133
        val imports = scala.Function.chain(oi.NeededImports :: oi.SortImports :: Nil)(existingImports)         
134
        // When we move the whole file, we only want to add imports to the originating package
121
        p copy (stats = imports ::: others) replaces p
135
        p copy (stats = imports ::: others) replaces p
122
    }
136
    }
123
  }
137
  }