Author Topic: How to restrict tag file search to specific tag files?  (Read 3038 times)

JimmieC

  • Senior Community Member
  • Posts: 423
  • Hero Points: 15
How to restrict tag file search to specific tag files?
« on: September 30, 2015, 07:33:12 pm »
v2011.

I work with Texas Instruments embedded projects. So, in the past I have created a tag file for the TI compiler and a tag file for the TI DSP\BIOS operating system. However, it seems that sometimes when I go to the definition of a symbol, I am taken to a Visual Studio file.

A have never quite figured out how to configure the project to only look at the TI tag files. This issue doesn't happen often as most of symbols do not match VStudio symbols. But, I would like to restrict the tag file scope on a per project basis.

Jim

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4627
  • Hero Points: 370
Re: How to restrict tag file search to specific tag files?
« Reply #1 on: September 30, 2015, 10:05:57 pm »
It is possible to setup a compiler/tag file per project. Would this be useful for your situation? For example, you could create a new compiler configuration called "No Tags", and set it to be the active compiler in your TI projects. Then the Visual Studio tags would never be used for that project. Visual Studio is actually setup as your default compiler/tag file when you have a workspace open and are editing a C++ file.

I just noticed that this feature appears to be broken in v20 beta. When you try to set the Project compiler (Project>Project Properties>Compile/Link), the setting doesn't get saved. We will fix this for the next beta.

JimmieC

  • Senior Community Member
  • Posts: 423
  • Hero Points: 15
Re: How to restrict tag file search to specific tag files?
« Reply #2 on: October 01, 2015, 01:12:04 pm »
I have never really figured out if there was any way to restrict the tag files that are used. I don't invoke the compiler through SE so I never considered the compiler options. I edit in SE and then switch over to Code Composer Studio to compile and debug. I just used the tag files for code navigation (Find Reference, Go To Definition, etc).

That said, I have created additional tag files, per project, in the past as I mentioned before but I abandoned that because really it is not an issue 99% of the time. SE always automatically tags the project code files and that is usually sufficient.

See the attached text file for some examples of my project includes.

I have about 20 TI projects that I work on and a few Freescale projects as well. Some of those will use the same compiler version, some won't. The same is true for the OS.

So, how I see it, is there would be a tag file for MSP430 compiler 4.21, and a tag file for MSP430 compiler version 4.22, etc. The same would be true for the DSP\BIOS OS. A tag file for DSP\BIOS 5.42.01.09, a file for 5.41.04.18, and file for 5.31.02, etc.

Then when I create a project from the source files, I can just hook in the additional correct tag files. Maybe the way to hook them in is in the compiler settings? I have tried just adding the directory trees for the OS, libs, & compiler to the project before but that was kind of messy. 99% of the time I am just making changes that are relegated to the target project code.

Like I mentioned before, this issue with it finding the definitions in Visual Studio happens rarely but it does happen. Further, occasionally SE can't find a definition for the OS because I gave up on creating those tag files per project and never really knew how to force SE to limit the scope to just those files.

Let me reiterate though that it really doesn't impact my work much. But, I figured that maybe I am missing some easy configuration that already exists and then I could use SE more correctly.

Jim

PS:  I think I used "in is in" in a grammatically correct way, Cool. ;-).

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4627
  • Hero Points: 370
Re: How to restrict tag file search to specific tag files?
« Reply #3 on: October 01, 2015, 02:32:21 pm »
It doesn't sound like you are currently using SlickEdit projects (i.e. no workspace is open)? Before I can give you the best answer, I need to know that for sure.

JimmieC

  • Senior Community Member
  • Posts: 423
  • Hero Points: 15
Re: How to restrict tag file search to specific tag files?
« Reply #4 on: October 01, 2015, 02:39:46 pm »
Hi Clark,

My apologies, I use the terms project & workspace interchangeably sometimes which I should not.

And, I am not working with one of those funky old projects without a workspace which I referenced in a previous post. I fixed those to use a new workspace & project as well

Yes, for each of these TI projects, I have workspace which has one project in it.

Jim

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4627
  • Hero Points: 370
Re: How to restrict tag file search to specific tag files?
« Reply #5 on: October 01, 2015, 02:50:57 pm »
Have you built tag files for your compiler and the OS? If not, we should address that first.

Also, do you want to see tags for all your TI compiler and OS versions at the same time?

JimmieC

  • Senior Community Member
  • Posts: 423
  • Hero Points: 15
Re: How to restrict tag file search to specific tag files?
« Reply #6 on: October 01, 2015, 03:06:38 pm »
I have built tag files in the past for the at least one version of the OS and a couple of the compilers. They were listed in the Tag Files window. I believe I even tried setting them up as Auto-Updated at one point.

I have since deleted them all because I never knew how to use them correctly.

However, I just created one for the BIOS operating system for this post.

See attached file...

Jim

JimmieC

  • Senior Community Member
  • Posts: 423
  • Hero Points: 15
Re: How to restrict tag file search to specific tag files?
« Reply #7 on: October 01, 2015, 03:14:39 pm »
I also just created a tag file for the compiler.

See attached file.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4627
  • Hero Points: 370
Re: How to restrict tag file search to specific tag files?
« Reply #8 on: October 01, 2015, 03:29:14 pm »
I think setting language specific tag files with the Tag Files dialog is the way to go. We use this here for Qt.

It does affect all projects but given the simplicity, it's almost always the right way to go.

You can get fancier, but since SlickEdit prompts you for which tag you want to go to, it's usually not worth the effort.

For example, after you've created say 10 tag files for who knows what, you can setup the "set_exttagfiles" command to get executed when the project opens. However, if you do this, you need to do this for every project. Typically this isn't worth the effort. You can also create a Compiler configuration like I explained before called "No Tags" and configure that for each project to avoid Visual C++ tags.

Place the following command in the Project Properties>Open Tab:

set_exttagfiles c f:\f\projects\cross1\junk.vtg;f:\f\projects\gnuc1\junk2.vtg

The above command will set the extension specific tag files for "c" to the two tag files specified. The extension specific tag files are not restored though which is why each project would need to set the extension specific tag files. Up to you whether it's worth the effort.

JimmieC

  • Senior Community Member
  • Posts: 423
  • Hero Points: 15
Re: How to restrict tag file search to specific tag files?
« Reply #9 on: October 01, 2015, 06:46:29 pm »
Thanks for info. The set_exttagfiles command looks promising. It seems that that will give me what I want. I will give it a try later.

In the mean time (not using set_exttagfiles), I have tag file for the compiler and a tag file for the OS. When I go to definition of memcpy(), I am taken immediately to C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\WinNT.h.

I think I may have to import my header files?

Attached is the string.h from the TI compiler file set.

Jim

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4627
  • Hero Points: 370
Re: How to restrict tag file search to specific tag files?
« Reply #10 on: October 01, 2015, 09:09:12 pm »
string.h seems to be confusing the tagging. There's no memcpy in there so I'm not surprised that doesn't work. However, I couldn't get tags which are there like memchr, memmove, strchr, etc. to work. The problem seems to be something to do with the "std" namespace.

I've narrowed it down to something much smaller:

------------myfile.h:
namespace N1 {
    void myfunc(int x);
}

using N1::myfunc;

-------------myfile.cpp
void main(int argc, char *argv[]) {
    myfunc(4);
}


If you put all the above code in one file, then it works???


JimmieC

  • Senior Community Member
  • Posts: 423
  • Hero Points: 15
Re: How to restrict tag file search to specific tag files?
« Reply #11 on: October 01, 2015, 09:28:11 pm »
Hi Clark,
Thanks for looking at this.

In my target code I only type memcpy() without the namespace specifier (scope resolution).

However, because the header file has the "using std::memcpy()" directive, I don't have to use the namespace specifier unless I am in a different namespace.

Is SE's tagging engine normally expected to be able to identify this?

Or is this out of scope (pun intended) for tagging?

Jim

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4627
  • Hero Points: 370
Re: How to restrict tag file search to specific tag files?
« Reply #12 on: October 01, 2015, 10:08:49 pm »
Hmm...good point. That is the limitation. The using statements would have to be in the .cpp file. Not sure if there is a way to fix this.

JimmieC

  • Senior Community Member
  • Posts: 423
  • Hero Points: 15
Re: How to restrict tag file search to specific tag files?
« Reply #13 on: October 01, 2015, 10:15:25 pm »
TI tends to utilize the "using namespace" directive a lot in their header files for the compiler.

Attached is a grep of the compiler header files for "using". You will see that there are quite a few entries.

Jim

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4627
  • Hero Points: 370
Re: How to restrict tag file search to specific tag files?
« Reply #14 on: October 01, 2015, 10:25:33 pm »
I can think of a way to handle this but it's a bit of a hack. As long as all using statements are stored in the tag database, simply allow some to be applied globally if they match to a function and are found in a .h file. This is definitely a hack. Might even have to require an option. Not sure if there is a better hack for this. The context tagging code doesn't currently differentiate between header files (.h) and code files and SlickEdit doesn't really provide a way for a user to define which is which.

Can't promise any improvements on this for v20. This sounds like a difficult change.