Ejemplo n.º 1
0
        public void Save(DFormattingPolicy p)
        {
            if (p == null)
                throw new ArgumentNullException("policy");

            p.CommentOutStandardHeaders = chk_CommentOutStdHeaders.Active;
            p.InsertStarAtCommentNewLine = chk_InsertStarAtCommentNewLine.Active;
            p.KeepAlignmentSpaces = check_KeepAlignmentSpaces.Active;
        }
Ejemplo n.º 2
0
		public void Load(DFormattingPolicy p)
		{
			if (p == null)
				throw new ArgumentNullException("p");

			chk_CommentOutStdHeaders.Active = p.CommentOutStandardHeaders;
			chk_InsertStarAtCommentNewLine.Active = p.InsertStarAtCommentNewLine;
			check_KeepAlignmentSpaces.Active = p.KeepAlignmentSpaces;
			check_IndentPastedCodeLines.Active = p.IndentPastedCodeLines;
		}
Ejemplo n.º 3
0
        public override string CreateContent(MonoDevelop.Projects.Project project, Dictionary <string, string> tags, string language)
        {
            var cc = base.CreateContent(project, tags, language);

            if (addStdHeader)
            {
                StandardHeaderPolicy headerPolicy = project != null?project.Policies.Get <StandardHeaderPolicy>() : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <StandardHeaderPolicy>();

                TextStylePolicy textPolicy = project != null?project.Policies.Get <TextStylePolicy>("text/plain") : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <TextStylePolicy>("text/plain");

                DFormattingPolicy dPolicy = project != null?project.Policies.Get <DFormattingPolicy>("text/x-d") : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <DFormattingPolicy>("text/x-d");

                if (string.IsNullOrWhiteSpace(headerPolicy.Text) || !headerPolicy.IncludeInNewFiles)
                {
                    return(cc);
                }

                var eol = TextStylePolicy.GetEolMarker(textPolicy.EolMarker);

                var hdr = StringParserService.Parse(headerPolicy.Text, tags);

                if (dPolicy.CommentOutStandardHeaders)
                {
                    var headerLines = hdr.Split('\n');

                    if (headerLines.Length == 1)
                    {
                        return("/// " + headerLines[0].Trim() + eol + cc);
                    }
                    else
                    {
                        var ret = "/**" + eol;
                        for (int i = 0; i < headerLines.Length; i++)
                        {
                            ret += " * " + headerLines[i].Trim() + eol;
                        }
                        return(ret + " */" + eol + cc);
                    }
                }
                else
                {
                    return(hdr + eol + cc);
                }
            }

            return(cc);
        }
Ejemplo n.º 4
0
 public DIndentEngine(DFormattingPolicy policy, TextStylePolicy textStyle)
     : base(policy.Options, textStyle.TabsToSpaces, textStyle.IndentWidth)
 {
     this.policy = policy;
     this.textStyle = textStyle;
 }
Ejemplo n.º 5
0
 public DIndentEngine(DFormattingPolicy policy, TextStylePolicy textStyle)
     : base(policy.Options, textStyle.TabsToSpaces, textStyle.IndentWidth, policy.KeepAlignmentSpaces)
 {
     this.policy    = policy;
     this.textStyle = textStyle;
 }