Bug? B4xlib2XML not checking for returntype for Subs without parameters

stevel05

Expert
Licensed User
As the title says, ParseSubLine is ignoring returntype when the sub does not have parameters. Modified code to correct this:

B4X:
Private Sub ParseSubLine (Line As String) As Member
    Dim m As Matcher = Regex.Matcher2("^\s*public\s*sub\s+([^\s(]+)", Regex.CASE_INSENSITIVE, Line)
    If m.Find = False Then Return Null
    Dim member As Member
    member.Initialize
    member.MemberType = "method"
    member.Name = m.Group(1)
    If member.Name.StartsWith("get") Or member.Name.StartsWith("set") Then
        member.MemberType = "property"
        member.Name = member.Name.SubString(3)
    End If
    member.Parameters.Initialize
    member.Comment = CurrentComment.Trim
    Dim i1 As Int = Line.IndexOf("(")
    Dim i2 As Int = Line.LastIndexOf(")")
    If i1 > -1 And i2 > -1 Then
        m = Regex.Matcher2("([\w_]+)(?:\(\))?\s+as\s+([\w_]+)", Regex.CASE_INSENSITIVE, Line.SubString2(i1 + 1, i2))
        Do While m.Find
            Dim p As Parameter
            p.Initialize
            p.Name = m.Group(1)
            p.VarType = m.Group(2)
            member.Parameters.Add(p)
        Loop
        m = Regex.Matcher2("as\s+([\w_]+(?:\(\))?)$", Regex.CASE_INSENSITIVE, Line)
        If m.Find Then
            member.ReturnType = m.Group(1)
        End If
    Else
        m = Regex.Matcher2("as\s+([\w_]+(?:\(\))?)$", Regex.CASE_INSENSITIVE, Line)
        If m.Find Then
            member.ReturnType = m.Group(1)
        End If
    End If
    Return member
End Sub
 
Top