本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbol.IsDefinedInSourceTree方法的典型用法代码示例。如果您正苦于以下问题:C# Symbol.IsDefinedInSourceTree方法的具体用法?C# Symbol.IsDefinedInSourceTree怎么用?C# Symbol.IsDefinedInSourceTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbol
的用法示例。
在下文中一共展示了Symbol.IsDefinedInSourceTree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefaultVisit
/// <summary>
/// Compile documentation comments on the symbol and write them to the stream if one is provided.
/// </summary>
public override void DefaultVisit(Symbol symbol)
{
_cancellationToken.ThrowIfCancellationRequested();
if (symbol.IsImplicitlyDeclared || symbol.IsAccessor())
{
return;
}
if (_filterTree != null && !symbol.IsDefinedInSourceTree(_filterTree, _filterSpanWithinTree))
{
return;
}
bool isPartialMethodDefinitionPart = symbol.IsPartialDefinition(); // CONSIDER: ignore this if isForSingleSymbol?
if (isPartialMethodDefinitionPart)
{
MethodSymbol implementationPart = ((MethodSymbol)symbol).PartialImplementationPart;
if ((object)implementationPart != null)
{
Visit(implementationPart);
}
}
DocumentationMode maxDocumentationMode;
ImmutableArray<DocumentationCommentTriviaSyntax> docCommentNodes;
if (!TryGetDocumentationCommentNodes(symbol, out maxDocumentationMode, out docCommentNodes))
{
// If the XML in any of the doc comments is invalid, skip all further processing (for this symbol) and
// just write a comment saying that info was lost for this symbol.
string message = ErrorFacts.GetMessage(MessageID.IDS_XMLIGNORED, CultureInfo.CurrentUICulture);
WriteLine(string.Format(CultureInfo.CurrentUICulture, message, symbol.GetDocumentationCommentId()));
return;
}
// If there are no doc comments, then no further work is required (other than to report a diagnostic if one is required).
if (docCommentNodes.IsEmpty)
{
if (maxDocumentationMode >= DocumentationMode.Diagnose && RequiresDocumentationComment(symbol))
{
// Report the error at a location in the tree that was parsing doc comments.
Location location = GetLocationInTreeReportingDocumentationCommentDiagnostics(symbol);
if (location != null)
{
_diagnostics.Add(ErrorCode.WRN_MissingXMLComment, location, symbol);
}
}
return;
}
_cancellationToken.ThrowIfCancellationRequested();
bool reportParameterOrTypeParameterDiagnostics = GetLocationInTreeReportingDocumentationCommentDiagnostics(symbol) != null;
string withUnprocessedIncludes;
bool haveParseError;
HashSet<TypeParameterSymbol> documentedTypeParameters;
HashSet<ParameterSymbol> documentedParameters;
ImmutableArray<CSharpSyntaxNode> includeElementNodes;
if (!TryProcessDocumentationCommentTriviaNodes(
symbol,
isPartialMethodDefinitionPart,
docCommentNodes,
reportParameterOrTypeParameterDiagnostics,
out withUnprocessedIncludes,
out haveParseError,
out documentedTypeParameters,
out documentedParameters,
out includeElementNodes))
{
return;
}
if (haveParseError)
{
// If the XML in any of the doc comments is invalid, skip all further processing (for this symbol) and
// just write a comment saying that info was lost for this symbol.
string message = ErrorFacts.GetMessage(MessageID.IDS_XMLIGNORED, CultureInfo.CurrentUICulture);
WriteLine(string.Format(CultureInfo.CurrentUICulture, message, symbol.GetDocumentationCommentId()));
return;
}
// If there are no include elements, then there's nothing to expand.
if (!includeElementNodes.IsDefaultOrEmpty)
{
_cancellationToken.ThrowIfCancellationRequested();
// NOTE: we are expanding include elements AFTER formatting the comment, since the included text is pure
// XML, not XML mixed with documentation comment trivia (e.g. ///). If we expanded them before formatting,
// the formatting engine would have trouble determining what prefix to remove from each line.
TextWriter expanderWriter = isPartialMethodDefinitionPart ? null : _writer; // Don't actually write partial method definition parts.
IncludeElementExpander.ProcessIncludes(withUnprocessedIncludes, symbol, includeElementNodes,
_compilation, ref documentedParameters, ref documentedTypeParameters, ref _includedFileCache, expanderWriter, _diagnostics, _cancellationToken);
}
else if (_writer != null && !isPartialMethodDefinitionPart)
{
// CONSIDER: The output would look a little different if we ran the XDocument through an XmlWriter. In particular,
//.........这里部分代码省略.........
示例2: IsSyntacticallyFilteredOut
private bool IsSyntacticallyFilteredOut(Symbol symbol)
{
// TODO: it would be nice to be more precise than this: we only want to
// warn about the base class if it is listed in the filter tree, not if
// any part of the type is in the filter tree.
return _filterTree != null && !symbol.IsDefinedInSourceTree(_filterTree, _filterSpanWithinTree);
}