Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public override string Description
{
get
{
// bug NullReferenceException thrown here - null Target
return string.Format(InspectionsUI.FunctionReturnValueNotUsedInspectionResultFormat, Target.IdentifierName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public override string Description
{
get
{
// bug NullReferenceException thrown here - null Target
return string.Format(InspectionsUI.NonReturningFunctionInspectionResultFormat, Target.IdentifierName);
}
}
Expand Down
26 changes: 22 additions & 4 deletions RetailCoder.VBE/Inspections/ObsoleteTypeHintInspectionResult.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Antlr4.Runtime;
using Microsoft.Vbe.Interop;
Expand Down Expand Up @@ -78,13 +79,30 @@ public override void Fix()

private void FixTypeHintUsage(string hint, CodeModule module, Selection selection, bool isDeclaration = false)
{
var line = module.get_Lines(selection.StartLine, 1);
var line = module.Lines[selection.StartLine, 1];

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

module.ReplaceLine(selection.StartLine, fix);
string fix;

if (isDeclaration && (Context is VBAParser.FunctionStmtContext || Context is VBAParser.PropertyGetStmtContext))
{
var typeHint = (ParserRuleContext)Context.children.First(c => c is VBAParser.TypeHintContext);
var argList = (ParserRuleContext) Context.children.First(c => c is VBAParser.ArgListContext);
var endLine = argList.Stop.Line;
var endColumn = argList.Stop.Column;

var oldLine = module.Lines[endLine, selection.LineCount];
fix = oldLine.Insert(endColumn + 1, asTypeClause).Remove(typeHint.Start.Column, 1); // adjust for VBA 0-based indexing

module.ReplaceLine(endLine, fix);
}
else
{
var pattern = "\\b" + _declaration.IdentifierName + "\\" + hint;
fix = Regex.Replace(line, pattern, _declaration.IdentifierName + (isDeclaration ? asTypeClause : string.Empty));
module.ReplaceLine(selection.StartLine, fix);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public ParameterNotUsedInspectionResult(IInspection inspection, string result,

public override string Description
{
// bug NullReferenceException thrown here - null Target
get { return string.Format(InspectionsUI.ParameterNotUsedInspectionResultFormat, Target.IdentifierName); }
}
}
Expand Down
3 changes: 3 additions & 0 deletions RetailCoder.VBE/Rubberduck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Antlr4.Runtime.net45">
<HintPath>..\packages\Antlr4.Runtime.4.3.0\lib\net45\Antlr4.Runtime.net45.dll</HintPath>
Expand Down
76 changes: 32 additions & 44 deletions RetailCoder.VBE/UI/About/AboutControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
d:DataContext="{d:DesignInstance {x:Type about:AboutControlViewModel}, IsDesignTimeCreatable=False}">
<UserControl.Resources>
<BitmapImage x:Key="DuckImage" UriSource="../../Resources/RD-AboutWindow.png" />
<BitmapImage x:Key="GitHubImage" UriSource="../../Resources/github_circle_black-128.png" />
<BitmapImage x:Key="TwitterImage" UriSource="../../Resources/twitter_circle_black-512.png" />
<BitmapImage x:Key="FacebookImage" UriSource="../../Resources/facebook-circle-256.png" />
<BitmapImage x:Key="GooglePlusImage" UriSource="../../Resources/google-circle-512.png" />
</UserControl.Resources>
<Grid Background="#F6F6F6F6">
<Grid.ColumnDefinitions>
Expand All @@ -21,7 +17,7 @@
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="65" />
<RowDefinition Height="55" />
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Left"
VerticalAlignment="Top"
Expand All @@ -41,7 +37,8 @@
<StackPanel Grid.Column="1"
Grid.Row="0"
Background="White"
Margin="10">
Margin="10,10,10,30"
Grid.RowSpan="2">
<TextBlock Margin="10"
Text="{Binding Version}"
FontWeight="Bold"
Expand All @@ -62,7 +59,7 @@
FontSize="12"
Margin="5,0,0,0" />
<ScrollViewer Margin="15,0,10,10"
Height="100">
Height="150">
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=AboutWindow_SpecialThanksList}"
FontSize="10" />
</ScrollViewer>
Expand All @@ -74,56 +71,47 @@
Grid.ColumnSpan="2"
Margin="10"
Orientation="Horizontal">
<!-- Circle logos created with Ai->XAML Export Plug-In Version 0.2 (PC/64) -->
<!-- By Mike Swanson (http://blog.mikeswanson.com/) -->
<TextBlock>
<Hyperlink Name="GitHubUrl"
NavigateUri="http://www.rubberduck-vba.com"
NavigateUri="https://github.com/rubberduck-vba/Rubberduck"
Command="{Binding UriCommand}"
CommandParameter="{Binding ElementName=GitHubUrl, Path=NavigateUri}"
TextDecorations="{x:Null}">
<Image Source="{StaticResource GitHubImage}"
Margin="4"
Height="40"
VerticalAlignment="Center" />
<Viewbox Width="35"
Height="35">
<Canvas Width="120"
Height="120"
Background="Transparent">
<Path Fill="Black"
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"/>
</Canvas>
</Viewbox>
</Hyperlink>
</TextBlock>
<TextBlock>
<Hyperlink Name="TwitterUrl"
NavigateUri="http://www.twitter.com/rubberduckvba"
Command="{Binding UriCommand}"
CommandParameter="{Binding ElementName=TwitterUrl, Path=NavigateUri}"
TextDecorations="{x:Null}">
<Image Source="{StaticResource TwitterImage}"
Margin="4"
Height="40"
VerticalAlignment="Center" />
</Hyperlink>
</TextBlock>
<TextBlock>
<Hyperlink Name="FacebookUrl"
NavigateUri="http://www.facebook.com/rubberduckvba"
Command="{Binding UriCommand}"
CommandParameter="{Binding ElementName=FacebookUrl, Path=NavigateUri}"
TextDecorations="{x:Null}">
<Image Source="{StaticResource FacebookImage}"
Margin="4"
VerticalAlignment="Center" />
<Viewbox Margin="10,0,0,0"
Width="35"
Height="35">
<Canvas Width="120"
Height="120"
Background="Transparent">
<Path Fill="Black"
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"/>
</Canvas>
</Viewbox>
</Hyperlink>
</TextBlock>
<TextBlock>
<Hyperlink Name="GooglePlusUrl"
NavigateUri="http://plus.google.com/116859653258584466987"
Command="{Binding UriCommand}"
CommandParameter="{Binding ElementName=GooglePlusUrl, Path=NavigateUri}"
TextDecorations="{x:Null}">
<Image Source="{StaticResource GooglePlusImage}"
Margin="4"
VerticalAlignment="Center" />
</Hyperlink>
</TextBlock>
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=AboutWindow_Copyright}"
FontSize="8"
VerticalAlignment="Center"
Margin="10,0,0,0"/>
</StackPanel>
<TextBlock Grid.Row="1"
Grid.Column="1"
Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=AboutWindow_Copyright}"
FontSize="8"
VerticalAlignment="Bottom"
Margin="10,0,0,10"/>
</Grid>
</UserControl>
2 changes: 1 addition & 1 deletion RetailCoder.VBE/UI/Controls/NumberPicker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Name="Root">
<Grid>
<StackPanel Orientation="Horizontal">
<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" />
<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" />
<StackPanel Margin="0,5" >
<Button Height="10" Width="20" Click="cmdUp_Click">
<TextBlock Text="˄" FontSize="10" Margin="0,-4,0,0"/>
Expand Down
39 changes: 37 additions & 2 deletions RetailCoder.VBE/UI/Controls/NumberPicker.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System.Windows;
using System.ComponentModel;
using System.Windows;

// credit to http://stackoverflow.com/a/2752538
namespace Rubberduck.UI.Controls
{
/// <summary>
/// Interaction logic for NumberPicker.xaml
/// </summary>
public partial class NumberPicker
public partial class NumberPicker : IDataErrorInfo
{
public static readonly DependencyProperty NumValueProperty =
DependencyProperty.Register("NumValue", typeof(int), typeof(NumberPicker), new UIPropertyMetadata(null));
Expand All @@ -24,6 +25,20 @@ public int NumValue
}
}

private int _minNumber = int.MinValue;
public int MinNumber
{
get { return _minNumber; }
set { _minNumber = value; }
}

private int _maxNumber = int.MaxValue;
public int MaxNumber
{
get { return _maxNumber; }
set { _maxNumber = value; }
}

public NumberPicker()
{
InitializeComponent();
Expand All @@ -38,5 +53,25 @@ private void cmdDown_Click(object sender, RoutedEventArgs e)
{
NumValue--;
}

public string this[string columnName]
{
get
{
if (columnName != "NumValue")
{
return string.Empty;
}

if (NumValue < MinNumber || NumValue > MaxNumber)
{
return "Invalid Selection";
}

return string.Empty;
}
}

public string Error { get; private set; }
}
}
8 changes: 6 additions & 2 deletions RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion RetailCoder.VBE/UI/RubberduckUI.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ Carlos J. Quintero (MZ-Tools articles &amp; help with VBE API)
Francis Veilleux-Gaboury
Frank Van Heeswijk
@Heslacher
Jeroen Vannevel dos Sànchez di Castello du Aragon de Pompidou
Jeroen Vannevel
@mjolka
Philip Wales
Rob Bovey
Expand Down
1 change: 1 addition & 0 deletions RetailCoder.VBE/UI/Settings/GeneralSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<controls:NumberPicker Margin="0,-6,0,0"
IsEnabled="{Binding ElementName=AutoSaveButton, Path=IsChecked}"
NumValue="{Binding AutoSavePeriod, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
MinNumber="1"
HorizontalAlignment="Left" />
</StackPanel>

Expand Down
9 changes: 6 additions & 3 deletions RetailCoder.VBE/UI/Settings/IndenterSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
<controls:NumberPicker Margin="0,-6,0,0"
IsEnabled="{Binding ElementName=AlignDimColumn, Path=IsChecked}"
NumValue="{Binding AlignDimColumn, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Left" />
HorizontalAlignment="Left"
MinNumber="0"/>
</StackPanel>
<Label Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=IndenterSettings_SpecialOptionsLabel}"
FontWeight="SemiBold" />
Expand Down Expand Up @@ -123,7 +124,8 @@
Margin="5,0,0,5"
HorizontalAlignment="Left" />
<controls:NumberPicker Margin="0,-6,0,0"
NumValue="{Binding IndentSpaces, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
NumValue="{Binding IndentSpaces, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
MinNumber="0"/>
</StackPanel>
<Label Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=IndenterSettings_EnableOptionsLabel}"
FontWeight="SemiBold" />
Expand All @@ -146,7 +148,8 @@
<controls:NumberPicker Margin="0,-4,0,0"
NumValue="{Binding EndOfLineCommentColumnSpaceAlignment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding EndOfLineCommentStyle, Converter={StaticResource EndOfLineCommentStyleToVisibility}}"
HorizontalAlignment="Left" />
HorizontalAlignment="Left"
MinNumber="0" />
</StackPanel>
</StackPanel>
</ScrollViewer>
Expand Down
3 changes: 2 additions & 1 deletion Rubberduck.Parsing/Grammar/VBA.g4
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
* - implemented proper specs for DATELITERAL.
* - added comments to parse tree (removes known limitation #2).
* - macroConstStmt now allowed in blockStmt.
* - allow type hints for parameter
*
*======================================================================================
*
Expand Down Expand Up @@ -637,7 +638,7 @@ dictionaryCallStmt : '!' ambiguousIdentifier typeHint?;

argList : LPAREN (WS? arg (WS? ',' WS? arg)*)? WS? RPAREN;

arg : (OPTIONAL WS)? ((BYVAL | BYREF) WS)? (PARAMARRAY WS)? ambiguousIdentifier (WS? LPAREN WS? RPAREN)? (WS? asTypeClause)? (WS? argDefaultValue)?;
arg : (OPTIONAL WS)? ((BYVAL | BYREF) WS)? (PARAMARRAY WS)? ambiguousIdentifier typeHint? (WS? LPAREN WS? RPAREN)? (WS? asTypeClause)? (WS? argDefaultValue)?;

argDefaultValue : EQ WS? valueStmt;

Expand Down
Loading