Function List for Java

Function List for Java

481
Basic UserBasic User
481

    Sep 17, 2013#1

    The configuration supplied currently doesn't work at all. I'll put a request in to IDM but in the meantime I've come up with this as a replacement. I daresay it's incomplete / faulty but it looks to be working on my code so far:

    Code: Select all

    ([ \t])*(public|private|protected)([ \t]+static)*[ \t]+((([a-zA-Z_][a-zA-Z_0-9]*)[ \t]+([a-zA-Z_][a-zA-Z_0-9]*))|([a-zA-Z_][a-zA-Z_0-9]*))[ \t]*\([^\)]*\)[ \t\r\n]*\{

    6,686585
    Grand MasterGrand Master
    6,686585

      Sep 17, 2013#2

      java.uew as installed with currently latest UE/UES contains a bunch of Perl regular expressions as they are designed for a grouped function list.

      For which of those regular expressions is your expression a replacement for?

      Please note that function string searches are always executed not case-sensitive. So it is absolutely enough to specify a-z in square brackets to match those letters in any case.

      Further, your regular expression search string contains a lot of capturing groups. The function list view with Perl regular expression engine is designed to concatenate all strings found by capturing groups with a space character and display all of them as single string.

      Do you really want to see the indenting spaces/tabs in the function list view?

      By the way: [ \t]* is the same as ([ \t])*

      In case you don't know: A non-capturing group starts with (?: instead of just ( and ends with ) as a capturing group, too.

      481
      Basic UserBasic User
      481

        Sep 17, 2013#3

        This was a replacement for "Methods". The one that ships wouldn't even match "public void run()"

        I test the regex using the find dialog before I put it into the Java configuration, hence the case sensitive expression.

        Whilst non-capturing groups works in a normal regex search I found that trying to use them in the Function List configuration causes the search to fail.

        6,686585
        Grand MasterGrand Master
        6,686585

          Sep 17, 2013#4

          Thanks for the clarifications. I have whether a Java source code file to test nor I am familiar with this language.

          It looks like the regular expressions in installed java.uew do not work for Java files with DOS line terminators. It's the same issue as for perl.uew, see Subroutines in DOS Perl script file missing in function list view of UE v19.10/20.00

          Replacing

          /TGBegin "Methods"
          /TGFindStr = "^[ \t]*[ps][a-z]+ [a-z0-9]+ (.*)\(.*\)[\n \ta-z0-9]+\{"


          by

          /TGBegin "Methods"
          /TGFindStr = "^[ \t]*[ps][a-z]+ [a-z0-9]+ (.*)\(.*\)[
          \r\n \ta-z0-9]+\{"

          results in displaying run when defined in a Java file with DOS line terminators as

          Code: Select all

          public void run()
          {
          }
          I cannot reproduce any problem with non-capturing groups in the regular expressions for the function list view.

          The test block

          Code: Select all

          public void run()
          {
          }
          public test () {
          }
          results with

          /TGBegin "Methods"
          /TGFindStr = "^[ \t]*(?:public|private|protected)(?:[ \t]+static)*[ \t]+(?:[a-z_][a-z_0-9]*[ \t]+([a-z_][a-z_0-9]*)|([a-z_][a-z_0-9]*))[ \t]*\([^)]*\)[ \t\r\n]*\{"


          in

          Code: Select all

          test
          run
          That is not optimal as the two capturing groups results in an added space left of test which is not good with sort feature enabled.

          I have to think about a better expression for matching with a single regular expression functions with and without a return type.


          Another solution would be the usage of

          /TGBegin "Methods"
          /TGFindStr = "^[ \t]*(?:public|private|protected)(?:[ \t]+static)*[ \t]+([a-z_][a-z_0-9]*[ \t]+[a-z_][a-z_0-9]*|[a-z_][a-z_0-9]*)[ \t]*\([^)]*\)[ \t\r\n]*\{"


          resulting in a function list displaying for the above example

          Code: Select all

          test
          void run
          Ah, wait, I got it.

          /TGBegin "Methods"
          /TGFindStr = "^[ \t]*(?:public|private|protected)(?:[ \t]+static)*[ \t]+(?:[a-z_][a-z_0-9]*[ \t]+)*([a-z_][a-z_0-9]*)[ \t]*\([^)]*\)[ \t\r\n]*\{"


          makes the return type optional resulting in a function list displaying for the above example

          Code: Select all

          run
          test

          481
          Basic UserBasic User
          481

            Sep 26, 2013#5

            Thanks for the effort here mofi. I'm pretty happy with my solution as it stands but I'll bear this thread in mind if I hit any difficulties with it in the future.