當前位置: 首頁>>代碼示例>>C#>>正文


C# TextEditorData.OpenStream方法代碼示例

本文整理匯總了C#中Mono.TextEditor.TextEditorData.OpenStream方法的典型用法代碼示例。如果您正苦於以下問題:C# TextEditorData.OpenStream方法的具體用法?C# TextEditorData.OpenStream怎麽用?C# TextEditorData.OpenStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.TextEditor.TextEditorData的用法示例。


在下文中一共展示了TextEditorData.OpenStream方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FormatText

        /// <summary>
        /// Used for formatting the entire document
        /// </summary>
        public override string FormatText(PolicyContainer policyParent, IEnumerable<string> mimeTypeChain, string input, int startOffset, int endOffset)
        {
            var policy = policyParent.Get<DFormattingPolicy> (mimeTypeChain);
            var textPolicy = policyParent.Get<TextStylePolicy> (mimeTypeChain);
            var data = new TextEditorData{ Text = input };

            if(IndentCorrectionOnly)
            {
                using(var s = data.OpenStream())
                    using(var r = new StreamReader(s))
                        D_Parser.Formatting.Indent.IndentEngineWrapper.CorrectIndent(r, startOffset, endOffset, data.Document.Replace, policy.Options, new TextStyleAdapter(textPolicy));
                return data.Text;
            }

            var ast = DParser.ParseString(input, false, true) as DModule;
            var formattingVisitor = new DFormattingVisitor(policy.Options, new DocAdapt(data.Document), ast, new TextStyleAdapter(textPolicy));

            // Only clip to a region if it's necessary
            if(startOffset > 0 || endOffset < input.Length-1)
            {
                formattingVisitor.CheckFormattingBoundaries = true;
                var dl = data.Document.OffsetToLocation(startOffset);
                formattingVisitor.FormattingStartLocation = new D_Parser.Dom.CodeLocation(dl.Column, dl.Line);
                dl = data.Document.OffsetToLocation(endOffset);
                formattingVisitor.FormattingEndLocation = new D_Parser.Dom.CodeLocation(dl.Column, dl.Line);
            }

            formattingVisitor.WalkThroughAst();

            formattingVisitor.ApplyChanges(data.Document.Replace);

            return data.Text;
        }
開發者ID:rikkimax,項目名稱:Mono-D,代碼行數:36,代碼來源:DCodeFormatter.cs

示例2: ParseSnippet

		public static AstNode ParseSnippet (this ICSharpCode.NRefactory.CSharp.CSharpParser parser, TextEditorData data)
		{
			using (var stream = new  StreamReader (data.OpenStream ())) {
				var result = parser.ParseExpression (stream);
				if (!parser.HasErrors)
					return result;
			}
			parser.ErrorPrinter.Reset ();
			using (var stream = new  StreamReader (data.OpenStream ())) {
				var result = parser.ParseStatements (stream);
				if (!parser.HasErrors)
					return result.FirstOrDefault ();
			}
			parser.ErrorPrinter.Reset ();
			using (var stream = data.OpenStream ()) {
				return parser.Parse (stream, data.Document.FileName);
			}
		}
開發者ID:head-thrash,項目名稱:monodevelop,代碼行數:18,代碼來源:HelperMethods.cs

示例3: Parse

		public MonoDevelop.CSharp.Dom.CompilationUnit Parse (TextEditorData data)
		{
			lock (CompilerCallableEntryPoint.parseLock) {
				CompilerCompilationUnit top;
				using (Stream stream = data.OpenStream ()) {
					top = CompilerCallableEntryPoint.ParseFile (new string[] { "-v", "-unsafe"}, stream, data.Document.FileName, Console.Out);
				}
	
				if (top == null)
					return null;
				CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (top.LocationsBag);
				top.UsingsBag.Global.Accept (conversionVisitor);
				return conversionVisitor.Unit;
			}
		}
開發者ID:pgoron,項目名稱:monodevelop,代碼行數:15,代碼來源:CSharpParser.cs

示例4: Parse

		public static ICSharpCode.NRefactory.CSharp.SyntaxTree Parse (this ICSharpCode.NRefactory.CSharp.CSharpParser parser, TextEditorData data)
		{
			using (var stream = data.OpenStream ()) {
				return parser.Parse (stream, data.Document.FileName);
			}
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:6,代碼來源:HelperMethods.cs

示例5: Parse

		public MonoDevelop.CSharp.Ast.CompilationUnit Parse (TextEditorData data)
		{
			lock (CompilerCallableEntryPoint.parseLock) {
				CompilerCompilationUnit top;
				using (Stream stream = data.OpenStream ()) {
					top = CompilerCallableEntryPoint.ParseFile (new string[] { "-v", "-unsafe"}, stream, data.Document.FileName ?? "empty.cs", Console.Out);
				}
	
				return Parse (top);
			}
		}
開發者ID:tech-uday-mca,項目名稱:monodevelop,代碼行數:11,代碼來源:CSharpParser.cs

示例6: Parse

		public MonoDevelop.CSharp.Dom.CompilationUnit Parse (TextEditorData data)
		{
			lock (CompilerCallableEntryPoint.parseLock) {
				CompilerCompilationUnit top;
				using (Stream stream = data.OpenStream ()) {
					top = CompilerCallableEntryPoint.ParseFile (new string[] { "-v", "-unsafe"}, stream, data.Document.FileName ?? "empty.cs", Console.Out);
				}
	
				if (top == null)
					return null;
				CSharpParser.ConversionVisitor conversionVisitor = new ConversionVisitor (top.LocationsBag);
				top.UsingsBag.Global.Accept (conversionVisitor);
				
				foreach (var special in top.SpecialsBag.Specials) {
					var comment = special as SpecialsBag.Comment;
					
					if (comment != null) {
						var type  = (MonoDevelop.CSharp.Dom.CommentType)comment.CommentType;
						var start =  new DomLocation (comment.Line, comment.Col);
						var end =  new DomLocation (comment.EndLine, comment.EndCol);
						var domComment = new MonoDevelop.CSharp.Dom.Comment (type, start, end);
						domComment.StartsLine = comment.StartsLine;
						domComment.Content = comment.Content;
						InsertComment (conversionVisitor.Unit, domComment);
					}
				}
				
				return conversionVisitor.Unit;
			}
		}
開發者ID:nickname100,項目名稱:monodevelop,代碼行數:30,代碼來源:CSharpParser.cs

示例7: Parse

		public static ICSharpCode.NRefactory.CSharp.CompilationUnit Parse (this ICSharpCode.NRefactory.CSharp.CSharpParser parser, TextEditorData data)
		{
			using (var stream = data.OpenStream ()) {
				return parser.Parse (stream);
			}
		}
開發者ID:nieve,項目名稱:monodevelop,代碼行數:6,代碼來源:HelperMethods.cs

示例8: Parse

 public static SyntaxTree Parse(this BVE5Language.Parser.BVE5RouteFileParser parser, TextEditorData editorData)
 {
     using(var stream = editorData.OpenStream()){
         return parser.Parse(stream, editorData.Document.FileName);
     }
 }
開發者ID:hazama-yuinyan,項目名稱:monodevelop-bvebinding,代碼行數:6,代碼來源:HelperMethods.cs


注:本文中的Mono.TextEditor.TextEditorData.OpenStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。