Skip to content

Commit

Permalink
- [Fixed] Fixed tooltip doesnt open for enum members.
Browse files Browse the repository at this point in the history
- [Fixed] Fixed tooltip doesnt open for this keyword.
- [Fixed] Fixed tooltip doesnt open for attributes that have not specified explicitly AllowMultiple and Inherited.
  • Loading branch information
DimitarCC committed Aug 30, 2022
1 parent 22ab28a commit 2cbc574
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 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 attributes that have not specified explicitly AllowMultiple and Inherited.

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,10 @@ private static AttributeUsageContent GetAttributeUsage(IClass attributeClass) {

if (attributeClass.GetAttributeInstances(PredefinedType.ATTRIBUTE_USAGE_ATTRIBUTE_CLASS, true).FirstOrDefault() is { } attributeUsage) {
targets = (AttributeTargets?) (attributeUsage.PositionParameter(0).ConstantValue.IntValue) ?? AttributeTargets.All;
allowMultiple = attributeUsage.NamedParameter(nameof(AttributeUsageAttribute.AllowMultiple)).ConstantValue.BoolValue as bool? ?? false;
inherited = attributeUsage.NamedParameter(nameof(AttributeUsageAttribute.Inherited)).ConstantValue.BoolValue as bool? ?? true;
var allowMultipleConstant = attributeUsage.NamedParameter(nameof(AttributeUsageAttribute.AllowMultiple)).ConstantValue;
allowMultiple = !allowMultipleConstant.IsBadValue() && ((Boolean)allowMultipleConstant.BoolValue);
var inheritedConstant = attributeUsage.NamedParameter(nameof(AttributeUsageAttribute.Inherited)).ConstantValue;
inherited = inheritedConstant.IsBadValue() || ((Boolean)attributeUsage.NamedParameter(nameof(AttributeUsageAttribute.Inherited)).ConstantValue.BoolValue);
}
else {
targets = AttributeTargets.All;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ private void AppendConstantValue(ConstantValue constantValue, bool treatEnumAsIn

if (constantValue.Type.GetEnumType() is { } enumType) {
if (treatEnumAsIntegral) {
AppendText(constantValue.StringValue ?? String.Empty, _highlighterIdProvider.Number);
AppendText(constantValue.IsEnum() ? constantValue.ToIntUnchecked().ToString() : constantValue.StringValue ?? String.Empty, _highlighterIdProvider.Number);
return;
}
if (AppendEnumValue(constantValue, enumType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,28 @@ internal sealed class CSharpPresentableNodeFinder : IPresentableNodeFinder {

if (tokenType == CSharpTokenType.NEW_KEYWORD)
return FindElementFromNewKeyword(node, file, out sourceRange);


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

sourceRange = TextRange.InvalidRange;
return null;
}

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

if (declaredElement is null)
return null;

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

private static DeclaredElementInstance? FindElementFromVarKeyword(ITreeNode varKeyword, IFile file, out TextRange sourceRange) {
sourceRange = TextRange.InvalidRange;

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.2")]
[assembly: AssemblyVersion("3.18.0.11")]

0 comments on commit 2cbc574

Please sign in to comment.