/// <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 top-level element completions. /// </summary> /// <param name="replaceRange"> /// The range of text to be replaced by the completions. /// </param> /// <returns> /// A sequence of <see cref="CompletionItem"/>s. /// </returns> public IEnumerable <CompletionItem> GetCompletionItems(Range replaceRange) { if (replaceRange == null) { throw new ArgumentNullException(nameof(replaceRange)); } LspModels.Range completionRange = replaceRange.ToLsp(); // <PropertyGroup> // $0 // </PropertyGroup> yield return(new CompletionItem { Label = "<PropertyGroup>", Detail = "Element", Documentation = MSBuildSchemaHelp.ForElement("PropertyGroup"), SortText = Priority + "<PropertyGroup>", TextEdit = new TextEdit { NewText = "<PropertyGroup>\n\t$0\n</PropertyGroup>", Range = completionRange }, InsertTextFormat = InsertTextFormat.Snippet }); // <ItemGroup> // $0 // </ItemGroup> yield return(new CompletionItem { Label = "<ItemGroup>", Detail = "Element", Documentation = MSBuildSchemaHelp.ForElement("ItemGroup"), SortText = Priority + "<ItemGroup>", TextEdit = new TextEdit { NewText = "<ItemGroup>\n\t$0\n</ItemGroup>", Range = completionRange }, InsertTextFormat = InsertTextFormat.Snippet }); // <Target Name="TargetName"> // $0 // </Target> yield return(new CompletionItem { Label = "<Target>", Detail = "Element", Documentation = MSBuildSchemaHelp.ForElement("Target"), SortText = Priority + "<Target>", TextEdit = new TextEdit { NewText = "<Target Name=\"${1:TargetName}\">\n\t$0\n</Target>", Range = completionRange }, InsertTextFormat = InsertTextFormat.Snippet }); // <Import Project="ProjectFile" /> yield return(new CompletionItem { Label = "<Import>", Detail = "Element", Documentation = MSBuildSchemaHelp.ForElement("Import"), SortText = Priority + "<Import>", TextEdit = new TextEdit { NewText = "<Import Project=\"${1:ProjectFile}\" />$0", Range = completionRange }, InsertTextFormat = InsertTextFormat.Snippet }); }