From 1e57216794cc23e6bf1d5ec0196d273d01dc6176 Mon Sep 17 00:00:00 2001 From: Kevin Glynn Date: Thu, 6 Sep 2012 15:50:35 +0200 Subject: [PATCH] Also allow for fully qualified types when making static calls --- .../src/CS2JTranslator/CS2JTransform/NetMaker.g | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CSharpTranslator/antlr3/src/CS2JTranslator/CS2JTransform/NetMaker.g b/CSharpTranslator/antlr3/src/CS2JTranslator/CS2JTransform/NetMaker.g index 08391e1..d980b11 100644 --- a/CSharpTranslator/antlr3/src/CS2JTranslator/CS2JTransform/NetMaker.g +++ b/CSharpTranslator/antlr3/src/CS2JTranslator/CS2JTransform/NetMaker.g @@ -1531,6 +1531,21 @@ scope { // Not a variable, not a property read, is it a type name? TypeRepTemplate staticType = findType(textSoFar); if (!staticType.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 (staticType.Imports.Length == 1 && staticType.Imports[0] == textSoFar) { + staticType.Java = staticType.Java.Replace($i.thetext, textSoFar); + staticType.Imports = new String[0]; + // Ditto for each constructor + if (staticType is ClassRepTemplate) { + foreach (ConstructorRepTemplate c in ((ClassRepTemplate)staticType).Constructors) + { + c.Java = c.Java.Replace($i.thetext, textSoFar); + c.Imports = new String[0]; + } + } + } ret = mkJavaWrapper(staticType.Java, new Dictionary(), $i.tree.Token); AddToImports(staticType.Imports); $dotNetType = staticType;