Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Some refactoring in the Move Refactoring, adapt call from Move Partic…

…ipant.
  • Loading branch information...
commit f8776e5ee93e6a5860e0d5ff2bf6b15a6cae4998 1 parent b82bffe
Mirko Stocker misto authored
51 org.scala-ide.sdt.core/src/scala/tools/eclipse/refactoring/move/MoveClassAction.scala
@@ -77,7 +77,34 @@ class MoveClassAction extends RefactoringAction {
77 77 }
78 78
79 79 override def createChange(pm: IProgressMonitor): CompositeChange = {
  80 +
  81 + val (textChanges, newFileChanges) = createRefactoringChanges(pm)
  82 +
  83 + new CompositeChange(getName) {
  84 +
  85 + scalaChangesToEclipseChanges(textChanges) foreach add
  86 +
  87 + newFileChanges match {
  88 +
  89 + // If there's no new file to create, we move the current file.
  90 + case Nil =>
  91 + add(new MoveResourceChange(file.getResource, target.getCorrespondingResource.asInstanceOf[IFolder]))
80 92
  93 + // Otherwise, create a new file with the changes's content.
  94 + case newFile :: rest =>
  95 + val pth = target.getPath.append(preparationResult.right.get.get.name.toString + ".scala")
  96 + add(new CreateFileChange(pth, newFile.text, file.getResource.asInstanceOf[IFile].getCharset))
  97 + }
  98 + }
  99 + }
  100 +
  101 + override def getPages = {
  102 + val selectedImpl = preparationResult.right.toOption flatMap (_.map(_.name.toString))
  103 + List(new ui.MoveClassRefactoringConfigurationPage(file.getResource(), selectedImpl, target_=, setMoveSingleImpl))
  104 + }
  105 +
  106 + private[move] def createRefactoringChanges(pm: IProgressMonitor) = {
  107 +
81 108 val (index, cleanupHandler) = {
82 109 val toMove = refactoring.statsToMove(selection(), refactoringParameters) collect {
83 110 case impl: refactoring.global.ImplDef => impl.name.toString
@@ -100,32 +127,10 @@ class MoveClassAction extends RefactoringAction {
100 127 (textChanges, change :: newFilesChanges)
101 128 }
102 129 }
103   -
104   - val change = new CompositeChange(getName) {
105   -
106   - scalaChangesToEclipseChanges(textChanges) foreach add
107   -
108   - newFileChanges match {
109   -
110   - // If there's no new file to create, we move the current file.
111   - case Nil =>
112   - add(new MoveResourceChange(file.getResource, target.getCorrespondingResource.asInstanceOf[IFolder]))
113   -
114   - // Otherwise, create a new file with the changes's content.
115   - case newFile :: rest =>
116   - val pth = target.getPath.append(preparationResult.right.get.get.name.toString + ".scala")
117   - add(new CreateFileChange(pth, newFile.text, file.getResource.asInstanceOf[IFile].getCharset))
118   - }
119   - }
120 130
121 131 cleanup()
122 132
123   - change
124   - }
125   -
126   - override def getPages = {
127   - val selectedImpl = preparationResult.right.toOption flatMap (_.map(_.name.toString))
128   - List(new ui.MoveClassRefactoringConfigurationPage(file.getResource(), selectedImpl, target_=, setMoveSingleImpl))
  133 + (textChanges, newFileChanges)
129 134 }
130 135 }
131 136 }
5 org.scala-ide.sdt.core/src/scala/tools/eclipse/refactoring/move/ScalaMoveParticipant.scala
@@ -59,10 +59,9 @@ class ScalaMoveParticipant extends MoveParticipant {
59 59 // but we skip our part. Really? Test! Add warning to the status.
60 60 pm.setCanceled(false)
61 61 } else {
  62 +
62 63 change = new CompositeChange("Move Scala Class") {
63   - val changes = moveRefactoring.performRefactoring() collect {
64   - case tc: TextChange => tc
65   - }
  64 + val changes = moveRefactoring.createRefactoringChanges(pm)._1
66 65 moveRefactoring.scalaChangesToEclipseChanges(changes) foreach add
67 66 }
68 67 }

0 comments on commit f8776e5

Please sign in to comment.
Something went wrong with that request. Please try again.