本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.CSharpParser.ParseSnippet方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpParser.ParseSnippet方法的具体用法?C# CSharpParser.ParseSnippet怎么用?C# CSharpParser.ParseSnippet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.NRefactory.CSharp.CSharpParser
的用法示例。
在下文中一共展示了CSharpParser.ParseSnippet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHighlighted
private string GetHighlighted()
{
var parser = new CSharpParser();
var nodes = parser.ParseSnippet(ref SourceCode);
Document = new ReadOnlyDocument(SourceCode);
foreach (var element in nodes)
{
Walk(element);
}
var merged = Merge();
var cleaned = ExtraCode.Remove(merged);
return cleaned;
}
示例2: OnTheFlyFormat
public override void OnTheFlyFormat (PolicyContainer policyParent, IEnumerable<string> mimeTypeChain,
TextEditorData data, int startOffset, int endOffset)
{
var parser = new CSharpParser ();
var compilationUnit = parser.ParseSnippet (data);
if (compilationUnit == null) {
Console.WriteLine ("couldn't parse : " + data.Text);
return;
}
if (parser.HasErrors)
return;
var policy = policyParent.Get<CSharpFormattingPolicy> (mimeTypeChain);
var adapter = new TextEditorDataAdapter (data);
var formattingVisitor = new ICSharpCode.NRefactory.CSharp.AstFormattingVisitor (policy.CreateOptions (), adapter, new FormattingActionFactory (data)) {
HadErrors = parser.HasErrors
};
var changes = new List<ICSharpCode.NRefactory.CSharp.Refactoring.Action> ();
changes.AddRange (formattingVisitor.Changes.
Where (c => (startOffset <= c.Offset && c.Offset < endOffset)));
using (var undo = data.OpenUndoGroup ()) {
MDRefactoringContext.MdScript.RunActions (changes, null);
}
}
示例3: ParseText
public AstNode ParseText (string text)
{
using (TextEditorData data = new TextEditorData()) {
data.Text = text;
var parser = new CSharpParser ();
return parser.ParseSnippet (data);
}
}