Skip to content

Commit c1b0686

Browse files
authored
Merge pull request #2166 from rubberduck-vba/next
Release 2.0.8
2 parents 20052b9 + 2e25afe commit c1b0686

File tree

122 files changed

+3933
-5774
lines changed

Some content is hidden

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

122 files changed

+3933
-5774
lines changed

RetailCoder.VBE/App.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public void Dispose()
205205
{
206206
_parser.State.StateChanged -= Parser_StateChanged;
207207
_parser.State.StatusMessageUpdate -= State_StatusMessageUpdate;
208+
_parser.State.Dispose();
208209
_parser.Dispose();
209210
// I won't set this to null because other components may try to release things
210211
}

RetailCoder.VBE/Inspections/ConvertToProcedureQuickFix.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,18 @@
66
using System.Collections.Generic;
77
using System.Linq;
88
using System.Text.RegularExpressions;
9-
using Microsoft.Vbe.Interop;
109
using Rubberduck.Parsing.Symbols;
1110

1211
namespace Rubberduck.Inspections
1312
{
1413
public class ConvertToProcedureQuickFix : CodeInspectionQuickFix
1514
{
16-
private readonly IEnumerable<string> _returnStatements;
15+
private readonly Declaration _target;
1716

18-
public ConvertToProcedureQuickFix(ParserRuleContext context, QualifiedSelection selection)
19-
: this(context, selection, new List<string>())
20-
{
21-
}
22-
23-
public ConvertToProcedureQuickFix(ParserRuleContext context, QualifiedSelection selection, IEnumerable<string> returnStatements)
17+
public ConvertToProcedureQuickFix(ParserRuleContext context, QualifiedSelection selection, Declaration target)
2418
: base(context, selection, InspectionsUI.ConvertFunctionToProcedureQuickFix)
2519
{
26-
_returnStatements = returnStatements;
20+
_target = target;
2721
}
2822

2923
public override void Fix()
@@ -37,47 +31,53 @@ public override void Fix()
3731
throw new InvalidOperationException(string.Format(InspectionsUI.InvalidContextTypeInspectionFix, Context.GetType(), GetType()));
3832
}
3933

34+
var functionName = Context is VBAParser.FunctionStmtContext
35+
? ((VBAParser.FunctionStmtContext) Context).functionName()
36+
: ((VBAParser.PropertyGetStmtContext) Context).functionName();
4037

41-
VBAParser.FunctionNameContext functionName = null;
42-
if (Context is VBAParser.FunctionStmtContext)
43-
{
44-
functionName = ((VBAParser.FunctionStmtContext)Context).functionName();
45-
}
46-
else
47-
{
48-
functionName = ((VBAParser.PropertyGetStmtContext)Context).functionName();
49-
}
50-
51-
string token = functionContext != null
38+
var token = functionContext != null
5239
? Tokens.Function
5340
: Tokens.Property + ' ' + Tokens.Get;
54-
string endToken = token == Tokens.Function
41+
var endToken = token == Tokens.Function
5542
? token
5643
: Tokens.Property;
5744

5845
string visibility = context.visibility() == null ? string.Empty : context.visibility().GetText() + ' ';
59-
string name = ' ' + Identifier.GetName(functionName.identifier());
60-
bool hasTypeHint = Identifier.GetTypeHintValue(functionName.identifier()) != null;
46+
var name = ' ' + Identifier.GetName(functionName.identifier());
47+
var hasTypeHint = Identifier.GetTypeHintValue(functionName.identifier()) != null;
6148

6249
string args = context.argList().GetText();
6350
string asType = context.asTypeClause() == null ? string.Empty : ' ' + context.asTypeClause().GetText();
6451

65-
string oldSignature = visibility + token + name + (hasTypeHint ? Identifier.GetTypeHintValue(functionName.identifier()) : string.Empty) + args + asType;
66-
string newSignature = visibility + Tokens.Sub + name + args;
52+
var oldSignature = visibility + token + name + (hasTypeHint ? Identifier.GetTypeHintValue(functionName.identifier()) : string.Empty) + args + asType;
53+
var newSignature = visibility + Tokens.Sub + name + args;
6754

68-
string procedure = Context.GetText();
69-
string noReturnStatements = procedure;
70-
_returnStatements.ToList().ForEach(returnStatement =>
55+
var procedure = Context.GetText();
56+
var noReturnStatements = procedure;
57+
58+
GetReturnStatements(_target).ToList().ForEach(returnStatement =>
7159
noReturnStatements = Regex.Replace(noReturnStatements, @"[ \t\f]*" + returnStatement + @"[ \t\f]*\r?\n?", ""));
72-
string result = noReturnStatements.Replace(oldSignature, newSignature)
60+
var result = noReturnStatements.Replace(oldSignature, newSignature)
7361
.Replace(Tokens.End + ' ' + endToken, Tokens.End + ' ' + Tokens.Sub)
7462
.Replace(Tokens.Exit + ' ' + endToken, Tokens.Exit + ' ' + Tokens.Sub);
7563

76-
CodeModule module = Selection.QualifiedName.Component.CodeModule;
77-
Selection selection = Context.GetSelection();
64+
var module = Selection.QualifiedName.Component.CodeModule;
65+
var selection = Context.GetSelection();
7866

7967
module.DeleteLines(selection.StartLine, selection.LineCount);
8068
module.InsertLines(selection.StartLine, result);
8169
}
70+
71+
private IEnumerable<string> GetReturnStatements(Declaration declaration)
72+
{
73+
return declaration.References
74+
.Where(usage => IsReturnStatement(declaration, usage))
75+
.Select(usage => usage.Context.Parent.GetText());
76+
}
77+
78+
private bool IsReturnStatement(Declaration declaration, IdentifierReference assignment)
79+
{
80+
return assignment.ParentScoping.Equals(declaration) && assignment.Declaration.Equals(declaration);
81+
}
8282
}
8383
}

RetailCoder.VBE/Inspections/EncapsulatePublicFieldInspectionResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override void Fix()
5454
{
5555
var vbe = Selection.QualifiedName.Project.VBE;
5656

57-
using (var view = new EncapsulateFieldDialog(_indenter))
57+
using (var view = new EncapsulateFieldDialog(_state, _indenter))
5858
{
5959
var factory = new EncapsulateFieldPresenterFactory(vbe, _state, view);
6060
var refactoring = new EncapsulateFieldRefactoring(vbe, _indenter, factory);

RetailCoder.VBE/Inspections/FunctionReturnValueNotUsedInspection.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ private IEnumerable<FunctionReturnValueNotUsedInspectionResult> GetInterfaceMemb
4646
implementationMember =>
4747
Tuple.Create(implementationMember.Context,
4848
new QualifiedSelection(implementationMember.QualifiedName.QualifiedModuleName,
49-
implementationMember.Selection), GetReturnStatements(implementationMember)))
49+
implementationMember.Selection), implementationMember))
5050
select
5151
new FunctionReturnValueNotUsedInspectionResult(this, interfaceMember.Context,
52-
interfaceMember.QualifiedName, GetReturnStatements(interfaceMember),
53-
implementationMemberIssues, interfaceMember);
52+
interfaceMember.QualifiedName, implementationMemberIssues, interfaceMember);
5453
}
5554

5655
private IEnumerable<FunctionReturnValueNotUsedInspectionResult> GetNonInterfaceIssues(IEnumerable<Declaration> nonInterfaceFunctions)
@@ -62,18 +61,10 @@ private IEnumerable<FunctionReturnValueNotUsedInspectionResult> GetNonInterfaceI
6261
this,
6362
function.Context,
6463
function.QualifiedName,
65-
GetReturnStatements(function),
6664
function));
6765
return nonInterfaceIssues;
6866
}
6967

70-
private IEnumerable<string> GetReturnStatements(Declaration function)
71-
{
72-
return function.References
73-
.Where(usage => IsReturnStatement(function, usage))
74-
.Select(usage => usage.Context.Parent.Parent.Parent.GetText());
75-
}
76-
7768
private bool IsReturnValueUsed(Declaration function)
7869
{
7970
foreach (var usage in function.References)

RetailCoder.VBE/Inspections/FunctionReturnValueNotUsedInspectionResult.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,20 @@ public FunctionReturnValueNotUsedInspectionResult(
1616
IInspection inspection,
1717
ParserRuleContext context,
1818
QualifiedMemberName qualifiedName,
19-
IEnumerable<string> returnStatements,
2019
Declaration target)
21-
: this(inspection, context, qualifiedName, returnStatements, new List<Tuple<ParserRuleContext, QualifiedSelection, IEnumerable<string>>>(), target)
20+
: this(inspection, context, qualifiedName, new List<Tuple<ParserRuleContext, QualifiedSelection, Declaration>>(), target)
2221
{
2322
}
2423

2524
public FunctionReturnValueNotUsedInspectionResult(
2625
IInspection inspection,
2726
ParserRuleContext context,
2827
QualifiedMemberName qualifiedName,
29-
IEnumerable<string> returnStatements,
30-
IEnumerable<Tuple<ParserRuleContext, QualifiedSelection, IEnumerable<string>>> children,
28+
IEnumerable<Tuple<ParserRuleContext, QualifiedSelection, Declaration>> children,
3129
Declaration target)
3230
: base(inspection, qualifiedName.QualifiedModuleName, context, target)
3331
{
34-
var root = new ConvertToProcedureQuickFix(context, QualifiedSelection, returnStatements);
32+
var root = new ConvertToProcedureQuickFix(context, QualifiedSelection, target);
3533
var compositeFix = new CompositeCodeInspectionFix(root);
3634
children.ToList().ForEach(child => compositeFix.AddChild(new ConvertToProcedureQuickFix(child.Item1, child.Item2, child.Item3)));
3735
_quickFixes = new CodeInspectionQuickFix[]

RetailCoder.VBE/Inspections/IInspector.cs

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

77
namespace Rubberduck.Inspections
88
{
9-
public interface IInspector
9+
public interface IInspector : IDisposable
1010
{
1111
Task<IEnumerable<ICodeInspectionResult>> FindIssuesAsync(RubberduckParserState state, CancellationToken token);
1212
}

RetailCoder.VBE/Inspections/InspectionsUI.Designer.cs

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/Inspections/InspectionsUI.fr.resx

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -59,7 +59,7 @@
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
62-
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
62+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
6363
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6464
<xsd:element name="root" msdata:IsDataSet="true">
6565
<xsd:complexType>
@@ -303,9 +303,6 @@
303303
<data name="UnassignedVariableUsageInspectionName" xml:space="preserve">
304304
<value>La variable est utilisée, mais non assignée</value>
305305
</data>
306-
<data name="UntypedFunctionUsageInspectionMeta" xml:space="preserve">
307-
<value>Une fonction équivalente existe, qui retourne une valeur 'String' et pourrait éviter une conversion implicite de type.</value>
308-
</data>
309306
<data name="UntypedFunctionUsageInspectionName" xml:space="preserve">
310307
<value>Utilisation d'une fonction retournant une 'String' dans une variable 'Variant'</value>
311308
</data>
@@ -494,64 +491,67 @@
494491
<data name="DisableThisInspection" xml:space="preserve">
495492
<value>Désactiver cette inspection</value>
496493
</data>
497-
<data name="InvalidContextTypeInspectionFix">
494+
<data name="InvalidContextTypeInspectionFix" xml:space="preserve">
498495
<value>Le type de contexte '{0}' est invalide pour {1}.</value>
499496
</data>
500-
<data name="SetObjectVariableQuickFix">
497+
<data name="SetObjectVariableQuickFix" xml:space="preserve">
501498
<value>Utiliser le mot-clé 'Set'</value>
502499
</data>
503-
<data name="QualifiedSelectionInspection">
500+
<data name="QualifiedSelectionInspection" xml:space="preserve">
504501
<value>{0}: {1} - {2} {3}.{4}, ligne {5}</value>
505502
</data>
506-
<data name="ObjectVariableNotSetInspectionName">
503+
<data name="ObjectVariableNotSetInspectionName" xml:space="preserve">
507504
<value>L'assignation d'une référence d'objet requiert le mot-clé 'Set'</value>
508505
</data>
509-
<data name="EmptyStringLiteralInspectionResultFormat">
506+
<data name="EmptyStringLiteralInspectionResultFormat" xml:space="preserve">
510507
<value>Préférez 'vbNullString' à une chaîne de caractères vide</value>
511508
</data>
512-
<data name="ObjectVariableNotSetInspectionResultFormat">
509+
<data name="ObjectVariableNotSetInspectionResultFormat" xml:space="preserve">
513510
<value>La variable '{0}' est assignée dans le mot-clé 'Set'</value>
514511
</data>
515-
<data name="ObjectVariableNotSetInspectionMeta">
512+
<data name="ObjectVariableNotSetInspectionMeta" xml:space="preserve">
516513
<value>Rubberduck voit cette variable comme étant une référence à un objet, assignée sans le mot-clé 'Set'. Ceci cause une erreur d'exécution (#91 'Object or With block variable not set').</value>
517514
</data>
518-
<data name="ImplicitActiveWorkbookReferenceInspectionResultFormat">
515+
<data name="ImplicitActiveWorkbookReferenceInspectionResultFormat" xml:space="preserve">
519516
<value>Le membre '{0}' réfère implicitement au classeur actif</value>
520517
</data>
521-
<data name="MultipleDeclarationsInspectionResultFormat">
518+
<data name="MultipleDeclarationsInspectionResultFormat" xml:space="preserve">
522519
<value>L'instruction comporte plusieurs déclarations</value>
523520
</data>
524-
<data name="Inspections_Usage">
521+
<data name="Inspections_Usage" xml:space="preserve">
525522
<value>Utilisation</value>
526523
</data>
527-
<data name="Inspections_Declaration">
524+
<data name="Inspections_Declaration" xml:space="preserve">
528525
<value>Déclaration</value>
529526
</data>
530-
<data name="VariableTypeNotDeclaredInspectionResultFormat">
527+
<data name="VariableTypeNotDeclaredInspectionResultFormat" xml:space="preserve">
531528
<value>{0} '{1}' est implicitement de type 'Variant'</value>
532529
</data>
533-
<data name="DefaultProjectNameInspectionResultFormat">
530+
<data name="DefaultProjectNameInspectionResultFormat" xml:space="preserve">
534531
<value>Le projet '{0}' n'est pas nommé</value>
535532
</data>
536-
<data name="ObsoleteCallStatementInspectionResultFormat">
533+
<data name="ObsoleteCallStatementInspectionResultFormat" xml:space="preserve">
537534
<value>L'assignation utilise le mot-clé obsolète 'Call'</value>
538535
</data>
539-
<data name="ObsoleteLetStatementInspectionResultFormat">
536+
<data name="ObsoleteLetStatementInspectionResultFormat" xml:space="preserve">
540537
<value>L'assignation utilise le mot-clé obsolète 'Let'</value>
541538
</data>
542-
<data name="OptionBaseInspectionResultFormat">
539+
<data name="OptionBaseInspectionResultFormat" xml:space="preserve">
543540
<value>Le module '{0}' utilise 'Option Base 1'</value>
544541
</data>
545-
<data name="ObsoleteCommentSyntaxInspectionResultFormat">
542+
<data name="ObsoleteCommentSyntaxInspectionResultFormat" xml:space="preserve">
546543
<value>Le commentaire utilise la forme obsolète 'Rem'</value>
547544
</data>
548-
<data name="ObsoleteTypeHintInspectionResultFormat">
545+
<data name="ObsoleteTypeHintInspectionResultFormat" xml:space="preserve">
549546
<value>{0} de {1} '{2}' utilise un indicateur de type</value>
550547
</data>
551-
<data name="ImplicitActiveSheetReferenceInspectionResultFormat">
548+
<data name="ImplicitActiveSheetReferenceInspectionResultFormat" xml:space="preserve">
552549
<value>Le membre '{0}' réfère implicitement à la feuille active</value>
553550
</data>
554-
<data name="UntypedFunctionUsageInspectionResultFormat">
551+
<data name="UntypedFunctionUsageInspectionResultFormat" xml:space="preserve">
555552
<value>Remplacer la fonction '{0}' par la fonction typée équivalente</value>
556553
</data>
557-
</root>
554+
<data name="UntypedFunctionUsageInspectionMeta" xml:space="preserve">
555+
<value />
556+
</data>
557+
</root>

RetailCoder.VBE/Inspections/InspectionsUI.ja.Designer.cs

Whitespace-only changes.

0 commit comments

Comments
 (0)