Hi Eric,

Thanks for your reply. I think you missed my point.

Firstly, I believe something should be changed because currently neither 'semantic-symref' nor 'semantic-symref-symbol' work for C++ member variable. As I had already pointed out, both functions eventually call the 'cedet-gnu-global-search' with exactly same parameters and finally 'cedet-gnu-global-search' executes 'global' using '-xar'. The problem is that 'global -r' would find nothing for a C++ member variable. As far as I can see, in order for 'global' to find references for a member variable, '-s' needs to be used. Since I'm very new to GNU Global and my knowledge on 'Global' is very limited, I could be wrong on the '-s' thing.

Secondly, even if both these two commands works, they eventually both call the same function 'cedet-gnu-global-search' with exactly the same parameters. In both cases, the parameters being passed are:  texttype='symbol, type='line, scope='project. This makes these two commands logically identical which I believe is not ideal.

As a workaround, I added a conditional case '((eq texttype 'symbol) "rs") which made both commands work for me. However, this is just a workaround for myself and I don't think it's a good solution, but since I'm very new to lisp (this was the first time for me to debug in lisp) and I'm too busy on my project at work, I'm not able to come up with any better fix at this time.

Lastly, I'm not sure if I'm missing anything and I hope I'm missing something. I'm not satisfied with the result from GNU Global. Here is my case:

class A {
  int Var1
}

class B {
  int Var1
}

The problem is when I want the references of A::Var1, I got not only the references of A::Var1 but also all the references of B::Var1. This is not good at all even though it's still better than returning nothing. Microsoft Visual C++ is much better on this which differentiates A::Var1 and B::Var1. Is there anything in GNU Global that I'm not aware of to achieve this? Or, is there anything semantic could do to differentiate same variable name defined in different classes?   


Thanks,

York


On Mon, Mar 28, 2011 at 9:08 PM, Eric M. Ludlam <eric@siege-engine.com> wrote:
Hi York,

The difference between the two functions is about what you need to type to go to the reference.  One will just use the current tag (ie - who calls me) and the other pulls the default from the symbol under point (ie - who also calls this).  Otherwise, you are right, they are the same.

To be honest, I don't recall the intent of the flags combinations or symref symbols very well, and am open to any suggestions that make this better.  It does seem like some combination of -s and -r together would be best, since the general case of getting everything would be best, though Darren suggests they are mutually exclusive.  My man page on global appears to allow them to be used together.

If you find something that works well, we should check in the change.

Eric


On 03/26/2011 10:07 PM, York Zhao wrote:
Hi Eric & David,

Logically, I don't see any difference between 'semantic-symref' and
'semantic-symref-symbol because eventually they both call
'cedet-gnu-global-search (searchtext texttype type scope)' with exactly
the same arguments. In both cases, the arguments are: texttype=symbol,
type=line, scope=project. So, what's the difference between these two
command?

On the other hand, regarding my previous complaint of
'semantic-symref-symbol' command not working for me, I have figured out
the reason. Since the symbol I searched for was a C++ class member
variable, and it seems that the GNU Global doesn't consider member
variable as 'TAG' thus member variable were never put into the file
'GTAGS', which was the reason why neither 'semantic-symref-symbol' nor
'semantic-symref' could find it. As an experiment, I changed
the'cedet-gnu-global-search':

(defun cedet-gnu-global-search (searchtext texttype type scope)Hi

"Perform a search with GNU Global, return the created buffer.
SEARCHTEXT is text to find.
TEXTTYPE is the type of text, such as 'regexp, 'string, 'tagname,
'tagregexp, or 'tagcompletions.
TYPE is the type of search, meaning that SEARCHTEXT is compared to
filename, tagname (tags table), references (uses of a tag) , or
symbol (uses of something not in the tag table.)
SCOPE is the scope of the search, such as 'project or 'subdirs."
  (let ((flgs (cond ((eq type 'file)
"-a")
   (t "-xa")))
(scopeflgs (cond
   ((eq scope 'project)
""
    )
   ((eq scope 'target)
"l")))
(stflag (cond ((or (eq texttype 'tagname)
  (eq texttype 'tagregexp))
"")
     ((eq texttype 'tagcompletions)
"c")
     ((eq texttype 'regexp)
"g")
      ;;
      ;; York's experient begins
     ((eq texttype 'symbol)
"s")
      ;; York's experient ends
      ;;
     (t "r")))
)
    (cedet-gnu-global-call (list (concat flgs scopeflgs stflag)
searchtext))))

My change made 'semantic-symref-symbol' work but then 'semantic-symref'
stopped working as both these two functions called
'cedet-gnu-global-search' with exactly the same arguments. What are your
thoughts?


Thanks,

York