当前位置: 首页>>代码示例>>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;未经允许,请勿转载。