|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Need Help: Creating a Ruby module for NetbeansHi,
i`m new to Netbeans Ruby module development and trying to create a module to provide special hints using given framework. I have severe problems in getting started and serveral questions: 1. My first goal is to do something like in the "Java Language Infrastructure Tutorial <http://platform.netbeans.org/tutorials/60/nbm-copyfqn.html>" found here: http://platform.netbeans.org/tutorials/60/nbm-copyfqn.html Therefore i need something like JavaSource to determine if a FileObject is a Ruby file. What should i use to do this? 2. How can i get an abstract syntax tree of the opened Ruby file in order to use a third party framework with it? 3. How can i access the opened Ruby file in order to underline words? I`d be really very happy if i could get some help. Best regards Philipp Marcus --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: Need Help: Creating a Ruby module for NetbeansOn Jul 22, 2008, at 11:09 AM, Philipp Marcus wrote:
> Hi, > > i`m new to Netbeans Ruby module development and trying to create a > module to provide special hints using given framework. I have severe > problems in getting started and serveral questions: > > 1. My first goal is to do something like in the "Java Language > Infrastructure Tutorial <http://platform.netbeans.org/tutorials/60/nbm-copyfqn.html > >" found here: http://platform.netbeans.org/tutorials/60/nbm-copyfqn.html > Therefore i need something like JavaSource to determine if a > FileObject is a Ruby file. What should i use to do this? Hi Philipp, Don't look at the above tutorial -- that's for the Java Infrastructure, which is completely Java specific, and has nothing to do with the Ruby support. Writing Ruby hints is probably the best documented area to get started in. Go to this page: http://wiki.netbeans.org/RubyAddHints Scroll past the idea list (which you should feel free to edit), and you'll see a tutorial on how to write quickfixes. I wrote this back when I first added the hints support. A few APIs have changed here and there, but the principles are the same. You should definitely use some of the existing hints (there are lots of classes, see the ruby.hints/ module) for inspiration. These will show you how things are done today since they've been tweaked along with the API changes. If I were you I'd pick one of the existing hints that are similar, copy it and adjust it for your needs. E.g. pick if you have an error rule (keyed off JRuby parser errors), or a "caret sensitive" rule (only run when the caret moves over code that is surrounded by an AST node of your given type, or a "selection sensitive rule" (run when the selection changes -- such as the Extract Method or Introduce Variable refactoring rules, or (the default, which most rules are: ) generic hints which are run over the whole buffer whenever it is opened or changed. For performance reasons, you key your rules off specific AST node types, and only rules applicable to a given node type are consulted. > 2. How can i get an abstract syntax tree of the opened Ruby file in > order to use a third party framework with it? For hints, this is done by the hints infrastructure - just implement the Rule interface and register your rule, and you'll be called with a RuleContext which provides the JRuby AST among other things. > 3. How can i access the opened Ruby file in order to underline words? Again, with the quickfix infrastructure you just have to create an instance of a Hint object (see examples) and put its offsets and description in there, and the rest is automagic. For extra credit, instead of just a hint, you can also add one or more fixes to mutate the document to fix the error. There are lots of examples of this in the source tree. Finally, be sure you take a look at the unit tests. Writing quickfix unit tests are trivial - the infrastructure does all the heavy lifting. You just register test cases by pointing to Ruby source files and caret positions, and then run the test; it will generate hint descriptions and diff them against your own goldenfiles (generated the first time you run the test). -- Tor --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
| Free Forum Powered by Nabble | Forum Help |