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

309Re: [jasspa] Re: java-class/function-tree

Expand Messages
  • Detlef Groth
    Dec 14, 2000
    • 0 Attachment
      Jasspa wrote:

      > Try being more specific in the search i.e.
      >
      > ^[ \t]*[a-zA-Z0-9_]+[ \t]*([^)]*)[ \t]*{
      >
      > There are too many ".*"'s. The above was taken from the
      > command line so you need to macro it up a bit.
      >
      > Regards
      > Jon.

      Okay a new version is the following:
      "^[ \t]*[a-zA-Z0-9_ ]*\([a-zA-Z0-9_ ,]*\){"
      see:

      define-macro list-java-functions
      ; set-variable $debug 1
      set-variable .buffer $buffer-bname
      delete-other-windows
      ; erase old-contents
      find-buffer &cat &cat "*" .buffer "functions*"
      split-window-horizontally
      25 shrink-window-horizontally
      set-variable :mouse-word-select "find-java-function"
      set-variable $buffer-hilight .hilight.java
      screen-update
      beginning-of-buffer
      set-mark
      end-of-buffer
      exchange-point-and-mark
      kill-region
      next-window-find-buffer .buffer
      ; now search for functions
      set-alpha-mark "p"
      beginning-of-buffer
      set-variable .searchstring "^[ \t]*[a-zA-Z0-9_ ]*\([a-zA-Z0-9_ ,]*\){" ;
      for easier updates of two places
      !force search-forward .searchstring
      !while $status
      beginning-of-line
      4 forward-char
      set-mark
      end-of-line
      exchange-point-and-mark
      copy-region
      set-variable .function @y
      -1 yank
      set-variable .line $window-line
      next-window-find-buffer &cat &cat "*" .buffer "functions*"
      execute-string &cat &cat &cat "" .function "\t\t\t Line:" .line
      insert-newline
      next-window-find-buffer .buffer
      !force search-forward .searchstring
      !done
      goto-alpha-mark "p"
      !emacro

      but what is with classes:
      see:
      class Flag extends java.applet.Applet
      {
      int x ; int y ;
      int $size = 30 ;
      Image flagImage ;;
      Flag(int x, int y, Image flagImage){ // constructor
      this.x = x ;
      this.y = y ;
      this.flagImage = flagImage;
      }
      void drawFlag(Graphics g){
      g.drawRoundRect(x,y,$size+4,$size+4,10,10);
      g.drawRoundRect(x-1,y-1,$size+6,$size+6,11,11);
      g.drawImage(flagImage,x+2,y+2, $size, $size, this);
      }
      boolean isClicked(int x_evt, int y_evt){
      if (x_evt > x && x_evt < (x+$size) && y_evt > y && y_evt < (y+$size)){

      return true ;
      }else return false ;
      }
      }
      I get something like:
      Flag(int x, int y, Image flagImage){ Line:231
      void drawFlag(Graphics g){ Line:236
      boolean isClicked(int x_evt, int y_evt){ Line:241

      but i want that:

      class Flag extends java.applet.Applet
      Flag(int x, int y, Image flagImage){ Line:231
      void drawFlag(Graphics g){ Line:236
      boolean isClicked(int x_evt, int y_evt){ Line:241

      so I have to provide two(!) search-stringes in one expression using the `|'
      operator like
      in the following short perl-program:
      # can be used in tools, but requires perl !!
      # variables
      my $file = $ARGV[0];
      # Main
      open (JAVA, "$file");
      while (<JAVA>){
      if (/^[ \t]*[a-zA-Z0-9_ ]+\([a-zA-Z0-9_ ,]*\){|^[a-zA-Z0-9_ ]*class
      [a-zA-Z0-9_ .]*/){ #}
      print ;
      }
      }
      if compiled into a *toc* window I have what I wan't, but how to do this with
      a ME-search-string
      searching for two strings the `\|' failed....

      Any suggestions ?
      regards,
      Detlef

      my hktoc.emf:
      define-macro find-line
      beginning-of-line
      set-mark
      end-of-line
      exchange-point-and-mark
      copy-region
      set-variable #l0 @y
      -1 yank
      next-window
      set-alpha-mark "p"
      beginning-of-buffer
      !force search-forward #l0
      !if $status
      ml-write "Here it is !!!"
      recenter
      !else
      ml-write "Sorry not found ..."
      goto-alpha-mark "p"
      !endif
      !emacro
      define-macro fhook-toc
      set-variable :mouse-word-select find-line
      ; execute user extensions if enabled
      !emacro

      ml-write "[toc file hook loaded]"

      ; load in user extensions if found
      !force execute-file "mytoc"
    • Show all 5 messages in this topic