Skip to content

Commit bcca242

Browse files
committed
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck into next
2 parents 9137c48 + 8428eb4 commit bcca242

File tree

6 files changed

+28
-17
lines changed

6 files changed

+28
-17
lines changed

RetailCoder.VBE/Inspections/FunctionReturnValueNotUsedInspection.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
3232
var nonInterfaceFunctions = functions.Except(interfaceMembers.Union(interfaceImplementationMembers));
3333
var nonInterfaceIssues = GetNonInterfaceIssues(nonInterfaceFunctions);
3434
return interfaceMemberIssues.Union(nonInterfaceIssues);
35-
//// Temporarily disabled until fix for lack of context because of new resolver is found...
36-
//return new List<InspectionResultBase>();
3735
}
3836

3937
private IEnumerable<FunctionReturnValueNotUsedInspectionResult> GetInterfaceMemberIssues(IEnumerable<Declaration> interfaceMembers)
4038
{
4139
return from interfaceMember in interfaceMembers
4240
let implementationMembers =
4341
UserDeclarations.FindInterfaceImplementationMembers(interfaceMember.IdentifierName).ToList()
44-
where
42+
where interfaceMember.DeclarationType == DeclarationType.Function &&
4543
!IsReturnValueUsed(interfaceMember) &&
4644
implementationMembers.All(member => !IsReturnValueUsed(member))
4745
let implementationMemberIssues =
@@ -58,7 +56,7 @@ private IEnumerable<FunctionReturnValueNotUsedInspectionResult> GetInterfaceMemb
5856

5957
private IEnumerable<FunctionReturnValueNotUsedInspectionResult> GetNonInterfaceIssues(IEnumerable<Declaration> nonInterfaceFunctions)
6058
{
61-
var returnValueNotUsedFunctions = nonInterfaceFunctions.Where(function => !IsReturnValueUsed(function));
59+
var returnValueNotUsedFunctions = nonInterfaceFunctions.Where(function => function.DeclarationType == DeclarationType.Function && !IsReturnValueUsed(function));
6260
var nonInterfaceIssues = returnValueNotUsedFunctions
6361
.Select(function =>
6462
new FunctionReturnValueNotUsedInspectionResult(

RetailCoder.VBE/UI/RubberduckUI.de.resx

Lines changed: 3 additions & 3 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
@@ -1586,9 +1586,9 @@ Allen Sternguckern, Likern &amp; Followern, für das warme Kribbeln
15861586
<value />
15871587
</data>
15881588
<data name="CodeExplorer_CopyToolTip">
1589-
<value />
1589+
<value>In Zwischenablage kopieren</value>
15901590
</data>
15911591
<data name="cross_circle">
15921592
<value />
15931593
</data>
1594-
</root>
1594+
</root>

Rubberduck.Parsing/Binding/BindingService.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Antlr4.Runtime;
1+
using System.Diagnostics;
2+
using Antlr4.Runtime;
3+
using Rubberduck.Parsing.Grammar;
24
using Rubberduck.Parsing.Symbols;
35

46
namespace Rubberduck.Parsing.Binding
@@ -39,7 +41,13 @@ public IBoundExpression ResolveDefault(Declaration module, Declaration parent, P
3941

4042
public IBoundExpression ResolveType(Declaration module, Declaration parent, ParserRuleContext expression)
4143
{
42-
return _typedBindingContext.Resolve(module, parent, expression, null, StatementResolutionContext.Undefined);
44+
var context = expression;
45+
var opContext = expression as VBAParser.RelationalOpContext;
46+
if (opContext != null && opContext.Parent is VBAParser.ComplexTypeContext)
47+
{
48+
context = opContext.GetChild<VBAParser.LExprContext>(0);
49+
}
50+
return _typedBindingContext.Resolve(module, parent, context, null, StatementResolutionContext.Undefined);
4351
}
4452

4553
public IBoundExpression ResolveProcedurePointer(Declaration module, Declaration parent, ParserRuleContext expression)

Rubberduck.Parsing/Binding/StatementResolutionContext.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public enum StatementResolutionContext
44
{
55
Undefined,
66
SetStatement,
7-
LetStatement
7+
LetStatement,
8+
DefaultParamValue,
89
}
910
}

Rubberduck.Parsing/Symbols/DeclarationSymbolsListener.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ private Declaration CreateDeclaration(
185185
{
186186
var argContext = (VBAParser.ArgContext)context;
187187
var isOptional = argContext.OPTIONAL() != null;
188+
if (isOptional)
189+
{
190+
// if parameter is optional, asTypeName may contain the default value
191+
var complexType = asTypeContext.type().complexType();
192+
if (complexType != null && complexType.expression() is VBAParser.RelationalOpContext)
193+
{
194+
asTypeName = complexType.expression().GetChild(0).GetText();
195+
}
196+
}
197+
188198
var isByRef = argContext.BYREF() != null;
189199
var isParamArray = argContext.PARAMARRAY() != null;
190200
result = new ParameterDeclaration(

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,8 @@ public RubberduckParser(
5656
_comReflector = new ReferencedDeclarationsCollector(_state);
5757

5858
state.ParseRequest += ReparseRequested;
59-
state.StateChanged += StateOnStateChanged;
6059
}
6160

62-
private void StateOnStateChanged(object sender, EventArgs e)
63-
{
64-
Logger.Debug("RubberduckParser handles OnStateChanged ({0})", _state.Status);
65-
}
6661

6762
private void ReparseRequested(object sender, ParseRequestEventArgs e)
6863
{
@@ -466,6 +461,7 @@ private void ParseAsyncInternal(VBComponent component, CancellationToken token,
466461

467462
private void Resolve(CancellationToken token)
468463
{
464+
State.SetStatusAndFireStateChanged(ParserState.Resolving);
469465
var sharedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_resolverTokenSource.Token, token);
470466
// tests expect this to be synchronous :/
471467
//Task.Run(() => ResolveInternal(sharedTokenSource.Token));
@@ -599,8 +595,6 @@ private void ResolveReferences(DeclarationFinder finder, VBComponent component,
599595
public void Dispose()
600596
{
601597
State.ParseRequest -= ReparseRequested;
602-
State.StateChanged -= StateOnStateChanged;
603-
604598
if (_resolverTokenSource != null)
605599
{
606600
_resolverTokenSource.Dispose();

0 commit comments

Comments
 (0)