Skip to content

Commit 2fa14f9

Browse files
committed
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck into RemoveComProjectFlag
2 parents 79f23f1 + a110623 commit 2fa14f9

File tree

58 files changed

+485
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+485
-296
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/MissingModuleAnnotationInspection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
1717
/// do not have a Rubberduck annotation corresponding to the hidden VB attribute.
1818
/// </why>
1919
/// <example hasResult="true">
20-
/// <module name="MyModule" type="Class Module">
20+
/// <module name="MyModule" type="Predeclared Class">
2121
/// <![CDATA[
2222
/// Attribute VB_PredeclaredId = True
2323
/// Option Explicit
@@ -26,7 +26,7 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
2626
/// </module>
2727
/// </example>
2828
/// <example hasResult="false">
29-
/// <module name="MyModule" type="Class Module">
29+
/// <module name="MyModule" type="Predeclared Class">
3030
/// <![CDATA[
3131
/// Attribute VB_PredeclaredId = True
3232
/// '@PredeclaredId
@@ -92,4 +92,4 @@ protected override string ResultDescription(Declaration declaration, (string Att
9292
string.Join(", ", properties.AttributeValues));
9393
}
9494
}
95-
}
95+
}

Rubberduck.CodeAnalysis/Inspections/Concrete/ShadowedDeclarationInspection.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ private static bool DeclarationInAnotherComponentCanBeShadowed(Declaration origi
263263

264264
// It is not possible to directly access any declarations placed inside a Document Module. (Document Modules have DeclarationType ClassMoodule.)
265265
if (originalDeclaration.DeclarationType != DeclarationType.ClassModule &&
266-
originalDeclaration.DeclarationType != DeclarationType.Document &&
266+
originalDeclaration.DeclarationType != DeclarationType.Document &&
267267
originalDeclarationEnclosingType == ComponentType.Document)
268268
{
269269
return false;
270270
}
271271

272-
// It is not possible to directly access any declarations placed inside a User Form. (User Forms have DeclarationType ClassMoodule.)
272+
// It is not possible to directly access any declarations placed inside a User Form.
273273
if (originalDeclaration.DeclarationType != DeclarationType.ClassModule &&
274-
originalDeclaration.DeclarationType != DeclarationType.Document &&
274+
originalDeclaration.DeclarationType != DeclarationType.Document &&
275275
originalDeclarationEnclosingType == ComponentType.UserForm)
276276
{
277277
return false;
@@ -312,10 +312,10 @@ private static bool DeclarationInAnotherComponentCanBeShadowed(Declaration origi
312312
private static bool DeclarationInTheSameComponentCanBeShadowed(Declaration originalDeclaration, Declaration userDeclaration)
313313
{
314314
// Shadowing the component containing the declaration is not a problem, because it is possible to directly access declarations inside that component
315-
if (originalDeclaration.DeclarationType == DeclarationType.ProceduralModule ||
315+
if (originalDeclaration.DeclarationType == DeclarationType.ProceduralModule ||
316316
originalDeclaration.DeclarationType == DeclarationType.ClassModule ||
317317
originalDeclaration.DeclarationType == DeclarationType.Document ||
318-
userDeclaration.DeclarationType == DeclarationType.ProceduralModule ||
318+
userDeclaration.DeclarationType == DeclarationType.ProceduralModule ||
319319
userDeclaration.DeclarationType == DeclarationType.ClassModule ||
320320
userDeclaration.DeclarationType == DeclarationType.Document)
321321
{

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ public CodeExplorerComponentViewModel(ICodeExplorerNode parent, Declaration decl
4949
Declaration.IsUserDefined &&
5050
Declaration.DeclarationType == DeclarationType.ClassModule &&
5151
Declaration.QualifiedName.QualifiedModuleName.ComponentType != ComponentType.Document &&
52+
Declaration.QualifiedName.QualifiedModuleName.ComponentType != ComponentType.UserForm &&
5253
Declaration.Attributes.HasPredeclaredIdAttribute(out _);
5354

5455
public bool IsTestModule => Declaration.DeclarationType == DeclarationType.ProceduralModule
55-
&& Declaration.Annotations.Any(annotation => annotation is TestModuleAnnotation);
56+
&& Declaration.Annotations.Any(annotation => annotation.Annotation is TestModuleAnnotation);
5657

5758
public override void Synchronize(ref List<Declaration> updated)
5859
{

Rubberduck.Core/Rubberduck.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ApplicationIcon>Ducky.ico</ApplicationIcon>
1414
<!-- Give a fixed version to not blow XAML generated code to smithereens -->
1515
<!-- This also fixes "Input string was not in the correct format" error message when referring to the current assembly in an XAML-Namespace -->
16-
<AssemblyVersion>2.5.0</AssemblyVersion>
16+
<AssemblyVersion>2.5.1</AssemblyVersion>
1717
</PropertyGroup>
1818
<Import Project="..\RubberduckBaseProject.csproj" />
1919
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugAccess|AnyCPU'">

Rubberduck.Core/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@
398398

399399
<TreeView x:Name="ProjectTree"
400400
Grid.Row="2"
401-
Background="{StaticResource BackgroundLightBrush}"
401+
Background="{StaticResource BackgroundWhiteBrush}"
402402
HorizontalContentAlignment="Stretch"
403403
ItemsSource="{Binding Projects}"
404404
ItemContainerStyle="{StaticResource TreeViewContainerStyle}"

Rubberduck.Core/UI/Converters/CodeExplorerNodeToIconConverter.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class CodeExplorerNodeToIconConverter : ImageSourceConverter, IMultiValue
6262

6363
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
6464
{
65-
if ((value as ICodeExplorerNode )?.Declaration is null)
65+
if ((value as ICodeExplorerNode)?.Declaration is null)
6666
{
6767
return NullIcon;
6868
}
@@ -93,19 +93,20 @@ public override object Convert(object value, Type targetType, object parameter,
9393
}
9494

9595
if (component.Declaration is ClassModuleDeclaration classModule &&
96-
(classModule.IsInterface || classModule.Annotations.Any(annotation => annotation is InterfaceAnnotation)))
96+
(classModule.IsInterface || classModule.Annotations.Any(annotation => annotation.Annotation is InterfaceAnnotation)))
9797
{
9898
return InterfaceIcon;
9999
}
100100

101+
var isUserForm = component.Declaration.QualifiedModuleName.ComponentType == VBEditor.SafeComWrappers.ComponentType.UserForm;
101102
return DeclarationIcons.ContainsKey(component.Declaration.DeclarationType)
102-
? DeclarationIcons[component.Declaration.DeclarationType]
103+
? DeclarationIcons[isUserForm ? DeclarationType.UserForm : component.Declaration.DeclarationType]
103104
: ExceptionIcon;
104105
default:
105106
return value is ICodeExplorerNode node &&
106107
node.Declaration != null &&
107108
DeclarationIcons.ContainsKey(node.Declaration.DeclarationType)
108-
? node.Declaration.Annotations.Any(a => a is TestMethodAnnotation)
109+
? node.Declaration.Annotations.Any(a => a.Annotation is TestMethodAnnotation)
109110
? TestMethodIcon
110111
: DeclarationIcons[node.Declaration.DeclarationType]
111112
: ExceptionIcon;

Rubberduck.Core/UI/Styles/LightBlueTheme.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
<Color x:Key="CaptionHyperlinkVisitedColor">#FFFF0000</Color>
3232
<Color x:Key="BackgroundDarkColor">#FFA9A9A9</Color>
3333
<Color x:Key="BackgroundLightColor">#FFF5F5F5</Color>
34+
<Color x:Key="BackgroundWhiteColor">#FFFFFFFF</Color>
3435
<Color x:Key="BackgroundSoftColor">#FFF8F8FF</Color>
3536
<Color x:Key="HeaderBackgroundDarkColor">#FFA9A9A9</Color>
3637
<Color x:Key="TabSelectionUnderlineColor">#FF0000FF</Color>
3738
<Color x:Key="GrayColor">#FF696969</Color>
38-
<Color x:Key="BlackColor">#FFFFFFFF</Color>
39-
<Color x:Key="WhiteColor">#FF000000</Color>
39+
<Color x:Key="BlackColor">#FFFFFFFF</Color> <!-- FIXME white is black... -->
40+
<Color x:Key="WhiteColor">#FF000000</Color> <!-- FIXME black is white... -->
4041
<Color x:Key="BusyIndicatorFillColor">#FF00569A</Color>
4142

4243
<Color x:Key="ToolBarButtonHoverColor">#210080FF</Color>

Rubberduck.Core/UI/ViewModelBase.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ protected virtual void OnErrorsChanged(string propertyName = null)
5151

5252
public IEnumerable GetErrors(string propertyName)
5353
{
54-
return _errors.TryGetValue(propertyName, out var errorList)
55-
? errorList
56-
: null;
54+
if (propertyName != null)
55+
{
56+
return _errors.TryGetValue(propertyName, out var errorList)
57+
? errorList
58+
: null;
59+
}
60+
return null;
5761
}
5862

5963
public bool HasErrors => _errors.Any();

Rubberduck.Parsing/VBA/DeclarationCaching/DeclarationFinder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ private IDictionary<ClassModuleDeclaration, List<Declaration>> FindAllInterfaceM
243243
{
244244
return UserDeclarations(DeclarationType.ClassModule)
245245
.Concat(UserDeclarations(DeclarationType.Document))
246+
.Concat(UserDeclarations(DeclarationType.UserForm))
246247
.Cast<ClassModuleDeclaration>()
247248
.Where(module => module.IsInterface)
248249
.ToDictionary(

Rubberduck.Parsing/VBA/DeclarationResolving/DeclarationResolveRunnerBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ private ModuleDeclaration NewModuleDeclaration(
191191
true,
192192
moduleAnnotations,
193193
moduleAttributes);
194+
194195
case ComponentType.ClassModule:
195196
return new ClassModuleDeclaration(
196197
qualifiedModuleName.QualifyMemberName(qualifiedModuleName.ComponentName),
@@ -199,14 +200,16 @@ private ModuleDeclaration NewModuleDeclaration(
199200
true,
200201
moduleAnnotations,
201202
moduleAttributes);
203+
202204
case ComponentType.Document:
203205
return new DocumentModuleDeclaration(
204206
qualifiedModuleName.QualifyMemberName(qualifiedModuleName.ComponentName),
205207
projectDeclaration,
206208
qualifiedModuleName.ComponentName,
207209
moduleAnnotations,
208210
moduleAttributes);
209-
default:
211+
212+
default: /*ComponentType.UserForm*/
210213
return new ClassModuleDeclaration(
211214
qualifiedModuleName.QualifyMemberName(qualifiedModuleName.ComponentName),
212215
projectDeclaration,

Rubberduck.Parsing/VBA/ReferenceManagement/CompilationPasses/TypeHierarchyPass.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public void Execute(IReadOnlyCollection<QualifiedModuleName> modules)
3333
{
3434
var toRelsolveSupertypesFor = _declarationFinder.UserDeclarations(DeclarationType.ClassModule)
3535
.Concat(_declarationFinder.UserDeclarations(DeclarationType.Document))
36+
.Concat(_declarationFinder.UserDeclarations(DeclarationType.UserForm))
3637
.Where(decl => modules.Contains(decl.QualifiedName.QualifiedModuleName))
3738
.Concat(_declarationFinder.BuiltInDeclarations(DeclarationType.ClassModule));
3839
foreach (var declaration in toRelsolveSupertypesFor)

Rubberduck.Refactorings/Common/CodeBuilder.cs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Rubberduck.Parsing.Grammar;
1+
using Rubberduck.Common;
2+
using Rubberduck.Parsing.Grammar;
23
using Rubberduck.Parsing.Symbols;
34
using System;
45
using System.Collections.Generic;
@@ -11,19 +12,13 @@ public interface ICodeBuilder
1112
/// <summary>
1213
/// Returns ModuleBodyElementDeclaration signature with an ImprovedArgument list
1314
/// </summary>
14-
/// <param name="declaration"></param>
15-
/// <returns></returns>
1615
string ImprovedFullMemberSignature(ModuleBodyElementDeclaration declaration);
1716

1817
/// <summary>
1918
/// Returns a ModuleBodyElementDeclaration block
2019
/// with an ImprovedArgument List
2120
/// </summary>
22-
/// <param name="declaration"></param>
2321
/// <param name="content">Main body content/logic of the member</param>
24-
/// <param name="accessibility"></param>
25-
/// <param name="newIdentifier"></param>
26-
/// <returns></returns>
2722
string BuildMemberBlockFromPrototype(ModuleBodyElementDeclaration declaration,
2823
string content = null,
2924
string accessibility = null,
@@ -34,19 +29,14 @@ string BuildMemberBlockFromPrototype(ModuleBodyElementDeclaration declaration,
3429
/// 1. Explicitly declares Property Let\Set value parameter as ByVal
3530
/// 2. Ensures UserDefined Type parameters are declared either explicitly or implicitly as ByRef
3631
/// </summary>
37-
/// <param name="declaration"></param>
38-
/// <returns></returns>
3932
string ImprovedArgumentList(ModuleBodyElementDeclaration declaration);
4033

4134
/// <summary>
4235
/// Generates a Property Get codeblock based on the prototype declaration
4336
/// </summary>
4437
/// <param name="prototype">VariableDeclaration or UserDefinedTypeMember</param>
45-
/// <param name="propertyIdentifier"></param>
46-
/// <param name="accessibility"></param>
4738
/// <param name="content">Member body content. Formatting is the responsibility of the caller</param>
48-
/// <param name="parameterIdentifier">Defaults to 'value' unless otherwise specified</param>
49-
/// <returns></returns>
39+
/// <param name="parameterIdentifier">Defaults to '<paramref name="propertyIdentifier"/>Value' unless otherwise specified</param>
5040
bool TryBuildPropertyGetCodeBlock(Declaration prototype,
5141
string propertyIdentifier,
5242
out string codeBlock,
@@ -57,11 +47,8 @@ bool TryBuildPropertyGetCodeBlock(Declaration prototype,
5747
/// Generates a Property Let codeblock based on the prototype declaration
5848
/// </summary>
5949
/// <param name="prototype">VariableDeclaration or UserDefinedTypeMember</param>
60-
/// <param name="propertyIdentifier"></param>
61-
/// <param name="accessibility"></param>
62-
/// <param name="content">Membmer body content. Formatting is the responsibility of the caller</param>
63-
/// <param name="parameterIdentifier">Defaults to 'value' unless otherwise specified</param>
64-
/// <returns></returns>
50+
/// <param name="content">Member body content. Formatting is the responsibility of the caller</param>
51+
/// <param name="parameterIdentifier">Defaults to '<paramref name="propertyIdentifier"/>Value' unless otherwise specified</param>
6552
bool TryBuildPropertyLetCodeBlock(Declaration prototype,
6653
string propertyIdentifier,
6754
out string codeBlock,
@@ -73,11 +60,8 @@ bool TryBuildPropertyLetCodeBlock(Declaration prototype,
7360
/// Generates a Property Set codeblock based on the prototype declaration
7461
/// </summary>
7562
/// <param name="prototype">VariableDeclaration or UserDefinedTypeMember</param>
76-
/// <param name="propertyIdentifier"></param>
77-
/// <param name="accessibility"></param>
78-
/// <param name="content">Membmer body content. Formatting is the responsibility of the caller</param>
79-
/// <param name="parameterIdentifier">Defaults to 'value' unless otherwise specified</param>
80-
/// <returns></returns>
63+
/// <param name="content">Member body content. Formatting is the responsibility of the caller</param>
64+
/// <param name="parameterIdentifier">Defaults to '<paramref name="propertyIdentifier"/>Value' unless otherwise specified</param>
8165
bool TryBuildPropertySetCodeBlock(Declaration prototype,
8266
string propertyIdentifier,
8367
out string codeBlock,
@@ -127,7 +111,7 @@ private bool TryBuildPropertyBlockFromTarget<T>(T prototype, DeclarationType let
127111
return false;
128112
}
129113

130-
var propertyValueParam = parameterIdentifier ?? Resources.RubberduckUI.EncapsulateField_DefaultPropertyParameter;
114+
var propertyValueParam = parameterIdentifier ?? Resources.Refactorings.Refactorings.CodeBuilder_DefaultPropertyRHSParam;
131115

132116
var asType = prototype.IsArray
133117
? $"{Tokens.Variant}"

Rubberduck.Refactorings/EncapsulateField/EncapsulateFieldElementsBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using Rubberduck.Parsing.Grammar;
2-
using Rubberduck.Parsing.Symbols;
1+
using Rubberduck.Parsing.Symbols;
32
using Rubberduck.Parsing.VBA;
43
using Rubberduck.Refactorings.Common;
5-
using Rubberduck.Refactorings.EncapsulateField.Extensions;
64
using Rubberduck.VBEditor;
75
using System;
86
using System.Collections.Generic;
@@ -16,12 +14,14 @@ public class EncapsulateFieldElementsBuilder
1614
private readonly IDeclarationFinderProvider _declarationFinderProvider;
1715
private QualifiedModuleName _targetQMN;
1816
private string _defaultObjectStateUDTTypeName;
17+
private ICodeBuilder _codeBuilder;
1918

2019
public EncapsulateFieldElementsBuilder(IDeclarationFinderProvider declarationFinderProvider, QualifiedModuleName targetQMN)
2120
{
2221
_declarationFinderProvider = declarationFinderProvider;
2322
_targetQMN = targetQMN;
2423
_defaultObjectStateUDTTypeName = $"T{_targetQMN.ComponentName}";
24+
_codeBuilder = new CodeBuilder();
2525
CreateRefactoringElements();
2626
}
2727

Rubberduck.Refactorings/EncapsulateField/FieldCandidates/ArrayCandidate.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
using Antlr4.Runtime;
2-
using Rubberduck.Parsing;
1+
using Rubberduck.Parsing;
32
using Rubberduck.Parsing.Grammar;
43
using Rubberduck.Parsing.Symbols;
54
using Rubberduck.Resources;
6-
using System;
75
using System.Linq;
86

97
namespace Rubberduck.Refactorings.EncapsulateField

Rubberduck.Refactorings/EncapsulateField/FieldCandidates/ConvertToUDTMemberCandidate.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using Antlr4.Runtime;
73
using Rubberduck.Common;
8-
using Rubberduck.Parsing.Grammar;
94
using Rubberduck.Parsing.Symbols;
105
using Rubberduck.VBEditor;
116

@@ -90,11 +85,7 @@ public bool IsReadOnly
9085
get => _wrapped.IsReadOnly;
9186
}
9287

93-
public string ParameterName
94-
{
95-
set => _wrapped.ParameterName = value;
96-
get => _wrapped.ParameterName;
97-
}
88+
public string ParameterName => _wrapped.ParameterName;
9889

9990
public IValidateVBAIdentifiers NameValidator
10091
{

0 commit comments

Comments
 (0)