Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tools/generator/CodeGeneratorContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,17 @@ public class CodeGeneratorContext
string ContextMethodString => ContextMethod != null ? "in method " + ContextMethod.Name + " " : null;
string ContextTypeString => ContextType != null ? "in managed type " + ContextType.FullName : null;
public string ContextString => ContextFieldString + ContextMethodString + ContextTypeString;

public string GetContextTypeMember ()
{
var output = ContextType?.FullName ?? string.Empty;

if (ContextMethod != null) {
output += $"{ContextMethod.Name} ({string.Join (", ", ContextMethod?.Parameters.Select (p => p.InternalType).ToArray ())})";
return output;
}

return output + ContextField?.Name;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public bool Validate (CodeGenerationOptions opt, GenericParameterDefinitionList
Symbol = opt.SymbolTable.Lookup (TypeName, type_params);

if (Symbol == null || !Symbol.Validate (opt, type_params, context)) {
Report.LogCodedWarning (0, Report.WarningUnexpectedFieldType, TypeName, context.ContextString);
Report.LogCodedWarning (0, Report.WarningUnexpectedFieldType, TypeName, context.GetContextTypeMember ());
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public bool Validate (CodeGenerationOptions opt, GenericParameterDefinitionList
foreach (var c in ConstraintExpressions) {
var sym = opt.SymbolTable.Lookup (c, type_params);
if (sym == null) {
Report.LogCodedWarning (0, Report.WarningUnknownGenericConstraint, c, context.ContextString);
Report.LogCodedWarning (0, Report.WarningUnknownGenericConstraint, c, context.GetContextTypeMember ());
validated = true;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ public string Type {
get { return managed_type ?? sym.FullName; }
}

public string InternalType => managed_type ?? sym?.FullName ?? type;

public string Annotation { get; internal set; }

public void SetGeneratedEnumType (string enumType)
Expand Down Expand Up @@ -260,11 +262,11 @@ public bool Validate (CodeGenerationOptions opt, GenericParameterDefinitionList
{
sym = opt.SymbolTable.Lookup (type, type_params);
if (sym == null) {
Report.LogCodedWarning (0, Report.WarningUnknownParameterType, type, context.ContextString);
Report.LogCodedWarning (0, Report.WarningUnknownParameterType, type, context.GetContextTypeMember ());
return false;
}
if (!sym.Validate (opt, type_params, context)) {
Report.LogCodedWarning (0, Report.WarningInvalidParameterType, type, context.ContextString);
Report.LogCodedWarning (0, Report.WarningInvalidParameterType, type, context.GetContextTypeMember ());
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public bool Validate (CodeGenerationOptions opt, GenericParameterDefinitionList
{
sym = (IsEnumified ? opt.SymbolTable.Lookup (managed_type, type_params) : null) ?? opt.SymbolTable.Lookup (java_type, type_params);
if (sym == null) {
Report.LogCodedWarning (0, Report.WarningUnknownReturnType, java_type, context.ContextString);
Report.LogCodedWarning (0, Report.WarningUnknownReturnType, java_type, context.GetContextTypeMember ());
return false;
}
if (!sym.Validate (opt, type_params, context)) {
Report.LogCodedWarning (0, Report.WarningInvalidReturnType, java_type, context.ContextString);
Report.LogCodedWarning (0, Report.WarningInvalidReturnType, java_type, context.GetContextTypeMember ());
return false;
}
return true;
Expand Down