本文整理汇总了C#中SyntaxTree.AcceptVisitor方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTree.AcceptVisitor方法的具体用法?C# SyntaxTree.AcceptVisitor怎么用?C# SyntaxTree.AcceptVisitor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree.AcceptVisitor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateText
public static string GenerateText(TypeDeclaration type,
OrderedPartCollection<AbstractDynamicCompilationExtension> extensions,
HashSet<string> namespaces = null)
{
var unit = new SyntaxTree();
if (namespaces == null)
{
namespaces = new HashSet<string>
{
typeof (SystemTime).Namespace,
typeof (AbstractViewGenerator).Namespace,
typeof (Enumerable).Namespace,
typeof (IEnumerable<>).Namespace,
typeof (IEnumerable).Namespace,
typeof (int).Namespace,
typeof (LinqOnDynamic).Namespace,
typeof (Field).Namespace,
typeof (CultureInfo).Namespace,
typeof (Regex).Namespace
};
}
foreach (var extension in extensions)
{
foreach (var ns in extension.Value.GetNamespacesToImport())
{
namespaces.Add(ns);
}
}
foreach (var ns in namespaces)
{
unit.Members.Add(new UsingDeclaration(ns));
}
unit.Members.Add(new WindowsNewLine());
unit.Members.Add(type);
var stringWriter = new StringWriter();
var output = new CSharpOutputVisitor(stringWriter, FormattingOptionsFactory.CreateSharpDevelop());
unit.AcceptVisitor(output);
return stringWriter.GetStringBuilder().ToString();
}
示例2: AnalyzeFormatting
/// <summary>
/// Analyzes the formatting of a given document and syntax tree.
/// </summary>
/// <param name="document">Document.</param>
/// <param name="syntaxTree">Syntax tree.</param>
/// <param name="token">The cancellation token.</param>
public FormattingChanges AnalyzeFormatting(IDocument document, SyntaxTree syntaxTree, CancellationToken token = default (CancellationToken))
{
if (document == null)
throw new ArgumentNullException("document");
if (syntaxTree == null)
throw new ArgumentNullException("syntaxTree");
var result = new FormattingChanges(document);
var visitor = new FormattingVisitor(this, document, result, token);
syntaxTree.AcceptVisitor(visitor);
return result;
}
示例3: ProcessAndReturnTrueIfEverythingIsSupported
public bool ProcessAndReturnTrueIfEverythingIsSupported(SyntaxTree syntaxTree)
{
_result = true;
syntaxTree.AcceptVisitor(this);
return _result;
}
示例4: CreateNewFoldings
List<NewFolding> CreateNewFoldings(SyntaxTree syntaxTree, IDocument document)
{
FoldingVisitor v = new FoldingVisitor();
v.document = document;
syntaxTree.AcceptVisitor(v);
return v.foldings;
}
示例5: Gather
public static ISet<string> Gather(SyntaxTree syntaxTree, IEnumerable<string> predefinedSymbols)
{
var obj = new DefinedSymbolsGatherer(predefinedSymbols);
syntaxTree.AcceptVisitor(obj);
return obj._definedSymbols;
}