Skip to content

Commit 6710770

Browse files
committed
Add allowed argument types to IAnnotation
There has to be at least one per required argument. All optional arguments have the last allowed type in the list.
1 parent 5fec4ad commit 6710770

22 files changed

+78
-74
lines changed

Rubberduck.Core/UI/Controls/FindAllReferencesService.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ public class FindAllReferencesService : IDisposable
2222
private readonly SearchResultPresenterInstanceManager _presenterService;
2323
private readonly IUiDispatcher _uiDispatcher;
2424

25-
public FindAllReferencesService(INavigateCommand navigateCommand, IMessageBox messageBox,
26-
RubberduckParserState state, ISearchResultsWindowViewModel viewModel,
27-
SearchResultPresenterInstanceManager presenterService, IUiDispatcher uiDispatcher)
25+
public FindAllReferencesService(
26+
INavigateCommand navigateCommand,
27+
IMessageBox messageBox,
28+
RubberduckParserState state,
29+
ISearchResultsWindowViewModel viewModel,
30+
SearchResultPresenterInstanceManager presenterService,
31+
IUiDispatcher uiDispatcher)
2832
{
2933
_navigateCommand = navigateCommand;
3034
_messageBox = messageBox;

Rubberduck.Parsing/Annotations/AnnotationBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ public abstract class AnnotationBase : IAnnotation
88
public bool AllowMultiple { get; }
99
public int RequiredArguments { get; }
1010
public int? AllowedArguments { get; }
11+
public IReadOnlyList<AnnotationArgumentType> AllowedArgumentTypes { get; }
1112
public string Name { get; }
1213
public AnnotationTarget Target { get; }
1314

14-
protected AnnotationBase(string name, AnnotationTarget target, int requiredArguments = 0, int? allowedArguments = 0, bool allowMultiple = false)
15+
protected AnnotationBase(string name, AnnotationTarget target, int requiredArguments = 0, int? allowedArguments = 0, IReadOnlyList<AnnotationArgumentType> allowedArgumentTypes = null, bool allowMultiple = false)
1516
{
1617
Name = name;
1718
Target = target;
1819
AllowMultiple = allowMultiple;
1920
RequiredArguments = requiredArguments;
2021
AllowedArguments = allowedArguments;
22+
AllowedArgumentTypes = allowedArgumentTypes ?? new List<AnnotationArgumentType>();
2123
}
2224

2325
public virtual IReadOnlyList<string> ProcessAnnotationArguments(IEnumerable<string> arguments)
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System.Collections.Generic;
2-
using System.Linq;
3-
using Rubberduck.Parsing.Grammar;
4-
using Rubberduck.VBEditor;
51
using Rubberduck.Resources.Registration;
62

73
namespace Rubberduck.Parsing.Annotations
@@ -13,7 +9,6 @@ public sealed class DefaultMemberAnnotation : FixedAttributeValueAnnotationBase
139
{
1410
public DefaultMemberAnnotation()
1511
: base("DefaultMember", AnnotationTarget.Member, "VB_UserMemId", new[] { WellKnownDispIds.Value.ToString() })
16-
{
17-
}
12+
{}
1813
}
1914
}
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
using System.Collections.Generic;
2-
using Rubberduck.Parsing.Grammar;
3-
using Rubberduck.VBEditor;
4-
5-
namespace Rubberduck.Parsing.Annotations
1+
namespace Rubberduck.Parsing.Annotations
62
{
73
/// <summary>
84
/// Used for specifying a member's <c>VB_Description</c> attribute.
95
/// </summary>
106
public sealed class DescriptionAnnotation : DescriptionAttributeAnnotationBase
117
{
128
public DescriptionAnnotation()
13-
: base("Description", AnnotationTarget.Member, "VB_Description", 1)
9+
: base("Description", AnnotationTarget.Member, "VB_Description")
1410
{}
1511
}
1612
}
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
using System.Collections.Generic;
2-
using System.Linq;
3-
using Rubberduck.Parsing.Grammar;
4-
using Rubberduck.VBEditor;
52

63
namespace Rubberduck.Parsing.Annotations
74
{
85
public abstract class DescriptionAttributeAnnotationBase : FlexibleAttributeValueAnnotationBase
96
{
10-
public DescriptionAttributeAnnotationBase(string name, AnnotationTarget target, string attribute, int valueCount)
11-
: base(name, target, attribute, valueCount)
12-
{ }
7+
public DescriptionAttributeAnnotationBase(string name, AnnotationTarget target, string attribute)
8+
: base(name, target, attribute, 1, new List<AnnotationArgumentType> { AnnotationArgumentType.Text })
9+
{}
1310
}
1411
}

Rubberduck.Parsing/Annotations/Concrete/EnumeratorMemberAnnotation.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System.Collections.Generic;
2-
using Rubberduck.Parsing.Grammar;
3-
using Rubberduck.VBEditor;
41
using Rubberduck.Resources.Registration;
52

63
namespace Rubberduck.Parsing.Annotations

Rubberduck.Parsing/Annotations/Concrete/ExcelHotKeyAnnotation.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
43
using Rubberduck.Common;
5-
using Rubberduck.Parsing.Grammar;
6-
using Rubberduck.VBEditor;
74

85
namespace Rubberduck.Parsing.Annotations
96
{
107
public sealed class ExcelHotKeyAnnotation : FlexibleAttributeValueAnnotationBase
118
{
129
public ExcelHotKeyAnnotation()
13-
: base("ExcelHotkey", AnnotationTarget.Member, "VB_ProcData.VB_Invoke_Func", 1)
14-
{ }
10+
: base("ExcelHotkey", AnnotationTarget.Member, "VB_ProcData.VB_Invoke_Func", 1, new[] { AnnotationArgumentType.Text})
11+
{}
1512

1613
public override IReadOnlyList<string> AnnotationToAttributeValues(IReadOnlyList<string> annotationValues)
1714
{

Rubberduck.Parsing/Annotations/Concrete/ExposedModuleAnnotation.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System.Collections.Generic;
2-
using Rubberduck.Parsing.Grammar;
3-
using Rubberduck.VBEditor;
4-
51
namespace Rubberduck.Parsing.Annotations
62
{
73
/// <summary>

Rubberduck.Parsing/Annotations/Concrete/FlexibleAttributeAnnotationBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace Rubberduck.Parsing.Annotations
66
{
77
public abstract class FlexibleAttributeAnnotationBase : AnnotationBase, IAttributeAnnotation
88
{
9-
protected FlexibleAttributeAnnotationBase(string name, AnnotationTarget target, bool allowMultiple = false)
10-
: base(name, target, 2, null, allowMultiple) //We need at least the attribute name and one value for it.
9+
protected FlexibleAttributeAnnotationBase(string name, AnnotationTarget target, IReadOnlyList<AnnotationArgumentType> allowedArgumentType, bool allowMultiple = false)
10+
: base(name, target, 2, null, allowedArgumentType, allowMultiple) //We need at least the attribute name and one value for it.
1111
{}
1212

1313
public IReadOnlyList<string> AnnotationToAttributeValues(IReadOnlyList<string> annotationValues)

Rubberduck.Parsing/Annotations/Concrete/FlexibleAttributeValueAnnotationBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public abstract class FlexibleAttributeValueAnnotationBase : AnnotationBase, IAt
99
private readonly string _attribute;
1010
private readonly int _numberOfValues;
1111

12-
protected FlexibleAttributeValueAnnotationBase(string name, AnnotationTarget target, string attribute, int numberOfValues)
12+
protected FlexibleAttributeValueAnnotationBase(string name, AnnotationTarget target, string attribute, int numberOfValues, IReadOnlyList<AnnotationArgumentType> argumentTypes)
1313
: base(name, target, numberOfValues, numberOfValues)
1414
{
1515
_attribute = attribute;

0 commit comments

Comments
 (0)