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

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

Expand Messages
  • Detlef Groth
    ... 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
    Message 1 of 5 , 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"
    • jirko@cassuben.net
      Try using this: ^[ t]*class |^[ t]*[a-zA-Z0-9_ ]*([a-zA-Z0-9_ ,]*){ You need to double the before the | , otherwise it is ignored. See the help on
      Message 2 of 5 , Dec 14, 2000
      • 0 Attachment
        Try using this:

        "^[ \t]*class\\|^[ \t]*[a-zA-Z0-9_ ]*([a-zA-Z0-9_ ,]*){"

        You need to double the '\' before the '|', otherwise it is ignored. See the
        help on "set-variable".

        Also you should think about the "4 forward-char" a few lines below, because it
        cuts of the first four characters if your function or your class definition
        starts on the beginning of the line.

        regards

        Jirko



        On 14-Dec-2000 Detlef Groth wrote:
        >
        >
        > 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"
        >
        >
        >
        >
        > __________________________________________________________________________
        >
        >
        >
        > This is an unmoderated list. JASSPA is not responsible for the content of
        >
        > any material posted to this list.
      • Detlef Groth
        ^[ t]*[a-zA-Z0-9_ ]* ([a-zA-Z0-9_ ,]* ){ | Wclass !!! ----------a space ! -------- two s sounds like a programmers poem. Thanks all, the trick
        Message 3 of 5 , Dec 15, 2000
        • 0 Attachment
          "^[ \t]*[a-zA-Z0-9_ ]*\([a-zA-Z0-9_ ,]*\){\\|\\Wclass " !!!
          '----------a space ! '-------- two \\s
          sounds like a programmers poem.
          Thanks all, the trick was simply `\\|',
          it is `|' in perl and it's competitors
          it is `\|' in the microemacs-commandline,
          it is `\\|' in the microemacs-macro.

          I got the followong tree :
          public class Start2 extends java.applet.Applet implements Runnable Line:2
          public void init(){ Line:39
          public void start(){ Line:77
          public void stop(){ Line:84
          public void run(){ Line:89
          while(true){ Line:110 // waiting for input not a function ..
          public void paint(Graphics g){ Line:144
          public void update(Graphics g){ Line:188
          public void drawSlogans(){ Line:191
          public boolean mouseDown(Event evt, int x, int y){ Line:208
          void show(String text){ Line:235
          class Flag extends java.applet.Applet Line:240
          Flag(int x, int y, Image flagImage){ Line:245
          void drawFlag(Graphics g){ Line:250
          boolean isClicked(int x_evt, int y_evt){ Line:255
          class Button extends java.applet.Applet Line:261
          Button(int x, int y, int modus){ Line:266
          void drawButton(Graphics g){ Line:271
          boolean isClicked(int x_evt, int y_evt){ Line:286

          what is almost that what I want. Of course this depends much on your coding style
          regarding the {}-brackets. Up to now I missed the javatags.emf. Did I miss a new
          release ?

          Follows the `final' release....

          define-macro list-java-functions
          ; set-variable $debug 1
          set-variable .buffer $buffer-bname
          delete-other-windows
          find-buffer &cat &cat "*" .buffer "functions*"
          split-window-horizontally
          25 shrink-window-horizontally
          ; to simple click the function
          set-variable :mouse-word-select "find-java-function"
          set-variable $buffer-hilight .hilight.java
          screen-update
          ; erase old-contents
          beginning-of-buffer
          set-mark
          end-of-buffer
          exchange-point-and-mark
          kill-region
          next-window-find-buffer .buffer
          set-alpha-mark "p"
          beginning-of-buffer
          ; declare what to find
          set-variable .searchstring "^[ \t]*[a-zA-Z0-9_ ]*\([a-zA-Z0-9_
          ,]*\){\\|\\Wclass "
          !force search-forward .searchstring
          !while $status ; if found put into the *function*-buffer
          beginning-of-line
          set-mark
          end-of-line
          exchange-point-and-mark
          copy-region
          end-of-line
          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

          define-macro find-java-function
          search-forward "Line:"
          set-mark
          forward-word
          exchange-point-and-mark
          copy-region
          set-variable #l0 @y
          -1 yank
          next-window
          #l0 goto-line
          recenter
          !emacro

          buffer-bind-key "list-java-functions" "f7"

          Best regards,
          Detlef
        Your message has been successfully submitted and would be delivered to recipients shortly.