Skip to content

Commit

Permalink
- [Fixed] Fixed tooltip doesnt open for "base" keyword.
Browse files Browse the repository at this point in the history
- [Updated] Updated ReSharper SDK to 2022.3.0.
- closes #176
  • Loading branch information
DimitarCC committed Dec 8, 2022
1 parent 2cbc574 commit 13ccc1d
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 34 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Changelog

## 3.19.0.4
- [Fixed] Fixed tooltip doesnt open for "base" keyword.
- [Updated] Updated ReSharper SDK to 2022.3.0.

## 3.18.0.11
- [Fixed] Fixed tooltip doesnt open for enum members.
- [Fixed] Fixed tooltip doesnt open for this keyword.
- [Fixed] Fixed tooltip doesnt open for "this" keyword.
- [Fixed] Fixed tooltip doesnt open for attributes that have not specified explicitly AllowMultiple and Inherited.

## 3.18.0.2
- [Fixed] Fixed wrongly labeled put parameters as ref.
- [Fixed] Fixed wrongly labeled out parameters as ref.

## 3.18.0.0
- [Updated] Updated ReSharper SDK to 2022.2.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="JetBrains.ReSharper.SDK" Version="2022.2.0" />
<PackageReference Include="JetBrains.ReSharper.SDK" Version="2022.3.0" />
<PackageReference Include="EnvDTE" Version="8.0.0" />
<PackageReference Include="VSSDK.Editor" Version="11.0.*" />
<PackageReference Include="VSSDK.Language" Version="11.0.*" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,36 @@ public RichTextBlock ObsoleteDescription
public int PositionalParameterCount
=> UnderlyingCandidate.PositionalParameterCount;

public RichTextBlock GetDescription()
=> UnderlyingCandidate.GetDescription();
/// <inheritdoc />
public RichTextBlock GetDescription(ParameterInfoSettings settings) => UnderlyingCandidate.GetDescription(settings);

public bool Matches(IDeclaredElement signature)
public bool Matches(IDeclaredElement signature)
=> UnderlyingCandidate.Matches(signature);

public void GetParametersInfo(out ParamPresentationInfo[] paramInfos, out Int32 paramArrayIndex)
/// <inheritdoc />
public RichText GetSignature(
String[] namedArguments,
ParameterInfoSettings settings,
out TextRange[] parameterRanges,
out Int32[] mapToOriginalOrder,
out ExtensionMethodInfo extensionMethodInfo) {

// TODO: handle named arguments with reordering; currently falling back to non-colored display
if (namedArguments.Any(s => s is not null)) {
RichText signature = UnderlyingCandidate.GetSignature(namedArguments, settings, out parameterRanges, out mapToOriginalOrder, out extensionMethodInfo);
if (!IsIdentityMap(mapToOriginalOrder))
return signature;
}

PresenterOptions options = GetPresenterOptions(_settings, settings.ShowAnnotations);
HighlighterIdProvider highlighterIdProvider = _highlighterIdProviderFactory.CreateProvider(_settings);

return TryGetSignatureCore(options, highlighterIdProvider, out parameterRanges, out mapToOriginalOrder, out extensionMethodInfo)
?? UnderlyingCandidate.GetSignature(namedArguments, settings, out parameterRanges, out mapToOriginalOrder, out extensionMethodInfo);

}

public void GetParametersInfo(out ParamPresentationInfo[] paramInfos, out Int32 paramArrayIndex)
=> UnderlyingCandidate.GetParametersInfo(out paramInfos, out paramArrayIndex);

public override bool Equals(object obj)
Expand All @@ -48,26 +71,6 @@ public override bool Equals(object obj)
public override int GetHashCode()
=> UnderlyingCandidate.GetHashCode();

public RichText GetSignature(
string[] namedArguments,
AnnotationsDisplayKind showAnnotations,
out TextRange[] parameterRanges,
out int[] mapToOriginalOrder,
out ExtensionMethodInfo extensionMethodInfo) {

// TODO: handle named arguments with reordering; currently falling back to non-colored display
if (namedArguments.Any(s => s is not null)) {
RichText signature = UnderlyingCandidate.GetSignature(namedArguments, showAnnotations, out parameterRanges, out mapToOriginalOrder, out extensionMethodInfo);
if (!IsIdentityMap(mapToOriginalOrder))
return signature;
}

PresenterOptions options = GetPresenterOptions(_settings, showAnnotations);
HighlighterIdProvider highlighterIdProvider = _highlighterIdProviderFactory.CreateProvider(_settings);

return TryGetSignatureCore(options, highlighterIdProvider, out parameterRanges, out mapToOriginalOrder, out extensionMethodInfo)
?? UnderlyingCandidate.GetSignature(namedArguments, showAnnotations, out parameterRanges, out mapToOriginalOrder, out extensionMethodInfo);
}

protected abstract PresenterOptions GetPresenterOptions(IContextBoundSettingsStore settings, AnnotationsDisplayKind showAnnotations);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using GammaJul.ReSharper.EnhancedTooltip.Presentation;
using GammaJul.ReSharper.EnhancedTooltip.Settings;
using JetBrains.Application.Settings;
using JetBrains.DocumentModel;
using JetBrains.ProjectModel;
Expand Down Expand Up @@ -29,7 +28,7 @@ public class EnhancedParameterInfoContextFactory : CSParameterInfoContextFactory
IContextBoundSettingsStore settingsStore) {

IParameterInfoContext? context = base.CreateContext(solution, caretOffset, expectedLParenthOffset, invocationChar, settingsStore);
if (context is null || !settingsStore.GetValue((ParameterInfoSettings s) => s.Enabled))
if (context is null || !settingsStore.GetValue((Settings.ParameterInfoSettings s) => s.Enabled))
return context;

return new EnhancedParameterInfoContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class EnhancedTypeArgumentContextFactory : CSTypeArgumentsInfoContextFact
IContextBoundSettingsStore settingsStore) {

IParameterInfoContext? context = base.CreateContext(solution, caretOffset, expectedLParenthOffset, invocationChar, settingsStore);
if (context is null || !settingsStore.GetValue((ParameterInfoSettings s) => s.Enabled))
if (context is null || !settingsStore.GetValue((Settings.ParameterInfoSettings s) => s.Enabled))
return context;

return new EnhancedTypeArgumentContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private void AppendDeclaredType(
}

if (context.Options.UseTypeKeywords) {
if (CSharpTypeFactory.GetTypeKeyword(declaredType.GetClrName()) is { } typeKeyword) {
if (CSharpTypeFactory.GetTypeKeyword(declaredType.GetTypeElement()) is { } typeKeyword) {
AppendText(typeKeyword, _highlighterIdProvider.Keyword);
if (declaredType.NullableAnnotation == NullableAnnotation.Annotated)
AppendText("?", _highlighterIdProvider.Operator);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.CSharp;
using JetBrains.ReSharper.Psi.CSharp.Parsing;
Expand Down Expand Up @@ -26,14 +27,31 @@ internal sealed class CSharpPresentableNodeFinder : IPresentableNodeFinder {
return FindElementFromThisKeyword(node, file, out sourceRange);
}

if (tokenType == CSharpTokenType.BASE_KEYWORD) {
return FindElementFromBaseKeyword(node, file, out sourceRange);
}

sourceRange = TextRange.InvalidRange;
return null;
}

private static DeclaredElementInstance? FindElementFromBaseKeyword(ITreeNode baseKeyword, IFile file, out TextRange sourceRange) {
sourceRange = TextRange.InvalidRange;
IDeclaredElement? declaredElement = (baseKeyword.Parent as IBaseExpression)
?.GetContainingTypeDeclaration()
?.DeclaredElement.GetSuperTypes().First().Resolve().DeclaredElement;

if (declaredElement is null)
return null;

sourceRange = file.GetDocumentRange(baseKeyword.GetTreeTextRange()).TextRange;
return new DeclaredElementInstance(declaredElement, EmptySubstitution.INSTANCE);
}

private static DeclaredElementInstance? FindElementFromThisKeyword(ITreeNode thisKeyword, IFile file, out TextRange sourceRange) {
sourceRange = TextRange.InvalidRange;
IDeclaredElement? declaredElement = (thisKeyword.Parent as IThisExpression)
?.GetContainingTypeDeclaration()
?.GetContainingTypeDeclaration()
?.DeclaredElement;

if (declaredElement is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("3.18.0.11")]
[assembly: AssemblyVersion("3.19.0.4")]
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void AugmentQuickInfoSession(IQuickInfoSession? session, IList<object?>?
[Pure]
private static IDocumentMarkup? TryGetDocumentMarkup(ITextView? textView)
=> VsTextViewSolutionContextProvider.TryGetContext(textView)?.TextControl.Document is { } document
&& Shell.Instance.TryGetComponent<IDocumentMarkupManager>()?.TryGetMarkupModel(document) is VsDocumentMarkupDevTen documentMarkup
&& Shell.Instance.TryGetComponent<IDocumentMarkupManager>()?.TryGetMarkupModel(document) is JetBrains.TextControl.DocumentMarkup.DocumentMarkup documentMarkup
? documentMarkup
: null;

Expand Down

0 comments on commit 13ccc1d

Please sign in to comment.