Mono/C#: Fix error when parsing nested generics
Also fixed the editor not including the parse error message in the error.
This commit is contained in:
parent
fa638a290f
commit
e4330e33e6
@ -25,14 +25,14 @@ namespace GodotTools.Internals
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||||
private static extern Error internal_ParseFile(string filePath, Array<Dictionary> classes);
|
private static extern Error internal_ParseFile(string filePath, Array<Dictionary> classes, out string errorStr);
|
||||||
|
|
||||||
public static void ParseFileOrThrow(string filePath, out IEnumerable<ClassDecl> classes)
|
public static void ParseFileOrThrow(string filePath, out IEnumerable<ClassDecl> classes)
|
||||||
{
|
{
|
||||||
var classesArray = new Array<Dictionary>();
|
var classesArray = new Array<Dictionary>();
|
||||||
var error = internal_ParseFile(filePath, classesArray);
|
var error = internal_ParseFile(filePath, classesArray, out string errorStr);
|
||||||
if (error != Error.Ok)
|
if (error != Error.Ok)
|
||||||
throw new Exception($"Failed to determine namespace and class for script: {filePath}. Parse error: {error}");
|
throw new Exception($"Failed to determine namespace and class for script: {filePath}. Parse error: {errorStr ?? error.ToString()}");
|
||||||
|
|
||||||
var classesList = new List<ClassDecl>();
|
var classesList = new List<ClassDecl>();
|
||||||
|
|
||||||
|
@ -201,7 +201,9 @@ uint32_t godot_icall_BindingsGenerator_CsGlueVersion() {
|
|||||||
return CS_GLUE_VERSION;
|
return CS_GLUE_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObject *p_classes) {
|
int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObject *p_classes, MonoString **r_error_str) {
|
||||||
|
*r_error_str = NULL;
|
||||||
|
|
||||||
String filepath = GDMonoMarshal::mono_string_to_godot(p_filepath);
|
String filepath = GDMonoMarshal::mono_string_to_godot(p_filepath);
|
||||||
|
|
||||||
ScriptClassParser scp;
|
ScriptClassParser scp;
|
||||||
@ -220,6 +222,11 @@ int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObje
|
|||||||
classDeclDict["base_count"] = classDecl.base.size();
|
classDeclDict["base_count"] = classDecl.base.size();
|
||||||
classes.push_back(classDeclDict);
|
classes.push_back(classDeclDict);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
String error_str = scp.get_error();
|
||||||
|
if (!error_str.empty()) {
|
||||||
|
*r_error_str = GDMonoMarshal::mono_string_from_godot(error_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -302,8 +302,10 @@ Error ScriptClassParser::_skip_generic_type_params() {
|
|||||||
Error err = _skip_generic_type_params();
|
Error err = _skip_generic_type_params();
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
continue;
|
tk = get_token();
|
||||||
} else if (tk == TK_OP_GREATER) {
|
}
|
||||||
|
|
||||||
|
if (tk == TK_OP_GREATER) {
|
||||||
return OK;
|
return OK;
|
||||||
} else if (tk != TK_COMMA) {
|
} else if (tk != TK_COMMA) {
|
||||||
error_str = "Unexpected token: " + get_token_name(tk);
|
error_str = "Unexpected token: " + get_token_name(tk);
|
||||||
|
Loading…
Reference in New Issue
Block a user