Author Topic: Troubleshooting tagging issues  (Read 2968 times)

asandler

  • Senior Community Member
  • Posts: 303
  • Hero Points: 27
Troubleshooting tagging issues
« on: February 10, 2016, 02:30:10 pm »
From time to time I have various tatting issues. For instance last night I asked to Go To Definition of a symbol, some C++ class, and instead of taking me to the class it took me to some other class where the class I was looking for was defined as friend. I often try to reproduce these on a small project that I can send to SE team, but I rarely succeed.

From my previous experience, most of the time there is a work-around for this or its something wrong with my setup. I would really love to be able to figure these things out myself. I am wondering if there is a way for me to analyze these issues. Is there a guide that explains how to tackle these kind of problems? I think I saw something on the forum awhile ago, but I could not find it.

Thanks,
Alex.
« Last Edit: February 11, 2016, 06:42:35 pm by asandler »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3179
  • Hero Points: 454
Re: Troubleshooting Context Tagging issues
« Reply #1 on: February 11, 2016, 05:41:02 pm »
The SlickEdit Book by John Hurst (2008 Wiley Publishing), Chapter 5, in the compendium on SlickEdit Context Tagging and hundreds of other aspects of how SlickEdit can be customized and tuned.  I recommend it, even though it may be a bit dated now.

I'm also going to share this rough-draft excerpt from the book, because these problems do come up in the forums a lot.  When tagging doesn't work, I find a lot of really smart people just stare at it with glazed angry eyes instead of doing what programmers do and tracking down the problem (which is almost always, always on account of horrible, insidious C Preprocessing).

OP:  I changed the subject line of this post so that people can find this easier without it getting confused with debugger integration issues.



This is a short set of guidelines for what to do when various Context Tagging(R) features do not work as expected.  It assumes that you know your source code well enough to debug the problem, or you know traditional techniques of source code navigation (grep) enough to do what the Context Tagging operation would have done.
 
Go to Definition (Ctrl+.) doesn't work:
 
Case 1:  An unqualified symbol, let's call it "x".
 
1. Where is "x" defined or declared?
 
    a) Is it a local variable or function parameter?
        Does it show up if you hit Alt+. (list-members)?
        If not, look at it's definition, is it correct (would the code compile)?
        In C/C++, is it declared using preprocessing?  If yes, see Solution A.
 
    b) Is it in the same file?
        Does "x" show up in the Defs tool window?  (you may have to turn off filtering options).
        Is the symbol information correct?  (check the symbol's name, class scope, and protection flags)
        If not, look at it's definition, is it correct (would the code compile)?
        In C/C++, is it declared using preprocessing?  If yes, see Solution A.
 
    c) Is it in a different file?  Is that file tagged?
        Is it in your workspace?  Is it in an extension specific tag file?
        If not, see Solution B.
 
2. Go to the file and line where "x" is defined or declared.
 
    a) Does the source file come up in the correct source language mode?
        Is this an extensionless C/C++ header file?  If yes, see Solution D.
        Does this file have an unrecognized file extension (like .hhh)?  If yes, see Solution C.
 
    b) Does "x" show up in the Defs tool window?  (you may have to turn off filtering options).
        Is the symbol information correct?  (check the symbol's name, class scope, and protection flags)
        If not, look at it's definition, is it correct (would the code compile)?
        In C/C++, is it declared using preprocessing?  If yes, see Solution A.
        Should the symbol be visible from the scope you were in?  (maybe the symbol is private, or needs to be imported)?
 
    c) If "x" shows up correctly in the Defs tool window, but Go to Definition was failing,
        make sure the tag file is up-to-date.  See Solution E.
 
Case 2:  A qualified symbol, such as "expr.x", "expr->x", or "expr::x".
 
1. Try list members (hit Alt+.).

    Does a list of items show up?
    Is it the correct list of items?  Is it the correct class?
    Is "x" in the list?
    If not, do you get an error message in the message bar?
    Does the error message help you figure out the problem?
 
2. Move your cursor to the right of the member access operator and hit Ctrl+. to go to the definition.

    Does it take you to the correct symbol?
    Is the symbol tagged correctly?  (check the symbol's name, class scope, and protection flags)
   
    a) If not, follow the guidelines for Go to Definition to determine why you can't jump to the last symbol in "expr".
 
    b) If yes, then look at the type of the symbol.
        Try to jump to the definition of the symbol's type using Ctrl+.
        Does it take you to the correct symbol?
        Is the symbol tagged correctly?  (check the symbol's name, class scope, and protection flags)
 
    c) Is the type name a typedef?  Can you navigate to the typedef'd type?
 
3. Evaluate "expr" to determine if it is recognized correctly.

    For a simple example:  Assume "expr" is a local variable of type "MyClass".
 
    a) Follow the guidelines for "Go to Definition" to determine if "expr" is correctly tagged.
    b) Follow the guidelines again to determine if "MyClass" is correctly tagged.
    c) For longer prefix expressions such as "a.getIterator()->currentItem()->x",
        you may need to follow this procedure iteratively to determine where the missing link is.
 
4. Assuming you've finally found the actual type of "expr" by now,

    Is "x" correctly seen as a member of the type?
    Follow the procedure in Case 1, step 2 to verify if the symbol is tagged correctly.
 
Go to Reference (Ctrl+/) doesn't work:
 
1. Does Go to Definition (Ctrl+.) work?

    Follow the Go to Definition procedure to determine that the symbol
    you are searching for references to is itself correctly tagged.
 
2. Are references missing?
 
    a) Are all the files you are expecting to find references in tagged correctly?  (see above).
        Is the tag file they are in build with cross-referencing enabled?
 
    b) Put your cursor on a reference that is skipped.
        Go to Definition should take you to the definition of the symbol you are looking for.
        If not, this is why the reference was skipped.
        Follow the Go to Definition debugging procedure.
 
3. Are there too many references found?
 
    a) Are the references displayed with a "?" icon.
        This indicates that SlickEdit was unsure about the reference.
        Put your cursor on a extra reference.
        Follow the Go to Definition debugging procedure.
 
    b) When symbol information is incomplete, references falls back on a
        philosophy that it is better to show too many items than miss items.
        This means it will only eliminate an occurrence of the symbol if it can prove that
        it is another symbol.  Otherwise, it is regarded as a correct reference or
        a miscellaneous (?) reference.
 
Auto-list members (Alt+.) doesn't work:
 
See Case 2 of the Go to Definition debugging procedure in order to determine if
the prefix expression (the expression before the member access operator) is
correctly recognized.
 
Auto-parameter information (Alt+,) doesn't work:
 
1. Does Go to Definition (Ctrl+.) work on the function name?
    Follow the Go to Definition procedure to determine that the function
    you are looking for parameter information about itself correctly tagged.
 
2. Is the incorrect prototype displayed?  Try hitting Alt+, again to
    cycle to the next prototype.  If there is only one prototype, make
    sure your tag file is up-to-date.  See Solution E.



Solution A:  add the symbol to your workspace or other tag file
 
Go to Project > Project Properties, switch to the Files... tab and add the file to your project.
If the file is part of a third-party library of files, you might want to create a library project for them and add that to your workspace.
If the file is part of a large library of files that you use in all your projects, you may want to create an extension specific tag file.
 
Solution B:  define C/C++ preprocessing to SlickEdit
 
Go to Tools > Options > File Extension Setup and click on C/C++ Options, switch to the Other tab, and then click on the C Preprocessing.. button.  Add your #define using this dialog, and let it rebuild your workspace tag file when you are done.
 
Solution C:  configure C/C++ extensionless header files for SlickEdit
 
Go to Tools > Options > File Extension Setup and click on C/C++ Options, switch to the Other tab, and then click on the Extensionless Headers button to configure the names of extensionless header files.  Also verify the Extensionless Header path regular expression to verify that your file now matches the criteria to be seen as C/C++ even though it doesn't have a proper extension.  Close and re-open the file and it should come up as C/C++ now.  You may have to rebuild your tag file after doing this step.
 
Solution D:  create a file extension alias
 
Go to Tools > Options > File Extension Setup and click on "New...".  Enter the file extension of the file you need to add (without the dot), select the language mode, then hit Ok.  Close and re-open the file and it should come up in the correct language mode now.  You may have to rebuild your tag file after doing this step.
 
Solution E:  rebuild your tag file(s)
 
Go to Tools > Tag Files.  Select your workspace tag file and click on Rebuild Tag File.  Turn off "Retag modified files only".  Follow the same procedure for any extension specific tag files you believe have fallen out of date.



 

asandler

  • Senior Community Member
  • Posts: 303
  • Hero Points: 27
Re: Troubleshooting tagging issues
« Reply #2 on: February 11, 2016, 06:38:57 pm »
Thanks a lot Dennis. I think this is exactly what I was looking for.
And yes, troubleshooting is really what I want.
« Last Edit: February 11, 2016, 06:42:56 pm by asandler »