зеркало из https://github.com/dotnet/razor.git
Remove ILogger from various extension methods
This commit is contained in:
Родитель
708f1e0f0f
Коммит
00a09d62fd
|
@ -48,7 +48,7 @@ public class RazorCompletionBenchmark : RazorLanguageServerBenchmarkBase
|
|||
var configurationService = new DefaultRazorConfigurationService(clientConnection, loggerFactory);
|
||||
var optionsMonitor = new RazorLSPOptionsMonitor(configurationService, RazorLSPOptions.Default);
|
||||
|
||||
CompletionEndpoint = new RazorCompletionEndpoint(completionListProvider, telemetryReporter: null, optionsMonitor, loggerFactory);
|
||||
CompletionEndpoint = new RazorCompletionEndpoint(completionListProvider, telemetryReporter: null, optionsMonitor);
|
||||
|
||||
var clientCapabilities = new VSInternalClientCapabilities
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ internal abstract class AbstractRazorDelegatingEndpoint<TRequest, TResponse> : I
|
|||
return default;
|
||||
}
|
||||
|
||||
var positionInfo = await DocumentPositionInfoStrategy.TryGetPositionInfoAsync(_documentMappingService, documentContext, request.Position, Logger, cancellationToken).ConfigureAwait(false);
|
||||
var positionInfo = await DocumentPositionInfoStrategy.TryGetPositionInfoAsync(_documentMappingService, documentContext, request.Position, cancellationToken).ConfigureAwait(false);
|
||||
if (positionInfo is null)
|
||||
{
|
||||
return default;
|
||||
|
|
|
@ -8,13 +8,12 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Syntax;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Formatting;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.LanguageServer.AutoInsert;
|
||||
|
||||
internal sealed class AutoClosingTagOnAutoInsertProvider : IOnAutoInsertProvider
|
||||
internal sealed class AutoClosingTagOnAutoInsertProvider(RazorLSPOptionsMonitor optionsMonitor) : IOnAutoInsertProvider
|
||||
{
|
||||
// From http://dev.w3.org/html5/spec/Overview.html#elements-0
|
||||
private static readonly ImmutableHashSet<string> s_voidElements = ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase,
|
||||
|
@ -36,26 +35,10 @@ internal sealed class AutoClosingTagOnAutoInsertProvider : IOnAutoInsertProvider
|
|||
"track",
|
||||
"wbr"
|
||||
);
|
||||
|
||||
private static readonly ImmutableHashSet<string> s_voidElementsCaseSensitive = s_voidElements.WithComparer(StringComparer.Ordinal);
|
||||
|
||||
private readonly RazorLSPOptionsMonitor _optionsMonitor;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public AutoClosingTagOnAutoInsertProvider(RazorLSPOptionsMonitor optionsMonitor, ILoggerFactory loggerFactory)
|
||||
{
|
||||
if (optionsMonitor is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(optionsMonitor));
|
||||
}
|
||||
|
||||
if (loggerFactory is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(loggerFactory));
|
||||
}
|
||||
|
||||
_optionsMonitor = optionsMonitor;
|
||||
_logger = loggerFactory.GetOrCreateLogger<IOnAutoInsertProvider>();
|
||||
}
|
||||
private readonly RazorLSPOptionsMonitor _optionsMonitor = optionsMonitor;
|
||||
|
||||
public string TriggerCharacter => ">";
|
||||
|
||||
|
@ -68,7 +51,7 @@ internal sealed class AutoClosingTagOnAutoInsertProvider : IOnAutoInsertProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!context.SourceText.TryGetAbsoluteIndex(position, _logger, out var afterCloseAngleIndex))
|
||||
if (!context.SourceText.TryGetAbsoluteIndex(position, out var afterCloseAngleIndex))
|
||||
{
|
||||
format = default;
|
||||
edit = default;
|
||||
|
|
|
@ -8,32 +8,14 @@ using Microsoft.AspNetCore.Razor.Language;
|
|||
using Microsoft.AspNetCore.Razor.Language.Legacy;
|
||||
using Microsoft.AspNetCore.Razor.Language.Syntax;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Formatting;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.LanguageServer.AutoInsert;
|
||||
|
||||
internal sealed class CloseTextTagOnAutoInsertProvider : IOnAutoInsertProvider
|
||||
internal sealed class CloseTextTagOnAutoInsertProvider(RazorLSPOptionsMonitor optionsMonitor) : IOnAutoInsertProvider
|
||||
{
|
||||
private readonly RazorLSPOptionsMonitor _optionsMonitor;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public CloseTextTagOnAutoInsertProvider(RazorLSPOptionsMonitor optionsMonitor, ILoggerFactory loggerFactory)
|
||||
{
|
||||
if (optionsMonitor is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(optionsMonitor));
|
||||
}
|
||||
|
||||
if (loggerFactory is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(loggerFactory));
|
||||
}
|
||||
|
||||
_optionsMonitor = optionsMonitor;
|
||||
_logger = loggerFactory.GetOrCreateLogger<IOnAutoInsertProvider>();
|
||||
}
|
||||
private readonly RazorLSPOptionsMonitor _optionsMonitor = optionsMonitor;
|
||||
|
||||
public string TriggerCharacter => ">";
|
||||
|
||||
|
@ -47,7 +29,7 @@ internal sealed class CloseTextTagOnAutoInsertProvider : IOnAutoInsertProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!IsAtTextTag(context, position, _logger))
|
||||
if (!IsAtTextTag(context, position))
|
||||
{
|
||||
format = default;
|
||||
edit = default;
|
||||
|
@ -61,11 +43,11 @@ internal sealed class CloseTextTagOnAutoInsertProvider : IOnAutoInsertProvider
|
|||
return true;
|
||||
}
|
||||
|
||||
private static bool IsAtTextTag(FormattingContext context, Position position, ILogger logger)
|
||||
private static bool IsAtTextTag(FormattingContext context, Position position)
|
||||
{
|
||||
var syntaxTree = context.CodeDocument.GetSyntaxTree();
|
||||
|
||||
if (!context.SourceText.TryGetAbsoluteIndex(position, logger, out var absoluteIndex))
|
||||
if (!context.SourceText.TryGetAbsoluteIndex(position, out var absoluteIndex))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language.Syntax;
|
||||
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Razor.Protocol;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
@ -21,9 +20,9 @@ internal class PreferHtmlInAttributeValuesDocumentPositionInfoStrategy : IDocume
|
|||
{
|
||||
public static IDocumentPositionInfoStrategy Instance { get; } = new PreferHtmlInAttributeValuesDocumentPositionInfoStrategy();
|
||||
|
||||
public async Task<DocumentPositionInfo?> TryGetPositionInfoAsync(IRazorDocumentMappingService documentMappingService, DocumentContext documentContext, Position position, ILogger logger, CancellationToken cancellationToken)
|
||||
public async Task<DocumentPositionInfo?> TryGetPositionInfoAsync(IRazorDocumentMappingService documentMappingService, DocumentContext documentContext, Position position, CancellationToken cancellationToken)
|
||||
{
|
||||
var defaultDocumentPositionInfo = await DefaultDocumentPositionInfoStrategy.Instance.TryGetPositionInfoAsync(documentMappingService, documentContext, position, logger, cancellationToken).ConfigureAwait(false);
|
||||
var defaultDocumentPositionInfo = await DefaultDocumentPositionInfoStrategy.Instance.TryGetPositionInfoAsync(documentMappingService, documentContext, position, cancellationToken).ConfigureAwait(false);
|
||||
if (defaultDocumentPositionInfo is null)
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -158,7 +158,7 @@ internal sealed class CodeActionEndpoint(
|
|||
request.Range = vsCodeActionContext.SelectionRange;
|
||||
}
|
||||
|
||||
if (!sourceText.TryGetSourceLocation(request.Range.Start, _logger, out var location))
|
||||
if (!sourceText.TryGetSourceLocation(request.Range.Start, out var location))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
|
||||
using Microsoft.AspNetCore.Razor.Telemetry;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
||||
|
@ -19,14 +17,12 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Completion;
|
|||
internal class RazorCompletionEndpoint(
|
||||
CompletionListProvider completionListProvider,
|
||||
ITelemetryReporter? telemetryReporter,
|
||||
RazorLSPOptionsMonitor optionsMonitor,
|
||||
ILoggerFactory loggerFactory)
|
||||
RazorLSPOptionsMonitor optionsMonitor)
|
||||
: IRazorRequestHandler<CompletionParams, VSInternalCompletionList?>, ICapabilitiesProvider
|
||||
{
|
||||
private readonly CompletionListProvider _completionListProvider = completionListProvider;
|
||||
private readonly ITelemetryReporter? _telemetryReporter = telemetryReporter;
|
||||
private readonly RazorLSPOptionsMonitor _optionsMonitor = optionsMonitor;
|
||||
private readonly ILogger _logger = loggerFactory.GetOrCreateLogger<RazorCompletionEndpoint>();
|
||||
|
||||
private VSInternalClientCapabilities? _clientCapabilities;
|
||||
|
||||
|
@ -58,7 +54,7 @@ internal class RazorCompletionEndpoint(
|
|||
}
|
||||
|
||||
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (!sourceText.TryGetAbsoluteIndex(request.Position, _logger, out var hostDocumentIndex))
|
||||
if (!sourceText.TryGetAbsoluteIndex(request.Position, out var hostDocumentIndex))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
||||
|
@ -16,10 +14,14 @@ internal class DefaultDocumentPositionInfoStrategy : IDocumentPositionInfoStrate
|
|||
{
|
||||
public static IDocumentPositionInfoStrategy Instance { get; } = new DefaultDocumentPositionInfoStrategy();
|
||||
|
||||
public async Task<DocumentPositionInfo?> TryGetPositionInfoAsync(IRazorDocumentMappingService documentMappingService, DocumentContext documentContext, Position position, ILogger logger, CancellationToken cancellationToken)
|
||||
public async Task<DocumentPositionInfo?> TryGetPositionInfoAsync(
|
||||
IRazorDocumentMappingService documentMappingService,
|
||||
DocumentContext documentContext,
|
||||
Position position,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (!sourceText.TryGetAbsoluteIndex(position, logger, out var absoluteIndex))
|
||||
if (!sourceText.TryGetAbsoluteIndex(position, out var absoluteIndex))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
|
||||
var filteredDiagnostics = diagnosticKind == RazorLanguageKind.CSharp
|
||||
? FilterCSharpDiagnostics(diagnostics, codeDocument, sourceText)
|
||||
: FilterHTMLDiagnostics(diagnostics, codeDocument, sourceText, _logger);
|
||||
: FilterHTMLDiagnostics(diagnostics, codeDocument, sourceText);
|
||||
if (filteredDiagnostics.Length == 0)
|
||||
{
|
||||
_logger.LogDebug($"No diagnostics remaining after filtering.");
|
||||
|
@ -99,8 +99,7 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
private static Diagnostic[] FilterHTMLDiagnostics(
|
||||
Diagnostic[] unmappedDiagnostics,
|
||||
RazorCodeDocument codeDocument,
|
||||
SourceText sourceText,
|
||||
ILogger logger)
|
||||
SourceText sourceText)
|
||||
{
|
||||
var syntaxTree = codeDocument.GetSyntaxTree();
|
||||
|
||||
|
@ -109,9 +108,9 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
var filteredDiagnostics = unmappedDiagnostics
|
||||
.Where(d =>
|
||||
!InCSharpLiteral(d, sourceText, syntaxTree) &&
|
||||
!InAttributeContainingCSharp(d, sourceText, syntaxTree, processedAttributes, logger) &&
|
||||
!AppliesToTagHelperTagName(d, sourceText, syntaxTree, logger) &&
|
||||
!ShouldFilterHtmlDiagnosticBasedOnErrorCode(d, sourceText, syntaxTree, logger))
|
||||
!InAttributeContainingCSharp(d, sourceText, syntaxTree, processedAttributes) &&
|
||||
!AppliesToTagHelperTagName(d, sourceText, syntaxTree) &&
|
||||
!ShouldFilterHtmlDiagnosticBasedOnErrorCode(d, sourceText, syntaxTree))
|
||||
.ToArray();
|
||||
|
||||
return filteredDiagnostics;
|
||||
|
@ -187,11 +186,7 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
or SyntaxKind.CSharpEphemeralTextLiteral;
|
||||
}
|
||||
|
||||
private static bool AppliesToTagHelperTagName(
|
||||
Diagnostic diagnostic,
|
||||
SourceText sourceText,
|
||||
RazorSyntaxTree syntaxTree,
|
||||
ILogger logger)
|
||||
private static bool AppliesToTagHelperTagName(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree)
|
||||
{
|
||||
// Goal of this method is to filter diagnostics that touch TagHelper tag names. Reason being is TagHelpers can output anything. Meaning
|
||||
// If you have a TagHelper like:
|
||||
|
@ -207,7 +202,7 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
return false;
|
||||
}
|
||||
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.End, logger);
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.End);
|
||||
|
||||
var startOrEndTag = owner?.FirstAncestorOrSelf<RazorSyntaxNode>(static n => n is MarkupTagHelperStartTagSyntax || n is MarkupTagHelperEndTagSyntax);
|
||||
if (startOrEndTag is null)
|
||||
|
@ -228,7 +223,7 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
return true;
|
||||
}
|
||||
|
||||
private static bool ShouldFilterHtmlDiagnosticBasedOnErrorCode(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
|
||||
private static bool ShouldFilterHtmlDiagnosticBasedOnErrorCode(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree)
|
||||
{
|
||||
if (!diagnostic.Code.HasValue)
|
||||
{
|
||||
|
@ -239,20 +234,20 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
|
||||
return str switch
|
||||
{
|
||||
CSSErrorCodes.MissingOpeningBrace => IsCSharpInStyleBlock(diagnostic, sourceText, syntaxTree, logger),
|
||||
CSSErrorCodes.MissingSelectorAfterCombinator => IsCSharpInStyleBlock(diagnostic, sourceText, syntaxTree, logger),
|
||||
CSSErrorCodes.MissingSelectorBeforeCombinatorCode => IsCSharpInStyleBlock(diagnostic, sourceText, syntaxTree, logger),
|
||||
HtmlErrorCodes.UnexpectedEndTagErrorCode => IsHtmlWithBangAndMatchingTags(diagnostic, sourceText, syntaxTree, logger),
|
||||
HtmlErrorCodes.InvalidNestingErrorCode => IsAnyFilteredInvalidNestingError(diagnostic, sourceText, syntaxTree, logger),
|
||||
CSSErrorCodes.MissingOpeningBrace => IsCSharpInStyleBlock(diagnostic, sourceText, syntaxTree),
|
||||
CSSErrorCodes.MissingSelectorAfterCombinator => IsCSharpInStyleBlock(diagnostic, sourceText, syntaxTree),
|
||||
CSSErrorCodes.MissingSelectorBeforeCombinatorCode => IsCSharpInStyleBlock(diagnostic, sourceText, syntaxTree),
|
||||
HtmlErrorCodes.UnexpectedEndTagErrorCode => IsHtmlWithBangAndMatchingTags(diagnostic, sourceText, syntaxTree),
|
||||
HtmlErrorCodes.InvalidNestingErrorCode => IsAnyFilteredInvalidNestingError(diagnostic, sourceText, syntaxTree),
|
||||
HtmlErrorCodes.MissingEndTagErrorCode => FileKinds.IsComponent(syntaxTree.Options.FileKind), // Redundant with RZ9980 in Components
|
||||
HtmlErrorCodes.TooFewElementsErrorCode => IsAnyFilteredTooFewElementsError(diagnostic, sourceText, syntaxTree, logger),
|
||||
HtmlErrorCodes.TooFewElementsErrorCode => IsAnyFilteredTooFewElementsError(diagnostic, sourceText, syntaxTree),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
static bool IsCSharpInStyleBlock(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
|
||||
static bool IsCSharpInStyleBlock(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree)
|
||||
{
|
||||
// C# in a style block causes diagnostics because the HTML background document replaces C# with "~"
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start, logger);
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start);
|
||||
if (owner is null)
|
||||
{
|
||||
return false;
|
||||
|
@ -266,9 +261,9 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
|
||||
// Ideally this would be solved instead by not emitting the "!" at the HTML backing file,
|
||||
// but we don't currently have a system to accomplish that
|
||||
static bool IsAnyFilteredTooFewElementsError(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
|
||||
static bool IsAnyFilteredTooFewElementsError(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree)
|
||||
{
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start, logger);
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start);
|
||||
if (owner is null)
|
||||
{
|
||||
return false;
|
||||
|
@ -295,9 +290,9 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
|
||||
// Ideally this would be solved instead by not emitting the "!" at the HTML backing file,
|
||||
// but we don't currently have a system to accomplish that
|
||||
static bool IsHtmlWithBangAndMatchingTags(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
|
||||
static bool IsHtmlWithBangAndMatchingTags(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree)
|
||||
{
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start, logger);
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start);
|
||||
if (owner is null)
|
||||
{
|
||||
return false;
|
||||
|
@ -319,13 +314,13 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
return haveBang && namesEquivalent;
|
||||
}
|
||||
|
||||
static bool IsAnyFilteredInvalidNestingError(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
|
||||
=> IsInvalidNestingWarningWithinComponent(diagnostic, sourceText, syntaxTree, logger) ||
|
||||
IsInvalidNestingFromBody(diagnostic, sourceText, syntaxTree, logger);
|
||||
static bool IsAnyFilteredInvalidNestingError(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree)
|
||||
=> IsInvalidNestingWarningWithinComponent(diagnostic, sourceText, syntaxTree) ||
|
||||
IsInvalidNestingFromBody(diagnostic, sourceText, syntaxTree);
|
||||
|
||||
static bool IsInvalidNestingWarningWithinComponent(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
|
||||
static bool IsInvalidNestingWarningWithinComponent(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree)
|
||||
{
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start, logger);
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start);
|
||||
if (owner is null)
|
||||
{
|
||||
return false;
|
||||
|
@ -338,9 +333,9 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
|
||||
// Ideally this would be solved instead by not emitting the "!" at the HTML backing file,
|
||||
// but we don't currently have a system to accomplish that
|
||||
static bool IsInvalidNestingFromBody(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree, ILogger logger)
|
||||
static bool IsInvalidNestingFromBody(Diagnostic diagnostic, SourceText sourceText, RazorSyntaxTree syntaxTree)
|
||||
{
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start, logger);
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.Start);
|
||||
if (owner is null)
|
||||
{
|
||||
return false;
|
||||
|
@ -366,8 +361,7 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
Diagnostic diagnostic,
|
||||
SourceText sourceText,
|
||||
RazorSyntaxTree syntaxTree,
|
||||
Dictionary<TextSpan, bool> processedAttributes,
|
||||
ILogger logger)
|
||||
Dictionary<TextSpan, bool> processedAttributes)
|
||||
{
|
||||
// Examine the _end_ of the diagnostic to see if we're at the
|
||||
// start of an (im/ex)plicit expression. Looking at the start
|
||||
|
@ -377,7 +371,7 @@ internal class RazorTranslateDiagnosticsService(IRazorDocumentMappingService doc
|
|||
return false;
|
||||
}
|
||||
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.End, logger);
|
||||
var owner = syntaxTree.FindInnermostNode(sourceText, diagnostic.Range.End);
|
||||
if (owner is null)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -36,10 +36,10 @@ internal abstract class AbstractTextDocumentPresentationEndpointBase<TParams> :
|
|||
IFilePathService filePathService,
|
||||
ILogger logger)
|
||||
{
|
||||
_razorDocumentMappingService = razorDocumentMappingService ?? throw new ArgumentNullException(nameof(razorDocumentMappingService));
|
||||
_clientConnection = clientConnection ?? throw new ArgumentNullException(nameof(clientConnection));
|
||||
_filePathService = filePathService ?? throw new ArgumentNullException(nameof(filePathService));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_razorDocumentMappingService = razorDocumentMappingService;
|
||||
_clientConnection = clientConnection;
|
||||
_filePathService = filePathService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public abstract string EndpointName { get; }
|
||||
|
@ -74,7 +74,7 @@ internal abstract class AbstractTextDocumentPresentationEndpointBase<TParams> :
|
|||
}
|
||||
|
||||
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (sourceText.TryGetAbsoluteIndex(request.Range.Start, _logger, out var hostDocumentIndex) != true)
|
||||
if (sourceText.TryGetAbsoluteIndex(request.Range.Start, out var hostDocumentIndex) != true)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.CommonLanguageServerProtocol.Framework;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
@ -70,17 +69,14 @@ internal class DocumentDidChangeEndpoint(
|
|||
{
|
||||
foreach (var change in contentChanges)
|
||||
{
|
||||
if (change.Range is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(change.Range), "Range of change should not be null.");
|
||||
}
|
||||
var range = change.Range.AssumeNotNull();
|
||||
|
||||
if (!sourceText.TryGetAbsoluteIndex(change.Range.Start, _logger, out var startPosition))
|
||||
if (!sourceText.TryGetAbsoluteIndex(range.Start, out var startPosition))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sourceText.TryGetAbsoluteIndex(change.Range.End, _logger, out var endPosition))
|
||||
if (!sourceText.TryGetAbsoluteIndex(range.End, out var endPosition))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
|
|||
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Razor.Protocol;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
||||
|
@ -91,7 +90,7 @@ internal class DocumentOnTypeFormattingEndpoint(
|
|||
}
|
||||
|
||||
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (!sourceText.TryGetAbsoluteIndex(request.Position, _logger, out var hostDocumentIndex))
|
||||
if (!sourceText.TryGetAbsoluteIndex(request.Position, out var hostDocumentIndex))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
||||
|
@ -12,5 +11,9 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer;
|
|||
|
||||
internal interface IDocumentPositionInfoStrategy
|
||||
{
|
||||
Task<DocumentPositionInfo?> TryGetPositionInfoAsync(IRazorDocumentMappingService documentMappingService, DocumentContext documentContext, Position position, ILogger logger, CancellationToken cancellationToken);
|
||||
Task<DocumentPositionInfo?> TryGetPositionInfoAsync(
|
||||
IRazorDocumentMappingService documentMappingService,
|
||||
DocumentContext documentContext,
|
||||
Position position,
|
||||
CancellationToken cancellationToken);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
@ -14,19 +13,10 @@ using Microsoft.VisualStudio.LanguageServer.Protocol;
|
|||
namespace Microsoft.AspNetCore.Razor.LanguageServer.LinkedEditingRange;
|
||||
|
||||
[RazorLanguageServerEndpoint(Methods.TextDocumentLinkedEditingRangeName)]
|
||||
internal class LinkedEditingRangeEndpoint : IRazorRequestHandler<LinkedEditingRangeParams, LinkedEditingRanges?>, ICapabilitiesProvider
|
||||
internal class LinkedEditingRangeEndpoint(ILoggerFactory loggerFactory)
|
||||
: IRazorRequestHandler<LinkedEditingRangeParams, LinkedEditingRanges?>, ICapabilitiesProvider
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public LinkedEditingRangeEndpoint(ILoggerFactory loggerFactory)
|
||||
{
|
||||
if (loggerFactory is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(loggerFactory));
|
||||
}
|
||||
|
||||
_logger = loggerFactory.GetOrCreateLogger<LinkedEditingRangeEndpoint>();
|
||||
}
|
||||
private readonly ILogger _logger = loggerFactory.GetOrCreateLogger<LinkedEditingRangeEndpoint>();
|
||||
|
||||
public bool MutatesSolutionState => false;
|
||||
|
||||
|
@ -59,7 +49,7 @@ internal class LinkedEditingRangeEndpoint : IRazorRequestHandler<LinkedEditingRa
|
|||
return null;
|
||||
}
|
||||
|
||||
if (LinkedEditingRangeHelper.GetLinkedSpans(request.Position.ToLinePosition(), codeDocument, _logger) is { } linkedSpans && linkedSpans.Length == 2)
|
||||
if (LinkedEditingRangeHelper.GetLinkedSpans(request.Position.ToLinePosition(), codeDocument) is { } linkedSpans && linkedSpans.Length == 2)
|
||||
{
|
||||
var ranges = new[] { linkedSpans[0].ToRange(), linkedSpans[1].ToRange() };
|
||||
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
||||
|
@ -21,11 +19,15 @@ internal class PreferAttributeNameDocumentPositionInfoStrategy : IDocumentPositi
|
|||
{
|
||||
public static IDocumentPositionInfoStrategy Instance { get; } = new PreferAttributeNameDocumentPositionInfoStrategy();
|
||||
|
||||
public async Task<DocumentPositionInfo?> TryGetPositionInfoAsync(IRazorDocumentMappingService documentMappingService, DocumentContext documentContext, Position position, ILogger logger, CancellationToken cancellationToken)
|
||||
public async Task<DocumentPositionInfo?> TryGetPositionInfoAsync(
|
||||
IRazorDocumentMappingService documentMappingService,
|
||||
DocumentContext documentContext,
|
||||
Position position,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
|
||||
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (sourceText.TryGetAbsoluteIndex(position, logger, out var absoluteIndex))
|
||||
if (sourceText.TryGetAbsoluteIndex(position, out var absoluteIndex))
|
||||
{
|
||||
// First, lets see if we should adjust the location to get a better result from C#. For example given <Component @bi|nd-Value="Pants" />
|
||||
// where | is the cursor, we would be unable to map that location to C#. If we pretend the caret was 3 characters to the right though,
|
||||
|
@ -37,6 +39,8 @@ internal class PreferAttributeNameDocumentPositionInfoStrategy : IDocumentPositi
|
|||
}
|
||||
|
||||
// We actually don't need a different projection strategy, we just wanted to move the caret position
|
||||
return await DefaultDocumentPositionInfoStrategy.Instance.TryGetPositionInfoAsync(documentMappingService, documentContext, position, logger, cancellationToken).ConfigureAwait(false);
|
||||
return await DefaultDocumentPositionInfoStrategy.Instance
|
||||
.TryGetPositionInfoAsync(documentMappingService, documentContext, position, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ internal class WrapWithTagEndpoint(
|
|||
|
||||
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (request.Range?.Start is not { } start ||
|
||||
!sourceText.TryGetAbsoluteIndex(start, _logger, out var hostDocumentIndex))
|
||||
!sourceText.TryGetAbsoluteIndex(start, out var hostDocumentIndex))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ internal abstract class AbstractRazorDocumentMappingService(
|
|||
continue;
|
||||
}
|
||||
|
||||
var startSync = generatedDocumentSourceText.TryGetAbsoluteIndex(range.Start, _logger, out var startIndex);
|
||||
var endSync = generatedDocumentSourceText.TryGetAbsoluteIndex(range.End, _logger, out var endIndex);
|
||||
var startSync = generatedDocumentSourceText.TryGetAbsoluteIndex(range.Start, out var startIndex);
|
||||
var endSync = generatedDocumentSourceText.TryGetAbsoluteIndex(range.End, out var endIndex);
|
||||
if (startSync is false || endSync is false)
|
||||
{
|
||||
break;
|
||||
|
@ -96,8 +96,8 @@ internal abstract class AbstractRazorDocumentMappingService(
|
|||
Debug.Assert(lastNewLine == 0 || edit.NewText[..(lastNewLine - 1)].All(c => c == '\r' || c == '\n'), "We are throwing away part of an edit that has more than just empty lines!");
|
||||
|
||||
var proposedRange = VsLspFactory.CreateSingleLineRange(range.End.Line, character: 0, length: range.End.Character);
|
||||
startSync = generatedDocumentSourceText.TryGetAbsoluteIndex(proposedRange.Start, _logger, out startIndex);
|
||||
endSync = generatedDocumentSourceText.TryGetAbsoluteIndex(proposedRange.End, _logger, out endIndex);
|
||||
startSync = generatedDocumentSourceText.TryGetAbsoluteIndex(proposedRange.Start, out startIndex);
|
||||
endSync = generatedDocumentSourceText.TryGetAbsoluteIndex(proposedRange.End, out endIndex);
|
||||
if (startSync is false || endSync is false)
|
||||
{
|
||||
break;
|
||||
|
@ -235,13 +235,13 @@ internal abstract class AbstractRazorDocumentMappingService(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!sourceText.TryGetAbsoluteIndex(range.Start, _logger, out var startIndex) ||
|
||||
if (!sourceText.TryGetAbsoluteIndex(range.Start, out var startIndex) ||
|
||||
!TryMapToGeneratedDocumentPosition(generatedDocument, startIndex, out var generatedRangeStart, out var _))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sourceText.TryGetAbsoluteIndex(range.End, _logger, out var endIndex) ||
|
||||
if (!sourceText.TryGetAbsoluteIndex(range.End, out var endIndex) ||
|
||||
!TryMapToGeneratedDocumentPosition(generatedDocument, endIndex, out var generatedRangeEnd, out var _))
|
||||
{
|
||||
return false;
|
||||
|
@ -562,13 +562,13 @@ internal abstract class AbstractRazorDocumentMappingService(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!generatedSourceText.TryGetAbsoluteIndex(range.Start, _logger, out var startIndex) ||
|
||||
if (!generatedSourceText.TryGetAbsoluteIndex(range.Start, out var startIndex) ||
|
||||
!TryMapToHostDocumentPosition(generatedDocument, startIndex, out var hostDocumentStart, out _))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!generatedSourceText.TryGetAbsoluteIndex(range.End, _logger, out var endIndex) ||
|
||||
if (!generatedSourceText.TryGetAbsoluteIndex(range.End, out var endIndex) ||
|
||||
!TryMapToHostDocumentPosition(generatedDocument, endIndex, out var hostDocumentEnd, out _))
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Text;
|
||||
|
||||
internal static class LinePositionExtensions
|
||||
|
@ -12,16 +10,4 @@ internal static class LinePositionExtensions
|
|||
|
||||
public static LinePositionSpan ToZeroWidthSpan(this LinePosition linePosition)
|
||||
=> new(linePosition, linePosition);
|
||||
|
||||
public static bool TryGetAbsoluteIndex(this LinePosition position, SourceText text, out int absoluteIndex)
|
||||
=> text.TryGetAbsoluteIndex(position, out absoluteIndex);
|
||||
|
||||
public static bool TryGetAbsoluteIndex(this LinePosition position, SourceText text, ILogger logger, out int absoluteIndex)
|
||||
=> text.TryGetAbsoluteIndex(position, logger, out absoluteIndex);
|
||||
|
||||
public static int GetRequiredAbsoluteIndex(this LinePosition position, SourceText text)
|
||||
=> text.GetRequiredAbsoluteIndex(position);
|
||||
|
||||
public static int GetRequiredAbsoluteIndex(this LinePosition position, SourceText text, ILogger logger)
|
||||
=> text.GetRequiredAbsoluteIndex(position, logger);
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Razor;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
|
||||
namespace Microsoft.CodeAnalysis.Text;
|
||||
|
@ -193,26 +191,13 @@ internal static class SourceTextExtensions
|
|||
public static bool TryGetAbsoluteIndex(this SourceText text, LinePosition position, out int absoluteIndex)
|
||||
=> text.TryGetAbsoluteIndex(position.Line, position.Character, out absoluteIndex);
|
||||
|
||||
public static bool TryGetAbsoluteIndex(this SourceText text, LinePosition position, ILogger logger, out int absoluteIndex)
|
||||
=> text.TryGetAbsoluteIndex(position.Line, position.Character, logger, out absoluteIndex);
|
||||
|
||||
public static bool TryGetAbsoluteIndex(this SourceText text, int line, int character, out int absoluteIndex)
|
||||
=> text.TryGetAbsoluteIndex(line, character, logger: null, out absoluteIndex);
|
||||
|
||||
public static bool TryGetAbsoluteIndex(this SourceText text, int line, int character, ILogger? logger, out int absoluteIndex)
|
||||
{
|
||||
absoluteIndex = 0;
|
||||
var lineCount = text.Lines.Count;
|
||||
|
||||
if (line > lineCount || (line == lineCount && character > 0))
|
||||
{
|
||||
if (logger is not null)
|
||||
{
|
||||
var errorMessage = SR.FormatPositionLine_Outside_Range(line, nameof(text), text.Lines.Count);
|
||||
logger.LogError(errorMessage);
|
||||
Debug.Fail(errorMessage);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -227,13 +212,6 @@ internal static class SourceTextExtensions
|
|||
var lineLengthIncludingLineBreak = sourceLine.SpanIncludingLineBreak.Length;
|
||||
if (character > lineLengthIncludingLineBreak)
|
||||
{
|
||||
if (logger is not null)
|
||||
{
|
||||
var errorMessage = SR.FormatPositionCharacter_Outside_Range(character, nameof(text), lineLengthIncludingLineBreak);
|
||||
logger.LogError(errorMessage);
|
||||
Debug.Fail(errorMessage);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -244,19 +222,11 @@ internal static class SourceTextExtensions
|
|||
public static int GetRequiredAbsoluteIndex(this SourceText text, LinePosition position)
|
||||
=> text.GetRequiredAbsoluteIndex(position.Line, position.Character);
|
||||
|
||||
public static int GetRequiredAbsoluteIndex(this SourceText text, LinePosition position, ILogger logger)
|
||||
=> text.GetRequiredAbsoluteIndex(position.Line, position.Character, logger);
|
||||
|
||||
public static int GetRequiredAbsoluteIndex(this SourceText text, int line, int character)
|
||||
=> text.TryGetAbsoluteIndex(line, character, out var absolutionPosition)
|
||||
? absolutionPosition
|
||||
: ThrowHelper.ThrowInvalidOperationException<int>($"({line},{character}) matches or exceeds SourceText boundary {text.Lines.Count}.");
|
||||
|
||||
public static int GetRequiredAbsoluteIndex(this SourceText text, int line, int character, ILogger logger)
|
||||
=> text.TryGetAbsoluteIndex(line, character, logger, out var absolutionPosition)
|
||||
? absolutionPosition
|
||||
: ThrowHelper.ThrowInvalidOperationException<int>($"({line},{character}) matches or exceeds SourceText boundary {text.Lines.Count}.");
|
||||
|
||||
public static TextSpan GetTextSpan(this SourceText text, int startLine, int startCharacter, int endLine, int endCharacter)
|
||||
{
|
||||
ArgHelper.ThrowIfNull(text);
|
||||
|
@ -280,12 +250,12 @@ internal static class SourceTextExtensions
|
|||
}
|
||||
}
|
||||
|
||||
public static bool TryGetSourceLocation(this SourceText text, LinePosition position, ILogger logger, out SourceLocation location)
|
||||
=> text.TryGetSourceLocation(position.Line, position.Character, logger, out location);
|
||||
public static bool TryGetSourceLocation(this SourceText text, LinePosition position, out SourceLocation location)
|
||||
=> text.TryGetSourceLocation(position.Line, position.Character, out location);
|
||||
|
||||
public static bool TryGetSourceLocation(this SourceText text, int line, int character, ILogger logger, out SourceLocation location)
|
||||
public static bool TryGetSourceLocation(this SourceText text, int line, int character, out SourceLocation location)
|
||||
{
|
||||
if (text.TryGetAbsoluteIndex(line, character, logger, out var absoluteIndex))
|
||||
if (text.TryGetAbsoluteIndex(line, character, out var absoluteIndex))
|
||||
{
|
||||
location = new SourceLocation(absoluteIndex, line, character);
|
||||
return true;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Razor;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
||||
|
@ -19,28 +18,6 @@ internal static partial class VsLspExtensions
|
|||
public static Range ToZeroWidthRange(this Position position)
|
||||
=> VsLspFactory.CreateZeroWidthRange(position);
|
||||
|
||||
public static bool TryGetAbsoluteIndex(this Position position, SourceText text, out int absoluteIndex)
|
||||
{
|
||||
ArgHelper.ThrowIfNull(position);
|
||||
ArgHelper.ThrowIfNull(text);
|
||||
|
||||
return text.TryGetAbsoluteIndex(position, out absoluteIndex);
|
||||
}
|
||||
|
||||
public static bool TryGetAbsoluteIndex(this Position position, SourceText text, ILogger logger, out int absoluteIndex)
|
||||
{
|
||||
ArgHelper.ThrowIfNull(position);
|
||||
ArgHelper.ThrowIfNull(text);
|
||||
|
||||
return text.TryGetAbsoluteIndex(position, logger, out absoluteIndex);
|
||||
}
|
||||
|
||||
public static int GetRequiredAbsoluteIndex(this Position position, SourceText text)
|
||||
=> text.GetRequiredAbsoluteIndex(position);
|
||||
|
||||
public static int GetRequiredAbsoluteIndex(this Position position, SourceText text, ILogger logger)
|
||||
=> text.GetRequiredAbsoluteIndex(position, logger);
|
||||
|
||||
public static int CompareTo(this Position position, Position other)
|
||||
{
|
||||
ArgHelper.ThrowIfNull(position);
|
||||
|
@ -55,7 +32,7 @@ internal static partial class VsLspExtensions
|
|||
ArgHelper.ThrowIfNull(position);
|
||||
ArgHelper.ThrowIfNull(text);
|
||||
|
||||
return text.TryGetAbsoluteIndex(position.Line, position.Character, logger: null, out _);
|
||||
return text.TryGetAbsoluteIndex(position.Line, position.Character, out _);
|
||||
}
|
||||
|
||||
public static string ToDisplayString(this Position position)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Syntax;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
namespace Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
@ -14,10 +13,9 @@ internal static partial class VsLspExtensions
|
|||
this RazorSyntaxTree syntaxTree,
|
||||
SourceText sourceText,
|
||||
Position position,
|
||||
ILogger logger,
|
||||
bool includeWhitespace = false)
|
||||
{
|
||||
if (!sourceText.TryGetAbsoluteIndex(position, logger, out var absoluteIndex))
|
||||
if (!sourceText.TryGetAbsoluteIndex(position, out var absoluteIndex))
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
namespace Microsoft.VisualStudio.LanguageServer.Protocol;
|
||||
|
@ -30,18 +29,12 @@ internal static partial class VsLspExtensions
|
|||
public static bool TryGetAbsoluteIndex(this SourceText text, Position position, out int absoluteIndex)
|
||||
=> text.TryGetAbsoluteIndex(position.Line, position.Character, out absoluteIndex);
|
||||
|
||||
public static bool TryGetAbsoluteIndex(this SourceText text, Position position, ILogger logger, out int absoluteIndex)
|
||||
=> text.TryGetAbsoluteIndex(position.Line, position.Character, logger, out absoluteIndex);
|
||||
|
||||
public static int GetRequiredAbsoluteIndex(this SourceText text, Position position)
|
||||
=> text.GetRequiredAbsoluteIndex(position.Line, position.Character);
|
||||
|
||||
public static int GetRequiredAbsoluteIndex(this SourceText text, Position position, ILogger logger)
|
||||
=> text.GetRequiredAbsoluteIndex(position.Line, position.Character, logger);
|
||||
|
||||
public static TextSpan GetTextSpan(this SourceText text, Range range)
|
||||
=> text.GetTextSpan(range.Start.Line, range.Start.Character, range.End.Line, range.End.Character);
|
||||
|
||||
public static bool TryGetSourceLocation(this SourceText text, Position position, ILogger logger, out SourceLocation location)
|
||||
=> text.TryGetSourceLocation(position.Line, position.Character, logger, out location);
|
||||
public static bool TryGetSourceLocation(this SourceText text, Position position, out SourceLocation location)
|
||||
=> text.TryGetSourceLocation(position.Line, position.Character, out location);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Syntax;
|
||||
using Microsoft.CodeAnalysis.Razor.Logging;
|
||||
using Microsoft.CodeAnalysis.Razor.Workspaces;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
|
@ -20,9 +19,9 @@ internal static class LinkedEditingRangeHelper
|
|||
// https://github.com/dotnet/aspnetcore/blob/9da42b9fab4c61fe46627ac0c6877905ec845d5a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/HtmlTokenizer.cs
|
||||
public static readonly string WordPattern = @"!?[^ <>!\/\?\[\]=""\\@" + Environment.NewLine + "]+";
|
||||
|
||||
public static LinePositionSpan[]? GetLinkedSpans(LinePosition linePosition, RazorCodeDocument codeDocument, ILogger logger)
|
||||
public static LinePositionSpan[]? GetLinkedSpans(LinePosition linePosition, RazorCodeDocument codeDocument)
|
||||
{
|
||||
if (GetSourceLocation(linePosition, codeDocument, logger) is not { } validLocation)
|
||||
if (GetSourceLocation(linePosition, codeDocument) is not { } validLocation)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -43,14 +42,11 @@ internal static class LinkedEditingRangeHelper
|
|||
return null;
|
||||
}
|
||||
|
||||
private static SourceLocation? GetSourceLocation(
|
||||
LinePosition linePosition,
|
||||
RazorCodeDocument codeDocument,
|
||||
ILogger logger)
|
||||
private static SourceLocation? GetSourceLocation(LinePosition linePosition, RazorCodeDocument codeDocument)
|
||||
{
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
|
||||
return sourceText.TryGetSourceLocation(linePosition, logger, out var location)
|
||||
return sourceText.TryGetSourceLocation(linePosition, out var location)
|
||||
? location
|
||||
: null;
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ internal abstract class AbstractRazorSemanticTokensInfoService(
|
|||
if (colorBackground)
|
||||
{
|
||||
tokenModifiers |= _semanticTokensLegendService.TokenModifiers.RazorCodeModifier;
|
||||
AddAdditionalCSharpWhitespaceRanges(razorRanges, textClassification, razorSource, previousRazorSemanticRange, originalRange, _logger);
|
||||
AddAdditionalCSharpWhitespaceRanges(razorRanges, textClassification, razorSource, previousRazorSemanticRange, originalRange);
|
||||
}
|
||||
|
||||
razorRanges.Add(new SemanticRange(semanticRange.Kind, originalRange.Start.Line, originalRange.Start.Character, originalRange.End.Line, originalRange.End.Character, tokenModifiers, fromRazor: false));
|
||||
|
@ -220,14 +220,14 @@ internal abstract class AbstractRazorSemanticTokensInfoService(
|
|||
return razorRanges.DrainToImmutable();
|
||||
}
|
||||
|
||||
private void AddAdditionalCSharpWhitespaceRanges(ImmutableArray<SemanticRange>.Builder razorRanges, int textClassification, SourceText razorSource, LinePositionSpan? previousRazorSemanticRange, LinePositionSpan originalRange, ILogger logger)
|
||||
private void AddAdditionalCSharpWhitespaceRanges(ImmutableArray<SemanticRange>.Builder razorRanges, int textClassification, SourceText razorSource, LinePositionSpan? previousRazorSemanticRange, LinePositionSpan originalRange)
|
||||
{
|
||||
var startLine = originalRange.Start.Line;
|
||||
var startChar = originalRange.Start.Character;
|
||||
if (previousRazorSemanticRange is { } previousRange &&
|
||||
previousRange.End.Line == startLine &&
|
||||
previousRange.End.Character < startChar &&
|
||||
razorSource.TryGetAbsoluteIndex(previousRange.End, logger, out var previousSpanEndIndex) &&
|
||||
razorSource.TryGetAbsoluteIndex(previousRange.End, out var previousSpanEndIndex) &&
|
||||
ContainsOnlySpacesOrTabs(razorSource, previousSpanEndIndex + 1, startChar - previousRange.End.Character - 1))
|
||||
{
|
||||
// we're on the same line as previous, lets extend ours to include whitespace between us and the proceeding range
|
||||
|
@ -235,7 +235,7 @@ internal abstract class AbstractRazorSemanticTokensInfoService(
|
|||
}
|
||||
else if (startChar > 0 &&
|
||||
previousRazorSemanticRange?.End.Line != startLine &&
|
||||
razorSource.TryGetAbsoluteIndex(originalRange.Start, logger, out var originalRangeStartIndex) &&
|
||||
razorSource.TryGetAbsoluteIndex(originalRange.Start, out var originalRangeStartIndex) &&
|
||||
ContainsOnlySpacesOrTabs(razorSource, originalRangeStartIndex - startChar + 1, startChar - 1))
|
||||
{
|
||||
// We're on a new line, and the start of the line is only whitespace, so give that a background color too
|
||||
|
|
|
@ -42,6 +42,6 @@ internal sealed class RemoteLinkedEditingRangeService(in ServiceArgs args) : Raz
|
|||
|
||||
var codeDocument = await context.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return LinkedEditingRangeHelper.GetLinkedSpans(linePosition, codeDocument, Logger);
|
||||
return LinkedEditingRangeHelper.GetLinkedSpans(linePosition, codeDocument);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using static Microsoft.AspNetCore.Razor.Language.CommonMetadata;
|
||||
|
@ -952,7 +951,7 @@ expected: @"
|
|||
var configService = StrictMock.Of<IConfigurationSyncService>();
|
||||
var optionsMonitor = new RazorLSPOptionsMonitor(configService, Options);
|
||||
|
||||
var provider = new AutoClosingTagOnAutoInsertProvider(optionsMonitor, LoggerFactory);
|
||||
var provider = new AutoClosingTagOnAutoInsertProvider(optionsMonitor);
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
|
||||
using Microsoft.AspNetCore.Razor.Test.Common;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
|
@ -44,7 +43,7 @@ expected: @"
|
|||
var configService = StrictMock.Of<IConfigurationSyncService>();
|
||||
var optionsMonitor = new RazorLSPOptionsMonitor(configService, RazorLSPOptions.Default);
|
||||
|
||||
var provider = new CloseTextTagOnAutoInsertProvider(optionsMonitor, LoggerFactory);
|
||||
var provider = new CloseTextTagOnAutoInsertProvider(optionsMonitor);
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.LanguageServer.AutoInsert;
|
||||
using Microsoft.CodeAnalysis.Razor.Protocol;
|
||||
|
@ -50,7 +49,8 @@ public class PreferHtmlInAttributeValuesDocumentPositionInfoStrategyTest(ITestOu
|
|||
var documentContext = CreateDocumentContext(uri, codeDocument);
|
||||
|
||||
// Act
|
||||
var result = await PreferHtmlInAttributeValuesDocumentPositionInfoStrategy.Instance.TryGetPositionInfoAsync(DocumentMappingService, documentContext, position, Logger, CancellationToken.None);
|
||||
var result = await PreferHtmlInAttributeValuesDocumentPositionInfoStrategy.Instance.TryGetPositionInfoAsync(
|
||||
DocumentMappingService, documentContext, position, DisposalToken);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(result);
|
||||
|
|
|
@ -139,9 +139,9 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
|
|||
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
|
||||
var editCodeDocumentEdit = textDocumentEdit1!.Edits.First();
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, Logger, out var removeStart));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, out var removeStart));
|
||||
Assert.Equal(actionParams.RemoveStart, removeStart);
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, Logger, out var removeEnd));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, out var removeEnd));
|
||||
Assert.Equal(actionParams.RemoveEnd, removeEnd);
|
||||
|
||||
var editCodeBehindChange = documentChanges[2];
|
||||
|
@ -202,9 +202,9 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
|
|||
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
|
||||
var editCodeDocumentEdit = textDocumentEdit1!.Edits.First();
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, Logger, out var removeStart));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, out var removeStart));
|
||||
Assert.Equal(actionParams.RemoveStart, removeStart);
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, Logger, out var removeEnd));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, out var removeEnd));
|
||||
Assert.Equal(actionParams.RemoveEnd, removeEnd);
|
||||
|
||||
var editCodeBehindChange = documentChanges[2];
|
||||
|
@ -273,9 +273,9 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
|
|||
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
|
||||
var editCodeDocumentEdit = textDocumentEdit1!.Edits.First();
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, Logger, out var removeStart));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, out var removeStart));
|
||||
Assert.Equal(actionParams.RemoveStart, removeStart);
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, Logger, out var removeEnd));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, out var removeEnd));
|
||||
Assert.Equal(actionParams.RemoveEnd, removeEnd);
|
||||
|
||||
var editCodeBehindChange = documentChanges[2];
|
||||
|
@ -354,9 +354,9 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
|
|||
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
|
||||
var editCodeDocumentEdit = textDocumentEdit1!.Edits.First();
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, Logger, out var removeStart));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, out var removeStart));
|
||||
Assert.Equal(actionParams.RemoveStart, removeStart);
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, Logger, out var removeEnd));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, out var removeEnd));
|
||||
Assert.Equal(actionParams.RemoveEnd, removeEnd);
|
||||
|
||||
var editCodeBehindChange = documentChanges[2];
|
||||
|
@ -437,9 +437,9 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
|
|||
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
|
||||
var editCodeDocumentEdit = textDocumentEdit1!.Edits.First();
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, Logger, out var removeStart));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, out var removeStart));
|
||||
Assert.Equal(actionParams.RemoveStart, removeStart);
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, Logger, out var removeEnd));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, out var removeEnd));
|
||||
Assert.Equal(actionParams.RemoveEnd, removeEnd);
|
||||
|
||||
var editCodeBehindChange = documentChanges[2];
|
||||
|
@ -508,9 +508,9 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
|
|||
Assert.True(editCodeDocumentChange.TryGetFirst(out var editCodeDocument));
|
||||
var editCodeDocumentEdit = editCodeDocument!.Edits.First();
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, Logger, out var removeStart));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, out var removeStart));
|
||||
Assert.Equal(actionParams.RemoveStart, removeStart);
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, Logger, out var removeEnd));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, out var removeEnd));
|
||||
Assert.Equal(actionParams.RemoveEnd, removeEnd);
|
||||
|
||||
var editCodeBehindChange = documentChanges[2];
|
||||
|
@ -571,9 +571,9 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
|
|||
Assert.True(editCodeDocumentChange.TryGetFirst(out var editCodeDocument));
|
||||
var editCodeDocumentEdit = editCodeDocument!.Edits.First();
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, Logger, out var removeStart));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, out var removeStart));
|
||||
Assert.Equal(actionParams.RemoveStart, removeStart);
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, Logger, out var removeEnd));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, out var removeEnd));
|
||||
Assert.Equal(actionParams.RemoveEnd, removeEnd);
|
||||
|
||||
var editCodeBehindChange = documentChanges[2];
|
||||
|
@ -636,9 +636,9 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
|
|||
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
|
||||
var editCodeDocumentEdit = textDocumentEdit1!.Edits.First();
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, Logger, out var removeStart));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, out var removeStart));
|
||||
Assert.Equal(actionParams.RemoveStart, removeStart);
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, Logger, out var removeEnd));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, out var removeEnd));
|
||||
Assert.Equal(actionParams.RemoveEnd, removeEnd);
|
||||
|
||||
var editCodeBehindChange = documentChanges[2];
|
||||
|
@ -705,9 +705,9 @@ public class ExtractToCodeBehindCodeActionResolverTest : LanguageServerTestBase
|
|||
Assert.True(editCodeDocumentChange.TryGetFirst(out var textDocumentEdit1));
|
||||
var editCodeDocumentEdit = textDocumentEdit1!.Edits.First();
|
||||
var sourceText = codeDocument.GetSourceText();
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, Logger, out var removeStart));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.Start, out var removeStart));
|
||||
Assert.Equal(actionParams.RemoveStart, removeStart);
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, Logger, out var removeEnd));
|
||||
Assert.True(sourceText.TryGetAbsoluteIndex(editCodeDocumentEdit.Range.End, out var removeEnd));
|
||||
Assert.Equal(actionParams.RemoveEnd, removeEnd);
|
||||
|
||||
var editCodeBehindChange = documentChanges[2];
|
||||
|
|
|
@ -21,7 +21,7 @@ public class RazorCompletionEndpointTest(ITestOutputHelper testOutput) : Languag
|
|||
// Arrange
|
||||
var documentPath = "C:/path/to/document.cshtml";
|
||||
var optionsMonitor = GetOptionsMonitor();
|
||||
var completionEndpoint = new RazorCompletionEndpoint(completionListProvider: null, telemetryReporter: null, optionsMonitor, LoggerFactory);
|
||||
var completionEndpoint = new RazorCompletionEndpoint(completionListProvider: null, telemetryReporter: null, optionsMonitor);
|
||||
var request = new CompletionParams()
|
||||
{
|
||||
TextDocument = new TextDocumentIdentifier()
|
||||
|
@ -49,7 +49,7 @@ public class RazorCompletionEndpointTest(ITestOutputHelper testOutput) : Languag
|
|||
var uri = new Uri(documentPath);
|
||||
var documentContext = CreateDocumentContext(uri, codeDocument);
|
||||
var optionsMonitor = GetOptionsMonitor(autoShowCompletion: false);
|
||||
var completionEndpoint = new RazorCompletionEndpoint(completionListProvider: null, telemetryReporter: null, optionsMonitor, LoggerFactory);
|
||||
var completionEndpoint = new RazorCompletionEndpoint(completionListProvider: null, telemetryReporter: null, optionsMonitor);
|
||||
var request = new CompletionParams()
|
||||
{
|
||||
TextDocument = new TextDocumentIdentifier()
|
||||
|
|
Загрузка…
Ссылка в новой задаче