Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
540e4a0
Fix 101 bugs in various parts of the project.
Hosch250 Jul 7, 2016
9811c66
Merge branch 'next' into cacheBugs
Hosch250 Jul 7, 2016
f8821bf
Merge branch 'next' into cacheBugs
Hosch250 Jul 7, 2016
1c00cc8
Another fix for #1974
Hosch250 Jul 7, 2016
fe7026d
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck i…
Hosch250 Jul 7, 2016
38b1be5
Merge pull request #1988 from Hosch250/Issue1974
Hosch250 Jul 7, 2016
c1e5314
Merge branch 'next' into cacheBugs
Hosch250 Jul 7, 2016
1b5fb36
Close #1974
Hosch250 Jul 7, 2016
2d46270
Merge branch 'next' into Issue1974
Hosch250 Jul 7, 2016
aab1475
Merge pull request #1989 from Hosch250/Issue1974
Hosch250 Jul 7, 2016
2bb0be0
Merge branch 'next' into cacheBugs
Hosch250 Jul 7, 2016
279e608
Attach/detach hotkeys when dockable windows get/lose focus.
comintern Jul 8, 2016
35c0ce9
Merge branch 'next' into next
comintern Jul 8, 2016
db6dcec
Catch COM exception when accessing code module for removed component.
Hosch250 Jul 8, 2016
c9feb2e
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck i…
Hosch250 Jul 8, 2016
13d2ce7
Merge pull request #1990 from comintern/next
Hosch250 Jul 8, 2016
97689ee
Merge branch 'next' into FixTestMethodCommands
Hosch250 Jul 8, 2016
a383fe7
Merge branch 'next' into cacheBugs
Hosch250 Jul 8, 2016
c764b1e
Merge pull request #1992 from Hosch250/FixTestMethodCommands
Hosch250 Jul 8, 2016
0f81ef7
Merge branch 'next' into cacheBugs
Hosch250 Jul 8, 2016
f843f49
Merge pull request #1986 from Hosch250/cacheBugs
retailcoder Jul 8, 2016
0bef34a
Make Open Project Properties open the properties for the correct proj…
Hosch250 Jul 8, 2016
9258158
Merge branch 'cacheBugs' of https://github.com/Hosch250/Rubberduck
Hosch250 Jul 8, 2016
bf5a454
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck i…
Hosch250 Jul 8, 2016
1a0ddf4
Merge pull request #1993 from Hosch250/cacheBugs
retailcoder Jul 8, 2016
366eb68
Merge pull request #142 from rubberduck-vba/next
retailcoder Jul 8, 2016
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
2 changes: 1 addition & 1 deletion RetailCoder.VBE/API/ParserState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void Initialize(VBE vbe)

Func<IVBAPreprocessor> preprocessorFactory = () => new VBAPreprocessor(double.Parse(vbe.Version, CultureInfo.InvariantCulture));
_attributeParser = new AttributeParser(new ModuleExporter(), preprocessorFactory);
_parser = new RubberduckParser(vbe, _state, _attributeParser, preprocessorFactory,
_parser = new RubberduckParser(_state, _attributeParser, preprocessorFactory,
new List<ICustomDeclarationLoader> { new DebugDeclarations(_state), new FormEventDeclarations(_state) });
}

Expand Down
27 changes: 14 additions & 13 deletions RetailCoder.VBE/Common/RubberduckHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ public void Detach()

private void hook_MessageReceived(object sender, HookEventArgs e)
{
var active = User32.GetForegroundWindow();
if (active != _mainWindowHandle)
{
return;
}

var hotkey = sender as IHotkey;
if (hotkey != null)
{
Expand Down Expand Up @@ -207,6 +201,16 @@ private IntPtr WindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam)
case WM.SETFOCUS:
Attach();
break;
case WM.RUBBERDUCK_CHILD_FOCUS:
if (lParam == IntPtr.Zero)
{
Detach();
}
else
{
Attach();
}
return IntPtr.Zero;
case WM.NCACTIVATE:
if (wParam == IntPtr.Zero)
{
Expand Down Expand Up @@ -235,14 +239,11 @@ private bool HandleHotkeyMessage(IntPtr wParam)
var processed = false;
try
{
if (User32.IsVbeWindowActive(_mainWindowHandle))
var hook = Hooks.OfType<Hotkey>().SingleOrDefault(k => k.HotkeyInfo.HookId == wParam);
if (hook != null)
{
var hook = Hooks.OfType<Hotkey>().SingleOrDefault(k => k.HotkeyInfo.HookId == wParam);
if (hook != null)
{
hook.OnMessageReceived();
processed = true;
}
hook.OnMessageReceived();
processed = true;
}
}
catch (Exception exception)
Expand Down
3 changes: 3 additions & 0 deletions RetailCoder.VBE/Common/WinAPI/User32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ public static class User32
[DllImport("user32.dll", SetLastError = true)]
internal static extern bool UnregisterDeviceNotification(IntPtr handle);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
internal static extern IntPtr SendMessage(IntPtr hWnd, WM msg, IntPtr wParam, IntPtr lParam);

/// <summary>
/// A helper function that returns <c>true</c> when the specified handle is that of the foreground window.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions RetailCoder.VBE/Common/WinAPI/WM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,11 @@ public enum WM : uint
/// </summary>
SYSTIMER = 0x118,

/// <summary>
/// Private message to signal focus set/lost for a DockableWindowHost. Set wParam to the DockableWindowHost hWnd, lParam to zero for lost focus, non-zero for gained focus.
/// </summary>
RUBBERDUCK_CHILD_FOCUS = USER + 0x0F00,

/// <summary>
/// The accessibility state has changed.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion RetailCoder.VBE/Inspections/InspectionResultBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public int CompareTo(object obj)
public object[] ToArray()
{
var module = QualifiedSelection.QualifiedName;
return new object[] { Inspection.Severity.ToString(), module.ProjectTitle, module.ComponentName, Description, QualifiedSelection.Selection.StartLine, QualifiedSelection.Selection.StartColumn };
return new object[] { Inspection.Severity.ToString(), module.ProjectName, module.ComponentName, Description, QualifiedSelection.Selection.StartLine, QualifiedSelection.Selection.StartColumn };
}

public string ToCsvString()
Expand Down
38 changes: 14 additions & 24 deletions RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
using Microsoft.Vbe.Interop;
using NLog;
using Rubberduck.Navigation.Folders;
Expand Down Expand Up @@ -87,17 +86,6 @@ public CodeExplorerItemViewModel SelectedItem
_selectedItem = value;
OnPropertyChanged();

if (_selectedItem is CodeExplorerProjectViewModel)
{
var vbe = _selectedItem.GetSelectedDeclaration().Project.VBE;
var project = vbe.VBProjects.Cast<VBProject>().FirstOrDefault(f => f.HelpFile == _selectedItem.GetSelectedDeclaration().Project.HelpFile);

if (project != null)
{
vbe.ActiveVBProject = project;
}
}

// ReSharper disable ExplicitCallerInfoArgument
OnPropertyChanged("CanExecuteIndenterCommand");
OnPropertyChanged("CanExecuteRenameCommand");
Expand Down Expand Up @@ -189,25 +177,27 @@ public string PanelTitle
return string.Empty;
}

if (SelectedItem is CodeExplorerProjectViewModel)
if (!(SelectedItem is ICodeExplorerDeclarationViewModel))
{
var node = (CodeExplorerProjectViewModel)SelectedItem;
return node.Declaration.IdentifierName + string.Format(" - ({0})", node.Declaration.DeclarationType);
return SelectedItem.Name;
}

if (SelectedItem is CodeExplorerComponentViewModel)
{
var node = (CodeExplorerComponentViewModel)SelectedItem;
return node.Declaration.IdentifierName + string.Format(" - ({0})", node.Declaration.DeclarationType);
}
var declaration = SelectedItem.GetSelectedDeclaration();

var nameWithDeclarationType = declaration.IdentifierName +
string.Format(" - ({0})", RubberduckUI.ResourceManager.GetString(
"DeclarationType_" + declaration.DeclarationType, UI.Settings.Settings.Culture));

if (SelectedItem is CodeExplorerMemberViewModel)
if (string.IsNullOrEmpty(declaration.AsTypeName))
{
var node = (CodeExplorerMemberViewModel)SelectedItem;
return node.Declaration.IdentifierName + string.Format(" - ({0})", node.Declaration.DeclarationType);
return nameWithDeclarationType;
}

return SelectedItem.Name;
var typeName = declaration.HasTypeHint
? Declaration.TypeHintToTypeName[declaration.TypeHint]
: declaration.AsTypeName;

return nameWithDeclarationType + ": " + typeName;
}
}

Expand Down
9 changes: 5 additions & 4 deletions RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@
CommandParameter="{Binding SelectedItem}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_OpenProjectProperties}"
Command="{Binding OpenProjectPropertiesCommand}" />
Command="{Binding OpenProjectPropertiesCommand}"
CommandParameter="{Binding SelectedItem}" />
<Separator />
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Add}">
<MenuItem Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_AddTestModuleText}"
Expand Down Expand Up @@ -740,8 +741,8 @@

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

<ScrollViewer Background="WhiteSmoke" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical" MinHeight="48" Background="WhiteSmoke">
<ScrollViewer Background="WhiteSmoke" VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Vertical" MinHeight="48" Background="WhiteSmoke">

<Grid Margin="4" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -776,7 +777,7 @@
CommandParameter="{Binding SelectedItem}"
Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_FindAllReferencesText}" />
</WrapPanel>
</StackPanel>
</WrapPanel>
</ScrollViewer>
</Border>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Runtime.InteropServices;
using Microsoft.Vbe.Interop;
using NLog;
using Rubberduck.Navigation.CodeExplorer;
using Rubberduck.UI.Command;

namespace Rubberduck.UI.CodeExplorer.Commands
Expand All @@ -13,10 +15,36 @@ public CodeExplorer_OpenProjectPropertiesCommand(VBE vbe) : base(LogManager.GetC
_vbe = vbe;
}

protected override bool CanExecuteImpl(object parameter)
{
return parameter != null || _vbe.VBProjects.Count == 1;
}

protected override void ExecuteImpl(object parameter)
{
const int openProjectPropertiesId = 2578;

if (_vbe.VBProjects.Count == 1)
{
_vbe.CommandBars.FindControl(Id: openProjectPropertiesId).Execute();
return;
}

var node = parameter as CodeExplorerItemViewModel;
while (!(node is ICodeExplorerDeclarationViewModel))
{
node = node.Parent; // the project node is an ICodeExplorerDeclarationViewModel--no worries here
}

try
{
_vbe.ActiveVBProject = node.GetSelectedDeclaration().Project;
}
catch (COMException)
{
return; // the project was probably removed from the VBE, but not from the CE
}

_vbe.CommandBars.FindControl(Id: openProjectPropertiesId).Execute();
}
}
Expand Down
13 changes: 11 additions & 2 deletions RetailCoder.VBE/UI/Command/AddTestMethodCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@ protected override bool CanExecuteImpl(object parameter)
d.DeclarationType == DeclarationType.ProceduralModule &&
d.Annotations.Any(a => a.AnnotationType == AnnotationType.TestModule));

// the code modules consistently match correctly, but the components don't
return testModules.Any(a => a.QualifiedName.QualifiedModuleName.Component.CodeModule == _vbe.SelectedVBComponent.CodeModule);
try
{
// the code modules consistently match correctly, but the components don't
return testModules.Any(a =>
a.QualifiedName.QualifiedModuleName.Component.CodeModule ==
_vbe.SelectedVBComponent.CodeModule);
}
catch (COMException)
{
return false;
}
}

protected override void ExecuteImpl(object parameter)
Expand Down
13 changes: 11 additions & 2 deletions RetailCoder.VBE/UI/Command/AddTestMethodExpectedErrorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@ protected override bool CanExecuteImpl(object parameter)
d.DeclarationType == DeclarationType.ProceduralModule &&
d.Annotations.Any(a => a.AnnotationType == AnnotationType.TestModule));

// the code modules consistently match correctly, but the components don't
return testModules.Any(a => a.QualifiedName.QualifiedModuleName.Component.CodeModule == _vbe.SelectedVBComponent.CodeModule);
try
{
// the code modules consistently match correctly, but the components don't
return testModules.Any(a =>
a.QualifiedName.QualifiedModuleName.Component.CodeModule ==
_vbe.SelectedVBComponent.CodeModule);
}
catch (COMException)
{
return false;
}
}

protected override void ExecuteImpl(object parameter)
Expand Down
2 changes: 1 addition & 1 deletion RetailCoder.VBE/UI/DockableToolwindowPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private Window CreateToolWindow(IDockableUserControl control)

toolWindow.Visible = false; //hide it again

userControlHost.AddUserControl(control as UserControl);
userControlHost.AddUserControl(control as UserControl, new IntPtr(_vbe.MainWindow.HWnd));
return toolWindow;
}

Expand Down
27 changes: 18 additions & 9 deletions RetailCoder.VBE/UI/DockableWindowHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Rubberduck.Common.WinAPI;
using Rubberduck.VBEditor;

namespace Rubberduck.UI
Expand Down Expand Up @@ -40,10 +41,10 @@ private struct Rect
private IntPtr _parentHandle;
private SubClassingWindow _subClassingWindow;

internal void AddUserControl(UserControl control)
internal void AddUserControl(UserControl control, IntPtr vbeHwnd)
{
_parentHandle = GetParent(Handle);
_subClassingWindow = new SubClassingWindow(_parentHandle);
_subClassingWindow = new SubClassingWindow(_parentHandle, vbeHwnd);
_subClassingWindow.CallBackEvent += OnCallBackEvent;

if (control != null)
Expand Down Expand Up @@ -116,27 +117,35 @@ public class SubClassingWindow : NativeWindow
public event SubClassingWindowEventHandler CallBackEvent;
public delegate void SubClassingWindowEventHandler(object sender, SubClassingWindowEventArgs e);

private readonly IntPtr _vbeHwnd;

private void OnCallBackEvent(SubClassingWindowEventArgs e)
{
Debug.Assert(CallBackEvent != null, "CallBackEvent != null");
CallBackEvent(this, e);
}

public SubClassingWindow(IntPtr handle)
public SubClassingWindow(IntPtr handle, IntPtr vbeHwnd)
{
_vbeHwnd = vbeHwnd;
AssignHandle(handle);
}

protected override void WndProc(ref Message msg)
{
const int wmSize = 0x5;

if (msg.Msg == wmSize)
switch ((uint)msg.Msg)
{
var args = new SubClassingWindowEventArgs(msg);
OnCallBackEvent(args);
case (uint)WM.SIZE:
var args = new SubClassingWindowEventArgs(msg);
OnCallBackEvent(args);
break;
case (uint)WM.SETFOCUS:
User32.SendMessage(_vbeHwnd, WM.RUBBERDUCK_CHILD_FOCUS, Handle, Handle);
break;
case (uint)WM.KILLFOCUS:
User32.SendMessage(_vbeHwnd, WM.RUBBERDUCK_CHILD_FOCUS, Handle, IntPtr.Zero);
break;
}

base.WndProc(ref msg);
}

Expand Down
2 changes: 1 addition & 1 deletion RetailCoder.VBE/UnitTesting/TestMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public NavigateCodeEventArgs GetNavigationArgs()

public object[] ToArray()
{
return new object[] { Declaration.QualifiedName.QualifiedModuleName.ProjectTitle, Declaration.QualifiedName.QualifiedModuleName.ComponentName, Declaration.IdentifierName,
return new object[] { Declaration.QualifiedName.QualifiedModuleName.ProjectName, Declaration.QualifiedName.QualifiedModuleName.ComponentName, Declaration.IdentifierName,
_result.Outcome.ToString(), _result.Output, _result.StartTime.ToString(CultureInfo.InvariantCulture), _result.EndTime.ToString(CultureInfo.InvariantCulture), _result.Duration };
}

Expand Down
Loading