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("Parsing methods")
|
||||
res.Methods, err = getMethods(doc, log)
|
||||
res.Methods, err = getMethods(doc, log, res.ClassName)
|
||||
if err != nil {
|
||||
log.Error("Error getting methods: %v", 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
|
||||
}
|
||||
|
||||
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")
|
||||
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))
|
||||
res = append(res, method)
|
||||
})
|
||||
|
8
main.go
8
main.go
@@ -81,9 +81,11 @@ func MapType(t string) string {
|
||||
case "var":
|
||||
return "any"
|
||||
case "var...":
|
||||
return "any..."
|
||||
return "..."
|
||||
case "int":
|
||||
return "number"
|
||||
case "int...":
|
||||
return "number..."
|
||||
case "unsigned int":
|
||||
return "number"
|
||||
case "float":
|
||||
@@ -92,6 +94,8 @@ func MapType(t string) string {
|
||||
return "number"
|
||||
case "bool":
|
||||
return "boolean"
|
||||
case "char":
|
||||
return "string"
|
||||
case "table_t":
|
||||
return "table"
|
||||
default:
|
||||
@@ -101,7 +105,7 @@ func MapType(t string) string {
|
||||
|
||||
func IsReservedKeyword(t string) bool {
|
||||
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 false
|
||||
|
Reference in New Issue
Block a user