Skip to content

Commit c9dd5fc

Browse files
authored
Merge branch 'next' into next
2 parents e5eb310 + c8e45f6 commit c9dd5fc

File tree

6 files changed

+15
-30
lines changed

6 files changed

+15
-30
lines changed

Rubberduck.Parsing/Preprocessing/LivelinessExpression.cs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,23 @@ public LivelinessExpression(IExpression isAlive, IExpression code)
1616

1717
public override IValue Evaluate()
1818
{
19-
bool isAlive = _isAlive.Evaluate().AsBool;
19+
var isAlive = _isAlive.Evaluate().AsBool;
2020
var code = _code.Evaluate().AsString;
21-
if (isAlive)
22-
{
23-
return new StringValue(code);
24-
}
25-
else
26-
{
27-
return new StringValue(MarkAsDead(code));
28-
}
21+
return isAlive ? new StringValue(code) : new StringValue(MarkAsDead(code));
2922
}
3023

3124
private string MarkAsDead(string code)
3225
{
33-
bool hasNewLine = false;
34-
if (code.EndsWith(Environment.NewLine))
35-
{
36-
hasNewLine = true;
37-
}
26+
var hasNewLine = code.EndsWith(Environment.NewLine);
3827
// Remove parsed new line.
39-
code = code.TrimEnd('\r', '\n');
40-
var lines = code.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
28+
code = code.Substring(0, code.Length - Environment.NewLine.Length);
29+
var lines = code.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
4130
var result = string.Join(Environment.NewLine, lines.Select(_ => string.Empty));
4231
if (hasNewLine)
4332
{
4433
result += Environment.NewLine;
4534
}
4635
return result;
4736
}
48-
49-
private string MarkLineAsDead(string line)
50-
{
51-
var result = string.Empty;
52-
if (line.EndsWith(Environment.NewLine))
53-
{
54-
result += Environment.NewLine;
55-
}
56-
return result;
57-
}
5837
}
5938
}

Rubberduck.Parsing/Symbols/DeclarationLoaders/AliasDeclarations.cs

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

5757
private IReadOnlyList<Declaration> AddAliasDeclarations()
5858
{
59-
var finder = new DeclarationFinder(_state.AllDeclarations, new IAnnotation[] { });
59+
var finder = _state.DeclarationFinder;;
6060

6161
if (WeHaveAlreadyLoadedTheDeclarationsBefore(finder))
6262
{

Rubberduck.Parsing/Symbols/DeclarationLoaders/DebugDeclarations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public DebugDeclarations(RubberduckParserState state)
1818

1919
public IReadOnlyList<Declaration> Load()
2020
{
21-
var finder = new DeclarationFinder(_state.AllDeclarations, new IAnnotation[] { });
21+
var finder = _state.DeclarationFinder;;
2222

2323
if (WeHaveAlreadyLoadedTheDeclarationsBefore(finder))
2424
{

Rubberduck.Parsing/Symbols/DeclarationLoaders/FormEventDeclarations.cs

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

2929
private static Declaration FormsClassModuleFromParserState(RubberduckParserState state)
3030
{
31-
var finder = new DeclarationFinder(state.AllDeclarations, new IAnnotation[] { });
31+
var finder = state.DeclarationFinder;
3232

3333
var msForms = finder.FindProject("MSForms");
3434
if (msForms == null)

Rubberduck.Parsing/Symbols/DeclarationLoaders/SpecialFormDeclarations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public SpecialFormDeclarations(RubberduckParserState state)
1919

2020
public IReadOnlyList<Declaration> Load()
2121
{
22-
var finder = new DeclarationFinder(_state.AllDeclarations, new IAnnotation[] { });
22+
var finder = _state.DeclarationFinder;
2323

2424
if (WeHaveAlreadyLoadedTheDeclarationsBefore(finder))
2525
{

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ public void Parse(CancellationTokenSource token)
107107
}
108108

109109
SyncComReferences(State.Projects);
110+
State.RefreshFinder(_hostApp);
111+
110112
AddBuiltInDeclarations();
113+
State.RefreshFinder(_hostApp);
111114

112115
foreach (var component in components)
113116
{
@@ -229,7 +232,10 @@ private void ParseAll(object requestor, CancellationTokenSource token)
229232
}
230233

231234
SyncComReferences(State.Projects);
235+
State.RefreshFinder(_hostApp);
236+
232237
AddBuiltInDeclarations();
238+
State.RefreshFinder(_hostApp);
233239

234240
// invalidation cleanup should go into ParseAsync?
235241
foreach (var key in _componentAttributes.Keys)

0 commit comments

Comments
 (0)