Skip to content

Commit 55cc4cf

Browse files
committed
Merge branch 'CodeExplorer' of https://github.com/retailcoder/Rubberduck.git
2 parents 49ee629 + b59bb64 commit 55cc4cf

21 files changed

+29638
-26314
lines changed

RetailCoder.VBE/Inspections/FunctionReturnValueNotUsedInspectionResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public override string Description
4242
{
4343
get
4444
{
45+
// bug NullReferenceException thrown here - null Target
4546
return string.Format(InspectionsUI.FunctionReturnValueNotUsedInspectionResultFormat, Target.IdentifierName);
4647
}
4748
}

RetailCoder.VBE/Inspections/NonReturningFunctionInspectionResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public override string Description
2727
{
2828
get
2929
{
30+
// bug NullReferenceException thrown here - null Target
3031
return string.Format(InspectionsUI.NonReturningFunctionInspectionResultFormat, Target.IdentifierName);
3132
}
3233
}

RetailCoder.VBE/Inspections/ObsoleteTypeHintInspectionResult.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Text.RegularExpressions;
45
using Antlr4.Runtime;
56
using Microsoft.Vbe.Interop;
@@ -78,13 +79,30 @@ public override void Fix()
7879

7980
private void FixTypeHintUsage(string hint, CodeModule module, Selection selection, bool isDeclaration = false)
8081
{
81-
var line = module.get_Lines(selection.StartLine, 1);
82+
var line = module.Lines[selection.StartLine, 1];
8283

8384
var asTypeClause = ' ' + Tokens.As + ' ' + TypeHints[hint];
84-
var pattern = "\\b" + _declaration.IdentifierName + "\\" + hint;
85-
var fix = Regex.Replace(line, pattern, _declaration.IdentifierName + (isDeclaration ? asTypeClause : String.Empty));
8685

87-
module.ReplaceLine(selection.StartLine, fix);
86+
string fix;
87+
88+
if (isDeclaration && (Context is VBAParser.FunctionStmtContext || Context is VBAParser.PropertyGetStmtContext))
89+
{
90+
var typeHint = (ParserRuleContext)Context.children.First(c => c is VBAParser.TypeHintContext);
91+
var argList = (ParserRuleContext) Context.children.First(c => c is VBAParser.ArgListContext);
92+
var endLine = argList.Stop.Line;
93+
var endColumn = argList.Stop.Column;
94+
95+
var oldLine = module.Lines[endLine, selection.LineCount];
96+
fix = oldLine.Insert(endColumn + 1, asTypeClause).Remove(typeHint.Start.Column, 1); // adjust for VBA 0-based indexing
97+
98+
module.ReplaceLine(endLine, fix);
99+
}
100+
else
101+
{
102+
var pattern = "\\b" + _declaration.IdentifierName + "\\" + hint;
103+
fix = Regex.Replace(line, pattern, _declaration.IdentifierName + (isDeclaration ? asTypeClause : string.Empty));
104+
module.ReplaceLine(selection.StartLine, fix);
105+
}
88106
}
89107
}
90108
}

RetailCoder.VBE/Inspections/ParameterNotUsedInspectionResult.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public ParameterNotUsedInspectionResult(IInspection inspection, string result,
2626

2727
public override string Description
2828
{
29+
// bug NullReferenceException thrown here - null Target
2930
get { return string.Format(InspectionsUI.ParameterNotUsedInspectionResultFormat, Target.IdentifierName); }
3031
}
3132
}

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@
218218
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
219219
<WarningLevel>4</WarningLevel>
220220
</PropertyGroup>
221+
<PropertyGroup>
222+
<StartupObject />
223+
</PropertyGroup>
221224
<ItemGroup>
222225
<Reference Include="Antlr4.Runtime.net45">
223226
<HintPath>..\packages\Antlr4.Runtime.4.3.0\lib\net45\Antlr4.Runtime.net45.dll</HintPath>

RetailCoder.VBE/UI/About/AboutControl.xaml

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
d:DataContext="{d:DesignInstance {x:Type about:AboutControlViewModel}, IsDesignTimeCreatable=False}">
1010
<UserControl.Resources>
1111
<BitmapImage x:Key="DuckImage" UriSource="../../Resources/RD-AboutWindow.png" />
12-
<BitmapImage x:Key="GitHubImage" UriSource="../../Resources/github_circle_black-128.png" />
13-
<BitmapImage x:Key="TwitterImage" UriSource="../../Resources/twitter_circle_black-512.png" />
14-
<BitmapImage x:Key="FacebookImage" UriSource="../../Resources/facebook-circle-256.png" />
15-
<BitmapImage x:Key="GooglePlusImage" UriSource="../../Resources/google-circle-512.png" />
1612
</UserControl.Resources>
1713
<Grid Background="#F6F6F6F6">
1814
<Grid.ColumnDefinitions>
@@ -21,7 +17,7 @@
2117
</Grid.ColumnDefinitions>
2218
<Grid.RowDefinitions>
2319
<RowDefinition />
24-
<RowDefinition Height="65" />
20+
<RowDefinition Height="55" />
2521
</Grid.RowDefinitions>
2622
<StackPanel HorizontalAlignment="Left"
2723
VerticalAlignment="Top"
@@ -41,7 +37,8 @@
4137
<StackPanel Grid.Column="1"
4238
Grid.Row="0"
4339
Background="White"
44-
Margin="10">
40+
Margin="10,10,10,30"
41+
Grid.RowSpan="2">
4542
<TextBlock Margin="10"
4643
Text="{Binding Version}"
4744
FontWeight="Bold"
@@ -62,7 +59,7 @@
6259
FontSize="12"
6360
Margin="5,0,0,0" />
6461
<ScrollViewer Margin="15,0,10,10"
65-
Height="100">
62+
Height="150">
6663
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=AboutWindow_SpecialThanksList}"
6764
FontSize="10" />
6865
</ScrollViewer>
@@ -74,56 +71,47 @@
7471
Grid.ColumnSpan="2"
7572
Margin="10"
7673
Orientation="Horizontal">
74+
<!-- Circle logos created with Ai->XAML Export Plug-In Version 0.2 (PC/64) -->
75+
<!-- By Mike Swanson (http://blog.mikeswanson.com/) -->
7776
<TextBlock>
7877
<Hyperlink Name="GitHubUrl"
79-
NavigateUri="http://www.rubberduck-vba.com"
78+
NavigateUri="https://github.com/rubberduck-vba/Rubberduck"
8079
Command="{Binding UriCommand}"
8180
CommandParameter="{Binding ElementName=GitHubUrl, Path=NavigateUri}"
8281
TextDecorations="{x:Null}">
83-
<Image Source="{StaticResource GitHubImage}"
84-
Margin="4"
85-
Height="40"
86-
VerticalAlignment="Center" />
82+
<Viewbox Width="35"
83+
Height="35">
84+
<Canvas Width="120"
85+
Height="120"
86+
Background="Transparent">
87+
<Path Fill="Black"
88+
Data=" M 59.996,0.000 C 26.866,0.000 0.000,26.863 0.000,60.003 C 0.000,86.510 17.190,108.999 41.035,116.934 C 44.035,117.484 45.130,115.632 45.130,114.041 C 45.130,112.617 45.078,108.844 45.049,103.837 C 28.359,107.463 24.837,95.794 24.837,95.794 C 22.109,88.862 18.175,87.017 18.175,87.017 C 12.728,83.294 18.588,83.370 18.588,83.370 C 24.609,83.794 27.778,89.553 27.778,89.553 C 33.130,98.722 41.821,96.074 45.240,94.539 C 45.785,90.661 47.335,88.017 49.049,86.517 C 35.725,85.003 21.719,79.856 21.719,56.863 C 21.719,50.313 24.057,44.957 27.895,40.763 C 27.278,39.245 25.219,33.145 28.483,24.884 C 28.483,24.884 33.521,23.271 44.982,31.035 C 49.768,29.704 54.901,29.039 60.003,29.016 C 65.099,29.039 70.232,29.704 75.025,31.035 C 86.479,23.271 91.508,24.884 91.508,24.884 C 94.781,33.145 92.722,39.245 92.105,40.763 C 95.950,44.957 98.272,50.313 98.272,56.863 C 98.272,79.913 84.244,84.985 70.877,86.471 C 73.032,88.323 74.951,91.985 74.951,97.582 C 74.951,105.603 74.877,112.074 74.877,114.041 C 74.877,115.646 75.958,117.513 79.003,116.927 C 102.824,108.977 120.000,86.503 120.000,60.003 C 120.000,26.863 93.134,0.000 59.996,0.000 Z"/>
89+
</Canvas>
90+
</Viewbox>
8791
</Hyperlink>
88-
</TextBlock>
89-
<TextBlock>
9092
<Hyperlink Name="TwitterUrl"
9193
NavigateUri="http://www.twitter.com/rubberduckvba"
9294
Command="{Binding UriCommand}"
9395
CommandParameter="{Binding ElementName=TwitterUrl, Path=NavigateUri}"
9496
TextDecorations="{x:Null}">
95-
<Image Source="{StaticResource TwitterImage}"
96-
Margin="4"
97-
Height="40"
98-
VerticalAlignment="Center" />
99-
</Hyperlink>
100-
</TextBlock>
101-
<TextBlock>
102-
<Hyperlink Name="FacebookUrl"
103-
NavigateUri="http://www.facebook.com/rubberduckvba"
104-
Command="{Binding UriCommand}"
105-
CommandParameter="{Binding ElementName=FacebookUrl, Path=NavigateUri}"
106-
TextDecorations="{x:Null}">
107-
<Image Source="{StaticResource FacebookImage}"
108-
Margin="4"
109-
VerticalAlignment="Center" />
97+
<Viewbox Margin="10,0,0,0"
98+
Width="35"
99+
Height="35">
100+
<Canvas Width="120"
101+
Height="120"
102+
Background="Transparent">
103+
<Path Fill="Black"
104+
Data="F1 M 92.670,42.747 C 92.702,43.460 92.718,44.177 92.718,44.897 C 92.718,66.860 76.001,92.185 45.431,92.185 C 36.045,92.185 27.310,89.433 19.954,84.718 C 21.255,84.871 22.577,84.950 23.919,84.950 C 31.706,84.950 38.872,82.293 44.560,77.836 C 37.287,77.701 31.149,72.896 29.034,66.293 C 30.049,66.487 31.090,66.591 32.161,66.591 C 33.677,66.591 35.145,66.388 36.540,66.009 C 28.937,64.482 23.208,57.765 23.208,49.712 C 23.208,49.642 23.208,49.572 23.209,49.503 C 25.450,50.748 28.013,51.496 30.737,51.582 C 26.278,48.601 23.344,43.514 23.344,37.748 C 23.344,34.703 24.163,31.848 25.594,29.393 C 33.791,39.448 46.037,46.065 59.850,46.758 C 59.567,45.541 59.420,44.273 59.420,42.970 C 59.420,33.792 66.861,26.351 76.040,26.351 C 80.820,26.351 85.139,28.369 88.171,31.599 C 91.957,30.854 95.514,29.471 98.725,27.566 C 97.484,31.447 94.849,34.704 91.417,36.761 C 94.779,36.359 97.982,35.466 100.963,34.144 C 98.735,37.477 95.917,40.404 92.670,42.747 Z M 60.000,0.000 C 26.863,0.000 0.000,26.863 0.000,60.000 C 0.000,93.137 26.863,120.000 60.000,120.000 C 93.137,120.000 120.000,93.137 120.000,60.000 C 120.000,26.863 93.137,0.000 60.000,0.000 Z"/>
105+
</Canvas>
106+
</Viewbox>
110107
</Hyperlink>
111108
</TextBlock>
112-
<TextBlock>
113-
<Hyperlink Name="GooglePlusUrl"
114-
NavigateUri="http://plus.google.com/116859653258584466987"
115-
Command="{Binding UriCommand}"
116-
CommandParameter="{Binding ElementName=GooglePlusUrl, Path=NavigateUri}"
117-
TextDecorations="{x:Null}">
118-
<Image Source="{StaticResource GooglePlusImage}"
119-
Margin="4"
120-
VerticalAlignment="Center" />
121-
</Hyperlink>
122-
</TextBlock>
123-
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=AboutWindow_Copyright}"
124-
FontSize="8"
125-
VerticalAlignment="Center"
126-
Margin="10,0,0,0"/>
127109
</StackPanel>
110+
<TextBlock Grid.Row="1"
111+
Grid.Column="1"
112+
Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=AboutWindow_Copyright}"
113+
FontSize="8"
114+
VerticalAlignment="Bottom"
115+
Margin="10,0,0,10"/>
128116
</Grid>
129117
</UserControl>

RetailCoder.VBE/UI/Controls/NumberPicker.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Name="Root">
99
<Grid>
1010
<StackPanel Orientation="Horizontal">
11-
<TextBox Margin="5,5,0,5" Height="20" Width="50" Text="{Binding ElementName=Root, Path=NumValue, Mode=TwoWay, StringFormat=\{0:D\}, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" VerticalContentAlignment="Center" />
11+
<TextBox Margin="5,5,0,5" Height="20" Width="50" Text="{Binding ElementName=Root, Path=NumValue, Mode=TwoWay, StringFormat=\{0:D\}, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" VerticalAlignment="Top" VerticalContentAlignment="Center" />
1212
<StackPanel Margin="0,5" >
1313
<Button Height="10" Width="20" Click="cmdUp_Click">
1414
<TextBlock Text="˄" FontSize="10" Margin="0,-4,0,0"/>

RetailCoder.VBE/UI/Controls/NumberPicker.xaml.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
using System.Windows;
1+
using System.ComponentModel;
2+
using System.Windows;
23

34
// credit to http://stackoverflow.com/a/2752538
45
namespace Rubberduck.UI.Controls
56
{
67
/// <summary>
78
/// Interaction logic for NumberPicker.xaml
89
/// </summary>
9-
public partial class NumberPicker
10+
public partial class NumberPicker : IDataErrorInfo
1011
{
1112
public static readonly DependencyProperty NumValueProperty =
1213
DependencyProperty.Register("NumValue", typeof(int), typeof(NumberPicker), new UIPropertyMetadata(null));
@@ -24,6 +25,20 @@ public int NumValue
2425
}
2526
}
2627

28+
private int _minNumber = int.MinValue;
29+
public int MinNumber
30+
{
31+
get { return _minNumber; }
32+
set { _minNumber = value; }
33+
}
34+
35+
private int _maxNumber = int.MaxValue;
36+
public int MaxNumber
37+
{
38+
get { return _maxNumber; }
39+
set { _maxNumber = value; }
40+
}
41+
2742
public NumberPicker()
2843
{
2944
InitializeComponent();
@@ -38,5 +53,25 @@ private void cmdDown_Click(object sender, RoutedEventArgs e)
3853
{
3954
NumValue--;
4055
}
56+
57+
public string this[string columnName]
58+
{
59+
get
60+
{
61+
if (columnName != "NumValue")
62+
{
63+
return string.Empty;
64+
}
65+
66+
if (NumValue < MinNumber || NumValue > MaxNumber)
67+
{
68+
return "Invalid Selection";
69+
}
70+
71+
return string.Empty;
72+
}
73+
}
74+
75+
public string Error { get; private set; }
4176
}
4277
}

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Lines changed: 6 additions & 2 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ Carlos J. Quintero (MZ-Tools articles &amp; help with VBE API)
13011301
Francis Veilleux-Gaboury
13021302
Frank Van Heeswijk
13031303
@Heslacher
1304-
Jeroen Vannevel dos Sànchez di Castello du Aragon de Pompidou
1304+
Jeroen Vannevel
13051305
@mjolka
13061306
Philip Wales
13071307
Rob Bovey

0 commit comments

Comments
 (0)