Skip to content

Commit db38004

Browse files
committed
Forgot about the parameter count thing, paramarrays.
1 parent ca722a7 commit db38004

File tree

2 files changed

+16
-46
lines changed

2 files changed

+16
-46
lines changed

Rubberduck.Parsing/ComReflection/ComMember.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
4+
using System.Linq;
45
using System.Runtime.InteropServices;
56
using System.Runtime.InteropServices.ComTypes;
67
using Rubberduck.Parsing.Symbols;
@@ -75,17 +76,16 @@ private void LoadParameters(FUNCDESC funcDesc, ITypeInfo info)
7576
int count;
7677
info.GetNames(Index, names, 255, out count);
7778

78-
for (var index = 0; index < funcDesc.cParams; index++)
79+
for (var index = 0; index < count - 1; index++)
7980
{
8081
var paramPtr = new IntPtr(funcDesc.lprgelemdescParam.ToInt64() + Marshal.SizeOf(typeof(ELEMDESC)) * index);
8182
var elemDesc = (ELEMDESC)Marshal.PtrToStructure(paramPtr, typeof(ELEMDESC));
8283
var param = new ComParameter(elemDesc, info, names[index + 1]);
8384
Parameters.Add(param);
84-
//TODO:
85-
//if (parameters.Any() && memberDescriptor.cParamsOpt == -1)
86-
//{
87-
// parameters.Last().IsParamArray = true;
88-
//}
85+
}
86+
if (Parameters.Any() && funcDesc.cParamsOpt == -1)
87+
{
88+
Parameters.Last().IsParamArray = true;
8989
}
9090
}
9191

Rubberduck.Parsing/Symbols/Declaration.cs

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public Declaration(
151151
_accessibility = accessibility;
152152
_declarationType = declarationType;
153153
_selection = selection;
154-
_context = context;
154+
Context = context;
155155
_isBuiltIn = isBuiltIn;
156156
_annotations = annotations;
157157
_attributes = attributes ?? new Attributes();
@@ -162,6 +162,7 @@ public Declaration(
162162
_isArray = isArray;
163163
_asTypeContext = asTypeContext;
164164
_typeHint = typeHint;
165+
Debug.Assert(!string.IsNullOrEmpty(_qualifiedName.MemberName));
165166
}
166167

167168
public Declaration(ComEnumeration enumeration, Declaration parent, QualifiedModuleName module) : this(
@@ -180,7 +181,7 @@ public Declaration(ComEnumeration enumeration, Declaration parent, QualifiedModu
180181
null,
181182
true,
182183
null,
183-
new Attributes()) { }
184+
new Attributes()) { Debug.Assert(module != null && !string.IsNullOrEmpty(_qualifiedName.MemberName)); }
184185

185186
public Declaration(ComEnumerationMember member, Declaration parent, QualifiedModuleName module) : this(
186187
new QualifiedMemberName(module, member.Name),
@@ -195,15 +196,14 @@ public Declaration(ComEnumerationMember member, Declaration parent, QualifiedMod
195196
null,
196197
Selection.Home,
197198
false,
198-
null,
199-
true) { }
199+
null) { Debug.Assert(module != null && !string.IsNullOrEmpty(_qualifiedName.MemberName)); }
200200

201201
public Declaration(ComField field, Declaration parent, QualifiedModuleName module)
202202
: this(
203-
new QualifiedMemberName(module, field.Name),
203+
new QualifiedMemberName(module, string.IsNullOrEmpty(field.Name) ? "Foo" : field.Name),
204204
parent,
205205
parent,
206-
field.Name,
206+
string.IsNullOrEmpty(field.Name) ? "Foo" : field.Name,
207207
null,
208208
false,
209209
false,
@@ -212,8 +212,7 @@ public Declaration(ComField field, Declaration parent, QualifiedModuleName modul
212212
null,
213213
Selection.Home,
214214
false,
215-
null,
216-
true) { }
215+
null) { Debug.Assert(module != null && !string.IsNullOrEmpty(_qualifiedName.MemberName)); }
217216

218217
private string FolderFromAnnotations()
219218
{
@@ -285,18 +284,7 @@ public bool IsTypeSpecified
285284
private readonly QualifiedMemberName _qualifiedName;
286285
public QualifiedMemberName QualifiedName { get { return _qualifiedName; } }
287286

288-
private ParserRuleContext _context;
289-
public ParserRuleContext Context
290-
{
291-
get
292-
{
293-
return _context;
294-
}
295-
set
296-
{
297-
_context = value;
298-
}
299-
}
287+
public ParserRuleContext Context { get; set; }
300288

301289
private ConcurrentBag<IdentifierReference> _references = new ConcurrentBag<IdentifierReference>();
302290
public IEnumerable<IdentifierReference> References
@@ -391,24 +379,6 @@ public void AddReference(
391379
annotations));
392380
}
393381

394-
//public void AddReference(IdentifierReference reference)
395-
//{
396-
// if (reference == null || reference.Declaration.Context == reference.Context)
397-
// {
398-
// return;
399-
// }
400-
// if (reference.Context.Parent != _context
401-
// && !_references.Select(r => r.Context).Contains(reference.Context.Parent)
402-
// && !_references.Any(r => r.QualifiedModuleName == reference.QualifiedModuleName
403-
// && r.Selection.StartLine == reference.Selection.StartLine
404-
// && r.Selection.EndLine == reference.Selection.EndLine
405-
// && r.Selection.StartColumn == reference.Selection.StartColumn
406-
// && r.Selection.EndColumn == reference.Selection.EndColumn))
407-
// {
408-
// _references.Add(reference);
409-
// }
410-
//}
411-
412382
public void AddMemberCall(IdentifierReference reference)
413383
{
414384
if (reference == null || reference.Declaration == null || reference.Declaration.Context == reference.Context)
@@ -459,7 +429,7 @@ public string ProjectName
459429

460430
public object[] ToArray()
461431
{
462-
return new object[] { this.ProjectName, this.CustomFolder, this.ComponentName, this.DeclarationType.ToString(), this.Scope, this.IdentifierName, this.AsTypeName };
432+
return new object[] { ProjectName, CustomFolder, ComponentName, DeclarationType.ToString(), Scope, IdentifierName, AsTypeName };
463433
}
464434

465435

@@ -548,7 +518,7 @@ internal set
548518
DeclarationType.PropertyLet,
549519
DeclarationType.PropertyLet,
550520
DeclarationType.UserDefinedType,
551-
DeclarationType.Constant,
521+
DeclarationType.Constant
552522
};
553523

554524
public bool IsSelected(QualifiedSelection selection)

0 commit comments

Comments
 (0)