Loading ...
Sorry, an error occurred while loading the content.

244Re: [NTS] Function lookup

Expand Messages
  • Stefan Elssner
    Sep 26, 2003
      On Thu, 25 Sep 2003 17:58:39 -0000, blade102071 <blade102071@...>
      wrote:

      > I am working on a PHP project that uses calls to MANY functions.
      > All of the functions are held in a few include files.
      >
      > Does anybody know where I can find or how I can implement a clip that
      > will allow me to do this? :

      - Try http://ctags.sourceforge.net as a starting point
      They provide the up-to-date implementation of a program specialized to
      fulfill the basic needs of your task for many operating systems, incl.
      windows
      - Find / read / try to get some out of the documentation (from the package
      or on their website, I'm not sure how it's deliverd and / or what is
      better) - (If you are new to the topic, maybe try twice or so to find the
      right answer for your question ... the docs _are_ GOOD! Even if you find
      your answer not at first... try oncemore)

      Generally the 'ctags' program produces listings of function declarations
      and other programming related key objects found in the files of a directory
      and it's subdirectories, together with more or less detailed info about
      where in what file found, type of the sighting, and so on, and writes them
      to a file. Most of that (range and format of info as well as the output
      (file)) configurable.

      Below you'll find a small and fast-hacked sample of a clip utilizing ctags
      I did for myself some days ago -- it's purpose was to find all object and
      function definitions in a single given file (actual the currently open doc)
      and present this in another doc in a clickable manner (using NoteTabs
      internal 'HyperLinks' ability). Not exactly what you need, but maybe just
      another hint how to start against your task...

      (There are some pathes or sections of pathes hardcoded, maybe you'll have
      to adapt this to your needs)

      --- clip ---
      H="ctags_sample"
      ^!SetDebug ON

      ;1) create a tags file of the current doc
      ^!Set %docfilename%=^$GetDocName$
      ^!Set %tagfilename%=c:\windows\desktop\^$GetName(^%docfilename%)
      $^$GetExt(^%docfilename%)$.tags

      ;Close tagfile if open and DISCARD (this is important, ctags -f refuses to
      overwrite since, ;see man ctags)
      ^!DestroyDoc ^%tagfilename%

      ;Fire command and wait until finished
      ^!ShellWait ctags -n -f ^%tagfilename% --format=2 --fields=k
      "^%docfilename%"

      ;2) Make a linked version of the tags file in memory (write it to
      clipboard)
      ; With the format produced by the above command this means (for each
      line)
      ; - Add a '[' to the start of the 2nd column
      ; - Add '^L]' to the end of the 3rd column
      ; - Replace the delimiter between 2nd and 3rd column with '::'

      ;Empty the clipboard
      ^!SetClipboard ^%Empty%

      ^!Open ^%tagfilename%
      ;Copies the line count number to a variable
      ^!Set %MaxRow%=^$GetLineCount$
      ;Initialize variable Row to 0
      ^!Set %Row%=0
      ;Set field delimiter
      ^!SetDelimiter=^t

      ;Loop through the file lines
      :LoopStart
      ;Add one to the value contained in the Index variable
      ^!Inc %Row%
      ;End loop if value contained in Row is greater than the value contained in
      MaxRow ;(i.e. Number of lines in document)
      ^!If ^%Row% >= ^%MaxRow% EndLoop
      ; Check for comments / ctags internal infos
      ^!IfFalse ^$StrPos("!_TAG";"^$GetLine(^%Row%)$";False)$ GoOn ELSE LoopStart
      :GoOn
      ;Get fields into vars
      ^!Set %field1%=^$GetField(^%Row%;1)$
      ^!Set %field2%=^$GetField(^%Row%;2)$
      ^!Set %field3%=^$GetField(^%Row%;3)$
      ^!Set %field4%=^$GetField(^%Row%;4)$
      ; Remove ';"' from field3
      ^!Set %field3%=^$StrDeleteRight(^%field3%;2)$
      ; Build ntb goto-line hyperlink from filename and linenumber (fields 2 & 3)
      ^!Set %hyperlink%=[^%field2%::^%field3%^L]
      ;Build new line
      ^!Set %newline%=(^%field4%)^%TAB%^%field1%^%TAB%^%hyperlink%
      ; Add to clipboard
      ^!SetClipboard ^$GetClipboard$^%newline%^%NL%
      ;Jump back to the start of the loop
      ^!GoTo LoopStart
      :EndLoop

      ; 3) Overwrite the tagsfile with reworked version
      ; Sort the clipboard content
      ^!SetClipboard ^$StrSort(^$GetClipboard$;False;True;False)$
      ^!Select ALL
      ^!Paste
      ^!Save
      ^!SetCursor 1:1
      :EndClip
      --- /clip ---

      Regards
      Stefan
      --
      elssner@...
    • Show all 3 messages in this topic