Author Topic: No symbols found matching ''.  (Read 1397 times)

uwe.solter

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
No symbols found matching ''.
« on: October 11, 2023, 01:25:01 PM »
I tried to implement vsfoo_list_tags to create tag database entries for some symbols of language 'foo' that can't be matched by existing language support:

int vsfoo_list_tags( int output_view_id, _str file_name, _str extension, int list_tags_flags, int tree_wid = 0, int func_bitmap = 0, int StartFromCursor = 0, int StartSeekPos = 0 )
{
   int status;

   if( file_name != '' )
   {
      say( 'vsfoo_list_tags file_name='file_name );
   }

   kind := "";
   name := "";

   status = search( '^[ \t]*{SIGNAL|NEWTYPE|PROCESS}:b{:v}', '@ri>' );

   while( !status )
   {
      kind = get_text( match_length('0'), match_length('S0') );
      name = get_text( match_length('1'), match_length('S1') );

      say( 'vsfoo_list_tags kind='kind' name='name );

      tag_init_tag_browse_info( auto cm, name, "", "label", 0, p_buf_name, p_RLine, match_length('S1') );
      tag_insert_tag_browse_info( cm );

      auto tag = tag_compose_tag_browse_info( cm );

      say( 'tag='tag );

      status = repeat_search();
   }

   return   0;
}

The symbols are added to the tag file and are visible in the tag database browser but when I try to 'jump' to the symbol by double-clicking it in the symbol view I get a message box telling "No symbols found matching ''." however at least the file is found and opened.
I don't see that vsfoo_list_tags is called in this case so assume that it's not sufficient in this case and some more callbacks would probably required to locate the symbol in the source file.
Also a bit strange is the fact that this attempt to locate the symbol is made with an empty string.

Any hints what might be missing or links to documentation or some sample list_vtags highly appreciated.

Dennis

  • Senior Community Member
  • Posts: 3965
  • Hero Points: 517
Re: No symbols found matching ''.
« Reply #1 on: October 16, 2023, 12:38:19 PM »
You are mostly on the right track.  The list tags callback get called with different flags depending on the target (list_tags_flags).  The important one is VSLTF_SET_TAG_CONTEXT.  Check that before doing tag_insert_tag_browse_info(cm), and do tag_insert_match_browse_info() instead.

There are a lot of other list tags flags, but the way you are doing this, this one is the only significant one, since you are not trying to support references or local variables.

Note that some of the "proc_search" based list tags functions deal with lists of declarations, you just have to queue up a static list of tags and peel them off in subsequent calls, until you run out and need to search again.

uwe.solter

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: No symbols found matching ''.
« Reply #2 on: October 16, 2023, 03:34:42 PM »
Thanks for coming back here.

I don't see my list_tags being called with this flag set. However my implementation is quite tiny so far and there might be some language setup or module initialisation requirements I missed.

That's the full code:

#pragma option(pedantic,on)
#region Imports
#include "slick.sh"
#import "adaptiveformatting.e"
#import "alias.e"
#import "alllanguages.e"
#import "autocomplete.e"
#import "c.e"
#import "cutil.e"
#import "notifications.e"
#import "optionsxml.e"
#import "se/lang/api/LanguageSettings.e"
#import "setupext.e"
#import "slickc.e"
#import "stdcmds.e"
#import "stdprocs.e"
#import "surround.e"
#import "tags.e"
#import "pmatch.e"
#endregion

using se.lang.api.LanguageSettings;

static const MXS_LANGUAGE_ID='foo';

_command foo_mode() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY|VSARG2_ICON)
{
   _SetEditorLanguage(MXS_LANGUAGE_ID);
}

_command void foo_enter() name_info(','VSARG2_MULTI_CURSOR|VSARG2_CMDLINE|VSARG2_ICON|VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
   generic_enter_handler(_foo_expand_enter);
}

bool _foo_expand_enter()
{
   return true;
}

int vsfoo_list_tags( int output_view_id, _str file_name, _str extension, int list_tags_flags, int tree_wid = 0, int func_bitmap = 0, int StartFromCursor = 0, int StartSeekPos = 0 )
{
   int status;

   if( file_name != '' )
   {
      say( 'vsfoo_list_tags file_name='file_name );
   }

   kind := "";
   name := "";

   status = search( '^[ \t]*{SIGNAL|NEWTYPE|PROCESS}:b{:v}', '@ri>' );

   while( !status )
   {
      kind = get_text( match_length('0'), match_length('S0') );
      name = get_text( match_length('1'), match_length('S1') );

      say( 'vsfoo_list_tags kind='kind' name='name );

      tag_init_tag_browse_info( auto cm, name, "", "label", 0, p_buf_name, p_RLine, match_length('S1') );

      if( list_tags_flags & VSLTF_SET_TAG_CONTEXT )
      {
         say( 'vsfoo_list_tags tag_insert_match_browse_info' );

         tag_insert_match_browse_info( 0, cm );
      }
      else
      {
         say( 'vsfoo_list_tags tag_insert_tag_browse_info' );

         tag_insert_tag_browse_info( cm );
      }

      auto tag = tag_compose_tag_browse_info( cm );

      say( 'tag='tag );

      status = repeat_search();
   }

   return   0;
}

Wanted to start with some simple parser/lexer implementation and other enhancements like this MaybeCreateTagFile etc. after the very basics are working. Any hints what might be missing here welcome. Note that I don't want to start some full fledged language support implementation with adaptive formatting etc., but adding symbols to the tag database is really desired :)