本文整理汇总了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;
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}