Created
May 26, 2012 08:20
-
-
Save datapimp/2792913 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # So, I have some class defintiions | |
| # written in coffeescript. I am writing | |
| # an app in coffeescript, which reads these files | |
| # on disk. I have access to the coffeescript compiler | |
| # from inside of my app. | |
| class SomeClass | |
| doSomething: ()-> | |
| 1 + 1 = 2 | |
| # | |
| # I want to be able to read the contents of | |
| # this file on disk, and then request the body of any | |
| # method definition by name. | |
| # | |
| # in the coffeescript REPL, SomeClass.doSomething.toString() | |
| # returns the compiled javascript, which is expected. but what | |
| # I want is to be able to get the method definition as it was | |
| # written in coffeescript. | |
| # | |
| # I am able to just parse the file, find the line where a method | |
| # is defined, and then work off of indentation, but this doesn't | |
| # feel correct to me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're also going to introduce (inconsequential) whitespace differences. What you really need is an AST that preserves the concrete syntax that caused the parser to create it. For that, you're either going to have to wait for my kickstarter to be done or fork CS and do it yourself.