• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# TextEditor.Document类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Document类属于Mono.TextEditor命名空间,在下文中一共展示了Document类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Setup

		static CSharpTextEditorIndentation Setup (string input, out TestViewContent content)
		{
			TestWorkbenchWindow tww = new TestWorkbenchWindow ();
			content = new TestViewContent ();
			content.Data.Options.IndentStyle = IndentStyle.Auto;
			tww.ViewContent = content;
			content.ContentName = "a.cs";
			content.GetTextEditorData ().Document.MimeType = "text/x-csharp";

			Document doc = new Document (tww);

			var text = input;
			int endPos = text.IndexOf ('$');
			if (endPos >= 0)
				text = text.Substring (0, endPos) + text.Substring (endPos + 1);

			content.Text = text;
			content.CursorPosition = System.Math.Max (0, endPos);


			var compExt = new CSharpCompletionTextEditorExtension ();
			compExt.Initialize (doc);
			content.Contents.Add (compExt);
			
			var ext = new CSharpTextEditorIndentation ();
			CSharpTextEditorIndentation.OnTheFlyFormatting = true;
			ext.Initialize (doc);
			content.Contents.Add (ext);
			
			doc.UpdateParseDocument ();
			return ext;
		}
开发者ID:kjnilsson,项目名称:monodevelop,代码行数:32,代码来源:OnTheFlyFormatterTests.cs


示例2: CreateCompletionAndUpdate

		CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (Document realDocument, UnderlyingDocumentInfo docInfo,
			out CodeCompletionContext codeCompletionContext)
		{
			var completion = CreateCompletion (realDocument, docInfo, out codeCompletionContext);
			completion.UpdateParsedDocument ();
			return completion;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:RazorCSharpCompletionBuilder.cs


示例3: FoldSegment

		public FoldSegment (Document doc, string description, int offset, int length, FoldingType foldingType) : base (offset, length)
		{
			this.doc = doc;
			this.IsFolded    = false;
			this.Description = description;
			this.FoldingType = foldingType;
		}
开发者ID:acken,项目名称:monodevelop,代码行数:7,代码来源:FoldSegment.cs


示例4: TestCreateMethod

		void TestCreateMethod (string input, string outputString, bool returnWholeFile)
		{
			var generator = new CSharpCodeGeneratorNode ();
			MonoDevelop.Projects.CodeGeneration.CodeGenerator.AddGenerator (generator);
			var refactoring = new CreateMethodCodeGenerator ();
			RefactoringOptions options = ExtractMethodTests.CreateRefactoringOptions (input);
			Assert.IsTrue (refactoring.IsValid (options));
			if (returnWholeFile) {
				refactoring.SetInsertionPoint (CodeGenerationService.GetInsertionPoints (options.Document, refactoring.DeclaringType).First ());
			} else {
				DocumentLocation loc = new DocumentLocation (1, 1);
				refactoring.SetInsertionPoint (new InsertionPoint (loc, NewLineInsertion.Eol, NewLineInsertion.Eol));
			}
			List<Change> changes = refactoring.PerformChanges (options, null);
//			changes.ForEach (c => Console.WriteLine (c));
			// get just the generated method.
			string output = ExtractMethodTests.GetOutput (options, changes);
			if (returnWholeFile) {
				Assert.IsTrue (ExtractMethodTests.CompareSource (output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output);
				return;
			}
			output = output.Substring (0, output.IndexOf ('}') + 1).Trim ();
			// crop 1 level of indent
			Document doc = new Document (output);
			foreach (LineSegment line in doc.Lines) {
				if (doc.GetCharAt (line.Offset) == '\t')
					((IBuffer)doc).Remove (line.Offset, 1);
			}
			output = doc.Text;
			
			Assert.IsTrue (ExtractMethodTests.CompareSource (output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output);
			MonoDevelop.Projects.CodeGeneration.CodeGenerator.RemoveGenerator (generator);
		}
开发者ID:hduregger,项目名称:monodevelop,代码行数:33,代码来源:CreateMethodTests.cs


示例5: HandleCompletion

		public ICompletionDataList HandleCompletion (Document realDocument,	CodeCompletionContext completionContext,
			UnderlyingDocumentInfo docInfo, char currentChar, ref int triggerWordLength)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc);
			return completion.HandleCodeCompletion (completionContext, currentChar, ref triggerWordLength);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:RazorCSharpCompletionBuilder.cs


示例6: Initialize

		public void Initialize (Document document)
		{
			if (this.document != null)
				throw new InvalidOperationException ("Extension is already initialized.");
			this.document = document;
			Initialize ();
		}
开发者ID:KseniaVensko,项目名称:gap-develop,代码行数:7,代码来源:TextEditorExtension.cs


示例7: Setup

		static Document Setup (string input)
		{
			TestWorkbenchWindow tww = new TestWorkbenchWindow ();
			var content = new TestViewContent ();
			tww.ViewContent = content;
			content.ContentName = "a.cs";
			content.GetTextEditorData ().Document.MimeType = "text/x-csharp";

			Document doc = new Document (tww);

			var text = input;
			int endPos = text.IndexOf ('$');
			if (endPos >= 0)
				text = text.Substring (0, endPos) + text.Substring (endPos + 1);

			content.Text = text;
			content.CursorPosition = System.Math.Max (0, endPos);

			var compExt = new CSharpCompletionTextEditorExtension ();
			compExt.Initialize (doc);
			content.Contents.Add (compExt);

			doc.UpdateParseDocument ();
			return doc;
		}
开发者ID:gary-b,项目名称:monodevelop,代码行数:25,代码来源:ResolveNamespaceTests.cs


示例8: Setup

		static Document Setup (string input)
		{
			var tww = new TestWorkbenchWindow ();
			var content = new TestViewContent ();

			var project = new DotNetAssemblyProject ("C#");
			project.Name = "test";
			project.References.Add (new ProjectReference (ReferenceType.Package, "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
			project.References.Add (new ProjectReference (ReferenceType.Package, "System.Core"));

			project.FileName = "test.csproj";

			TypeSystemService.LoadProject (project);
			TypeSystemService.GetProjectContentWrapper (project).ReconnectAssemblyReferences (); 
			content.Project = project;

			tww.ViewContent = content;
			content.ContentName = "a.cs";
			content.GetTextEditorData ().Document.MimeType = "text/x-csharp";
			var doc = new Document (tww);

			var text = input;
			int endPos = text.IndexOf ('$');
			if (endPos >= 0)
				text = text.Substring (0, endPos) + text.Substring (endPos + 1);

			content.Text = text;
			content.CursorPosition = Math.Max (0, endPos);

			var compExt = new CSharpCompletionTextEditorExtension ();
			compExt.Initialize (doc);
			content.Contents.Add (compExt);
			doc.UpdateParseDocument ();
			return doc;
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:35,代码来源:ResolveNamespaceTests.cs


示例9: SourceEditorPrintOperation

		public SourceEditorPrintOperation (Document doc, FilePath filename)
		{
			this.doc = doc;
			this.filename = filename;
			this.settings = SourceEditorPrintSettings.Load ();
			
			this.Unit = Unit.Mm;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:8,代码来源:SourceEditorPrintOperation.cs


示例10: MDRefactoringScript

		public MDRefactoringScript (MDRefactoringContext context, Document document, CSharpFormattingOptions formattingOptions) : base(document.Editor.Document, formattingOptions, document.Editor.CreateNRefactoryTextEditorOptions ())
		{
			this.context = context;
			this.document = document;
			undoGroup  = this.document.Editor.OpenUndoGroup ();
			this.startVersion = this.document.Editor.Version;

		}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:8,代码来源:MDRefactoringScript.cs


示例11: GetNextOffset

		static int GetNextOffset (Document document, int lineNumber)
		{
			int startLineNumber = lineNumber + 1;
			if (startLineNumber > document.Length) 
				startLineNumber = 0;
			var line = document.GetLinesStartingAt (startLineNumber).FirstOrDefault (l => l.IsBookmarked);
			return line != null ? line.Offset : -1;
		}
开发者ID:nieve,项目名称:monodevelop,代码行数:8,代码来源:BookmarkActions.cs


示例12: GetPrevOffset

		static int GetPrevOffset (Document document, int lineNumber)
		{
			int startLineNumber = lineNumber - 1;
			if (startLineNumber < 0) 
				startLineNumber =  document.Length - 1;
			var line = document.GetLinesReverseStartingAt (startLineNumber - 1).FirstOrDefault (l => l.IsBookmarked);
			return line != null ? line.Offset : -1;
		}
开发者ID:nieve,项目名称:monodevelop,代码行数:8,代码来源:BookmarkActions.cs


示例13: GetFormatter

		internal static CodeFormatter GetFormatter (out Document doc)
		{
			doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null)
				return null;
			var editor = doc.Editor;
			if (editor == null)
				return null;
			return editor == null ? null : CodeFormatterService.GetFormatter (editor.MimeType);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:10,代码来源:CodeFormattingCommands.cs


示例14: StartsWithListMember

		static int StartsWithListMember (Document document, List<string> list, int offset)
		{
			for (int i = 0; i < list.Count; i++) {
				string item = list[i];
				if (offset + item.Length < document.Length) {
					if (document.GetTextAt (offset, item.Length) == item) 
						return i;
				}
			}
			return -1;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:11,代码来源:IBracketMatcher.cs


示例15: Check

		public static IEnumerable<Result> Check (Document input, CancellationToken cancellationToken)
		{
			if (!QuickTaskStrip.EnableFancyFeatures)
				return Enumerable.Empty<Result> ();

//			var now = DateTime.Now;

			var editor = input.Editor;
			if (editor == null)
				return Enumerable.Empty<Result> ();
			var loc = editor.Caret.Location;
			var result = new BlockingCollection<Result> ();
		
			var codeIssueProvider = RefactoringService.GetInspectors (editor.Document.MimeType).ToArray ();
			var context = input.ParsedDocument.CreateRefactoringContext != null ?
				input.ParsedDocument.CreateRefactoringContext (input, cancellationToken) : null;
//			Console.WriteLine ("start check:"+ (DateTime.Now - now).TotalMilliseconds);
			Parallel.ForEach (codeIssueProvider, (parentProvider) => {
				try {
					foreach (var provider in EnumerateProvider (parentProvider)){
						var severity = provider.GetSeverity ();
						if (severity == Severity.None)
							return;
	//					var now2 = DateTime.Now;
						foreach (var r in provider.GetIssues (context, cancellationToken)) {
							var fixes = new List<GenericFix> (r.Actions.Where (a => a != null).Select (a => 
								new GenericFix (
									a.Title,
									new System.Action (() => a.Run (input, loc))) {
									DocumentRegion = new DocumentRegion (r.Region.Begin, r.Region.End)
							}));
							result.Add (new InspectorResults (
								provider, 
								r.Region, 
								r.Description,
								severity, 
								provider.IssueMarker,
								fixes.ToArray ()
							));
						}
					}
/*					var ms = (DateTime.Now - now2).TotalMilliseconds;
					if (ms > 1000)
						Console.WriteLine (ms +"\t\t"+ provider.Title);*/
				} catch (OperationCanceledException) {
					//ignore
				} catch (Exception e) {
					LoggingService.LogError ("CodeAnalysis: Got exception in inspector '" + parentProvider + "'", e);
				}
			});
//			Console.WriteLine ("END check:"+ (DateTime.Now - now).TotalMilliseconds);
			return result;
		}
开发者ID:OnorioCatenacci,项目名称:monodevelop,代码行数:53,代码来源:CodeAnalysisRunner.cs


示例16: GetPrevOffset

		static int GetPrevOffset (Document document, int lineNumber)
		{
			LineSegment startLine = document.GetLine (lineNumber);
			RedBlackTree<LineSegmentTree.TreeNode>.RedBlackTreeIterator iter = startLine.Iter;
			while (iter.MoveBack ()) {
				LineSegment line = iter.Current;
				if (line.IsBookmarked) {
					return line.Offset;
				}
			}
			return -1;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:12,代码来源:BookmarkActions.cs


示例17: AttachToDocument

        public void AttachToDocument(Document document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            document.Editor.Parent.ButtonReleaseEvent -= this.HandleButtonReleaseEvent;
            document.Editor.Parent.MotionNotifyEvent -= this.HandleMotionNotifyEvent;

            document.Editor.Parent.ButtonReleaseEvent += this.HandleButtonReleaseEvent;
            document.Editor.Parent.MotionNotifyEvent += this.HandleMotionNotifyEvent;
        }
开发者ID:sgmunn,项目名称:MonkeyWrench,代码行数:13,代码来源:ClickToDefinition.cs


示例18: Initialize

		public override void Initialize ()
		{
			base.Initialize ();

			defaultCompletionWidget = CompletionWidget;
			defaultDocument = Document;
			completionBuilder = RazorCompletionBuilderService.GetBuilder ("C#");

			defaultDocument.Editor.Document.TextReplacing += UnderlyingDocument_TextReplacing;
			defaultDocument.Editor.Caret.PositionChanged += delegate
			{
				OnCompletionContextChanged (CompletionWidget, EventArgs.Empty);
			};
		}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:14,代码来源:RazorCSharpEditorExtension.cs


示例19: Analyze

		public override void Analyze (Document doc, LineSegment line, Chunk startChunk, int startOffset, int endOffset)
		{
			if (endOffset <= startOffset || startOffset >= doc.Length)
				return;
			
			string text = doc.GetTextAt (startOffset, endOffset - startOffset);
			int startColumn = startOffset - line.Offset;
			line.RemoveMarker (typeof(UrlMarker));
			foreach (System.Text.RegularExpressions.Match m in urlRegex.Matches (text)) {
				line.AddMarker (new UrlMarker (line, m.Value, UrlType.Url, syntax, startColumn + m.Index, startColumn + m.Index + m.Length));
			}
			foreach (System.Text.RegularExpressions.Match m in mailRegex.Matches (text)) {
				line.AddMarker (new UrlMarker (line, m.Value, UrlType.Email, syntax, startColumn + m.Index, startColumn + m.Index + m.Length));
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:15,代码来源:SemanticRule.cs


示例20: CreateCompletion

		CSharpCompletionTextEditorExtension CreateCompletion (Document realDocument, UnderlyingDocumentInfo docInfo,
			out CodeCompletionContext codeCompletionContext)
		{
			var documentLocation = docInfo.UnderlyingDocument.Editor.OffsetToLocation (docInfo.CaretPosition);

			codeCompletionContext = new CodeCompletionContext () {
				TriggerOffset = docInfo.CaretPosition,
				TriggerLine = documentLocation.Line,
				TriggerLineOffset = documentLocation.Column - 1
			};

			return new CSharpCompletionTextEditorExtension (docInfo.UnderlyingDocument) {
				CompletionWidget = CreateCompletionWidget (realDocument, docInfo)
			};
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:15,代码来源:RazorCSharpCompletionBuilder.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TextEditor.DocumentChangeEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# TextEditor.CodeSegmentPreviewWindow类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap