protected override async Task <(int ExitCode, string Value, int HasDefaultValue)> GetDefaultValueAsync(CancellationToken cancellationToken) { var value = _fullyQualifiedName; var hasDefaultValue = 1; if (!TryGetDocument(out var document)) { return(VSConstants.E_FAIL, value, hasDefaultValue); } if (!TryGetFieldSpan(out var fieldSpan)) { return(VSConstants.E_FAIL, value, hasDefaultValue); } var simplifierOptions = await document.GetSimplifierOptionsAsync(snippetExpansionClient.GlobalOptions, cancellationToken).ConfigureAwait(false); var simplifiedTypeName = await SnippetFunctionService.GetSimplifiedTypeNameAsync(document, fieldSpan.Value, _fullyQualifiedName, simplifierOptions, cancellationToken).ConfigureAwait(false); if (string.IsNullOrEmpty(simplifiedTypeName)) { return(VSConstants.E_FAIL, value, hasDefaultValue); } return(VSConstants.S_OK, simplifiedTypeName !, hasDefaultValue); }
public async Task <SnippetFunctionPart> WithSnippetFunctionResultAsync(Document documentWithSnippet, TextSpan fieldSpan, SimplifierOptions simplifierOptions, CancellationToken cancellationToken) { var snippetFunctionService = documentWithSnippet.Project.GetRequiredLanguageService <SnippetFunctionService>(); switch (FunctionName) { case "SimpleTypeName": if (FunctionParam == null) { return(this); } var simplifiedTypeName = await SnippetFunctionService.GetSimplifiedTypeNameAsync(documentWithSnippet, fieldSpan, FunctionParam, simplifierOptions, cancellationToken).ConfigureAwait(false); if (simplifiedTypeName == null) { return(this); } return(this with { DefaultText = simplifiedTypeName });