Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #36 #40

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
Kuinox marked this conversation as resolved.
Show resolved Hide resolved
else
{
lookupItem.WithInitializedRanges(context.CompletionRanges, context.BasicContext);
}

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