1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

If class is fully qualified and doesn;t have a special translation then keep fully qualified in the Java. This allows a way to refer to multiple classes eith the same name (but different namespace ...)

This commit is contained in:
Kevin Glynn 2012-09-03 17:47:30 +02:00
parent e7a8fe4efe
commit 3d7e2a0dc6

View File

@ -1869,8 +1869,23 @@ type_or_generic[String prefix] returns [TypeRepTemplate dotNetType, List<CommonT
// (identifier generic_argument_list) => t=identifier ga=generic_argument_list // (identifier generic_argument_list) => t=identifier ga=generic_argument_list
t=identifier (ga=generic_argument_list {$hasTyArgs = true;})? t=identifier (ga=generic_argument_list {$hasTyArgs = true;})?
{ {
$dotNetType = findType(prefix+$t.thetext, $ga.argTypes); $dotNetType = findType(prefix+$t.thetext, $ga.argTypes);
if (!$dotNetType.IsUnknownType) { if (!$dotNetType.IsUnknownType) {
// In the case that type is fully qualified, and matches the name in $dotNetType then emit a fully
// qualified type and don't add imports. this allows a class to refer to multiple classes with identical names
// as long as you fully qualify one of them.
if ($dotNetType.Imports.Length == 1 && $dotNetType.Imports[0] == prefix+$t.thetext) {
$dotNetType.Java = $dotNetType.Java.Replace($t.thetext, prefix+$t.thetext);
$dotNetType.Imports = new String[0];
// Ditto for each constructor
if ($dotNetType is ClassRepTemplate) {
foreach (ConstructorRepTemplate c in ((ClassRepTemplate)$dotNetType).Constructors)
{
c.Java = c.Java.Replace($t.thetext, prefix + $t.thetext);
c.Imports = new String[0];
}
}
}
if (!$MkNonGeneric::scrubGenericArgs && $hasTyArgs && $dotNetType.TypeParams.Length == $ga.argTrees.Count) { if (!$MkNonGeneric::scrubGenericArgs && $hasTyArgs && $dotNetType.TypeParams.Length == $ga.argTrees.Count) {
int i = 0; int i = 0;
foreach (CommonTree ty in $ga.argTrees) { foreach (CommonTree ty in $ga.argTrees) {