Hallucinate more fixes
This commit is contained in:
22
class.go
22
class.go
@@ -221,7 +221,7 @@ func ParseClass(file string) (*Class, error) {
|
|||||||
log.Debug("Found %d fields", len(res.Fields))
|
log.Debug("Found %d fields", len(res.Fields))
|
||||||
|
|
||||||
log.Debug("Parsing methods")
|
log.Debug("Parsing methods")
|
||||||
res.Methods, err = getMethods(doc, log)
|
res.Methods, err = getMethods(doc, log, res.ClassName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error getting methods: %v", err)
|
log.Error("Error getting methods: %v", err)
|
||||||
return nil, fmt.Errorf("error getting methods: %w", err)
|
return nil, fmt.Errorf("error getting methods: %w", err)
|
||||||
@@ -332,7 +332,7 @@ func getFields(doc *goquery.Document, log *logger.Logger) ([]Field, error) {
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMethods(doc *goquery.Document, log *logger.Logger) ([]Method, error) {
|
func getMethods(doc *goquery.Document, log *logger.Logger, className string) ([]Method, error) {
|
||||||
log.Debug("Starting method parsing")
|
log.Debug("Starting method parsing")
|
||||||
res := []Method{}
|
res := []Method{}
|
||||||
|
|
||||||
@@ -495,6 +495,24 @@ func getMethods(doc *goquery.Document, log *logger.Logger) ([]Method, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this is a constructor (method name matches class name or is contained in the original class name), ensure it returns the correct type
|
||||||
|
// Handle cases where method name is "Alliance" but class name is "Alliance_Client"
|
||||||
|
originalClassName := strings.TrimSpace(doc.Find("div.floatright > h1").Text())
|
||||||
|
if method.Name == className || method.Name == originalClassName || strings.Contains(originalClassName, method.Name) {
|
||||||
|
// Override the return type to be the cleaned class name
|
||||||
|
if len(method.Returns) > 0 {
|
||||||
|
method.Returns[0].Type = className
|
||||||
|
method.Returns[0].Comment = "A new instance of " + className
|
||||||
|
} else {
|
||||||
|
method.Returns = []Return{
|
||||||
|
{
|
||||||
|
Type: className,
|
||||||
|
Comment: "A new instance of " + className,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.Trace("Method %s has %d parameters and %d return values", method.Name, len(method.Params), len(method.Returns))
|
log.Trace("Method %s has %d parameters and %d return values", method.Name, len(method.Params), len(method.Returns))
|
||||||
res = append(res, method)
|
res = append(res, method)
|
||||||
})
|
})
|
||||||
|
|||||||
8
main.go
8
main.go
@@ -81,9 +81,11 @@ func MapType(t string) string {
|
|||||||
case "var":
|
case "var":
|
||||||
return "any"
|
return "any"
|
||||||
case "var...":
|
case "var...":
|
||||||
return "any..."
|
return "..."
|
||||||
case "int":
|
case "int":
|
||||||
return "number"
|
return "number"
|
||||||
|
case "int...":
|
||||||
|
return "number..."
|
||||||
case "unsigned int":
|
case "unsigned int":
|
||||||
return "number"
|
return "number"
|
||||||
case "float":
|
case "float":
|
||||||
@@ -92,6 +94,8 @@ func MapType(t string) string {
|
|||||||
return "number"
|
return "number"
|
||||||
case "bool":
|
case "bool":
|
||||||
return "boolean"
|
return "boolean"
|
||||||
|
case "char":
|
||||||
|
return "string"
|
||||||
case "table_t":
|
case "table_t":
|
||||||
return "table"
|
return "table"
|
||||||
default:
|
default:
|
||||||
@@ -101,7 +105,7 @@ func MapType(t string) string {
|
|||||||
|
|
||||||
func IsReservedKeyword(t string) bool {
|
func IsReservedKeyword(t string) bool {
|
||||||
switch t {
|
switch t {
|
||||||
case "any", "boolean", "number", "string", "table", "function", "thread", "userdata", "nil", "var", "in":
|
case "and", "break", "do", "else", "elseif", "end", "false", "for", "function", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while", "any", "boolean", "number", "string", "table", "thread", "userdata", "var":
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user