Replace FullName with CSharpSignature
[mono.git] / mcs / mcs / doc.cs
index 3ba61bec8adcf21710f6d2e01eaad4715aa5a395..489a0f9797e6c982683c172ac0540781eee61965 100644 (file)
@@ -4,9 +4,9 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Licensed under the terms of the GNU GPL
+// Dual licensed under the terms of the MIT X11 or GNU GPL
 //
-// (C) 2004 Novell, Inc.
+// Copyright 2004 Novell, Inc.
 //
 //
 #if ! BOOTSTRAP_WITH_OLDLIB
@@ -87,7 +87,7 @@ namespace Mono.CSharp {
                                        p.GenerateDocComment (t);
 
                        if (t.Methods != null)
-                               foreach (Method m in t.Methods)
+                               foreach (MethodOrOperator m in t.Methods)
                                        m.GenerateDocComment (t);
 
                        if (t.Operators != null)
@@ -128,7 +128,7 @@ namespace Mono.CSharp {
                                el.InnerXml = line_head + String.Join (
                                        line_head, split, 0, j);
                                return el;
-                       } catch (XmlException ex) {
+                       } catch (Exception ex) {
                                Report.Warning (1570, 1, mc.Location, "XML comment on `{0}' has non-well-formed XML ({1})", name, ex.Message);
                                XmlComment com = doc.CreateComment (String.Format ("FIXME: Invalid documentation markup was found for member {0}", name));
                                return com;
@@ -292,37 +292,37 @@ namespace Mono.CSharp {
                {
                        switch (identifier) {
                        case "int":
-                               return typeof (int);
+                               return TypeManager.int32_type;
                        case "uint":
-                               return typeof (uint);
+                               return TypeManager.uint32_type;
                        case "short":
-                               return typeof (short);
+                               return TypeManager.short_type;;
                        case "ushort":
-                               return typeof (ushort);
+                               return TypeManager.ushort_type;
                        case "long":
-                               return typeof (long);
+                               return TypeManager.int64_type;
                        case "ulong":
-                               return typeof (ulong);
+                               return TypeManager.uint64_type;;
                        case "float":
-                               return typeof (float);
+                               return TypeManager.float_type;;
                        case "double":
-                               return typeof (double);
+                               return TypeManager.double_type;
                        case "char":
-                               return typeof (char);
+                               return TypeManager.char_type;;
                        case "decimal":
-                               return typeof (decimal);
+                               return TypeManager.decimal_type;;
                        case "byte":
-                               return typeof (byte);
+                               return TypeManager.byte_type;;
                        case "sbyte":
-                               return typeof (sbyte);
+                               return TypeManager.sbyte_type;;
                        case "object":
-                               return typeof (object);
+                               return TypeManager.object_type;;
                        case "bool":
-                               return typeof (bool);
+                               return TypeManager.bool_type;;
                        case "string":
-                               return typeof (string);
+                               return TypeManager.string_type;;
                        case "void":
-                               return typeof (void);
+                               return TypeManager.void_type;;
                        }
                        FullNamedExpression e = ds.LookupNamespaceOrType (identifier, mc.Location, false);
                        if (e != null) {
@@ -366,8 +366,8 @@ namespace Mono.CSharp {
                        if (!MethodGroupExpr.IsAncestralType (base_prop.DeclaringType, deriv_prop.DeclaringType))
                                return false;
 
-                       Type [] deriv_pd = TypeManager.GetArgumentTypes (deriv_prop);
-                       Type [] base_pd = TypeManager.GetArgumentTypes (base_prop);
+                       Type [] deriv_pd = TypeManager.GetParameterData (deriv_prop).Types;
+                       Type [] base_pd = TypeManager.GetParameterData (base_prop).Types;
                
                        if (deriv_pd.Length != base_pd.Length)
                                return false;
@@ -505,11 +505,11 @@ namespace Mono.CSharp {
                        string oper = null;
                        string return_type_name = null;
                        if (member_name.StartsWith ("implicit operator ")) {
-                               oper = "op_Implicit";
+                               Operator.GetMetadataName (Operator.OpType.Implicit);
                                return_type_name = member_name.Substring (18).Trim (wsChars);
                        }
                        else if (member_name.StartsWith ("explicit operator ")) {
-                               oper = "op_Explicit";
+                               oper = Operator.GetMetadataName (Operator.OpType.Explicit);
                                return_type_name = member_name.Substring (18).Trim (wsChars);
                        }
                        else if (member_name.StartsWith ("operator ")) {
@@ -518,58 +518,19 @@ namespace Mono.CSharp {
                                // either unary or binary
                                case "+":
                                        oper = param_list.Length == 2 ?
-                                               Binary.oper_names [(int) Binary.Operator.Addition] :
-                                               Unary.oper_names [(int) Unary.Operator.UnaryPlus];
+                                               Operator.GetMetadataName (Operator.OpType.Addition) :
+                                               Operator.GetMetadataName (Operator.OpType.UnaryPlus);
                                        break;
                                case "-":
                                        oper = param_list.Length == 2 ?
-                                               Binary.oper_names [(int) Binary.Operator.Subtraction] :
-                                               Unary.oper_names [(int) Unary.Operator.UnaryNegation];
+                                               Operator.GetMetadataName (Operator.OpType.Subtraction) :
+                                               Operator.GetMetadataName (Operator.OpType.UnaryNegation);
                                        break;
-                               // unary
-                               case "!":
-                                       oper = Unary.oper_names [(int) Unary.Operator.LogicalNot]; break;
-                               case "~":
-                                       oper = Unary.oper_names [(int) Unary.Operator.OnesComplement]; break;
-                                       
-                               case "++":
-                                       oper = "op_Increment"; break;
-                               case "--":
-                                       oper = "op_Decrement"; break;
-                               case "true":
-                                       oper = "op_True"; break;
-                               case "false":
-                                       oper = "op_False"; break;
-                               // binary
-                               case "*":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Multiply]; break;
-                               case "/":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Division]; break;
-                               case "%":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Modulus]; break;
-                               case "&":
-                                       oper = Binary.oper_names [(int) Binary.Operator.BitwiseAnd]; break;
-                               case "|":
-                                       oper = Binary.oper_names [(int) Binary.Operator.BitwiseOr]; break;
-                               case "^":
-                                       oper = Binary.oper_names [(int) Binary.Operator.ExclusiveOr]; break;
-                               case "<<":
-                                       oper = Binary.oper_names [(int) Binary.Operator.LeftShift]; break;
-                               case ">>":
-                                       oper = Binary.oper_names [(int) Binary.Operator.RightShift]; break;
-                               case "==":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Equality]; break;
-                               case "!=":
-                                       oper = Binary.oper_names [(int) Binary.Operator.Inequality]; break;
-                               case "<":
-                                       oper = Binary.oper_names [(int) Binary.Operator.LessThan]; break;
-                               case ">":
-                                       oper = Binary.oper_names [(int) Binary.Operator.GreaterThan]; break;
-                               case "<=":
-                                       oper = Binary.oper_names [(int) Binary.Operator.LessThanOrEqual]; break;
-                               case ">=":
-                                       oper = Binary.oper_names [(int) Binary.Operator.GreaterThanOrEqual]; break;
                                default:
+                                       oper = Operator.GetMetadataName (oper);
+                                       if (oper != null)
+                                               break;
+
                                        warning_type = 1584;
                                        Report.Warning (1020, 1, mc.Location, "Overloadable {0} operator is expected", param_list.Length == 2 ? "binary" : "unary");
                                        Report.Warning (1584, 1, mc.Location, "XML comment on `{0}' has syntactically incorrect cref attribute `{1}'",
@@ -711,7 +672,7 @@ namespace Mono.CSharp {
                        Type type = FindDocumentedType (mc, name, ds, cref);
                        if (type != null
                                // delegate must not be referenced with args
-                               && (!type.IsSubclassOf (typeof (System.Delegate))
+                               && (!TypeManager.IsDelegateType (type)
                                || parameter_types == null)) {
                                string result = GetSignatureForDoc (type)
                                        + (brace_pos < 0 ? String.Empty : signature.Substring (brace_pos));
@@ -760,7 +721,7 @@ namespace Mono.CSharp {
                        // It still might be part of namespace name.
                        Namespace ns = ds.NamespaceEntry.NS.GetNamespace (name, false);
                        if (ns != null) {
-                               xref.SetAttribute ("cref", "N:" + ns.FullName);
+                               xref.SetAttribute ("cref", "N:" + ns.GetSignatureForError ());
                                return; // a namespace
                        }
                        if (RootNamespace.Global.IsNamespace (name)) {
@@ -789,7 +750,7 @@ namespace Mono.CSharp {
                        if (mb == null)
                                return String.Empty;
 
-                       ParameterData parameters = TypeManager.GetParameterData (mb);
+                       AParametersCollection parameters = TypeManager.GetParameterData (mb);
                        if (parameters == null || parameters.Count == 0)
                                return String.Empty;
 
@@ -800,7 +761,7 @@ namespace Mono.CSharp {
                                        break; // skip "value".
                                if (i > 0)
                                        sb.Append (',');
-                               Type t = parameters.ParameterType (i);
+                               Type t = parameters.Types [i];
                                sb.Append (GetSignatureForDoc (t));
                        }
                        sb.Append (')');
@@ -861,13 +822,16 @@ namespace Mono.CSharp {
                //
                public static string GetMethodDocCommentName (MemberCore mc, Parameters parameters, DeclSpace ds)
                {
-                       Parameter [] plist = parameters.FixedParameters;
+                       IParameterData [] plist = parameters.FixedParameters;
                        string paramSpec = String.Empty;
                        if (plist != null) {
                                StringBuilder psb = new StringBuilder ();
+                               int i = 0;
                                foreach (Parameter p in plist) {
                                        psb.Append (psb.Length != 0 ? "," : "(");
-                                       psb.Append (GetSignatureForDoc (p.ExternalType ()));
+                                       psb.Append (GetSignatureForDoc (parameters.Types [i++]));
+                                       if ((p.ModFlags & Parameter.Modifier.ISBYREF) != 0)
+                                               psb.Append ('@');
                                }
                                paramSpec = psb.ToString ();
                        }
@@ -876,6 +840,10 @@ namespace Mono.CSharp {
                                paramSpec += ")";
 
                        string name = mc is Constructor ? "#ctor" : mc.Name;
+#if GMCS_SOURCE                                                    
+                       if (mc.MemberName.IsGeneric)
+                               name += "``" + mc.MemberName.CountTypeArguments;
+#endif
                        string suffix = String.Empty;
                        Operator op = mc as Operator;
                        if (op != null) {
@@ -891,8 +859,23 @@ namespace Mono.CSharp {
 
                static string GetSignatureForDoc (Type type)
                {
+#if GMCS_SOURCE
                        if (TypeManager.IsGenericParameter (type))
-                               return "`" + TypeManager.GenericParameterPosition (type);
+                               return (type.DeclaringMethod != null ? "``" : "`") + TypeManager.GenericParameterPosition (type);
+
+                       if (TypeManager.IsGenericType (type)) {
+                               string g = type.Namespace;
+                               if (g != null && g.Length > 0)
+                                       g += '.';
+                               int idx = type.Name.LastIndexOf ('`');
+                               g += (idx < 0 ? type.Name : type.Name.Substring (0, idx)) + '{';
+                               int argpos = 0;
+                               foreach (Type t in type.GetGenericArguments ())
+                                       g += (argpos++ > 0 ? "," : String.Empty) + GetSignatureForDoc (t);
+                               g += '}';
+                               return g;
+                       }
+#endif
 
                        string name = type.FullName != null ? type.FullName : type.Name;
                        return name.Replace ("+", ".").Replace ('&', '@');
@@ -910,11 +893,10 @@ namespace Mono.CSharp {
                {
                        Hashtable paramTags = new Hashtable ();
                        foreach (XmlElement pelem in el.SelectNodes ("param")) {
-                               int i;
                                string xname = pelem.GetAttribute ("name");
                                if (xname.Length == 0)
                                        continue; // really? but MS looks doing so
-                               if (xname != "" && mc.Parameters.GetParameterByName (xname, out i) == null)
+                               if (xname != "" && mc.Parameters.GetParameterIndexByName (xname) < 0)
                                        Report.Warning (1572, 2, mc.Location, "XML comment on `{0}' has a param tag for `{1}', but there is no parameter by that name",
                                                mc.GetSignatureForError (), xname);
                                else if (paramTags [xname] != null)
@@ -922,7 +904,7 @@ namespace Mono.CSharp {
                                                mc.GetSignatureForError (), xname);
                                paramTags [xname] = xname;
                        }
-                       Parameter [] plist = mc.Parameters.FixedParameters;
+                       IParameterData [] plist = mc.Parameters.FixedParameters;
                        foreach (Parameter p in plist) {
                                if (paramTags.Count > 0 && paramTags [p.Name] == null)
                                        Report.Warning (1573, 4, mc.Location, "Parameter `{0}' has no matching param tag in the XML comment for `{1}'",