OpenStream() public method

public OpenStream ( ) : Stream
return Stream
コード例 #1
1
ファイル: DCodeFormatter.cs プロジェクト: rikkimax/Mono-D
        /// <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;
        }
コード例 #2
0
		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);
			}
		}
コード例 #3
0
ファイル: CSharpParser.cs プロジェクト: pgoron/monodevelop
		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;
			}
		}
コード例 #4
0
ファイル: HelperMethods.cs プロジェクト: Kalnor/monodevelop
		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);
			}
		}
コード例 #5
0
		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);
			}
		}
コード例 #6
0
		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;
			}
		}
コード例 #7
0
ファイル: HelperMethods.cs プロジェクト: nieve/monodevelop
		public static ICSharpCode.NRefactory.CSharp.CompilationUnit Parse (this ICSharpCode.NRefactory.CSharp.CSharpParser parser, TextEditorData data)
		{
			using (var stream = data.OpenStream ()) {
				return parser.Parse (stream);
			}
		}
コード例 #8
0
 public static SyntaxTree Parse(this BVE5Language.Parser.BVE5RouteFileParser parser, TextEditorData editorData)
 {
     using(var stream = editorData.OpenStream()){
         return parser.Parse(stream, editorData.Document.FileName);
     }
 }