MarkupBuilder ILabeled.GetLabel(DeltinScript deltinScript, LabelInfo labelInfo)
        {
            var builder = new MarkupBuilder();

            builder.StartCodeLine().Add("new " + Name + "(");

            for (int i = 0; i < ParameterProviders.Length; i++)
            {
                if (i != 0)
                {
                    builder.Add(", ");
                }

                // Add the parameter type.
                if (labelInfo.IncludeParameterTypes)
                {
                    builder.Add(ParameterProviders[i].Type.GetName());

                    // Add a space if the name is also included.
                    if (labelInfo.IncludeParameterNames)
                    {
                        builder.Add(" ");
                    }
                }

                // Add the parameter name.
                if (labelInfo.IncludeParameterNames)
                {
                    builder.Add(ParameterProviders[i].Name);
                }
            }

            return(builder.Add(")").EndCodeLine());
        }
        public MarkupBuilder MakeVariableLabel(CodeType type, string name)
        {
            var builder = new MarkupBuilder().StartCodeLine();

            if (IncludeReturnType)
            {
                builder.Add(type.GetName()).Add(" ");
            }

            return(builder.Add(name).EndCodeLine());
        }
        public MarkupBuilder GetLabel(DeltinScript deltinScript, LabelInfo labelInfo)
        {
            var builder = new MarkupBuilder().StartCodeLine();

            if (Parameters.Length == 1)
            {
                builder.Add(_argumentTypes[0].GetName() + " " + Parameters[0].Name);
            }
            else
            {
                builder.Add("(");
                for (int i = 0; i < Parameters.Length; i++)
                {
                    if (i != 0)
                    {
                        builder.Add(", ");
                    }
                    builder.Add(_argumentTypes[i].GetName() + " " + Parameters[i].Name);
                }
                builder.Add(")");
            }
            builder.Add(" => ");
            builder.Add(ReturnType.GetNameOrVoid());

            return(builder);
        }
        public MarkupBuilder MakeFunctionLabel(DeltinScript deltinScript, CodeType type, string name, IParameterLike[] parameters, AnonymousType[] typeArgs)
        {
            var builder = new MarkupBuilder().StartCodeLine();

            if (IncludeReturnType)
            {
                builder.Add(AnonymousLabelInfo.NameFromSolver(deltinScript, type) + " ");
            }

            builder.Add(name);

            if (typeArgs.Length != 0)
            {
                builder.Add("<" + string.Join(", ", typeArgs.Select(typeArg => typeArg.GetDeclarationName())) + ">");
            }

            builder.Add("(");

            for (int i = 0; i < parameters.Length; i++)
            {
                if (i != 0)
                {
                    builder.Add(", ");
                }
                builder.Add(parameters[i].GetLabel(deltinScript, AnonymousLabelInfo));
            }

            return(builder.Add(")").EndCodeLine());
        }
        public MarkupBuilder GetLabel(DeltinScript deltinScript, LabelInfo labelInfo)
        {
            var builder = new MarkupBuilder().StartCodeLine().Add("new " + Type.GetName());

            builder.Add(CodeParameter.GetLabels(deltinScript, labelInfo.AnonymousLabelInfo, Parameters)).EndCodeLine();

            if (labelInfo.IncludeDocumentation)
            {
                builder.NewSection().Add(Documentation);
            }

            return(builder);
        }
        /// <summary>Calls a type from the specified document range.</summary>
        /// <param name="parseInfo">The script that the type was called from.</param>
        /// <param name="callRange">The range of the call.</param>
        public virtual void Call(ParseInfo parseInfo, DocRange callRange)
        {
            parseInfo.Script.AddToken(callRange, TokenType, TokenModifiers.ToArray());

            var hover = new MarkupBuilder().StartCodeLine().Add(Kind.ToString().ToLower() + " " + Name);

            if (Generics.Length != 0)
            {
                hover.Add("<" + string.Join(", ", Generics.Select(g => g.GetName())) + ">");
            }
            hover.EndCodeLine();

            if (Description != null)
            {
                hover.NewSection().Add(Description);
            }
            parseInfo.Script.AddHover(callRange, hover);
        }