Method creation tab order FR

people type everything in when / if they can
and if they cant they report it as a bug or fr :stuck_out_tongue:

Should also test against array params and returns at the very least

Things like
method(s() as integer)
method (s() as integer ) as string()

validating the params (decl order & type of params) can probably be left to the compiler

but splitting it up into the correct bits has to be the IDE

To be clear, the problem at hand is identifying the parts to be moved to the other fields, with validation being left to subsequent methods.

Here’s another approach. Let’s say that what can be entered in the method name is expected to take one of these forms:

$1
$1 ( $2 )
$1 ( $2 ) as $3
$1 () as $3
$1 as $3

We don’t care what the values of $1, $2, or $3 are, we just want to identify them so we can put them in the right places. Also, $1 might contain more than just the method name, it might have additional, valid syntax like “sub” or “private”. That can be parsed separately too. All three should be trimmed separately after being identified.

I came up with this:

(?x) # Free space mode
^
# Clear any leading spaces
\\x20*

# Get the method name
#  - Anthing before an open paren
#  - Can't include the keyword "as"
((?:(?!\\bas\\b)[^(\\r\
)])+)

# Grab the params - anthing between the parens, if there is a "("
(?(?=\\() \\( ((?:\\(\\x20*\\)|[^)\\r\
])*)\\)? \\x20*)

# Grab the return type - anything after "as"
(?:as\\x20+([^\\r\
]+))?
$

I’ve tested against this data:

method
method(s as integer
method(s as integer)
method ( s as integer )
method (s as integer ) as string
method  ( s as)as something
method()as string
method as string
method()
method(s() as integer)
method (s() as integer ) as string()
sub method (s() as integer ) as string()
sub method as string
sub method as mac gruber
method ( s as integer as string

The IDE code would run this RegEx on leaving the field, identify the parts, move them to the right places, then perform whatever validation was needed at that point.

Or something like that.