Custom find symbol definition in project files

Custom find symbol definition in project files

3
NewbieNewbie
3

    Mar 12, 2014#1

    It is possible by using a script to click on the name of a function and open the file where this function is defined?

    Example:

    test.prg:

    Code: Select all

    ShowMsg ('Hello World') <----- positioned in this function, clicking or pressing key (example: F9), UEStudio opens file test2.prg containing function ShowMsg.
    test2.prg:

    Code: Select all

    static Function ShowMsg( cMsg ) 
    MsgInfo (cMsg, cTitle) 
    return

    6,686585
    Grand MasterGrand Master
    6,686585

      Mar 13, 2014#2

      It would be possible to code a Script for this purpose, but I recommend using the already available features of UEStudio for symbol parsing and lookup.

      UEStudio has built-in a symbol parser which supports languages like C, C++, C#, PHP. This symbol parser is automatically active when using an UEStudio project and creates the symbol database automatically on opening a project and updates it on saving a project file. Several features like the function tips feature depends on this symbol parser and database. See at Advanced - Configuration - IDE the configuration dialogs for IntelliTips and Parser.

      The command to jump to the definition of a symbol (function, global variable, preprocessor makro, ...) can be found in the IntelliTips toolbar. The command has a green arrow with a white X and a magnifying glass over the X and has the tooltip Find symbol definition in project files. It is of course possible to execute this command by hotkey assigned to command IntellitipFindSymbolDef in Key Mapping configuration dialog.

      Alternatively it is possible to configure in the project settings dialog the usage of Ctags. Ctags is an open source symbol parser like the built-in parser of UES and installed already with UEStudio ready for usage. It supports more languages as the built-in symbol parser of UES. The disadvantage of using Ctags in comparison to using built-in symbol parser of UES is that all the intellitips features do not work with symbol database created by Ctags. However, with using Ctags it is possible to use the command Find Symbol from menu Search to jump to the definition of a symbol like a function included in the symbol database created by Ctags. Also this command can be executed by hotkey. The command has the name SearchFindSymbol in key mapping configuration dialog. A jump back can be done after execution of Find Symbol with Search - Back (last position).

      Open help of UEStudio and search on tab Search for parser to find all help pages about symbol parsing and how to use the symbol database by features like find symbol, function tips, ...
      Best regards from an UC/UE/UES for Windows user from Austria

      3
      NewbieNewbie
      3

        Mar 13, 2014#3

        Mofi,

        I use xHarbour (clipper) language and I am not able to use IntelliTips. Could you help me?

        I spotted the IntelliTips bar, but could not make it to work for my files.

        All I need is the UEStudio locate FUNCTION / PROCEDURE created another PRG.

        Thank you very much (I'm using Google translator).

        Example of a PRG file:

        Code: Select all

        /*
        PRG  : SGCOMPILER
        */
        #include 'FiveWin.ch'
        
        #define PARAMETRO_DIALOG_TOP         10
        #define PARAMETRO_DIALOG_LEFT        11
        
        static s_aParametros, s_cVersaoSelecionada, s_hDadosSistema
        
        /*******************************************/
        procedure SgCompiler()
        /*
        */
        
           local oDialogPrincipal, oIcone, oBrowse, hInput := HB_Hash(), hButton := HB_Hash()
           local nVersao, lModoCompacto := .f., lFecha
           local cParametro1 := Lower( AllTrim( HB_Argv( 1 ) ) )
           local cParametro2 := AllTrim( HB_Argv( 2 ) )
        
           if !VerificaTabelasCompiler()
              return
           endif
        
           s_hDadosSistema := HB_Hash()
        
           if !Empty( cParametro1 )
        
              CarregaValoresParametros()
        
              if cParametro1 == 'c'                       
                 AutoCompila( cParametro2, .f., .f.  )
              elseif cParametro1 == 'ce'                
                 AutoCompila( cParametro2, .t., .f.  )
              elseif cParametro1 == 'cr'                 
                 AutoCompila( cParametro2, .t., .t.  )
              elseif cParametro1 == 'cer'               
                 AutoCompila( cParametro2, .t., .t.  )
              endif
              return
           endif
        
           do while .t.
              lFecha := .t.
        
              CarregaValoresParametros()
              lModoCompacto := s_aParametros[ PARAMETRO_MODO_COMPACTO ] == 'S'
        
              define icon  oIcone  resource 'ICON_COMPILER'
        
              define   dialog   oDialogPrincipal                                 ;
                       resource IIf( lModoCompacto, "COMPACTO", "PRINCIPAL"   )  ;
                       title    IIf( lModoCompacto, "Compiler", "SG Compiler" )  ;
                       icon     oIcone
        
              redefine xBrowse oBrowse id 100 of oDialogPrincipal columns   'descabrev'      sizes   80   alias   'siscompiler'
        
              oBrowse:bLDblClick := { || hButton['CompilarExecutar']:Click() }
              oBrowse:bKeyDown := { |nTecla| TrataTeclasBrowse( nTecla, oDialogPrincipal, oBrowse, @lFecha ) }
              oBrowse:bRClicked  := { |nLinha, nColuna| MenuBrowseSistemas( oDialogPrincipal, oBrowse, nLinha, nColuna, @lFecha ) }
              oBrowse:bChange   := { || AtualizaBotoes( hButton ) }
        
              redefine button hButton[ 'CompilarExecutar'    ]  id 101 of oDialogPrincipal action ( CompilarExecutar( oDialogPrincipal, .f. ), ForcaFoco( oBrowse ) )
        
              oDialogPrincipal:lHelpIcon := .f.
              activate dialog oDialogPrincipal 
        
              if lFecha
                 exit
              endif
        
           enddo
        
        return
        
        /******************************************************************************/
        static procedure AtivaTray( oDialogPrincipal, oIcone )
        
        Local oTray
        
           oTray := TTrayIcon():New( oDialogPrincipal, oIcone, 'Sg Compiler',,{|nLinha, nColuna| MenuTray( nLinha, nColuna, oDialogPrincipal, oTray )} )
        
        return

        6,686585
        Grand MasterGrand Master
        6,686585

          Mar 14, 2014#4

          I would know how to code an UltraEdit script which searches in all files of a project for the definition of the function at caret position and open that file respectively make it active and position the caret on the function definition line in this file. But I do not think it is really a good to code such a script for various reasons.

          First, with using a project and a syntax highlighting wordfile, the function list can display not only the functions defined in the active file. The function list can display also all functions defined in any file of a project with clicking on secondary (right) mouse button on Function List and clicking with primary (left) mouse button on List for all Project Files. That would already help.

          Second, Exuberant Ctags as installed with UEStudio and UltraEdit supports currently 41 languages directly, but not xHarbour.

          However, by reading carefully the Ctags manual it can be seen that it is possible to define support for any language by yourself. Among -f "%fo" and -L "%fi" to define name of tag list file and the name of the file containing the file names of the project passed both by UES to Ctags via %fo and %fi, some additional options are needed to use Ctags for a not built-in supported language like xHarbour.

          To create a symbol database for a not built-in supported language Ctags offers the options --langdef=, --langmap= and --regex-<LANG>=. With those 3 options and perhaps some more if necessary it should be possible that Ctags parses the xHarbour files of the UEStudio project for function definitions and put them into the tag list file like UEStudio does to create the function list. This would make it possible to use the Find Symbol command.

          I don't know if the built-in symbol parser of UEStudio can be also used for any language. There is /Member String = and /Variable String = in some syntax highlighting wordfiles which are for the symbol parser of UEStudio. But I don't know if those regular expression definitions are evaluated only on some languages defined by the language marker keyword like C_LANG or can be used for any language. I have just sent an email to IDM support with appropriate questions and will post the answers useful for the user community here.

          Update:
          /Member String = and /Variable String = are not associated with the language markers. They are used to extend the symbol parsing capability for IntelliTip features for a better language intellisense. They cannot be really used for any language. Extending the built-in symbol parser of UEStudio for other languages than the supported languages is not possible yet in UES v14.10. The built-in symbol parser of UEStudio is based on Exuberant Ctags but was enhanced and improved by the developers of IDM.
          Best regards from an UC/UE/UES for Windows user from Austria

          3
          NewbieNewbie
          3

            Mar 14, 2014#5

            Mofi,

            success INTELLITIP ... simply fantastic. UEStudio is the best!

            thank you very much