Author Topic: Go to references with in a directory  (Read 5015 times)

Anil Kumar

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Go to references with in a directory
« on: June 21, 2012, 05:30:53 am »
Hey All,
I was trying to figure out how to restrict the references of a symbol to a directory (of course recursively with in that directory).

Is it not available? I dont think so. Please help me out.

Thanks a lot,
Anil.

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Go to references with in a directory
« Reply #1 on: June 21, 2012, 07:49:20 am »
No way - finding references and other symbol or tag based operations are based on the tag database(s).
The workspace tag database resp. file includes all files of your workspace.
So the only way to restrict symbol lookup is setting up a dedicated workspace with exactly the files you want to deal with.
HS2

Graeme

  • Senior Community Member
  • Posts: 2363
  • Hero Points: 311
Re: Go to references with in a directory
« Reply #2 on: June 21, 2012, 09:01:11 am »
What version of slickedit are you using?

There's a function called grep_tag that you might be able to hack to do what you want  - except that when I typed the following on the slick cmd line in slick V17
grep_tag on_create
slickedit became "not responding" and I had to kill it.
Anyway, the code you could try changing is in the following.  The if(project_only) statement is restricting the tag match to files in a particular project.  You could add an if statement after that  - if(directory_only)  - and check the filename against a directory name.

Code: [Select]
   while (tag_filename!='') {
      message("searching "tag_filename":");
      status = tag_find_regex(search_str, options);
      while (!status) {
         boolean foundInProject=true;
         if (project_only) {
            _str file_name='';
            tag_get_detail(VS_TAGDETAIL_file_name, file_name);
            _str relativeFilename = _RelativeToProject(file_name);
            if(_projectFindFile(_workspace_filename, _project_name, relativeFilename) == "") {
               foundInProject=false;
            }
         }
         if (foundInProject) {
            tag_insert_match_fast(VS_TAGMATCH_tag,0);
         }
         status = tag_next_regex(search_str, options);
      }
      tag_reset_find_tag();
      tag_filename = next_tag_filea(tag_files, i, false, true);
   }

Anil Kumar

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: Go to references with in a directory
« Reply #3 on: June 21, 2012, 09:21:13 am »
Thanks for the replies.
I am using v17 trail version.

I will try the solution proposed by Graeme. Hoping it works!

Graeme

  • Senior Community Member
  • Posts: 2363
  • Hero Points: 311
Re: Go to references with in a directory
« Reply #4 on: June 21, 2012, 09:23:46 am »
If you're new to slickedit you probably won't be able to do it.  I'm trying it at the moment.  I'll let you know how it goes.

Graeme

  • Senior Community Member
  • Posts: 2363
  • Hero Points: 311
Re: Go to references with in a directory
« Reply #5 on: June 21, 2012, 09:35:01 am »
Actually I won't be able to do it either because I misunderstood what grep_tag is for  - it doesn't find references.  Sorry about that.

Anil Kumar

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: Go to references with in a directory
« Reply #6 on: June 22, 2012, 04:18:38 am »
Ok.
Can I do the following?
I can divide the whole code base (a work space) in to multiple project. A project per directory.
Now if I look for references, is their an option to say first try in the current project if fails to find then try in the whole work space?

I am liking the power of this community. Thanks a lot for the replies and information.

Graeme

  • Senior Community Member
  • Posts: 2363
  • Hero Points: 311
Re: Go to references with in a directory
« Reply #7 on: June 22, 2012, 11:36:48 am »
No, there's no option like that.  Did you notice in the references toolwindow that you can right click and select "collapse" to show just a list of filenames.

Why don't you just do a normal search?

If you become familiar with Slick C you could probably write your own function similar to tag_remove_duplicate_symbol_matches below.  The bit at the start copies the current tag list, the bit at the end re-creates the tag list minus duplicates.

Code: [Select]
void tag_remove_duplicate_symbol_matches( ... )

   // ...
   VS_TAG_BROWSE_INFO taglist[];
   taglist._makeempty();
   for (i=0; i<n; ++i) {
      tag_get_match_info(i+1,taglist[i]);
      if (tag_tree_type_is_func(taglist[i].type_name)) ++numFuncs;
   }

    //  ... filter the tag list

   // reconstruct the set of tag matches
   tag_clear_matches();
   n = taglist._length();
   for (i=0; i<n; ++i) {
      if (taglist[i] != null) {
         tag_insert_match_info(taglist[i]);
      }
   }
}