Skip to content

Commit b8c3403

Browse files
committed
Downgrade the SDK version to 17.5.33428.388
1 parent b6e62cb commit b8c3403

File tree

7 files changed

+64
-30
lines changed

7 files changed

+64
-30
lines changed

CodeiumVS/CodeiumVS.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
138138
</PackageReference>
139139
<PackageReference Include="Microsoft.VisualStudio.SDK">
140-
<Version>17.8.37222</Version>
140+
<Version>17.5.33428.388</Version>
141141
</PackageReference>
142142
<PackageReference Include="Microsoft.VisualStudio.SDK.VsixSuppression">
143143
<Version>14.1.37</Version>

CodeiumVS/InlineDiff/InlineDiffAdornment.cs

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@
2626

2727
namespace CodeiumVs.InlineDiff;
2828

29-
internal class InlineDiffAdornment : TextViewExtension<IWpfTextView, InlineDiffAdornment>, ILineTransformSource, IOleCommandTarget
29+
internal sealed class Components
3030
{
31-
[Export(typeof(AdornmentLayerDefinition))]
32-
[Name("CodeiumInlineDiffAdornment")]
31+
internal const string DiffAdornmentLayerName = "CodeiumInlineDiffAdornment";
32+
33+
[Export]
34+
[Name(DiffAdornmentLayerName)]
3335
[Order(After = "Text")]
34-
private static readonly AdornmentLayerDefinition _codeiumInlineDiffAdornment;
36+
[TextViewRole(PredefinedTextViewRoles.Document)]
37+
internal AdornmentLayerDefinition viewLayerDefinition = null;
38+
}
3539

40+
internal class InlineDiffAdornment : TextViewExtension<IWpfTextView, InlineDiffAdornment>, ILineTransformSource, IOleCommandTarget
41+
{
3642
private static readonly LineTransform _defaultTransform = new(1.0);
3743
private static MethodInfo? _fnSetInterceptsAggregateFocus = null;
3844

@@ -59,15 +65,15 @@ internal class InlineDiffAdornment : TextViewExtension<IWpfTextView, InlineDiffA
5965
private double _codeBlockHeight = 0;
6066

6167
private LineTransform _lineTransform = _defaultTransform;
62-
private ITagAggregator<InterLineAdornmentTag>? _tagAggregator = null;
68+
//private ITagAggregator<InterLineAdornmentTag>? _tagAggregator = null;
6369

6470
public bool HasAdornment => _adornment != null;
6571
public bool IsAdornmentFocused => HasAdornment && (_adornment.ActiveView != null) && _adornment.ActiveView.VisualElement.IsKeyboardFocused;
6672

6773
public InlineDiffAdornment(IWpfTextView view) : base(view)
6874
{
6975
_vsHostView = _hostView.ToIVsTextView();
70-
_layer = _hostView.GetAdornmentLayer("CodeiumInlineDiffAdornment");
76+
_layer = _hostView.GetAdornmentLayer(Components.DiffAdornmentLayerName);
7177

7278
_hostView.Closed += HostView_OnClosed;
7379
_hostView.LayoutChanged += HostView_OnLayoutChanged;
@@ -610,19 +616,20 @@ LineTransform ILineTransformSource.GetLineTransform(ITextViewLine line, double y
610616
/// <returns></returns>
611617
private bool IsPeekOnAdornment()
612618
{
613-
ThreadHelper.ThrowIfNotOnUIThread("IsPeekOnAnchor");
614-
_tagAggregator ??= IntellisenseUtilities.GetTagAggregator<InterLineAdornmentTag>(_hostView);
615-
616-
SnapshotSpan extent = _leftTrackingSpan.GetSpan(_hostView.TextSnapshot);
617-
618-
foreach (IMappingTagSpan<InterLineAdornmentTag> tag in _tagAggregator.GetTags(extent))
619-
{
620-
if (!tag.Tag.IsAboveLine && tag.Span.GetSpans(_hostView.TextSnapshot).IntersectsWith(extent))
621-
{
622-
return true;
623-
}
624-
}
625-
return false;
619+
//Microsoft.VisualStudio.Text.Editor.InterLineAdornmentTag
620+
//ThreadHelper.ThrowIfNotOnUIThread("IsPeekOnAnchor");
621+
//_tagAggregator ??= IntellisenseUtilities.GetTagAggregator<InterLineAdornmentTag>(_hostView);
622+
623+
//SnapshotSpan extent = _leftTrackingSpan.GetSpan(_hostView.TextSnapshot);
624+
625+
//foreach (IMappingTagSpan<InterLineAdornmentTag> tag in _tagAggregator.GetTags(extent))
626+
//{
627+
// if (!tag.Tag.IsAboveLine && tag.Span.GetSpans(_hostView.TextSnapshot).IntersectsWith(extent))
628+
// {
629+
// return true;
630+
// }
631+
//}
632+
return true;
626633
}
627634

628635
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread

CodeiumVS/Proposal/CodeiumProposalManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace CodeiumVS;
88

9+
#pragma warning disable CS0618 // Type or member is obsolete
910
internal class CodeiumProposalManager : ProposalManagerBase
1011
{
1112
private readonly IWpfTextView view;
@@ -62,3 +63,5 @@ public override bool TryGetIsProposalPosition(VirtualSnapshotPoint caret, Propos
6263
return value;
6364
}
6465
}
66+
67+
#pragma warning restore CS0618 // Type or member is obsolete

CodeiumVS/Proposal/CodeiumProposalManagerProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace CodeiumVS;
99

10+
#pragma warning disable CS0618 // Type or member is obsolete
11+
1012
[Export(typeof(ProposalManagerProviderBase))]
1113
[Name("CodeiumProposalManagerProvider")]
1214
[Order(Before = "InlineCSharpProposalManagerProvider")]
@@ -19,3 +21,5 @@ internal class CodeiumProposalManagerProvider : ProposalManagerProviderBase
1921
return CodeiumProposalManager.TryCreateAsync(view, this);
2022
}
2123
}
24+
25+
#pragma warning restore CS0618 // Type or member is obsolete

CodeiumVS/Proposal/CodeiumProposalSource.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace CodeiumVS;
1414

15+
#pragma warning disable CS0618 // Type or member is obsolete
1516
internal class CodeiumProposalSource : ProposalSourceBase
1617
{
1718

@@ -43,7 +44,7 @@ public override Task DisposeAsync()
4344
{
4445
_document.FileActionOccurred -= OnFileActionOccurred;
4546
_document.TextBuffer.ContentTypeChanged -= OnContentTypeChanged;
46-
UpdateRequestTokenSource(null, "source is being disposed");
47+
UpdateRequestTokenSource(null);
4748
return base.DisposeAsync();
4849
}
4950

@@ -69,7 +70,7 @@ public override async Task<ProposalCollectionBase> RequestProposalsAsync(Virtual
6970

7071
CancellationTokenSource cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
7172
cancellationToken = cancellationTokenSource.Token;
72-
UpdateRequestTokenSource(cancellationTokenSource, "new proposal requested");
73+
UpdateRequestTokenSource(cancellationTokenSource);
7374

7475
if (completionState != null)
7576
{
@@ -113,7 +114,7 @@ public override async Task<ProposalCollectionBase> RequestProposalsAsync(Virtual
113114
}
114115
}
115116

116-
private void UpdateRequestTokenSource(CancellationTokenSource newSource, string reason)
117+
private void UpdateRequestTokenSource(CancellationTokenSource newSource)
117118
{
118119
CancellationTokenSource cancellationTokenSource = Interlocked.Exchange(ref _requestTokenSource, newSource);
119120
if (cancellationTokenSource != null)
@@ -191,3 +192,5 @@ private void RefreshLanguage()
191192
}
192193

193194
}
195+
196+
#pragma warning restore CS0618 // Type or member is obsolete

CodeiumVS/Proposal/CodeiumProposalSourceProvider.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
namespace CodeiumVS;
1414

15-
// this get called first
15+
#pragma warning disable CS0618 // Type or member is obsolete
16+
1617
[Export(typeof(CodeiumProposalSourceProvider))]
1718
[Export(typeof(ProposalSourceProviderBase))]
1819
[Name("CodeiumProposalSourceProvider")]
@@ -27,7 +28,8 @@ internal class CodeiumProposalSourceProvider : ProposalSourceProviderBase
2728
internal CodeiumProposalSourceProvider(ITextDocumentFactoryService textDocumentFactoryService, SuggestionServiceBase suggestionServiceBase)
2829
{
2930
_textDocumentFactoryService = textDocumentFactoryService;
30-
suggestionServiceBase.GetType().GetEvent("SuggestionAcceptedInternal", BindingFlags.Instance | BindingFlags.Public)?.AddEventHandler(suggestionServiceBase, new EventHandler<EventArgs>(OnSuggestionAccepted));
31+
EventInfo? acceptedEvent = suggestionServiceBase.GetType().GetEvent("SuggestionAcceptedInternal", BindingFlags.Instance | BindingFlags.Public);
32+
acceptedEvent?.AddEventHandler(suggestionServiceBase, new EventHandler<EventArgs>(OnSuggestionAccepted));
3133
}
3234

3335
internal CodeiumProposalSource TryCreate(ITextView view)
@@ -36,8 +38,7 @@ internal CodeiumProposalSource TryCreate(ITextView view)
3638
wpfView = view as IWpfTextView;
3739
if (wpfView != null)
3840
{
39-
ITextDocument document = null;
40-
_textDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out document);
41+
_textDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out ITextDocument document);
4142
if (document != null && IsAbsolutePath(document.FilePath))
4243
{
4344
return view.Properties.GetOrCreateSingletonProperty(typeof(CodeiumProposalSource), () => new CodeiumProposalSource(wpfView, document));
@@ -57,12 +58,28 @@ private static bool IsAbsolutePath(string path)
5758

5859
private void OnSuggestionAccepted(object sender, EventArgs e)
5960
{
60-
string proposalId = ((SuggestionAcceptedEventArgs)e).FinalProposal.ProposalId;
61+
//string proposalId = ((SuggestionAcceptedEventArgs)e).FinalProposal.ProposalId;
62+
63+
// unfortunately in the SDK version 17.5.33428.388, there are no
64+
// SuggestionAcceptedEventArgs so we have to use reflection here
65+
66+
FieldInfo? fieldFinalProposal = e.GetType().GetField("FinalProposal", BindingFlags.Instance | BindingFlags.Public);
67+
if (fieldFinalProposal == null) return;
68+
69+
object finalProposal = fieldFinalProposal.GetValue(e);
70+
if (finalProposal == null) return;
71+
72+
PropertyInfo? propertydProposalId = fieldFinalProposal.FieldType.GetProperty("ProposalId", BindingFlags.Instance | BindingFlags.Public);
73+
if (propertydProposalId == null) return;
74+
75+
if (propertydProposalId.GetValue(finalProposal) is not string proposalId) return;
6176

62-
CodeiumVSPackage.Instance.Log("Accepted completion " + proposalId);
6377
ThreadHelper.JoinableTaskFactory.RunAsync(async delegate
6478
{
79+
await CodeiumVSPackage.Instance.LogAsync($"Accepted completion {proposalId}");
6580
await CodeiumVSPackage.Instance.LanguageServer.AcceptCompletionAsync(proposalId);
6681
}).FireAndForget(true);
6782
}
6883
}
84+
85+
#pragma warning restore CS0618 // Type or member is obsolete

CodeiumVS/Utilities/MefProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private MefProvider()
5050
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
5151

5252
// sastify mef import
53-
_compositionService = Requires.NotNull(await ServiceProvider.GetGlobalServiceAsync(typeof(SComponentModel)) as IComponentModel);
53+
_compositionService = Requires.NotNull(await ServiceProvider.GetGlobalServiceAsync(typeof(SComponentModel)) as IComponentModel, "_compositionService");
5454
_compositionService.DefaultCompositionService.SatisfyImportsOnce(this);
5555

5656
// disabled because not needed right now

0 commit comments

Comments
 (0)