Skip to content

Commit 053e267

Browse files
committed
resolver now correctly locates assignment target in functions & property getters; fixes false positives of NonReturningFunction inspection; added debug output to CodeExplorer and Inspection viewmodels when executing refresh - the double parse at startup is caused by the CodeInspections viewmodel.. need to fix that.
1 parent 27fe666 commit 053e267

File tree

6 files changed

+13
-200
lines changed

6 files changed

+13
-200
lines changed

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.ObjectModel;
2+
using System.Diagnostics;
23
using System.Linq;
34
using System.Windows.Input;
45
using System.Windows.Media.Imaging;
@@ -100,6 +101,7 @@ private void ParserState_ModuleStateChanged(object sender, Parsing.ParseProgress
100101

101102
private void ExecuteRefreshCommand(object param)
102103
{
104+
Debug.WriteLine("CodeExplorerViewModel.ExecuteRefreshCommand - requesting reparse");
103105
_state.OnParseRequested();
104106
}
105107
}

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.Windows;
7-
using System.Windows.Controls;
8-
using System.Windows.Data;
9-
using System.Windows.Documents;
1+
using System.Windows.Controls;
102
using System.Windows.Input;
11-
using System.Windows.Media;
12-
using System.Windows.Media.Imaging;
13-
using System.Windows.Navigation;
14-
using System.Windows.Shapes;
153
using Rubberduck.Navigation.CodeExplorer;
16-
using Rubberduck.VBEditor;
174

185
namespace Rubberduck.UI.CodeExplorer
196
{

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerDockablePresenter.cs

Lines changed: 0 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -10,186 +10,5 @@ public CodeExplorerDockablePresenter(VBE vbe, AddIn addIn, IDockableUserControl
1010
: base(vbe, addIn, view)
1111
{
1212
}
13-
14-
//private string GetNodeText(Declaration declaration)
15-
//{
16-
// if (Control.DisplayStyle == TreeViewDisplayStyle.MemberNames)
17-
// {
18-
// var result = declaration.IdentifierName;
19-
// if (declaration.DeclarationType == DeclarationType.PropertyGet)
20-
// {
21-
// result += " (" + Tokens.Get + ")";
22-
// }
23-
// else if (declaration.DeclarationType == DeclarationType.PropertyLet)
24-
// {
25-
// result += " (" + Tokens.Let + ")";
26-
// }
27-
// else if (declaration.DeclarationType == DeclarationType.PropertySet)
28-
// {
29-
// result += " (" + Tokens.Set + ")";
30-
// }
31-
32-
// return result;
33-
// }
34-
35-
// if (declaration.DeclarationType == DeclarationType.Procedure)
36-
// {
37-
// return ((VBAParser.SubStmtContext) declaration.Context).Signature();
38-
// }
39-
40-
// if (declaration.DeclarationType == DeclarationType.Function)
41-
// {
42-
// return ((VBAParser.FunctionStmtContext)declaration.Context).Signature();
43-
// }
44-
45-
// if (declaration.DeclarationType == DeclarationType.PropertyGet)
46-
// {
47-
// return ((VBAParser.PropertyGetStmtContext)declaration.Context).Signature();
48-
// }
49-
50-
// if (declaration.DeclarationType == DeclarationType.PropertyLet)
51-
// {
52-
// return ((VBAParser.PropertyLetStmtContext)declaration.Context).Signature();
53-
// }
54-
55-
// if (declaration.DeclarationType == DeclarationType.PropertySet)
56-
// {
57-
// return ((VBAParser.PropertySetStmtContext)declaration.Context).Signature();
58-
// }
59-
60-
// return declaration.IdentifierName;
61-
//}
62-
63-
//private string GetImageKeyForDeclaration(Declaration declaration)
64-
//{
65-
// var result = string.Empty;
66-
// switch (declaration.DeclarationType)
67-
// {
68-
// case DeclarationType.Module:
69-
// break;
70-
// case DeclarationType.Class:
71-
// break;
72-
// case DeclarationType.Procedure:
73-
// case DeclarationType.Function:
74-
// if (declaration.Accessibility == Accessibility.Private)
75-
// {
76-
// result = "PrivateMethod";
77-
// break;
78-
// }
79-
// if (declaration.Accessibility == Accessibility.Friend)
80-
// {
81-
// result = "FriendMethod";
82-
// break;
83-
// }
84-
// result = "PublicMethod";
85-
// break;
86-
87-
// case DeclarationType.PropertyGet:
88-
// case DeclarationType.PropertyLet:
89-
// case DeclarationType.PropertySet:
90-
// if (declaration.Accessibility == Accessibility.Private)
91-
// {
92-
// result = "PrivateProperty";
93-
// break;
94-
// }
95-
// if (declaration.Accessibility == Accessibility.Friend)
96-
// {
97-
// result = "FriendProperty";
98-
// break;
99-
// }
100-
// result = "PublicProperty";
101-
// break;
102-
103-
// case DeclarationType.Parameter:
104-
// break;
105-
// case DeclarationType.Variable:
106-
// if (declaration.Accessibility == Accessibility.Private)
107-
// {
108-
// result = "PrivateField";
109-
// break;
110-
// }
111-
// if (declaration.Accessibility == Accessibility.Friend)
112-
// {
113-
// result = "FriendField";
114-
// break;
115-
// }
116-
// result = "PublicField";
117-
// break;
118-
119-
// case DeclarationType.Constant:
120-
// if (declaration.Accessibility == Accessibility.Private)
121-
// {
122-
// result = "PrivateConst";
123-
// break;
124-
// }
125-
// if (declaration.Accessibility == Accessibility.Friend)
126-
// {
127-
// result = "FriendConst";
128-
// break;
129-
// }
130-
// result = "PublicConst";
131-
// break;
132-
133-
// case DeclarationType.Enumeration:
134-
// if (declaration.Accessibility == Accessibility.Private)
135-
// {
136-
// result = "PrivateEnum";
137-
// break;
138-
// }
139-
// if (declaration.Accessibility == Accessibility.Friend)
140-
// {
141-
// result = "FriendEnum";
142-
// break;
143-
// }
144-
// result = "PublicEnum";
145-
// break;
146-
147-
// case DeclarationType.EnumerationMember:
148-
// result = "EnumItem";
149-
// break;
150-
151-
// case DeclarationType.Event:
152-
// if (declaration.Accessibility == Accessibility.Private)
153-
// {
154-
// result = "PrivateEvent";
155-
// break;
156-
// }
157-
// if (declaration.Accessibility == Accessibility.Friend)
158-
// {
159-
// result = "FriendEvent";
160-
// break;
161-
// }
162-
// result = "PublicEvent";
163-
// break;
164-
165-
// case DeclarationType.UserDefinedType:
166-
// if (declaration.Accessibility == Accessibility.Private)
167-
// {
168-
// result = "PrivateType";
169-
// break;
170-
// }
171-
// if (declaration.Accessibility == Accessibility.Friend)
172-
// {
173-
// result = "FriendType";
174-
// break;
175-
// }
176-
// result = "PublicType";
177-
// break;
178-
179-
// case DeclarationType.UserDefinedTypeMember:
180-
// result = "PublicField";
181-
// break;
182-
183-
// case DeclarationType.LibraryProcedure:
184-
// case DeclarationType.LibraryFunction:
185-
// result = "Identifier";
186-
// break;
187-
188-
// default:
189-
// throw new ArgumentOutOfRangeException();
190-
// }
191-
192-
// return result;
193-
//}
19413
}
19514
}

RetailCoder.VBE/UI/CodeInspections/InspectionResultsViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Collections.ObjectModel;
4+
using System.Diagnostics;
45
using System.Linq;
56
using System.Threading;
67
using System.Threading.Tasks;
@@ -142,6 +143,7 @@ private async void ExecuteRefreshCommandAsync(object parameter)
142143
IsBusy = true;
143144

144145
_state.StateChanged += _state_StateChanged;
146+
Debug.WriteLine("InspectionResultsViewModel.ExecuteRefreshCommand - requesting reparse");
145147
_state.OnParseRequested();
146148
}
147149

RetailCoder.VBE/UI/Command/CodeExplorerCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Runtime.InteropServices;
2-
using Rubberduck.UI.CodeExplorer;
32

43
namespace Rubberduck.UI.Command
54
{

Rubberduck.Parsing/Symbols/IdentifierReferenceResolver.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,12 @@ private Declaration ResolveInternal(ParserRuleContext callSiteContext, Declarati
496496
}
497497

498498
var reference = CreateReference(callSiteContext, callee, isAssignmentTarget, hasExplicitLetStatement);
499-
callee.AddReference(reference);
500-
_alreadyResolved.Add(reference.Context);
501-
_alreadyResolved.Add(callSiteContext);
499+
if (reference != null)
500+
{
501+
callee.AddReference(reference);
502+
_alreadyResolved.Add(reference.Context);
503+
_alreadyResolved.Add(callSiteContext);
504+
}
502505

503506
if (fieldCall != null)
504507
{
@@ -1004,7 +1007,8 @@ private Declaration FindFunctionOrPropertyGetter(string identifierName, Declarat
10041007

10051008
var matches = _declarations.Where(d => d.IdentifierName == identifierName);
10061009
var parent = matches.SingleOrDefault(item =>
1007-
item.ParentScopeDeclaration.Equals(localScope));
1010+
(item.DeclarationType == DeclarationType.Function || item.DeclarationType == DeclarationType.PropertyGet)
1011+
&& item.Equals(localScope));
10081012

10091013
return parent;
10101014
}

0 commit comments

Comments
 (0)