[cedet-semantic] Re: Improved defadvice add-log-current-defun
Brought to you by:
zappo
From: Stefan <st...@xs...> - 2005-08-17 11:19:30
|
"Eric M. Ludlam" <er...@si...> writes: >>However, I looked in wisent-python.wy. I think the following parts are relevant: >> >>;; funcdef: 'def' NAME parameters ':' suite >>funcdef >> : DEF NAME function_parameter_list COLON suite >> (FUNCTION-TAG $2 nil $3) >> ; >> >>;; classdef: 'class' NAME ['(' testlist ')'] ':' suite >>class_declaration >> : CLASS NAME paren_class_list_opt COLON suite >> (TYPE-TAG $2 $1 ;; Name "class" >> $5 ;; Members >> (cons $3 nil) ;; (SUPERCLASSES . INTERFACES) >> ) >> ; >> >> >>But I have no idea, how to set the :parent tag for the funcdef. >>Any pointers? > [ ... ] > > It seems that a class should indeed be a type class. I suspect that > the 'parent' is found via nesting instead of via a :parent attribute. > > As such, I now better understand the original question. > > If you have a definition like this in some invented language: > > class foo { > > method whatever { > } > > } > > then 'whatever' has a parent determined by tag nesting. ie: > > (semantic-tag-functio-parent whatevertag) > => nil > > but > > (semantic-tag-components footag) > => <#TAG whatever> > > where 'components' just means "more tags inside this one". In the > case of a tag of class type, that means methods and fields. For a > function, it may be arguments to the function. The situation you described above is exactly the case for python. > In C++, you can do this instead: > > class foo { > > void whatever(); > > } > > void foo::whatever() { > } > > and in this file, there are two 'whatever' tags. The first is as > described above. The second has a :parent attribute which contains > the name of the 'foo' tag. To get the foo tag, you would need to > perform some sort of semantic search. > > Does that make sense? Basically, tag tables mirror the code, and it > is up to various programs to make logical sense from the bounty of > language implementations. Thanks for that nice explanation, now I see the difference between python and C++ from the viewpoint of semantic. My use case (get class name + method name) for the point position didn't need that distinction. If I understood you correct, the new format function will provide a unified way to get class name + method name for every supported language. Stefan. |