Author Topic: _ExtractTagComments2 change request  (Read 5444 times)

byates

  • Senior Community Member
  • Posts: 106
  • Hero Points: 8
_ExtractTagComments2 change request
« on: January 30, 2009, 07:57:35 PM »
I would like to request the following change to the function _ExtractTagComments2() in the file 'codehelp.e'.  Currently _ExtractTagComments2() calls the function _do_default_get_tag_comments() to extract the comments for a given tag.  However, there is no way to override this behavior for languages that _do_default_get_tag_comments() doesn't work very well for.  The following change will allow customization of the comment extraction for those languages.  Right now I manually make this change, but as we all know that is a bad thing.  ;)

p.s.  Note that the parameters to the %s_get_tag_comments function include the tag_name (as the first parameter).  I have found that this simplifies the coding of the %s_get_tag_comments greatly.

Code: [Select]
// Call the language specific callback to get the comments, otherwise call the default.
index := _FindLanguageCallbackIndex('%s_get_tag_comments');
if ( index > 0 )
  {
  call_index(tag_name,comment_flags,tag_type,member_msg,line_limit,index);
  }
else
  {
  _do_default_get_tag_comments(comment_flags,tag_type,member_msg,line_limit);
  }
« Last Edit: January 30, 2009, 07:59:38 PM by byates »

Dennis

  • Senior Community Member
  • Posts: 3992
  • Hero Points: 520
Re: _ExtractTagComments2 change request
« Reply #1 on: February 09, 2009, 05:05:09 PM »
A few questions:

1) Are you extracting comments from the source file, or from elsewhere?

2) Is the existing language specific callback _[lang]_get_tag_header_comments() not useful to you?

3) The above-mentioned callback is called with the cursor initially positioned on the symbol we are extracting comments for.  Given that the cursor is already where you need it to be, why is the symbol name that useful to you?  You can use tag_get_current_context() to get the tag name if you really need it in your callback.


byates

  • Senior Community Member
  • Posts: 106
  • Hero Points: 8
Re: _ExtractTagComments2 change request
« Reply #2 on: February 11, 2009, 04:13:11 AM »
A few questions:

1) Are you extracting comments from the source file, or from elsewhere?

From a source file now, but that will change.

2) Is the existing language specific callback _[lang]_get_tag_header_comments() not useful to you?

This function returns the first line and last line of the comments.  It doesn't return the actual comment text.  _ExtractTagComments2() returns the text after calling _do_default_get_tag_comments() which calls _do_default_get_tag_header_comments().  The comment lines in question are then processed through standard code (looking for javadocs, etc.).  What I would like to do is modify this text based on the unique specifics of the language.  Having a callback at the _ExtractTagComments2() level allows for the most flexibility for alternate language support.  All I have to do is return the text formated as I feel necessary.

3) The above-mentioned callback is called with the cursor initially positioned on the symbol we are extracting comments for.  Given that the cursor is already where you need it to be, why is the symbol name that useful to you?  You can use tag_get_current_context() to get the tag name if you really need it in your callback.

    a) I wasn't sure that the cursor would ALWAYS be at the first character of the tag.
    b) Calling tag_get_current_context() seems wasteful since the tag name is already available.

My language specific callback function (in _ExtractTagComments2) actually just turns around and calls _do_default_get_tag_comments() and then, based on the type of tag, formats the comment data appropriately.

I intend to replace the call to _do_default_get_tag_comments() with a language specific extractor, but I just haven't got around to it yet.  When I do, the comment data will not be extracted from the cursor position and iterating through the text.  I already have a background parser (as a SlickEdit DLL which is doing the tag generation) which has all of the relevant information (tokens and full AST).  I just need to walk the token list and pull out the comments which apply to a given symbol based on the coding standards that we use.

Probably more information than you wanted but... 8)