Skip to content

add -P:sxr:output-class:<class> option#10

Open
ezh wants to merge 2 commits intoharrah:masterfrom
ezh:master
Open

add -P:sxr:output-class:<class> option#10
ezh wants to merge 2 commits intoharrah:masterfrom
ezh:master

Conversation

@ezh
Copy link

@ezh ezh commented Jul 28, 2011

Dear Mark,
Thank you very much for 'browse'. I slightly modify your code by adding new option. I try to preserve all punctuation, tabs, \r\n. I hope that addition look like original code. This new option allow add external class writer for sxr.

For example
somewhere at build.sbt or like one:
scalacOptions += "-Xplugin:other.package.jar"
scalacOptions <+= (scalaSource in Compile) map { (source) => { "-P:sxr:output-class:other.package.CustomWriter" }

Our custom writer

package other.package

import java.io.File
import sxr.OutputWriter
import sxr.Token
import sxr.OutputWriterContext

class CustomWriter(context: OutputWriterContext) extends OutputWriter {
/** Generates initial content. */
def writeStart() {
}

/** Generates content for a given source file. */
def writeUnit(source: File, relativeSourcePath: String, tokenList: List[Token]) {
println("--- " + source.toString)
...
withReader(source, context.encoding) { input =>
withWriter(destination) { output =>
tokenList.foreach( ... custom code ...))
}
}
}

/** Generates final content. */
def writeEnd() {
}
}

It's work surprisingly well. I hope that you accept this addition. If i need it modify, please tell me about.

King regards,
Alexey

@harrah
Copy link
Owner

harrah commented Sep 23, 2013

I apologize for the long delay in looking at this. I like the idea. If you still happen to be interested, please rebase onto master and it will get merged.

@jsuereth
Copy link

Hey @ezh If you have the opportunity, can you rebase this patch on master over here: https://github.com/sbt/sxr.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants