/// <summary> /// Get hover content for an XML element that does not directly correspond to an <see cref="MSBuildObject"/>. /// </summary> /// <param name="element"> /// The <see cref="XSElement"/>. /// </param> /// <returns> /// The content, or <c>null</c> if no content is provided. /// </returns> public MarkedStringContainer Element(XSElement element) { if (element == null) { throw new ArgumentNullException(nameof(element)); } string elementDescription = MSBuildSchemaHelp.ForElement(element.Name); if (String.IsNullOrWhiteSpace(elementDescription)) { return(null); } List <MarkedString> content = new List <MarkedString> { elementDescription }; string helpLink = MSBuildSchemaHelp.HelpLinkForElement(element.Name); if (!String.IsNullOrWhiteSpace(helpLink)) { content.Add( $"[Help]({helpLink})" ); } return(new MarkedStringContainer(content)); }
/// <summary> /// Get hover content for an <see cref="MSBuildImport"/>. /// </summary> /// <param name="import"> /// The <see cref="MSBuildImport"/>. /// </param> /// <returns> /// The content, or <c>null</c> if no content is provided. /// </returns> public MarkedStringContainer Import(MSBuildImport import) { if (import == null) { throw new ArgumentNullException(nameof(import)); } List <MarkedString> content = new List <MarkedString> { $"Import: `{import.Name}`" }; StringBuilder imports = new StringBuilder("Imports:"); imports.AppendLine(); foreach (string projectFile in import.ImportedProjectFiles) { imports.AppendLine($"* [{Path.GetFileName(projectFile)}]({VSCodeDocumentUri.FromFileSystemPath(projectFile)})"); } content.Add( imports.ToString() ); string helpLink = MSBuildSchemaHelp.HelpLinkForElement(import.Element.Name); if (!String.IsNullOrWhiteSpace(helpLink)) { content.Add( $"[Help]({helpLink})" ); } return(new MarkedStringContainer(content)); }
/// <summary> /// Get hover content for an MSBuild condition. /// </summary> /// <param name="elementName"> /// The name of the element that contains the Condition attribute. /// </param> /// <param name="condition"> /// The raw (unevaluated) condition. /// </param> /// <returns> /// The content, or <c>null</c> if no content is provided. /// </returns> public MarkedStringContainer Condition(string elementName, string condition) { if (String.IsNullOrWhiteSpace(elementName)) { throw new ArgumentException("Argument cannot be null, empty, or entirely composed of whitespace: 'elementName'.", nameof(elementName)); } if (String.IsNullOrWhiteSpace(condition)) { return(null); } string evaluatedCondition = _projectDocument.MSBuildProject.ExpandString(condition); List <MarkedString> content = new List <MarkedString> { "Condition", $"Evaluated: `{evaluatedCondition}`" }; string helpLink = MSBuildSchemaHelp.HelpLinkForElement("*.Condition"); if (!String.IsNullOrWhiteSpace(helpLink)) { content.Add( $"[Help]({helpLink})" ); } return(new MarkedStringContainer(content)); }
/// <summary> /// Get hover content for an <see cref="MSBuildImport"/>. /// </summary> /// <param name="unresolvedImport"> /// The <see cref="MSBuildImport"/>. /// </param> /// <returns> /// The content, or <c>null</c> if no content is provided. /// </returns> public MarkedStringContainer UnresolvedImport(MSBuildUnresolvedImport unresolvedImport) { if (unresolvedImport == null) { throw new ArgumentNullException(nameof(unresolvedImport)); } string condition = unresolvedImport.Condition; string evaluatedCondition = _projectDocument.MSBuildProject.ExpandString(condition); string project = unresolvedImport.Project; string evaluatedProject = _projectDocument.MSBuildProject.ExpandString(project); StringBuilder descriptionContent = new StringBuilder(); descriptionContent.AppendLine( $"Project: `{project}`" ); descriptionContent.AppendLine(); descriptionContent.AppendLine( $"Evaluated Project: `{evaluatedProject}`" ); descriptionContent.AppendLine(); descriptionContent.AppendLine( $"Condition: `{condition}`" ); descriptionContent.AppendLine(); descriptionContent.AppendLine( $"Evaluated Condition: `{evaluatedCondition}`" ); List <MarkedString> content = new List <MarkedString> { "Unresolved Import (condition is false)", descriptionContent.ToString() }; string helpLink = MSBuildSchemaHelp.HelpLinkForElement(unresolvedImport.Element.Name); if (!String.IsNullOrWhiteSpace(helpLink)) { content.Add( $"[Help]({helpLink})" ); } return(new MarkedStringContainer(content)); }
/// <summary> /// Get hover content for an <see cref="MSBuildTarget"/>. /// </summary> /// <param name="target"> /// The <see cref="MSBuildTarget"/>. /// </param> /// <returns> /// The content, or <c>null</c> if no content is provided. /// </returns> public MarkedStringContainer Target(MSBuildTarget target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } List <MarkedString> content = new List <MarkedString> { $"Target: `{target.Name}`" }; string helpLink = MSBuildSchemaHelp.HelpLinkForElement(target.Element.Name); if (!String.IsNullOrWhiteSpace(helpLink)) { content.Add( $"[Help]({helpLink})" ); } return(new MarkedStringContainer(content)); }