Skip to content

Commit

Permalink
Merge pull request #40 from Abc-Arbitrage/fix/36
Browse files Browse the repository at this point in the history
  • Loading branch information
ltrzesniewski authored Mar 12, 2024
2 parents a8b32c8 + ddc9b88 commit bee91de
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
using Abc.MoqComplete.Services;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Feature.Services.CodeCompletion;
using JetBrains.ReSharper.Feature.Services.CodeCompletion.Infrastructure;
using JetBrains.ReSharper.Feature.Services.CodeCompletion.Infrastructure.LookupItems;
using JetBrains.ReSharper.Feature.Services.CSharp.CodeCompletion.Infrastructure;
using JetBrains.ReSharper.Features.Intellisense.CodeCompletion.CSharp;
using JetBrains.ReSharper.Features.Intellisense.CodeCompletion.CSharp.Rules;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.CSharp;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using JetBrains.ReSharper.Psi.ExpectedTypes;
using JetBrains.ReSharper.Psi.ExtensionsAPI.Tree;
using JetBrains.ReSharper.Psi.Resources;
using JetBrains.ReSharper.Psi.Util;

Expand Down Expand Up @@ -50,7 +53,20 @@ protected override bool AddLookupItems(CSharpCodeCompletionContext context, IIte
private static ILookupItem GetLookupItem(CSharpCodeCompletionContext context, string proposedCompletion)
{
var lookupItem = CSharpLookupItemFactory.Instance.CreateKeywordLookupItem(context, proposedCompletion, TailType.None, PsiSymbolsThemedIcons.Variable.Id);
lookupItem.WithInitializedRanges(context.CompletionRanges, context.BasicContext);

var node = context.NodeInFile;
while (!(node is ICSharpArgument) && node != null) node = node?.Parent;
if (node != null)
{
var arg = (ICSharpArgument)node;
var range = arg.GetExtendedDocumentRange();
lookupItem.SetRanges(context.CompletionRanges.WithReplaceRange(range));
}
else
{
lookupItem.WithInitializedRanges(context.CompletionRanges, context.BasicContext);
}

lookupItem.SetTopPriority();
return lookupItem;
}
Expand Down

0 comments on commit bee91de

Please sign in to comment.