>>> Kai Grossjohann <kai@...> seems to think that:
>"Eric M. Ludlam" <eric@...> writes:
>
>> The semantic tag database excludes any code in the body of a
>> function. You could use the semantic-ctxt-* functions for some
>> generic language-independent context navigation if that is what you
>> are looking for.
>
>I didn't find what I needed. Hm. Perhaps I didn't try hard enough.
>Here is some code:
>
> try { // outer
> foo();
> bar();
> try { // inner
> quux();
> if (a == b) {
> mumble();
> }
> } catch (FooException e) {
> sldkjf();
> }
> frob();
> } catch (BarException f) {
> lsdkjf();
> }
>
>Suppose that point is on the mumble() line. Then I would like to find
>the try/catch block labeled "inner" and append a catch block to it.
>
>Currently, I do this: I invoke backward-up-list, then backward-sexp.
>Then I look to see if I'm looking at "try". If not, I repeat until I
>find one or get out of the current function. (I find the beginning of
>the current function with semantic-beginning-of-defun.)
>
>If I find a "try", then I forward-sexp over the "try { ... }" bit,
>then check whether I'm looking at a "catch". If so, I forward-sexp
>over the "catch (...) { ... }" bit, as well, and repeat. When I've
>reached the end of the "try {...} catch () {...} catch () {...}"
>sequence, I stop and insert my new catch block.
>
>I was wondering if there was perhaps a method I could call that would
>find me the closest enclosing try/catch block, and especially its
>start and end. Then it would have been trivial to move to the right
>spot.
>
>I was thinking that Semantic has that information.
[ ... ]
Hi,
Semantic doesn't have anything like that outside of the
semantic-ctxt.el file. For java, those APIs are just wrappers around
things like 'up-list' already, so that probably wouldn't help.
David's Java parser will parse the entire file, but we haven't
worked out the detail for representing code in a parse tree so I'm
not sure what else you could extract from that.
Representing code like this in a language independent way is an
important goal for many types of automated code modification routines,
parser-based font-lock, and complex syntax checking, so I'd like to
see it, but I doubt that would be anytime soon.
Eric
--
Eric Ludlam: zappo@..., eric@...
Home: http://www.ludlam.net Siege: http://www.siege-engine.com
Emacs: http://cedet.sourceforge.net GNU: http://www.gnu.org
|