Skip to content

Instantly share code, notes, and snippets.

@vifon
Created July 22, 2015 21:59
Show Gist options
  • Save vifon/b9e6a09c4f221d414a2b to your computer and use it in GitHub Desktop.
Save vifon/b9e6a09c4f221d414a2b to your computer and use it in GitHub Desktop.
"add imports on the first line" in withAnalyzer { (dir, analyzerRef) =>
val file = srcFile(dir, "tmp-contents", contents(
"import scala.collection.mutable.Set"
), write = true, encoding = encoding)
val analyzer = analyzerRef.underlyingActor
val procId = 1
analyzer.handleRefactorPrepareRequest(
new PrepareRefactorReq(
procId, 'Ignored, AddImportRefactorDesc(
"javax.swing.JPanel", new File(file.path)
),
false
)
)
analyzer.handleRefactorExec(
new ExecRefactorReq(procId, RefactorType.AddImport)
)
val formatted = analyzer.handleFormatFile(ContentsInSourceFileInfo(
new File("abc.scala"), new File(file.path)
))
val expectedContents = contents(
"import javax.swing.JPanel",
"import scala.collection.mutable.Set"
)
println("STARTING")
println(formatted)
println(expectedContents)
println("END")
assert(formatted === expectedContents)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment