Skip to content

Commit 193c66a

Browse files
committed
reinstated cached results for IsArray, HasTypeHint and IsTypeSpecified.
1 parent af22ddf commit 193c66a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Rubberduck.Parsing/Symbols/Declaration.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,13 @@ public virtual bool IsArray()
385385
var rParenMethod = Context.GetType().GetMethod("RPAREN");
386386
if (rParenMethod == null)
387387
{
388-
return false;
388+
_isArray = false;
389+
return _isArray.Value;
389390
}
390391

391392
var declaration = (dynamic)Context;
392-
return declaration.LPAREN() != null && declaration.RPAREN() != null;
393+
_isArray = declaration.LPAREN() != null && declaration.RPAREN() != null;
394+
return _isArray.Value;
393395
}
394396

395397
private bool? _isTypeSpecified;
@@ -425,15 +427,18 @@ public virtual bool IsTypeSpecified()
425427
var method = Context.GetType().GetMethod("asTypeClause");
426428
if (method == null)
427429
{
430+
_isTypeSpecified = false;
428431
return false;
429432
}
430433

431434
if (HasTypeHint())
432435
{
436+
_isTypeSpecified = false;
433437
return true;
434438
}
435439

436-
return ((dynamic)Context).asTypeClause() is VBAParser.AsTypeClauseContext;
440+
_isTypeSpecified = ((dynamic)Context).asTypeClause() is VBAParser.AsTypeClauseContext;
441+
return _isTypeSpecified.Value;
437442
}
438443

439444
private bool? _hasTypeHint;
@@ -471,19 +476,22 @@ public bool HasTypeHint(out string token)
471476
if (Context == null || _neverHinted.Any(item => DeclarationType.HasFlag(item)))
472477
{
473478
token = null;
474-
return false;
479+
_hasTypeHint = false;
480+
return _hasTypeHint.Value;
475481
}
476482

477483
try
478484
{
479485
var hint = ((dynamic) Context).typeHint();
480486
token = hint == null ? null : hint.GetText();
481-
return hint != null;
487+
_hasTypeHint = hint != null;
488+
return _hasTypeHint.Value;
482489
}
483490
catch (RuntimeBinderException)
484491
{
485492
token = null;
486-
return false;
493+
_hasTypeHint = false;
494+
return _hasTypeHint.Value;
487495
}
488496
}
489497

0 commit comments

Comments
 (0)