示例#1
0
        public static TooltipInformation Generate(DelegateType dt, int currentParam = -1)
        {
            var dd = dt.TypeDeclarationOf as DelegateDeclaration;
            if (dd != null)
                return Generate(dd, currentParam);

            return new TooltipInformation();
        }
		public void VisitDelegateType(DelegateType t)
		{
			AcceptType(t.Base);
			sb.Append(' ').Append(t.IsFunction ? "function" : "delegate").Append(" (");

			if (t.Parameters != null)
				foreach (var p in t.Parameters)
				{
					AcceptType(p); 
					sb.Append(',');
				}

			if (sb[sb.Length - 1] == ',')
				sb.Length--;

			sb.Append(')');
		}
示例#3
0
        public ITypeDeclaration VisitDelegateType(DelegateType t)
        {
            var dd = new DelegateDeclaration
            {
                ReturnType = AcceptType(t.ReturnType),
                IsFunction = t.IsFunction
            };

            if (t.Parameters != null)
            {
                foreach (var p in t.Parameters)
                {
                    dd.Parameters.Add(new DVariable {
                        Type = AcceptType(p)
                    });
                }
            }

            return(dd);
        }
示例#4
0
        public void VisitDelegateType(DelegateType t)
        {
            AcceptType(t.Base);
            sb.Append(' ').Append(t.IsFunction ? "function" : "delegate").Append(" (");

            if (t.Parameters != null)
            {
                foreach (var p in t.Parameters)
                {
                    AcceptType(p);
                    sb.Append(',');
                }
            }

            if (sb[sb.Length - 1] == ',')
            {
                sb.Length--;
            }

            sb.Append(')');
        }
示例#5
0
        public static TooltipInformation Generate(DelegateType dd, bool templateParamInsight, int currentParam = -1)
        {
            var sb = new StringBuilder("<i>(Delegate)</i> ");

            if (dd.ReturnType != null)
                sb.Append(dd.ReturnType.ToString()).Append(' ');

            if (dd.IsFunction)
                sb.Append("function");
            else
                sb.Append("delegate");

            var tti = new TooltipInformation();

            var fn = dd.DeclarationOrExpressionBase as D_Parser.Dom.Expressions.FunctionLiteral;
            if (fn != null)
                RenderParamtersAndFooters (tti, fn.AnonymousMethod, sb, templateParamInsight, currentParam);
            else {
                sb.Append ('(');
                var parms = dd.Parameters;
                if (parms != null && parms.Length != 0) {
                    for (int i = 0; i < parms.Length; i++) {
                        if (i == currentParam)
                            sb.Append ("<u>");

                        sb.Append (parms [i] is DSymbol ? (parms [i] as DSymbol).Definition.ToString (true, false) : parms [i].ToCode ());

                        if (i == currentParam)
                            sb.Append ("</u>");
                        sb.Append (',');
                    }

                    sb.Remove (sb.Length - 1, 1);
                }
                sb.Append (')');
                tti.SignatureMarkup = sb.ToString();
            }

            return tti;
        }
示例#6
0
 public DelegateValue(DelegateType Dg)
     : base(Dg)
 {
     this.Definition = Dg;
 }
示例#7
0
文件: DType.cs 项目: Orvid/D_Parser
 public DelegateCallSymbol(DelegateType dg, ISyntaxRegion callExpression) : base(dg.Base, callExpression)
 {
     this.Delegate = dg;
 }
 public void VisitDelegateType(DelegateType dg)
 {
     GenUfcsAndStaticProperties(dg);
 }
		void GenDelegateSignature(DelegateType dt, StringBuilder sb, bool templArgs = false, int curArg = -1)
		{
			if (dt.delegateTypeBase is FunctionLiteral)
				S((dt.delegateTypeBase as FunctionLiteral).AnonymousMethod, sb, templArgs, curArg, DTypeToTypeDeclVisitor.GenerateTypeDecl(dt.ReturnType));
			else if (dt.delegateTypeBase is DelegateDeclaration)
			{
				var delegateDecl = dt.delegateTypeBase as DelegateDeclaration;
				AppendAttributes(delegateDecl.Modifiers, sb);

				if (dt.ReturnType != null)
					sb.Append(DCodeToMarkup(dt.ReturnType.ToCode(true)));
				else
					sb.Append(DCodeToMarkup(delegateDecl.ReturnType.ToString()));

				sb.Append(' ').Append(delegateDecl.IsFunction ? "function" : "delegate");

				AppendParameters(delegateDecl.Parameters, sb, templArgs, curArg);
			}
			else
			{
				if (dt.ReturnType != null)
					sb.Append(DCodeToMarkup(dt.ReturnType.ToCode(true)));

				sb.Append(" (");

				int i = -1;
				foreach (var parm in dt.Parameters)
				{
					i++;
					if ((SignatureFlags & TooltipSignatureFlags.NoLineBreakedMethodParameters) == 0)
						sb.AppendLine().Append("  ");

					var indexBackup = sb.Length;

					sb.Append(parm.ToCode(true));

					if (!templArgs && curArg == i)
					{
						//TODO: Optimize
						var contentToUnderline = sb.ToString(indexBackup, sb.Length - indexBackup);
						sb.Remove(indexBackup, contentToUnderline.Length);
						AppendFormat(contentToUnderline, sb, FormatFlags.Underline);
					}

					sb.Append(',');
				}

				RemoveLastChar(sb, ',');
				if ((SignatureFlags & TooltipSignatureFlags.NoLineBreakedMethodParameters) == 0)
					sb.AppendLine();

				sb.Append(')');
			}
		}
示例#10
0
 public DelegateValue(DelegateType Dg)
     : base(ExpressionValueType.Delegate, Dg)
 {
     this.Definition = Dg;
 }