Update to use latest completion APIs
This commit is contained in:
parent
c371fa29fe
commit
333989af7a
|
|
@ -24,10 +24,10 @@
|
|||
<MicrosoftNETCoreApp22PackageVersion>2.2.0-preview2-26905-02</MicrosoftNETCoreApp22PackageVersion>
|
||||
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
|
||||
<MicrosoftVisualStudioComponentModelHostPackageVersion>15.8.525</MicrosoftVisualStudioComponentModelHostPackageVersion>
|
||||
<MicrosoftVisualStudioEditorPackageVersion> 15.8.525</MicrosoftVisualStudioEditorPackageVersion>
|
||||
<MicrosoftVisualStudioImageCatalogPackageVersion>15.8.28010</MicrosoftVisualStudioImageCatalogPackageVersion>
|
||||
<MicrosoftVisualStudioLanguageIntellisensePackageVersion>15.8.525</MicrosoftVisualStudioLanguageIntellisensePackageVersion>
|
||||
<MicrosoftVisualStudioLanguagePackageVersion>15.8.525</MicrosoftVisualStudioLanguagePackageVersion>
|
||||
<MicrosoftVisualStudioEditorPackageVersion>16.0.142-g25b7188c54</MicrosoftVisualStudioEditorPackageVersion>
|
||||
<MicrosoftVisualStudioLanguagePackageVersion>16.0.142-g25b7188c54</MicrosoftVisualStudioLanguagePackageVersion>
|
||||
<MicrosoftVisualStudioLanguageIntellisensePackageVersion>16.0.142-g25b7188c54</MicrosoftVisualStudioLanguageIntellisensePackageVersion>
|
||||
<MicrosoftVisualStudioOLEInteropPackageVersion>7.10.6071</MicrosoftVisualStudioOLEInteropPackageVersion>
|
||||
<MicrosoftVisualStudioProjectSystemAnalyzersPackageVersion>15.8.243</MicrosoftVisualStudioProjectSystemAnalyzersPackageVersion>
|
||||
<MicrosoftVisualStudioProjectSystemManagedVSPackageVersion>2.0.6142705</MicrosoftVisualStudioProjectSystemManagedVSPackageVersion>
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
<MicrosoftVisualStudioShellInterop80PackageVersion>8.0.50728</MicrosoftVisualStudioShellInterop80PackageVersion>
|
||||
<MicrosoftVisualStudioShellInterop90PackageVersion>9.0.30730</MicrosoftVisualStudioShellInterop90PackageVersion>
|
||||
<MicrosoftVisualStudioShellInteropPackageVersion>7.10.6072</MicrosoftVisualStudioShellInteropPackageVersion>
|
||||
<MicrosoftVisualStudioTextUIPackageVersion>15.8.525</MicrosoftVisualStudioTextUIPackageVersion>
|
||||
<MicrosoftVisualStudioTextUIPackageVersion>16.0.142-g25b7188c54</MicrosoftVisualStudioTextUIPackageVersion>
|
||||
<MicrosoftVisualStudioThreadingPackageVersion>15.8.168</MicrosoftVisualStudioThreadingPackageVersion>
|
||||
<MonoAddinsPackageVersion>1.3.8</MonoAddinsPackageVersion>
|
||||
<MonoDevelopSdkPackageVersion>1.0.1</MonoDevelopSdkPackageVersion>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
}
|
||||
|
||||
public Task<CompletionContext> GetCompletionContextAsync(
|
||||
InitialTrigger trigger,
|
||||
IAsyncCompletionSession session,
|
||||
CompletionTrigger trigger,
|
||||
SnapshotPoint triggerLocation,
|
||||
SnapshotSpan applicableSpan,
|
||||
CancellationToken token)
|
||||
|
|
@ -96,7 +97,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
return Task.FromResult(context);
|
||||
}
|
||||
|
||||
public Task<object> GetDescriptionAsync(CompletionItem item, CancellationToken token)
|
||||
public Task<object> GetDescriptionAsync(IAsyncCompletionSession session, CompletionItem item, CancellationToken token)
|
||||
{
|
||||
if (!item.Properties.TryGetProperty<string>(DescriptionKey, out var directiveDescription))
|
||||
{
|
||||
|
|
@ -106,14 +107,13 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
return Task.FromResult<object>(directiveDescription);
|
||||
}
|
||||
|
||||
public bool TryGetApplicableToSpan(char typeChar, SnapshotPoint triggerLocation, out SnapshotSpan applicableToSpan, CancellationToken token)
|
||||
public CompletionStartData InitializeCompletion(CompletionTrigger trigger, SnapshotPoint triggerLocation, CancellationToken token)
|
||||
{
|
||||
// The applicable span for completion is the piece of text a completion is for. For example:
|
||||
// @Date|Time.Now
|
||||
// If you trigger completion at the | then the applicable span is the region of 'DateTime'; however, Razor
|
||||
// doesn't know this information so we rely on Roslyn to define what the applicable span for a completion is.
|
||||
applicableToSpan = default(SnapshotSpan);
|
||||
return false;
|
||||
return CompletionStartData.ParticipatesInCompletionIfAny;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
|
||||
// Act
|
||||
var completionContext = await Task.Run(
|
||||
async () => await completionSource.GetCompletionContextAsync(new InitialTrigger(), triggerLocation, applicableSpan, CancellationToken.None));
|
||||
async () => await completionSource.GetCompletionContextAsync(null, new CompletionTrigger(CompletionTriggerReason.Invoke, triggerLocation.Snapshot), triggerLocation, applicableSpan, CancellationToken.None));
|
||||
|
||||
// Assert
|
||||
Assert.Empty(completionContext.Items);
|
||||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
|
||||
// Act
|
||||
var completionContext = await Task.Run(
|
||||
async () => await completionSource.GetCompletionContextAsync(new InitialTrigger(), triggerLocation, applicableSpan, CancellationToken.None));
|
||||
async () => await completionSource.GetCompletionContextAsync(null, new CompletionTrigger(CompletionTriggerReason.Invoke, triggerLocation.Snapshot), triggerLocation, applicableSpan, CancellationToken.None));
|
||||
|
||||
// Assert
|
||||
Assert.Empty(completionContext.Items);
|
||||
|
|
@ -80,7 +80,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
|
||||
// Act
|
||||
var completionContext = await Task.Run(
|
||||
async () => await completionSource.GetCompletionContextAsync(new InitialTrigger(), triggerLocation, applicableSpan, CancellationToken.None));
|
||||
async () => await completionSource.GetCompletionContextAsync(null, new CompletionTrigger(CompletionTriggerReason.Invoke, triggerLocation.Snapshot), triggerLocation, applicableSpan, CancellationToken.None));
|
||||
|
||||
// Assert
|
||||
Assert.Collection(
|
||||
|
|
@ -101,7 +101,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
var completionSource = new RazorDirectiveCompletionSource(Dispatcher, Mock.Of<VisualStudioRazorParser>(), CompletionFactsService);
|
||||
|
||||
// Act
|
||||
var descriptionObject = await completionSource.GetDescriptionAsync(completionItem, CancellationToken.None);
|
||||
var descriptionObject = await completionSource.GetDescriptionAsync(null, completionItem, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
var description = Assert.IsType<string>(descriptionObject);
|
||||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.VisualStudio.Editor.Razor
|
|||
var completionSource = new RazorDirectiveCompletionSource(Dispatcher, Mock.Of<VisualStudioRazorParser>(), CompletionFactsService);
|
||||
|
||||
// Act
|
||||
var descriptionObject = await completionSource.GetDescriptionAsync(completionItem, CancellationToken.None);
|
||||
var descriptionObject = await completionSource.GetDescriptionAsync(null, completionItem, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
var description = Assert.IsType<string>(descriptionObject);
|
||||
|
|
|
|||
Loading…
Reference in New Issue