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
3 changes: 3 additions & 0 deletions RetailCoder.VBE/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Rubberduck.UI.Command.MenuItems;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
Expand Down Expand Up @@ -174,6 +175,8 @@ async void sink_ProjectRemoved(object sender, DispatcherEventArgs<VBProject> e)
}

var projectId = e.Item.HelpFile;
Debug.Assert(projectId != null);

_componentsEventsSinks.Remove(projectId);
_referencesEventsSinks.Remove(projectId);
_parser.State.RemoveProject(e.Item);
Expand Down
10 changes: 9 additions & 1 deletion RetailCoder.VBE/Common/RubberduckHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Windows.Input;
using Microsoft.Vbe.Interop;
using Rubberduck.Common.Hotkeys;
Expand Down Expand Up @@ -106,9 +107,16 @@ private void Mouse_RawMouseInputReceived(object sender, RawMouseEventArgs e)
}
}

// keys that change the current selection.
private static readonly HashSet<Keys> NavKeys = new HashSet<Keys>
{
Keys.Up, Keys.Down, Keys.Left, Keys.Right, Keys.PageDown, Keys.PageUp, Keys.Enter
};

private void Keyboard_RawKeyboardInputReceived(object sender, RawKeyEventArgs e)
{
if (e.Message == WM.KEYUP)
// note: handling *all* keys causes annoying RTrim of current line, making editing code a PITA.
if (e.Message == WM.KEYUP && NavKeys.Contains((Keys)e.VKey))
{
OnMessageReceived(this, HookEventArgs.Empty);
}
Expand Down
4 changes: 0 additions & 4 deletions RetailCoder.VBE/Inspections/ParameterCanBeByValInspection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Threading;
using Rubberduck.Common;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Symbols;
Expand All @@ -13,11 +12,8 @@ public sealed class ParameterCanBeByValInspection : InspectionBase
public ParameterCanBeByValInspection(RubberduckParserState state)
: base(state, CodeInspectionSeverity.Suggestion)
{
_dispatcher = Dispatcher.CurrentDispatcher;
}

private readonly Dispatcher _dispatcher;

public override string Meta { get { return InspectionsUI.ParameterCanBeByValInspectionMeta; } }
public override string Description { get { return InspectionsUI.ParameterCanBeByValInspectionName; } }
public override CodeInspectionType InspectionType { get { return CodeInspectionType.CodeQualityIssues; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public PassParameterByValueQuickFix(ParserRuleContext context, QualifiedSelectio

public override void Fix()
{
var parameter = Context.GetText();
var parameter = Context.Parent.GetText();
var newContent = string.Concat(Tokens.ByVal, " ", parameter.Replace(Tokens.ByRef, string.Empty).Trim());
var selection = Selection.Selection;

var module = Selection.QualifiedName.Component.CodeModule;
var lines = module.get_Lines(selection.StartLine, selection.LineCount);
var lines = module.Lines[selection.StartLine, selection.LineCount];

var result = lines.Replace(parameter, newContent);
module.ReplaceLine(selection.StartLine, result);
Expand Down
2 changes: 1 addition & 1 deletion RetailCoder.VBE/Root/RubberduckModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using Rubberduck.SourceControl;
using Rubberduck.UI;
using Rubberduck.UI.CodeExplorer;
using Rubberduck.UI.CodeInspections;
using Rubberduck.UI.Inspections;
using Rubberduck.UI.Command;
using Rubberduck.UI.Command.MenuItems;
using Rubberduck.UI.Command.MenuItems.ParentMenus;
Expand Down
22 changes: 11 additions & 11 deletions RetailCoder.VBE/Rubberduck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,13 @@
<Compile Include="Navigation\CodeExplorer\CodeExplorerMemberViewModel.cs" />
<Compile Include="Navigation\CodeExplorer\CodeExplorerProjectViewModel.cs" />
<Compile Include="Navigation\CodeExplorer\CodeExplorerViewModel.cs" />
<Compile Include="UI\CodeInspections\InspectionDescriptionConverter.cs" />
<Compile Include="UI\CodeInspections\InspectionImageSourceConverter.cs" />
<Compile Include="UI\CodeInspections\InspectionResultsControl.xaml.cs">
<Compile Include="UI\Inspections\InspectionDescriptionConverter.cs" />
<Compile Include="UI\Inspections\InspectionImageSourceConverter.cs" />
<Compile Include="UI\Inspections\InspectionResultsControl.xaml.cs">
<DependentUpon>InspectionResultsControl.xaml</DependentUpon>
</Compile>
<Compile Include="UI\CodeInspections\InspectionResultsViewModel.cs" />
<Compile Include="UI\CodeInspections\InspectionSeverityImageSourceConverter.cs" />
<Compile Include="UI\Inspections\InspectionResultsViewModel.cs" />
<Compile Include="UI\Inspections\InspectionSeverityImageSourceConverter.cs" />
<Compile Include="UI\Command\AboutCommand.cs" />
<Compile Include="UI\Command\AddTestMethodExpectedErrorCommand.cs" />
<Compile Include="UI\Command\AddTestMethodCommand.cs" />
Expand Down Expand Up @@ -880,15 +880,15 @@
<Compile Include="UI\CodeExplorer\CodeExplorerWindow.Designer.cs">
<DependentUpon>CodeExplorerWindow.cs</DependentUpon>
</Compile>
<Compile Include="UI\CodeInspections\CodeInspectionsDockablePresenter.cs" />
<Compile Include="UI\CodeInspections\CodeInspectionsWindow.cs">
<Compile Include="UI\Inspections\CodeInspectionsDockablePresenter.cs" />
<Compile Include="UI\Inspections\CodeInspectionsWindow.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UI\CodeInspections\CodeInspectionsWindow.Designer.cs">
<Compile Include="UI\Inspections\CodeInspectionsWindow.Designer.cs">
<DependentUpon>CodeInspectionsWindow.cs</DependentUpon>
</Compile>
<Compile Include="UI\NavigateCodeEventArgs.cs" />
<Compile Include="UI\CodeInspections\QuickFixEventArgs.cs" />
<Compile Include="UI\Inspections\QuickFixEventArgs.cs" />
<Compile Include="UI\DockableToolwindowPresenter.cs" />
<Compile Include="Settings\Configuration.cs" />
<Compile Include="Settings\ToDoListSettings.cs" />
Expand Down Expand Up @@ -992,7 +992,7 @@
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="UI\CodeInspections\CodeInspectionsWindow.resx">
<EmbeddedResource Include="UI\Inspections\CodeInspectionsWindow.resx">
<DependentUpon>CodeInspectionsWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Controls\SearchResultWindow.resx">
Expand Down Expand Up @@ -1484,7 +1484,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UI\CodeInspections\InspectionResultsControl.xaml">
<Page Include="UI\Inspections\InspectionResultsControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
4 changes: 2 additions & 2 deletions RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@
</ToolBar>
</ToolBarTray>

<TreeView Grid.Row="1"
<TreeView Grid.Row="1" Background="White"
ItemContainerStyle="{StaticResource ShinyTreeView}"
HorizontalContentAlignment="Stretch"
MouseDoubleClick="TreeView_OnMouseDoubleClick"
Expand All @@ -730,7 +730,7 @@

<Border Grid.Row="3" BorderThickness="0,1,0,0" BorderBrush="DimGray">

<StackPanel Orientation="Vertical" MinHeight="48" Background="Gainsboro">
<StackPanel Orientation="Vertical" MinHeight="48" Background="WhiteSmoke">

<Grid Margin="4" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Vbe.Interop;

namespace Rubberduck.UI.CodeInspections
namespace Rubberduck.UI.Inspections
{
public class CodeInspectionsDockablePresenter : DockableToolwindowPresenter
{
Expand Down

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

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Windows.Forms;

namespace Rubberduck.UI.CodeInspections
namespace Rubberduck.UI.Inspections
{
public partial class CodeInspectionsWindow : UserControl, IDockableUserControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Windows.Data;
using Rubberduck.Inspections;

namespace Rubberduck.UI.CodeInspections
namespace Rubberduck.UI.Inspections
{
public class InspectionTypeConverter : IValueConverter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Windows.Data;
using Rubberduck.Inspections;

namespace Rubberduck.UI.CodeInspections
namespace Rubberduck.UI.Inspections
{
public class InspectionImageSourceConverter : IValueConverter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<UserControl x:Class="Rubberduck.UI.CodeInspections.InspectionResultsControl"
<UserControl x:Class="Rubberduck.UI.Inspections.InspectionResultsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:inspections="clr-namespace:Rubberduck.Inspections"
xmlns:codeInspections="clr-namespace:Rubberduck.UI.CodeInspections"
xmlns:codeInspections="clr-namespace:Rubberduck.UI.Inspections"
xmlns:controls="clr-namespace:Rubberduck.UI.Controls"
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
Expand Down Expand Up @@ -483,7 +483,7 @@
<RowDefinition Height="Auto" MinHeight="48"/>
</Grid.RowDefinitions>

<Border Grid.Row="0" Grid.RowSpan="3" Background="#FFEEF5FD" />
<Border Grid.Row="0" Grid.RowSpan="3" Background="White" />

<ToolBarTray Grid.Row="0" IsLocked="True">
<ToolBar Style="{StaticResource ToolBarWithOverflowOnlyShowingWhenNeededStyle}">
Expand Down Expand Up @@ -590,7 +590,7 @@

<Border Grid.Row="3" BorderThickness="0,1,0,0" BorderBrush="DimGray">

<StackPanel Orientation="Vertical" MinHeight="48" Background="Gainsboro">
<StackPanel Orientation="Vertical" MinHeight="48" Background="WhiteSmoke">

<Grid Margin="4" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Windows;
using System.Windows.Controls;

namespace Rubberduck.UI.CodeInspections
namespace Rubberduck.UI.Inspections
{
/// <summary>
/// Interaction logic for InspectionResultsControl.xaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using Rubberduck.VBEditor.Extensions;
using NLog;

namespace Rubberduck.UI.CodeInspections
namespace Rubberduck.UI.Inspections
{
public sealed class InspectionResultsViewModel : ViewModelBase, INavigateSelection, IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Windows.Media.Imaging;
using Rubberduck.Inspections;

namespace Rubberduck.UI.CodeInspections
namespace Rubberduck.UI.Inspections
{
public class InspectionSeverityImageSourceConverter : IValueConverter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Rubberduck.UI.CodeInspections
namespace Rubberduck.UI.Inspections
{
public class QuickFixEventArgs : EventArgs
{
Expand Down
3 changes: 1 addition & 2 deletions RetailCoder.VBE/UI/Settings/SettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
d:DesignHeight="300" d:DesignWidth="600"
d:DataContext="{d:DesignInstance {x:Type settings:SettingsControlViewModel}, IsDesignTimeCreatable=False}">
<UserControl.InputBindings>
<KeyBinding Key="Escape"
Command="{Binding CancelButtonCommand}" />
<KeyBinding Key="Escape" Command="{Binding CancelButtonCommand}" />
</UserControl.InputBindings>
<UserControl.Resources>
<converters:SettingsViewToPageConverter x:Key="SettingsViewToPage" />
Expand Down

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

5 changes: 5 additions & 0 deletions Rubberduck.Parsing/Symbols/TypeAnnotationPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ private void AnnotateType(Declaration declaration)
return;
}
var module = Declaration.GetModuleParent(declaration);
if (module == null)
{
_logger.Warn("Type annotation failed for {0} because module parent is missing.", typeExpression);
return;
}
var expressionContext = _expressionParser.Parse(typeExpression.Trim());
var boundExpression = _bindingService.ResolveType(module, declaration.ParentDeclaration, expressionContext);
if (boundExpression.Classification != ExpressionClassification.ResolutionFailed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ public void ParameterCanByByVal_ReturnsResult_QuickFixWorks_PassedByUnspecified(

[TestMethod]
[TestCategory("Inspections")]
public void ParameterCanByByVal_ReturnsResult_QuickFixWorks_PassedByRefUnassigned()
public void ParameterCanByByVal_ReturnsResult_QuickFixWorks_PassedByRef()
{
const string inputCode =
@"Sub Foo(arg1 As String)
@"Sub Foo(ByRef arg1 As String)
End Sub";

const string expectedCode =
Expand Down