Re[1]: [cedet-semantic] help with semanticdb?
Brought to you by:
zappo
From: Eric M. L. <er...@si...> - 2003-03-05 04:30:56
|
>>> Stuart Popejoy <st...@pi...> seems to think that: >I'm using semanticdb-find-nonterminal-by-name function, with the >SEARCH-PARTS option, in hopes of finding variables and functions in >various files from a single command. Hi, >The docs say the results are in the form: > >( (DATABASE TOKEN1 TOKEN2 ...) (DATABASE2 TOKEN3 TOKEN4 ...) ...) > >However, when I search for, say, "aMethod", the results don't seem to >match this. Printing the first item of the results looks like (commas >added for clarity): > >([object semanticdb-table Foo.java > [object semanticdb-project-database semantic.cache > /foo/bar/semantic.cache /foo/bar > [object semanticdb-table Foo.java #2 Foo.java 29230 jde-mode > (( ... token list for Foo.java ... )) > (( ... close-paren and open-paren stuff ... )) ] > [object semanticdb-table Bar.java > (similar to Foo previous) ... ] > [ .. more objects in db .. ] > ] ) ], > myMethod, function, String, > (( .. variable token list .. )), ((typemodifiers)), ..., extent) When you see something like this: [ object blah blah ...] That is a single EIEIO object. I tried this again myself to make sure, and I get a structure like this: ( ( [ object ...] ("name" 'whatever ...) ) ( [ object ...] ("name" 'whatever ...) ) ) which is correct. >There seems to be one entry like this for each semanticdb-table object >that matched the search. Yup. The table object the token was found in is returned for each file because some files are not in Emacs, which means you cannot figure out where the token came from unless you also have the table. If you use the FIND-FILE-MATCH option, you can safely ignore every object returned because the tokens will all have an overlay in them which contains the originating buffer. This can be expensive, however, if you have lots of matches. >My questions are: > >1) Even if, in a result for a given semanticdb-table object, multiple >sub-tokens match the search, the data at the end of the entry only >corresponds to one of those sub-tokens. Does this mean one would have to >walk the token tree of the matching object to find every match for the >term? That is an unfortunate restriction of the `-by-name' search routines. They use `assoc' for extra speed. If you use `-by-name-regexp' instead, you will get a full list of every match. You will just have to match "^eMethod$". >2) How do you access that token list of a semanticdb-table object? I'm >assuming the objects are eieio objects, which I don't know how to >program. Is there an easy way to get the list? Ideally, it would be >accessing that first object with the db inside of it, instead of walking >the db object and finding the table object ... Once you have one of the [object ...] things, you can use `oref' to get at the fields. Use `describe-variable' on C-h v to get the doc for `semanticdb-table' and `semanticdb-project-database' to learn about all the slots on those objects. Specifically, you can do this: (oref (car (car results)) tokens) and then you can use `semantic-find-nonterminal-by-whatever' to do your own searches. >Thanks! I hope to create etags-like functionality with this, so all help >is greatly appreciated. Sounds like a good project to me. Good Luck. Eric -- Eric Ludlam: za...@gn..., er...@si... Home: http://www.ludlam.net Siege: www.siege-engine.com Emacs: http://cedet.sourceforge.net GNU: www.gnu.org |