Ejemplo n.º 1
0
        public string GetLiteralEntityName(ICSharpCode.NRefactory.TypeSystem.IEntity member)
        {
            var semantic = NameSemantic.Create(member, this);

            semantic.IsObjectLiteral = true;
            return(semantic.Name);
        }
Ejemplo n.º 2
0
    public ICompletionData CreateEntityCompletionData(ICSharpCode.NRefactory.TypeSystem.IEntity entity)
    {
        ////[Method System.Object.Equals(objA:System.Object, objB:System.Object):System.Boolean]
        //[CSharpInvocationResolveResult [SpecializedMethod System.Linq.Enumerable.First[System.String](source:System.Collections.Generic.IEnumerable`1[[System.String]]):System.String]]
        //if (entity.Name.Contains("Length"))
        //    Debug.WriteLine("");
        //var tooltip = entity.ToTooltip();

        return(new EntityCompletionData(entity));
    }
Ejemplo n.º 3
0
 public static string[] GetDocumentationLines(this NRefTypes.IEntity entity)
 {
     if (entity.Documentation != null)
     {
         return(entity.Documentation.Xml.Text.XmlToPlainText(true, IgnoreDocumentationExceptions)
                .GetLines()
                .Select(l => "/// " + l)
                .ToArray());
     }
     else
     {
         return(EmptyStringArray);
     }
 }
 public ICompletionData CreateEntityCompletionData(ICSharpCode.NRefactory.TypeSystem.IEntity entity, string text)
 {
     return(new CompletionData(text));
 }
 public ICompletionData CreateEntityCompletionData(ICSharpCode.NRefactory.TypeSystem.IEntity entity)
 {
     return(new EntityCompletionData(entity));
 }
Ejemplo n.º 6
0
        public static string ToTooltip(this ICSharpCode.NRefactory.TypeSystem.IEntity entity, bool full)
        {
            try
            {
                var builder = new StringBuilder();
                builder.Append(entity.EntityType);
                builder.Append(": ");

                var property = (entity as IProperty);
                var field    = (entity as IField);

                var method = (entity as IMethod);
                if (method != null && entity.EntityType != EntityType.Constructor)
                {
                    builder.Append(method.ReturnType.ReflectionName);
                    builder.Append(' ');
                }
                else if (property != null)
                {
                    if (property.CanGet)
                    {
                        builder.Append(property.Getter.ReturnType.ReflectionName);
                    }
                    else if (property.CanSet)
                    {
                        builder.Append(property.Setter.ReturnType.ReflectionName);
                    }

                    builder.Append(' ');
                }
                else if (field != null)
                {
                    builder.Append(field.ReturnType.ReflectionName);
                    builder.Append(' ');
                }

                builder.Append(entity.DeclaringType.ReflectionName);
                if (entity.EntityType != EntityType.Constructor)
                {
                    builder.Append('.');
                    builder.Append(entity.Name);
                }

                if (method != null && method.TypeParameters.Count > 0)
                {
                    builder.Append('`');
                    builder.Append(method.TypeParameters.Count);
                    builder.Append('[');
                    for (int i = 0; i < method.TypeParameters.Count; i++)
                    {
                        if (i > 0)
                        {
                            builder.Append(",");
                        }
                        builder.Append("[``");
                        builder.Append(i);
                        builder.Append("]");
                    }

                    builder.Append(']');
                }

                if (entity.EntityType == EntityType.Method || entity.EntityType == EntityType.Constructor || entity.EntityType == EntityType.Destructor)
                {
                    builder.Append('(');
                    if (method != null)
                    {
                        for (int i = 0; i < method.Parameters.Count; i++)
                        {
                            if (i > 0)
                            {
                                builder.Append(", ");
                            }

                            object param = method.Parameters[i];
                            string s     = param.ToString();
                            builder.Append(method.Parameters[i].ToDisplayString());
                        }
                    }
                    else
                    {
                        builder.Append("...");
                    }

                    builder.Append(')');
                }

                string retval = builder.ToString().ProcessGenricNotations().ReplaceClrAliaces();

                if (entity.Documentation != null)
                {
                    /*
                     * <summary>Writes the current line terminator to the standard output stream.</summary>
                     *  <exception cref="T:System.IO.IOException">An I/O error occurred. </exception>
                     *  <filterpriority>1</filterpriority>
                     */

                    if (full)
                    {
                        retval += "\r\n" + entity.Documentation.Xml.Text.XmlToPlainText();
                    }
                    else
                    {
                        var doc = XElement.Parse("<root>" + entity.Documentation.Xml.Text + "</root>");

                        //retval += "\r\n";

                        var summary = doc.Element("summary");
                        if (summary != null)
                        {
                            retval += "\r\n" + summary.Value.NormalizeLines();
                        }

                        var returns = doc.Element("returns");
                        if (returns != null)
                        {
                            retval += "\r\nReturns: " + returns.Value.NormalizeLines();
                        }
                    }
                }
                return(retval);
            }
            catch
            {
                return(null);
            }
        }