Skip to content

Commit

Permalink
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck i…
Browse files Browse the repository at this point in the history
…nto next
  • Loading branch information
ThunderFrame committed Jun 5, 2016
2 parents 9137c48 + 8428eb4 commit bcca242
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
var nonInterfaceFunctions = functions.Except(interfaceMembers.Union(interfaceImplementationMembers));
var nonInterfaceIssues = GetNonInterfaceIssues(nonInterfaceFunctions);
return interfaceMemberIssues.Union(nonInterfaceIssues);
//// Temporarily disabled until fix for lack of context because of new resolver is found...
//return new List<InspectionResultBase>();
}

private IEnumerable<FunctionReturnValueNotUsedInspectionResult> GetInterfaceMemberIssues(IEnumerable<Declaration> interfaceMembers)
{
return from interfaceMember in interfaceMembers
let implementationMembers =
UserDeclarations.FindInterfaceImplementationMembers(interfaceMember.IdentifierName).ToList()
where
where interfaceMember.DeclarationType == DeclarationType.Function &&
!IsReturnValueUsed(interfaceMember) &&
implementationMembers.All(member => !IsReturnValueUsed(member))
let implementationMemberIssues =
Expand All @@ -58,7 +56,7 @@ private IEnumerable<FunctionReturnValueNotUsedInspectionResult> GetInterfaceMemb

private IEnumerable<FunctionReturnValueNotUsedInspectionResult> GetNonInterfaceIssues(IEnumerable<Declaration> nonInterfaceFunctions)
{
var returnValueNotUsedFunctions = nonInterfaceFunctions.Where(function => !IsReturnValueUsed(function));
var returnValueNotUsedFunctions = nonInterfaceFunctions.Where(function => function.DeclarationType == DeclarationType.Function && !IsReturnValueUsed(function));
var nonInterfaceIssues = returnValueNotUsedFunctions
.Select(function =>
new FunctionReturnValueNotUsedInspectionResult(
Expand Down
6 changes: 3 additions & 3 deletions RetailCoder.VBE/UI/RubberduckUI.de.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -1586,9 +1586,9 @@ Allen Sternguckern, Likern &amp; Followern, für das warme Kribbeln
<value />
</data>
<data name="CodeExplorer_CopyToolTip">
<value />
<value>In Zwischenablage kopieren</value>
</data>
<data name="cross_circle">
<value />
</data>
</root>
</root>
12 changes: 10 additions & 2 deletions Rubberduck.Parsing/Binding/BindingService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Antlr4.Runtime;
using System.Diagnostics;
using Antlr4.Runtime;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Symbols;

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

public IBoundExpression ResolveType(Declaration module, Declaration parent, ParserRuleContext expression)
{
return _typedBindingContext.Resolve(module, parent, expression, null, StatementResolutionContext.Undefined);
var context = expression;
var opContext = expression as VBAParser.RelationalOpContext;
if (opContext != null && opContext.Parent is VBAParser.ComplexTypeContext)
{
context = opContext.GetChild<VBAParser.LExprContext>(0);
}
return _typedBindingContext.Resolve(module, parent, context, null, StatementResolutionContext.Undefined);
}

public IBoundExpression ResolveProcedurePointer(Declaration module, Declaration parent, ParserRuleContext expression)
Expand Down
3 changes: 2 additions & 1 deletion Rubberduck.Parsing/Binding/StatementResolutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum StatementResolutionContext
{
Undefined,
SetStatement,
LetStatement
LetStatement,
DefaultParamValue,
}
}
10 changes: 10 additions & 0 deletions Rubberduck.Parsing/Symbols/DeclarationSymbolsListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ private void DeclareControlsAsMembers(VBComponent form)
{
var argContext = (VBAParser.ArgContext)context;
var isOptional = argContext.OPTIONAL() != null;
if (isOptional)
{
// if parameter is optional, asTypeName may contain the default value
var complexType = asTypeContext.type().complexType();
if (complexType != null && complexType.expression() is VBAParser.RelationalOpContext)
{
asTypeName = complexType.expression().GetChild(0).GetText();
}
}

var isByRef = argContext.BYREF() != null;
var isParamArray = argContext.PARAMARRAY() != null;
result = new ParameterDeclaration(
Expand Down
8 changes: 1 addition & 7 deletions Rubberduck.Parsing/VBA/RubberduckParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,8 @@ public class RubberduckParser : IRubberduckParser, IDisposable
_comReflector = new ReferencedDeclarationsCollector(_state);

state.ParseRequest += ReparseRequested;
state.StateChanged += StateOnStateChanged;
}

private void StateOnStateChanged(object sender, EventArgs e)
{
Logger.Debug("RubberduckParser handles OnStateChanged ({0})", _state.Status);
}

private void ReparseRequested(object sender, ParseRequestEventArgs e)
{
Expand Down Expand Up @@ -466,6 +461,7 @@ private void ParseAsyncInternal(VBComponent component, CancellationToken token,

private void Resolve(CancellationToken token)
{
State.SetStatusAndFireStateChanged(ParserState.Resolving);
var sharedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(_resolverTokenSource.Token, token);
// tests expect this to be synchronous :/
//Task.Run(() => ResolveInternal(sharedTokenSource.Token));
Expand Down Expand Up @@ -599,8 +595,6 @@ private void ResolveReferences(DeclarationFinder finder, VBComponent component,
public void Dispose()
{
State.ParseRequest -= ReparseRequested;
State.StateChanged -= StateOnStateChanged;

if (_resolverTokenSource != null)
{
_resolverTokenSource.Dispose();
Expand Down

0 comments on commit bcca242

Please sign in to comment.