public override Evaluation VisitXmlNameAttribute(XmlNameAttributeSyntax node) { node.Name?.Accept <Evaluation>(this); node.Identifier?.Accept <Evaluation>(this); return(base.VisitXmlNameAttribute(node)); }
public override void VisitXmlNameAttribute(XmlNameAttributeSyntax node) { node.Name?.Accept(this); node.Identifier?.Accept(this); base.VisitXmlNameAttribute(node); }
public override SyntaxNode VisitXmlNameAttribute(XmlNameAttributeSyntax node) { _cancellationToken.ThrowIfCancellationRequested(); var newNode = (XmlNameAttributeSyntax)base.VisitXmlNameAttribute(node); return(node.CopyAnnotationsTo(newNode)); }
private void FormatTagNameAttribute(XmlNameAttributeSyntax node) { EnqueueTrailingTriviaChange(node.StartQuoteToken, string.Empty); EnqueueLeadingTriviaChange(node.Identifier, string.Empty); AddWord(node.Identifier.Span); EnqueueTrailingTriviaChange(node.Identifier, string.Empty); EnqueueLeadingTriviaChange(node.EndQuoteToken, string.Empty); }
public override SyntaxNode VisitXmlNameAttribute(XmlNameAttributeSyntax node) { node = (XmlNameAttributeSyntax)base.VisitXmlNameAttribute(node); if (((XmlElementStartTagSyntax)node.Parent).Name.LocalName.ToString() == "param" && node.Identifier.ToString() == _callSettingsParameterSyntax.Identifier.ToString()) { // Replace the parameter doc comment name attribute with the name of the new parameter. node = node.WithIdentifier(IdentifierName(CancellationTokenParameterName)); } return(node); }
public override void VisitXmlNameAttribute(XmlNameAttributeSyntax node) { if (!PreVisit(node)) { return; } node.Name?.Accept(this); node.Identifier?.Accept(this); base.VisitXmlNameAttribute(node); PostVisit(node); }
internal ImmutableArray <Symbol> BindXmlNameAttribute( XmlNameAttributeSyntax syntax, ref CompoundUseSiteInfo <AssemblySymbol> useSiteInfo ) { var identifier = syntax.Identifier; if (identifier.IsMissing) { return(ImmutableArray <Symbol> .Empty); } var name = identifier.Identifier.ValueText; var lookupResult = LookupResult.GetInstance(); this.LookupSymbolsWithFallback( lookupResult, name, arity: 0, useSiteInfo: ref useSiteInfo ); if (lookupResult.Kind == LookupResultKind.Empty) { lookupResult.Free(); return(ImmutableArray <Symbol> .Empty); } // If we found something, it must be viable, since only parameters or type parameters // of the current member are considered. Debug.Assert(lookupResult.IsMultiViable); ArrayBuilder <Symbol> lookupSymbols = lookupResult.Symbols; Debug.Assert( lookupSymbols[0].Kind == SymbolKind.TypeParameter || lookupSymbols[0].Kind == SymbolKind.Parameter ); Debug.Assert(lookupSymbols.All(sym => sym.Kind == lookupSymbols[0].Kind)); // We can sort later when we disambiguate. ImmutableArray <Symbol> result = lookupSymbols.ToImmutable(); lookupResult.Free(); return(result); }
private bool IsNameAttribute(XmlNameAttributeSyntax xmlNameAttribute, string name) { var parent = xmlNameAttribute.Parent as XmlElementStartTagSyntax; if (parent == null) { return(false); } if (parent.Name.ToString().Equals(name)) { return(true); } return(false); }
internal static XmlNameAttributeElementKind GetElementKind(this XmlNameAttributeSyntax attributeSyntax) { Debug.Assert(attributeSyntax.Parent is object); CSharpSyntaxNode parentSyntax = attributeSyntax.Parent; SyntaxKind parentKind = parentSyntax.Kind(); string parentName; if (parentKind == SyntaxKind.XmlEmptyElement) { var parent = (XmlEmptyElementSyntax)parentSyntax; parentName = parent.Name.LocalName.ValueText; Debug.Assert(parent.Name.Prefix is null); } else if (parentKind == SyntaxKind.XmlElementStartTag) { var parent = (XmlElementStartTagSyntax)parentSyntax; parentName = parent.Name.LocalName.ValueText; Debug.Assert(parent.Name.Prefix is null); } else { throw ExceptionUtilities.UnexpectedValue(parentKind); } if (DocumentationCommentXmlNames.ElementEquals(parentName, DocumentationCommentXmlNames.ParameterElementName)) { return(XmlNameAttributeElementKind.Parameter); } else if (DocumentationCommentXmlNames.ElementEquals(parentName, DocumentationCommentXmlNames.ParameterReferenceElementName)) { return(XmlNameAttributeElementKind.ParameterReference); } else if (DocumentationCommentXmlNames.ElementEquals(parentName, DocumentationCommentXmlNames.TypeParameterElementName)) { return(XmlNameAttributeElementKind.TypeParameter); } else if (DocumentationCommentXmlNames.ElementEquals(parentName, DocumentationCommentXmlNames.TypeParameterReferenceElementName)) { return(XmlNameAttributeElementKind.TypeParameterReference); } else { throw ExceptionUtilities.UnexpectedValue(parentName); } }
private void BindName( XAttribute attribute, CSharpSyntaxNode originatingSyntax, bool isParameter, bool isTypeParameterRef ) { XmlNameAttributeSyntax attrSyntax = ParseNameAttribute( attribute.ToString(), attribute.Parent.Name.LocalName ); // CONSIDER: It would be easy to construct an XmlLocation from the XAttribute, so that // we could point the user at the actual problem. Location sourceLocation = originatingSyntax.Location; RecordSyntaxDiagnostics(attrSyntax, sourceLocation); // Respects DocumentationMode. MemberDeclarationSyntax memberDeclSyntax = BinderFactory.GetAssociatedMemberForXmlSyntax(originatingSyntax); Debug.Assert( memberDeclSyntax != null, "Why are we processing a documentation comment that is not attached to a member declaration?" ); var nameDiagnostics = BindingDiagnosticBag.GetInstance(_diagnostics); Binder binder = MakeNameBinder( isParameter, isTypeParameterRef, _memberSymbol, _compilation ); DocumentationCommentCompiler.BindName( attrSyntax, binder, _memberSymbol, ref _documentedParameters, ref _documentedTypeParameters, nameDiagnostics ); RecordBindingDiagnostics(nameDiagnostics, sourceLocation); // Respects DocumentationMode. nameDiagnostics.Free(); }
/// <summary> /// Creates parameter element syntax. /// </summary> /// <param name="parameterName">The parameter name.</param> /// <param name="parameterContent">The parameter content.</param> /// <returns>A XmlElementSyntax.</returns> private static XmlElementSyntax CreateParameterElementSyntax(string parameterName, string parameterContent) { XmlNameSyntax paramName = SyntaxFactory.XmlName("param"); /// <param name="parameterName">[0][1]</param>[2] // [0] -- param start tag with attribute XmlNameAttributeSyntax paramAttribute = SyntaxFactory.XmlNameAttribute(parameterName); XmlElementStartTagSyntax startTag = SyntaxFactory.XmlElementStartTag(paramName, SyntaxFactory.SingletonList <XmlAttributeSyntax>(paramAttribute)); // [1] -- content XmlTextSyntax content = SyntaxFactory.XmlText(parameterContent); // [2] -- end tag XmlElementEndTagSyntax endTag = SyntaxFactory.XmlElementEndTag(paramName); return(SyntaxFactory.XmlElement(startTag, SyntaxFactory.SingletonList <SyntaxNode>(content), endTag)); }
/// <summary> /// Checks param element. /// </summary> /// <param name="xmlElement">XML element.</param> /// <param name="location">Location.</param> /// <param name="message">Message.</param> /// <param name="paramCommentNameList">Parameter comment name list.</param> /// <returns>True if there is no error.</returns> private static bool CheckParamElement(XmlElementSyntax xmlElement, ref Location location, ref string message, ref List <string> paramCommentNameList) { // Check tags if (!BTAnalyzer.CheckXmlTags(xmlElement, ref location, ref message)) { return(false); } // Set location location = xmlElement.StartTag.GetLocation(); Position position = Position.Origin; // Add param name to the list XmlNameAttributeSyntax xmlNameAttribute = xmlElement.StartTag.Attributes.Where(attr => SyntaxKind.XmlNameAttribute == attr.Kind()).FirstOrDefault() as XmlNameAttributeSyntax; if (null == xmlNameAttribute) { message = ErrorCode.MissingNameAttribute; return(false); } paramCommentNameList.Add(xmlNameAttribute.Identifier.ToString()); // Remove <see cref .. /> elements, remove start and end tags // Check XML element text string text = xmlElement.ToString().Replace(xmlElement.StartTag.ToString(), String.Empty).Replace(xmlElement.EndTag.ToString(), String.Empty).TrimStart('/'); foreach (StringValidator.Validate validate in BTAnalyzer.ParamTextValidators) { if (!validate(text, ref message, ref position)) { location = BTAnalyzer.GetLocation(xmlElement.SyntaxTree, location, position, xmlElement.StartTag.ToString().Length); return(false); } } // Return true return(true); }
// Diagnostics are generated in a separate pass when we emit. internal ImmutableArray<Symbol> BindXmlNameAttribute(XmlNameAttributeSyntax syntax, ref HashSet<DiagnosticInfo> useSiteDiagnostics) { var identifier = syntax.Identifier; if (identifier.IsMissing) { return ImmutableArray<Symbol>.Empty; } var name = identifier.Identifier.ValueText; var lookupResult = LookupResult.GetInstance(); this.LookupSymbolsWithFallback(lookupResult, name, arity: 0, useSiteDiagnostics: ref useSiteDiagnostics); if (lookupResult.Kind == LookupResultKind.Empty) { lookupResult.Free(); return ImmutableArray<Symbol>.Empty; } // If we found something, it must be viable, since only parameters or type parameters // of the current member are considered. Debug.Assert(lookupResult.IsMultiViable); ArrayBuilder<Symbol> lookupSymbols = lookupResult.Symbols; Debug.Assert(lookupSymbols[0].Kind == SymbolKind.TypeParameter || lookupSymbols[0].Kind == SymbolKind.Parameter); Debug.Assert(lookupSymbols.All(sym => sym.Kind == lookupSymbols[0].Kind)); // We can sort later when we disambiguate. ImmutableArray<Symbol> result = lookupSymbols.ToImmutable(); lookupResult.Free(); return result; }
public override SyntaxNode VisitXmlNameAttribute(XmlNameAttributeSyntax node) { node = (XmlNameAttributeSyntax)base.VisitXmlNameAttribute(node); Classes.Add(node); return(node); }
public override void VisitXmlNameAttribute(XmlNameAttributeSyntax node) { Debug.Fail(node.ToString()); base.VisitXmlNameAttribute(node); }
public override SyntaxNode VisitXmlNameAttribute(XmlNameAttributeSyntax node) { _cancellationToken.ThrowIfCancellationRequested(); var newNode = (XmlNameAttributeSyntax)base.VisitXmlNameAttribute(node); return node.CopyAnnotationsTo(newNode); }
public TameXmlNameAttributeSyntax(XmlNameAttributeSyntax node) { Node = node; AddChildren(); }
/// <summary> /// Bind an XmlNameAttributeSyntax and update the sets of documented parameters and type parameters. /// </summary> /// <remarks> /// Does not respect DocumentationMode, so do not call unless diagnostics are desired. /// </remarks> private static void BindName( XmlNameAttributeSyntax syntax, Binder binder, Symbol memberSymbol, ref HashSet<ParameterSymbol> documentedParameters, ref HashSet<TypeParameterSymbol> documentedTypeParameters, DiagnosticBag diagnostics) { XmlNameAttributeElementKind elementKind = syntax.GetElementKind(); // NOTE: We want the corresponding hash set to be non-null if we saw // any <param>/<typeparam> elements, even if they didn't bind (for // WRN_MissingParamTag and WRN_MissingTypeParamTag). if (elementKind == XmlNameAttributeElementKind.Parameter) { if (documentedParameters == null) { documentedParameters = new HashSet<ParameterSymbol>(); } } else if (elementKind == XmlNameAttributeElementKind.TypeParameter) { if (documentedTypeParameters == null) { documentedTypeParameters = new HashSet<TypeParameterSymbol>(); } } IdentifierNameSyntax identifier = syntax.Identifier; if (identifier.ContainsDiagnostics) { return; } HashSet<DiagnosticInfo> useSiteDiagnostics = null; ImmutableArray<Symbol> referencedSymbols = binder.BindXmlNameAttribute(syntax, ref useSiteDiagnostics); diagnostics.Add(syntax, useSiteDiagnostics); if (referencedSymbols.IsEmpty) { switch (elementKind) { case XmlNameAttributeElementKind.Parameter: diagnostics.Add(ErrorCode.WRN_UnmatchedParamTag, identifier.Location, identifier); break; case XmlNameAttributeElementKind.ParameterReference: diagnostics.Add(ErrorCode.WRN_UnmatchedParamRefTag, identifier.Location, identifier, memberSymbol); break; case XmlNameAttributeElementKind.TypeParameter: diagnostics.Add(ErrorCode.WRN_UnmatchedTypeParamTag, identifier.Location, identifier); break; case XmlNameAttributeElementKind.TypeParameterReference: diagnostics.Add(ErrorCode.WRN_UnmatchedTypeParamRefTag, identifier.Location, identifier, memberSymbol); break; default: Debug.Assert(false, "Unknown element kind " + syntax.GetElementKind()); break; } } else { foreach (Symbol referencedSymbol in referencedSymbols) { if (elementKind == XmlNameAttributeElementKind.Parameter) { Debug.Assert(referencedSymbol.Kind == SymbolKind.Parameter); Debug.Assert(documentedParameters != null); // Restriction preserved from dev11: don't report this for the "value" parameter. // Here, we detect that case by checking the containing symbol - only "value" // parameters are contained by accessors, others are on the corresponding property/event. ParameterSymbol parameter = (ParameterSymbol)referencedSymbol; if (!parameter.ContainingSymbol.IsAccessor() && !documentedParameters.Add(parameter)) { diagnostics.Add(ErrorCode.WRN_DuplicateParamTag, syntax.Location, identifier); } } else if (elementKind == XmlNameAttributeElementKind.TypeParameter) { Debug.Assert(referencedSymbol.Kind == SymbolKind.TypeParameter); Debug.Assert(documentedTypeParameters != null); if (!documentedTypeParameters.Add((TypeParameterSymbol)referencedSymbol)) { diagnostics.Add(ErrorCode.WRN_DuplicateTypeParamTag, syntax.Location, identifier); } } } } }
public override void DefaultVisit(SyntaxNode node) { SyntaxKind nodeKind = node.Kind(); bool diagnose = node.SyntaxTree.ReportDocumentationCommentDiagnostics(); if (nodeKind == SyntaxKind.XmlCrefAttribute) { XmlCrefAttributeSyntax crefAttr = (XmlCrefAttributeSyntax)node; CrefSyntax cref = crefAttr.Cref; BinderFactory factory = _compilation.GetBinderFactory(cref.SyntaxTree); Binder binder = factory.GetBinder(cref); // Do this for the diagnostics, even if it won't be written. DiagnosticBag crefDiagnostics = DiagnosticBag.GetInstance(); string docCommentId = GetDocumentationCommentId(cref, binder, crefDiagnostics); if (diagnose) { _diagnostics.AddRange(crefDiagnostics); } crefDiagnostics.Free(); if (_writer != null) { Visit(crefAttr.Name); VisitToken(crefAttr.EqualsToken); // Not going to visit normally, because we want to skip trivia within // the attribute value. crefAttr.StartQuoteToken.WriteTo(_writer, leading: true, trailing: false); // We're not going to visit the cref because we want to bind it // and write a doc comment ID in its place. _writer.Write(docCommentId); // Not going to visit normally, because we want to skip trivia within // the attribute value. crefAttr.EndQuoteToken.WriteTo(_writer, leading: false, trailing: true); } // Don't descend - we've already written out everything necessary. return; } else if (diagnose && nodeKind == SyntaxKind.XmlNameAttribute) { XmlNameAttributeSyntax nameAttr = (XmlNameAttributeSyntax)node; BinderFactory factory = _compilation.GetBinderFactory(nameAttr.SyntaxTree); Binder binder = factory.GetBinder(nameAttr, nameAttr.Identifier.SpanStart); // Do this for diagnostics, even if we aren't writing. BindName(nameAttr, binder, _memberSymbol, ref _documentedParameters, ref _documentedTypeParameters, _diagnostics); // Do descend - we still need to write out the tokens of the attribute. } // NOTE: if we're recording any include element nodes (i.e. if includeElementsNodes is non-null), // then we want to record all of them, because we won't be able to distinguish in the XML DOM. if (_includeElementNodes != null) { XmlNameSyntax nameSyntax = null; if (nodeKind == SyntaxKind.XmlEmptyElement) { nameSyntax = ((XmlEmptyElementSyntax)node).Name; } else if (nodeKind == SyntaxKind.XmlElementStartTag) { nameSyntax = ((XmlElementStartTagSyntax)node).Name; } if (nameSyntax != null && nameSyntax.Prefix == null && DocumentationCommentXmlNames.ElementEquals(nameSyntax.LocalName.ValueText, DocumentationCommentXmlNames.IncludeElementName)) { _includeElementNodes.Add((CSharpSyntaxNode)node); } } base.DefaultVisit(node); }
public override void VisitXmlNameAttribute(XmlNameAttributeSyntax node) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="node"></param> public override sealed void VisitXmlNameAttribute(XmlNameAttributeSyntax node) { this.OnNodeVisited(node, this.type.IsInstanceOfType(node)); base.VisitXmlNameAttribute(node); }
public override void VisitXmlNameAttribute(XmlNameAttributeSyntax node) { }
// // Summary: // Called when the visitor visits a XmlNameAttributeSyntax node. public virtual void VisitXmlNameAttribute(XmlNameAttributeSyntax node);
/// <summary> /// /// </summary> /// <param name="node"></param> public override sealed void VisitXmlNameAttribute(XmlNameAttributeSyntax node) { this.OnNodeVisited(node); if (!this.traverseRootOnly) base.VisitXmlNameAttribute(node); }
public override SyntaxNode VisitXmlNameAttribute(XmlNameAttributeSyntax node) => Expand(node);