Skip to content

Commit acee813

Browse files
committed
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck into Issue1851
2 parents 28f1420 + 2414e80 commit acee813

File tree

10 files changed

+66
-15
lines changed

10 files changed

+66
-15
lines changed

RetailCoder.VBE/Inspections/ImplicitActiveSheetReferenceInspection.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
3636
}
3737

3838
var matches = BuiltInDeclarations.Where(item =>
39-
Targets.Contains(item.IdentifierName)).ToList();
39+
Targets.Contains(item.IdentifierName) &&
40+
item.ParentScope == "EXCEL.EXE;Excel._Global" &&
41+
item.AsTypeName == "Range").ToList();
4042

4143
var issues = matches.Where(item => item.References.Any())
4244
.SelectMany(declaration => declaration.References);

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@
676676
IsCheckable="True" />
677677
<MenuItem Name="SortBySelection"
678678
Style="{DynamicResource MenuItemStyle}" VerticalAlignment="Center"
679-
Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SortStyle_BySelection}"
679+
Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=SortStyle_ByCodeOrder}"
680680
IsChecked="{Binding SortBySelection, UpdateSourceTrigger=PropertyChanged}"
681681
Command="{Binding SetSelectionSortCommand}"
682682
CommandParameter="{Binding ElementName=SortBySelection, Path=IsChecked}"

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,8 +1578,8 @@ All our stargazers, likers &amp; followers, for the warm fuzzies
15781578
<data name="SortStyle_ByType" xml:space="preserve">
15791579
<value>By type</value>
15801580
</data>
1581-
<data name="SortStyle_BySelection" xml:space="preserve">
1582-
<value>By selection</value>
1581+
<data name="SortStyle_ByCodeOrder" xml:space="preserve">
1582+
<value>By code order</value>
15831583
</data>
15841584
<data name="CodeExplorer_RefreshComponent" xml:space="preserve">
15851585
<value>Refresh component</value>

RetailCoder.VBE/UI/UnitTesting/TestExplorerControl.xaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@
258258

259259
<CollectionViewSource x:Key="ResultsByModule" Source="{Binding Model.Tests}">
260260
<CollectionViewSource.SortDescriptions>
261-
<componentModel:SortDescription PropertyName="QualifiedMemberName.QualifiedModuleName.Name" />
261+
<componentModel:SortDescription PropertyName="Declaration.QualifiedName.QualifiedModuleName.Name" />
262262
</CollectionViewSource.SortDescriptions>
263263
<CollectionViewSource.GroupDescriptions>
264-
<PropertyGroupDescription PropertyName="QualifiedMemberName.QualifiedModuleName.Name" />
264+
<PropertyGroupDescription PropertyName="Declaration.QualifiedName.QualifiedModuleName.Name" />
265265
</CollectionViewSource.GroupDescriptions>
266266
</CollectionViewSource>
267267

@@ -584,7 +584,8 @@
584584
<controls:GroupingGrid ItemsSource="{Binding Source={StaticResource ResultsByOutcome}}"
585585
SelectedItem="{Binding SelectedTest}"
586586
ShowGroupingItemCount="True"
587-
Visibility="{Binding IsChecked, ElementName=GroupByOutcome, Converter={StaticResource BoolToVisibility}}" Margin="-1,0,1,0">
587+
Visibility="{Binding IsChecked, ElementName=GroupByOutcome, Converter={StaticResource BoolToVisibility}}"
588+
Margin="-1,0,1,0">
588589
<DataGrid.Columns>
589590
<DataGridTemplateColumn Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Outcome}">
590591
<DataGridTemplateColumn.CellTemplate>
@@ -612,8 +613,8 @@
612613
</DataTemplate>
613614
</DataGridTemplateColumn.CellTemplate>
614615
</DataGridTemplateColumn>
615-
<DataGridTextColumn Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=TestExplorer_QualifiedModuleName}" Binding="{Binding QualifiedMemberName.QualifiedModuleName}" />
616-
<DataGridTextColumn Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=TestExplorer_MethodName}" Binding="{Binding QualifiedMemberName.MemberName}" />
616+
<DataGridTextColumn Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=TestExplorer_QualifiedModuleName}" Binding="{Binding Declaration.QualifiedName.QualifiedModuleName}" />
617+
<DataGridTextColumn Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=TestExplorer_MethodName}" Binding="{Binding Declaration.QualifiedName.MemberName}" />
617618
<DataGridTextColumn Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=TestExplorer_Message}" Binding="{Binding Result.Output}" Width="*" />
618619
<DataGridTextColumn Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=TestExplorer_Duration}" Binding="{Binding Result.Duration, StringFormat={}{0}ms}" />
619620
</DataGrid.Columns>

Rubberduck.Parsing/Binding/DefaultBindingContext.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ private IExpressionBinding Visit(Declaration module, Declaration parent, VBAPars
119119
return new SimpleNameDefaultBinding(_declarationFinder, Declaration.GetProjectParent(parent), module, parent, expression, Identifier.GetName(expression.identifier()), statementContext);
120120
}
121121

122+
private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.IdentifierValueContext expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext)
123+
{
124+
return new SimpleNameDefaultBinding(_declarationFinder, Declaration.GetProjectParent(parent), module, parent, expression, Identifier.GetName(expression), statementContext);
125+
}
126+
122127
private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.MemberAccessExprContext expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext)
123128
{
124129
dynamic lExpression = expression.lExpression();

Rubberduck.Parsing/Symbols/ClassModuleDeclaration.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ public bool IsGlobalClassModule
104104
attributeIsGlobalClassModule = value.Single() == "True";
105105
}
106106
_isGlobal = attributeIsGlobalClassModule;
107+
108+
if (!_isGlobal.Value)
109+
{
110+
foreach (var type in Subtypes)
111+
{
112+
if (type is ClassModuleDeclaration && ((ClassModuleDeclaration) type).IsGlobalClassModule)
113+
{
114+
_isGlobal = true;
115+
break;
116+
}
117+
}
118+
}
119+
107120
return _isGlobal.Value;
108121
}
109122
}

Rubberduck.Parsing/Symbols/ReferencedDeclarationsCollector.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ public List<Declaration> GetDeclarationsForReference(Reference reference)
207207
attributes.AddPredeclaredIdTypeAttribute();
208208
}
209209

210+
if (typeAttributes.wTypeFlags.HasFlag(TYPEFLAGS.TYPEFLAG_FAPPOBJECT))
211+
{
212+
attributes.AddGlobalClassAttribute();
213+
}
214+
210215
Declaration moduleDeclaration;
211216
switch (typeDeclarationType)
212217
{

Rubberduck.Parsing/VBA/Attributes.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,10 @@ public void AddPredeclaredIdTypeAttribute()
3939
{
4040
Add("VB_PredeclaredId", new[] {"True"});
4141
}
42+
43+
public void AddGlobalClassAttribute()
44+
{
45+
Add("VB_GlobalNamespace", new[] {"True"});
46+
}
4247
}
4348
}

RubberduckTests/Grammar/ResolverTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,26 @@ End Sub
19571957
Assert.AreEqual(4, declaration.References.Count());
19581958
}
19591959

1960+
[TestMethod]
1961+
public void FieldLengthStmt_IsReferenceToLocalVariable()
1962+
{
1963+
// arrange
1964+
var code = @"
1965+
Public Sub Test()
1966+
Const Len As Integer = 4
1967+
Dim a As String * Len
1968+
End Sub
1969+
";
1970+
// act
1971+
var state = Resolve(code);
1972+
1973+
// assert
1974+
var declaration = state.AllUserDeclarations.Single(item =>
1975+
item.DeclarationType == DeclarationType.Constant && item.IdentifierName == "Len");
1976+
1977+
Assert.AreEqual(1, declaration.References.Count());
1978+
}
1979+
19601980
// Ignored because handling forms/hierarchies is an open issue.
19611981
[Ignore]
19621982
[TestMethod]

0 commit comments

Comments
 (0)