Author Topic: Case sensitive in tagging  (Read 7091 times)

yhlove

  • Community Member
  • Posts: 8
  • Hero Points: 0
Case sensitive in tagging
« on: July 15, 2008, 07:42:39 am »
Hi

I've noticed that slickedit tags the source code in case-insentive.
The meaning is: if a function void foo(); is define and mistakely I called it like that:  Foo()
I'll get a compilation error but it will be difficult to detect that mistake with slickedit.

Is there any option to set tagging option to be case sensitive ?

Thanks
Yhlove

Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Case sensitive in tagging
« Reply #1 on: July 15, 2008, 12:11:38 pm »
Hi

I've noticed that slickedit tags the source code in case-insentive.
The meaning is: if a function void foo(); is define and mistakely I called it like that:  Foo()
I'll get a compilation error but it will be difficult to detect that mistake with slickedit.

Is there any option to set tagging option to be case sensitive ?

Thanks
Yhlove

If you're using slickedit 2008, in tools -> options -> "select a language" -> context tagging  - there are 3 checkboxes that let you select strict case sensitivity.

Graeme


yhlove

  • Community Member
  • Posts: 8
  • Hero Points: 0
Re: Case sensitive in tagging
« Reply #2 on: July 15, 2008, 12:17:38 pm »
I'm using SlickEdit 11.0.2
There is no solution for me?

Buy the way, my license is registered. Can I upgrade to a newer version without paying more money ? (updates are free ?)

Thanks
Yhlove

Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Case sensitive in tagging
« Reply #3 on: July 15, 2008, 01:06:01 pm »
I'm using SlickEdit 11.0.2
There is no solution for me?

Buy the way, my license is registered. Can I upgrade to a newer version without paying more money ? (updates are free ?)

Thanks
Yhlove

With 11.0.2 you can't make tagging case sensitive.  Major version upgrades aren't free but if you get maintenance and support you don't pay anything extra for the upgrades and you get "unlimited" technical support.

I suspect the best way to find spelling mistakes is to let the compiler tell you rather than have the tagging refuse to find a name.  If you really wanted, you could probably write a macro to replace push tag that compared the word at the cursor with the destination word

Graeme

yhlove

  • Community Member
  • Posts: 8
  • Hero Points: 0
Re: Case sensitive in tagging
« Reply #4 on: July 15, 2008, 02:17:58 pm »
Hi

I didn't get the point about the macro. What will this macro do?
Where can I find an example for such macro?

Yhlove

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Case sensitive in tagging
« Reply #5 on: July 15, 2008, 02:51:35 pm »
@yhlove Did you accidentally post to this topic?  You ask about a macro, but there has been no mention of a macro yet in this topic.

Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Case sensitive in tagging
« Reply #6 on: July 16, 2008, 12:53:54 am »
Chris, I mentioned about a macro in my previous post.

Yhlove - about the macro, I was thinking of something along the lines of this

Code: [Select]
   _str s1 = cur_word(x);
   push_tag();
   _str s2 = cur_word(x);
   if (s1 != s2) {
      _message_box('No match ' :+ s1 "\n" :+ s2);
   }

but this doesn't work, due to the cursor at the destination not landing on the actual target identifier but at the start of the declaration of that identifier.  Hence you would have to add a search forwards function to the above etc...    - which is starting to get messy.  I suspect there's a better way  e.g. in the defs toolbar, if you click "show call tree" for the current symbol, you get a "question mark" symbol beside every identifier in the current function that slick can't identify.  You could find the code that puts up this question mark and use it as the basis of searching the entire current file for tags that slick can't identify.

I guess really you're just surprised that slick jumps to a tag when it's spelt wrong.  Even if slick gave you a warning about this, it's not going to detect the majorirty of errors because you presumably don't do push-tag on every identifier. 

Anyway, if you really want, you could pursue the idea above and find out how slick identifies a tag and create your own push-tag that checked if the current symbol was a known tag first.  This should work because the defs toolbar still puts up a "question mark" when the word is spelt correctly but has incorrect case (in slick V11).

Graeme

yhlove

  • Community Member
  • Posts: 8
  • Hero Points: 0
Re: Case sensitive in tagging
« Reply #7 on: July 22, 2008, 04:27:14 pm »
I expect that one of the SlickEdit developers group will assist with this bug.
I fill that this is a real bug in slickEdit since c++ is case sensitive language...  :(

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Case sensitive in tagging
« Reply #8 on: July 22, 2008, 05:54:59 pm »
@yhlove:
SlickEdit only releases fixes for the current version, and v12 and v13 already do have a number of settings to control strictness of case sensitivity.
You've said that you want "tagging option to be case sensitive".
Can you describe some specific behaviors that you want to see changed?
Maybe if you describe specific behavior(s) that you want to see, then one of us fellow users could suggest how you can achieve those behaviors.
If you just want Ctrl+. to refuse to find a tag if the case is wrong, have you tried Graeme's macro?

yhlove

  • Community Member
  • Posts: 8
  • Hero Points: 0
Re: Case sensitive in tagging
« Reply #9 on: July 23, 2008, 07:19:34 am »
Graeme already said that his macro doesn't work. He suggested to write other macro but I find it too complicated for me to understand and investigate how to write it. As you said, I just want that Ctrl+. will refuse to find a tag if the case is wrong.

Thanks

Graeme

  • Senior Community Member
  • Posts: 2446
  • Hero Points: 322
Re: Case sensitive in tagging
« Reply #10 on: July 23, 2008, 01:00:54 pm »
Here's a macro that will do what you want most of the time.  It puts up a message box warning if the case doesn't match.  If you want the cursor to stay on the actual search word (rather than the start of the declaration), remove the save_pos, restore_pos.

If pust-tag succeeds, the code searches forward for a matching name using case insensitive search, then checks for case match.  Occasionally, this may give you a spurious warning e.g. if you manage to use the function name in the return type of a function.  Off the top of my head I can't think how you would do that in C++ except perhaps in an obscure template argument list where the function name was used in a non-type argument, but maybe there's an obvious case that I'm missing.  There's also the grep-tag function you can use which allows you to specify case sensitive match but it doesn't work quite the same as find-tag.

Graeme

Code: [Select]
_command void my_push_tag() name_info(',')
{
   int x;
   _str s1 = cur_word(x);
   if (push_tag() == 0)
   {
      typeless pp;
      save_pos(pp)
      // found it and gone to it
      if (search(s1, 'WI') == 0)
      {
         // case insensitive search found it, check exact match
         _str s2 = cur_word(x);

         if (length(s1) == length(s2) && pos(s1,s2) != 1) {
            _message_box('Warning : check case' \n :+ s1 \n :+ s2);
         }
      }
      restore_pos(pp);
   }
}

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Case sensitive in tagging
« Reply #11 on: July 23, 2008, 04:13:18 pm »
Graeme beat me to posting a macro with that sort of approach.

On a somewhat related note, here is a patch that I applied to 13.0.1 which tries to put the cursor at the beginning of the symbol instead of the beginning of the statement.  I don't know how easily it can be applied to 13.0.0 or to 12 or 11.  It can be fooled in some cases, but should do the right thing for most occurrences of a symbol.  My original motivation for making the patch was that I wanted to be able to press Ctrl+. repeatedly to cycle between declaration and definition of a function without needing to manually reposition the cursor onto the symbol.

The patch is inserted around line 9707 in the tag_edit_symbol function in the 13.0.1 r17 version of tags.e.  I include some context around the patch, below:

Warning:  It can be dangerous to patch the built in macros under the macros\ directory in your SlickEdit installation.  Proceed with caution.

Code: [Select]
   // go to the specified seek position
   maybe_deselect(true);
   if (cm.line_no>=0) {
      p_RLine=cm.line_no;
      if(!isVisualStudioPlugin()) {
         //center_line();
         
         // calculate the number of lines in the function's header comment
         int first_line=p_line, last_line=p_line;
         if (_do_default_get_tag_header_comments(first_line, last_line)) first_line=p_line;
         if (first_line > p_line) first_line = p_line;
   
         // now center the screen on the entire symbol
         center_region(first_line, p_line+cm.end_line_no-cm.line_no);
      }
      if (cm.seekpos > 0) {
         _GoToROffset(cm.seekpos);
      }
// ==== PATCH STARTS HERE ====
      // chrisant: Try to position the cursor at the beginning of the tag.
      if (cm.member_name != '') {
         typeless p, m, ss, sf, sw, sr, sf2;
         save_pos(p);
         save_selection(m);
         save_search(ss, sf, sw, sr, sf2);
         // Look for the tag within 10 lines starting from the expected line.
         deselect();
         _select_line();
         down(10);
         _select_line();
         _begin_select();
         boolean fRestorePos = (search(cm.member_name, '@EM') != 0);
         restore_search(ss, sf, sw, sr, sf2);
         restore_selection(m);
         if (fRestorePos) restore_pos(p);
      }
// ==== PATCH ENDS HERE ====
   }

   // make sure the symbols is not on a hidden line
   if (!p_IsTempEditor && (_lineflags() & HIDDEN_LF)) {
      expand_line_level();
   }

   // that's all folks
   return 0;
}