当前位置: 首页>>代码示例>>C#>>正文


C# Document.IsEmptyLine方法代码示例

本文整理汇总了C#中Mono.TextEditor.Document.IsEmptyLine方法的典型用法代码示例。如果您正苦于以下问题:C# Document.IsEmptyLine方法的具体用法?C# Document.IsEmptyLine怎么用?C# Document.IsEmptyLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.TextEditor.Document的用法示例。


在下文中一共展示了Document.IsEmptyLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Format

		public static void Format (TextEditorData data, IType type, IMember member, ProjectDom dom, ICompilationUnit unit, DomLocation caretLocation)
		{
			if (type == null)
				return;
			if (member == null) {
				//				member = type;
				return;
			}
			string wrapper;
			int endPos;
			wrapper = CreateWrapperClassForMember (member, member != type, data, out endPos);
			if (string.IsNullOrEmpty (wrapper) || endPos < 0)
				return;
		//			Console.WriteLine (wrapper);
			
			int bracketIndex = wrapper.IndexOf ('{') + 1;
			int col = GetColumn (wrapper, bracketIndex, data.Options.TabSize);
			
			CSharpFormatter formatter = new CSharpFormatter ();
			formatter.startIndentLevel = System.Math.Max (0, col / data.Options.TabSize - 1);
			
			string formattedText = formatter.InternalFormat (dom != null && dom.Project != null ? dom.Project.Policies : null, MimeType, wrapper, 0, wrapper.Length);
			
			if (formatter.hasErrors)
				return;
			
			int startPos = data.Document.LocationToOffset (member.Location.Line, 1) - 1;
			InFormat = true;
			if (member != type) {
				int len1 = formattedText.IndexOf ('{') + 1;
				int last = formattedText.LastIndexOf ('}');
				formattedText = formattedText.Substring (len1, last - len1 - 1).TrimStart ('\n', '\r');
			} else {
				startPos++;
			}
			
			//Console.WriteLine ("formattedText0:" + formattedText.Replace ("\t", "->").Replace (" ", "°"));
			if (member != type) {
				string indentToRemove = GetIndent (formattedText);
		//				Console.WriteLine ("Remove:" + indentToRemove.Replace ("\t", "->").Replace (" ", "°"));
				formattedText = RemoveIndent (formattedText, indentToRemove);
			} else {
				formattedText = formattedText.TrimStart ();
			}
			//Console.WriteLine ("Indent:" + GetIndent (data, member.Location.Line - 1).Replace ("\t", "->").Replace (" ", "°"));
			//Console.WriteLine ("formattedText1:" + formattedText.Replace ("\t", "->").Replace (" ", "°"));
			formattedText = AddIndent (formattedText, GetIndent (data, member.Location.Line));
			
			Document doc = new Document ();
			doc.Text = formattedText;
			for (int i = doc.LineCount; i --> DocumentLocation.MinLine;) {
				LineSegment lineSegment = doc.GetLine (i);
				if (doc.IsEmptyLine (lineSegment))
					((IBuffer)doc).Remove (lineSegment.Offset, lineSegment.Length);
			}
			formattedText = doc.Text;
			
			//Console.WriteLine ("formattedText3:" + formattedText.Replace ("\t", "->").Replace (" ", "°").Replace ("\n", "\\n").Replace ("\r", "\\r"));
	
			int textLength = CanInsertFormattedText (data, startPos, data.Document.LocationToOffset (caretLocation.Line, caretLocation.Column), formattedText);
			if (textLength > 0) {
//				Console.WriteLine (formattedText.Substring (0, textLength));
				InsertFormattedText (data, startPos, formattedText.Substring (0, textLength).TrimEnd ());
			} else {
				Console.WriteLine ("Can't insert !!!");
			}
			InFormat = false;
		}
开发者ID:pgoron,项目名称:monodevelop,代码行数:68,代码来源:CSharpFormatter.cs


注:本文中的Mono.TextEditor.Document.IsEmptyLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。