Skip to content

Commit f960479

Browse files
authored
Merge pull request #2354 from retailcoder/next
Green build!
2 parents ab14c05 + eaea7cc commit f960479

21 files changed

+295
-202
lines changed

RetailCoder.VBE/Inspections/ObjectVariableNotSetInspection.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
7575
(item.DeclarationType == DeclarationType.Function || item.DeclarationType == DeclarationType.PropertyGet)
7676
&& !item.IsArray
7777
&& item.IsTypeSpecified
78-
&& !ValueTypes.Contains(item.AsTypeName)
79-
&& (item.AsTypeDeclaration != null && (
80-
item.AsTypeDeclaration.DeclarationType != DeclarationType.Enumeration
81-
&& item.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType)));
78+
&& !ValueTypes.Contains(item.AsTypeName)
79+
&& (item.AsTypeDeclaration == null // null if unresolved (e.g. in unit tests)
80+
|| (item.AsTypeDeclaration.DeclarationType != DeclarationType.Enumeration && item.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType)));
8281

8382
var interestingReferences = interestingDeclarations
8483
.Union(interestingMembers.SelectMany(item =>

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,8 @@ private void SwitchNodeState(CodeExplorerItemViewModel node, bool expandedState)
506506
private void ExecuteRemoveComand(object param)
507507
{
508508
var node = (CodeExplorerComponentViewModel)SelectedItem;
509-
SelectedItem = Projects.First(p => ((CodeExplorerProjectViewModel)p).Declaration.Project.Equals(node.Declaration.Project));
509+
SelectedItem = Projects.FirstOrDefault(p => p.QualifiedSelection.HasValue
510+
&& p.QualifiedSelection.Value.QualifiedName.ProjectId == node.Declaration.ProjectId);
510511

511512
_externalRemoveCommand.Execute(param);
512513
}

RetailCoder.VBE/Refactorings/ImplementInterface/ImplementInterfaceRefactoring.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,15 @@ public void Refactor(QualifiedSelection selection)
7878
{
7979
var module = oldSelection.Value.QualifiedName.Component.CodeModule;
8080
var pane = module.CodePane;
81-
{
82-
pane.Selection = oldSelection.Value.Selection;
83-
}
81+
pane.Selection = oldSelection.Value.Selection;
8482
}
8583

8684
_state.OnParseRequested(this);
8785
}
8886

8987
public void Refactor(Declaration target)
9088
{
91-
throw new NotImplementedException();
89+
throw new NotSupportedException();
9290
}
9391

9492
private void ImplementMissingMembers()

RetailCoder.VBE/UI/CodeExplorer/Commands/RemoveCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Rubberduck.Navigation.CodeExplorer;
77
using Rubberduck.UI.Command;
88
using Rubberduck.VBEditor.SafeComWrappers;
9-
using Rubberduck.VBEditor.SafeComWrappers.VBA;
109

1110
namespace Rubberduck.UI.CodeExplorer.Commands
1211
{

RetailCoder.VBE/UI/Command/Refactorings/RefactorExtractInterfaceCommand.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections.Generic;
12
using System.Linq;
23
using System.Runtime.InteropServices;
34
using Rubberduck.Parsing.Symbols;
@@ -21,6 +22,13 @@ public RefactorExtractInterfaceCommand(IVBE vbe, RubberduckParserState state, IM
2122
_messageBox = messageBox;
2223
}
2324

25+
private static readonly IReadOnlyList<DeclarationType> ModuleTypes = new[]
26+
{
27+
DeclarationType.ClassModule,
28+
DeclarationType.UserForm,
29+
DeclarationType.ProceduralModule,
30+
};
31+
2432
protected override bool CanExecuteImpl(object parameter)
2533
{
2634
var selection = Vbe.ActiveCodePane.GetQualifiedSelection();
@@ -29,14 +37,18 @@ protected override bool CanExecuteImpl(object parameter)
2937
return false;
3038
}
3139

32-
var target = _state.AllUserDeclarations.SingleOrDefault(item =>
40+
var interfaceClass = _state.AllUserDeclarations.SingleOrDefault(item =>
3341
item.QualifiedName.QualifiedModuleName.Equals(selection.Value.QualifiedName)
34-
&& item.IdentifierName == selection.Value.QualifiedName.ComponentName
35-
&& (item.DeclarationType == DeclarationType.ClassModule || item.DeclarationType == DeclarationType.Document || item.DeclarationType == DeclarationType.UserForm));
36-
var hasMembers = _state.AllUserDeclarations.Any(item => item.DeclarationType.HasFlag(DeclarationType.Member) && item.ParentDeclaration != null && item.ParentDeclaration.Equals(target));
42+
&& ModuleTypes.Contains(item.DeclarationType));
43+
44+
// interface class must have members to be implementable
45+
var hasMembers = _state.AllUserDeclarations.Any(item =>
46+
item.DeclarationType.HasFlag(DeclarationType.Member)
47+
&& item.ParentDeclaration != null
48+
&& item.ParentDeclaration.Equals(interfaceClass));
3749

3850
// true if active code pane is for a class/document/form module
39-
return target != null && hasMembers;
51+
return interfaceClass != null && hasMembers;
4052
}
4153

4254
protected override void ExecuteImpl(object parameter)

Rubberduck.Parsing/Binding/SimpleNameDefaultBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public IBoundExpression Resolve()
7070

7171
var undeclaredLocal = _declarationFinder.OnUndeclaredVariable(_parent, _name, _context);
7272
return new SimpleNameExpression(undeclaredLocal, ExpressionClassification.Variable, _context);
73-
return new ResolutionFailedExpression();
73+
//return new ResolutionFailedExpression();
7474
}
7575

7676
private IBoundExpression ResolveProcedureNamespace()

Rubberduck.Parsing/Binding/SimpleNameTypeBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public SimpleNameTypeBinding(
2929

3030
public IBoundExpression Resolve()
3131
{
32-
string name = Identifier.GetName(_expression.identifier());
32+
var name = Identifier.GetName(_expression.identifier());
3333
if (PreferProjectOverUdt)
3434
{
3535
return ResolvePreferProject(name);

Rubberduck.Parsing/Rubberduck.Parsing.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
<Compile Include="Symbols\IdentifierReference.cs" />
273273
<Compile Include="Symbols\IdentifierReferenceListener.cs" />
274274
<Compile Include="Symbols\ConstantDeclaration.cs" />
275-
<Compile Include="Syntax\SyntaxNode.cs" />
275+
<Compile Include="Syntax\SyntaxTree.cs" />
276276
<Compile Include="Syntax\TextSpan.cs" />
277277
<Compile Include="VBA\AttributeParser.cs" />
278278
<Compile Include="VBA\Attributes.cs" />

Rubberduck.Parsing/Symbols/DebugDeclarations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public IReadOnlyList<Declaration> Load()
4545

4646
private IReadOnlyList<Declaration> Load(Declaration parentProject, Declaration parentModule)
4747
{
48-
List<Declaration> declarations = new List<Declaration>();
48+
var declarations = new List<Declaration>();
4949
var debugModuleName = new QualifiedModuleName(parentProject.QualifiedName.QualifiedModuleName.ProjectName, parentProject.QualifiedName.QualifiedModuleName.ProjectPath, "DebugClass");
5050
var debugModule = new ProceduralModuleDeclaration(new QualifiedMemberName(debugModuleName, "DebugModule"), parentProject, "DebugModule", true, new List<IAnnotation>(), new Attributes());
5151
var debugClassName = new QualifiedModuleName(parentProject.QualifiedName.QualifiedModuleName.ProjectName, parentProject.QualifiedName.QualifiedModuleName.ProjectPath, "DebugClass");

Rubberduck.Parsing/Syntax/SyntaxNode.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)