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
1 change: 1 addition & 0 deletions Rewrite/src/Rewrite.CSharp/CSharpTypeMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private JavaType Type(IMethodSymbol methodSymbol)
methodSymbol.Parameters.Select(Type).ToList(),
null,
null,
null,
null
);
}
Expand Down
23 changes: 14 additions & 9 deletions Rewrite/src/Rewrite.Java/Tree/JavaType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ namespace Rewrite.RewriteJava.Tree;
[SuppressMessage("ReSharper", "PossibleUnintendedReferenceComparison")]
public interface JavaType
{
internal static JavaType[] EMPTY_JAVA_TYPE_ARRAY = [];
internal static FullyQualified[] EMPTY_FULLY_QUALIFIED_ARRAY = [];
internal static Method[] EMPTY_METHOD_ARRAY = [];
internal static Variable[] EMPTY_VARIABLE_ARRAY = [];
internal static readonly JavaType[] EMPTY_JAVA_TYPE_ARRAY = [];
internal static readonly FullyQualified[] EMPTY_FULLY_QUALIFIED_ARRAY = [];
internal static readonly Method[] EMPTY_METHOD_ARRAY = [];
internal static readonly Variable[] EMPTY_VARIABLE_ARRAY = [];
internal static readonly string[] EMPTY_STRING_ARRAY = [];

internal int? ManagedReference => null;

Expand Down Expand Up @@ -324,7 +325,7 @@ internal void UnsafeSet(IList<JavaType>? typeParameters, FullyQualified? superty
IList<FullyQualified>? annotations, IList<FullyQualified>? interfaces,
IList<Variable>? members, IList<Method>? methods)
{

TypeParameters = typeParameters ?? EMPTY_JAVA_TYPE_ARRAY;
Supertype = supertype;
OwningClass = owningClass;
Expand Down Expand Up @@ -531,9 +532,10 @@ public Method(int? managedReference,
JavaType? returnType,
IList<string>? parameterNames,
IList<JavaType>? parameterTypes,
IList<FullyQualified>? thrownExceptions,
IList<JavaType>? thrownExceptions,
IList<FullyQualified>? annotations,
IList<string>? defaultValue)
IList<string>? defaultValue,
IList<string>? declaredFormalTypeNames)
{
ManagedReference = managedReference;
FlagsBitMap = flagsBitMap;
Expand All @@ -542,9 +544,10 @@ public Method(int? managedReference,
ReturnType = returnType ?? Unknown.Instance;
ParameterNames = parameterNames ?? (Enumerable.Empty<string>() as IList<string>)!;
ParameterTypes = parameterTypes ?? EMPTY_JAVA_TYPE_ARRAY;
ThrownExceptions = thrownExceptions ?? EMPTY_FULLY_QUALIFIED_ARRAY;
ThrownExceptions = thrownExceptions ?? EMPTY_JAVA_TYPE_ARRAY;
Annotations = annotations ?? EMPTY_FULLY_QUALIFIED_ARRAY;
DefaultValue = defaultValue;
DeclaredFormalTypeNames = declaredFormalTypeNames ?? EMPTY_STRING_ARRAY;
}

public int? ManagedReference { get; internal set; }
Expand Down Expand Up @@ -573,11 +576,13 @@ public bool isConstructor()
return "<constructor>".Equals(Name);
}

public IList<FullyQualified> ThrownExceptions { get; set; } = [];
public IList<JavaType> ThrownExceptions { get; set; } = [];

public IList<FullyQualified> Annotations { get; internal set; } = [];

public IList<string>? DefaultValue { get; internal set; } = [];

public IList<string>? DeclaredFormalTypeNames { get; internal set; } = [];
}

public sealed class Variable : JavaType
Expand Down
22 changes: 21 additions & 1 deletion Rewrite/src/Rewrite.Remote.Codec/Java/Initialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static void RegisterValueDeserializers()
break;
case "thrownExceptions":
reader.ReadStartArray();
IList<JavaType.FullyQualified> exceptions = [];
IList<JavaType> exceptions = [];
while (reader.PeekState() != CborReaderState.EndArray)
{
exceptions.Add(context.Deserialize<JavaType.FullyQualified>(reader)!);
Expand Down Expand Up @@ -127,6 +127,17 @@ private static void RegisterValueDeserializers()
reader.ReadEndArray();
method.DefaultValue = defaultValue;
break;
case "declaredFormalTypeNames":
reader.ReadStartArray();
IList<string> declaredFormalTypeNames = [];
while (reader.PeekState() != CborReaderState.EndArray)
{
declaredFormalTypeNames.Add(reader.ReadTextString());
}

reader.ReadEndArray();
method.DeclaredFormalTypeNames = declaredFormalTypeNames;
break;
default:
throw new NotImplementedException(prop);
}
Expand Down Expand Up @@ -491,6 +502,15 @@ private static void RegisterValueSerializers()
writer.WriteEndArray();
}

if (value.DeclaredFormalTypeNames != null)
{
writer.WriteTextString("declaredFormalTypeNames");
writer.WriteStartArray(value.DeclaredFormalTypeNames.Count);
foreach (var defaultValue in value.DeclaredFormalTypeNames)
writer.WriteTextString(defaultValue);
writer.WriteEndArray();
}

writer.WriteEndMap();
});
RemotingContext.RegisterValueSerializer<JavaType.Variable>((value, type, writer, context) =>
Expand Down
Loading