Skip to content

Commit 21d6add

Browse files
committed
Merge pull request #649 from Hosch250/next
Misc. Fixes in prep for 1.4
2 parents f416117 + faec03a commit 21d6add

File tree

9 files changed

+102
-41
lines changed

9 files changed

+102
-41
lines changed

RetailCoder.VBE/Inspections/VariableTypeNotDeclaredInspectionResult.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ public override IDictionary<string, Action> GetQuickFixes()
2626
private void DeclareAsExplicitVariant()
2727
{
2828
var codeModule = QualifiedSelection.QualifiedName.Component.CodeModule;
29-
var codeLine = codeModule.get_Lines(QualifiedSelection.Selection.StartLine, QualifiedSelection.Selection.LineCount);
29+
var codeLine = codeModule.Lines[QualifiedSelection.Selection.StartLine, QualifiedSelection.Selection.LineCount];
3030

3131
// methods return empty string if soft-cast context is null - just concat results:
3232
string originalInstruction;
33-
var fix = DeclareExplicitVariant(Context as VBAParser.VariableSubStmtContext, out originalInstruction);
33+
var fix = DeclareExplicitVariant(Context.Parent as VBAParser.VariableSubStmtContext, out originalInstruction);
3434

3535
if (string.IsNullOrEmpty(originalInstruction))
3636
{
37-
fix = DeclareExplicitVariant(Context as VBAParser.ConstSubStmtContext, out originalInstruction);
37+
fix = DeclareExplicitVariant(Context.Parent as VBAParser.ConstSubStmtContext, out originalInstruction);
3838
}
3939

4040
if (string.IsNullOrEmpty(originalInstruction))
4141
{
42-
fix = DeclareExplicitVariant(Context as VBAParser.ArgContext, out originalInstruction);
42+
fix = DeclareExplicitVariant(Context.Parent as VBAParser.ArgContext, out originalInstruction);
4343
}
4444

4545
var fixedCodeLine = codeLine.Replace(originalInstruction, fix);

RetailCoder.VBE/Settings/ConfigurationLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected override Configuration HandleIOException(IOException ex)
7070
protected override Configuration HandleInvalidOperationException(InvalidOperationException ex)
7171
{
7272
var message = string.Format(RubberduckUI.PromptLoadDefaultConfig, ex.Message, ex.InnerException.Message, ConfigFile);
73-
var result = MessageBox.Show(message, RubberduckUI.LoadConfigError, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
73+
var result = MessageBox.Show(message, RubberduckUI.LoadConfigError, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
7474

7575
if (result == DialogResult.Yes)
7676
{

RetailCoder.VBE/UI/CodeInspections/CodeInspectionsWindow.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ public void SetIssuesStatus(int issueCount, bool completed = false)
8989
{
9090
_issueCount = issueCount;
9191

92-
RefreshButton.Image = completed
92+
RefreshButton.Enabled = completed; // remove this when uncommenting below lines
93+
94+
/*RefreshButton.Image = completed
9395
? Resources.arrow_circle_double
9496
: Resources.cross_circle;
9597
@@ -102,7 +104,7 @@ public void SetIssuesStatus(int issueCount, bool completed = false)
102104
{
103105
RefreshButton.Click -= CancelButton_Click;
104106
RefreshButton.Click += RefreshButtonClicked;
105-
}
107+
}*/
106108

107109

108110
if (issueCount == 0)

RetailCoder.VBE/UI/ToDoItems/IToDoExplorerWindow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public interface IToDoExplorerWindow : IDockableUserControl
1010
DataGridView GridView { get; }
1111
event EventHandler<ToDoItemClickEventArgs> NavigateToDoItem;
1212
event EventHandler RefreshToDoItems;
13+
event EventHandler RemoveToDoMarker;
1314
event EventHandler<DataGridViewCellMouseEventArgs> SortColumn;
1415
IEnumerable<ToDoItem> TodoItems { get; set; }
1516
}

RetailCoder.VBE/UI/ToDoItems/ToDoExplorerDockablePresenter.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
4+
using System.ComponentModel;
45
using System.Linq;
56
using System.Threading.Tasks;
67
using System.Windows.Forms;
@@ -33,6 +34,7 @@ public ToDoExplorerDockablePresenter(IRubberduckParser parser, IEnumerable<ToDoM
3334
_view = window;
3435
_view.NavigateToDoItem += NavigateToDoItem;
3536
_view.RefreshToDoItems += RefreshToDoList;
37+
_view.RemoveToDoMarker += RemoveMarker;
3638
_view.SortColumn += SortColumn;
3739
}
3840

@@ -60,6 +62,23 @@ private void RefreshToDoList(object sender, EventArgs e)
6062
Refresh();
6163
}
6264

65+
private void RemoveMarker(object sender, EventArgs e)
66+
{
67+
var selectedIndex = _view.GridView.SelectedRows[0].Index;
68+
var dataSource = ((BindingList<ToDoItem>)_view.GridView.DataSource).ToList();
69+
var selectedItem = dataSource[selectedIndex];
70+
71+
var module = selectedItem.GetSelection().QualifiedName.Component.CodeModule;
72+
73+
var oldContent = module.Lines[selectedItem.LineNumber, 1];
74+
var newContent =
75+
oldContent.Remove(selectedItem.GetSelection().Selection.StartColumn - 1);
76+
77+
module.ReplaceLine(selectedItem.LineNumber, newContent);
78+
79+
Refresh();
80+
}
81+
6382
private void SortColumn(object sender, DataGridViewCellMouseEventArgs e)
6483
{
6584
var columnName = _view.GridView.Columns[e.ColumnIndex].Name;
@@ -84,12 +103,12 @@ private async Task<IOrderedEnumerable<ToDoItem>> GetItems()
84103
items.Add(marker);
85104
}
86105
}
87-
};
106+
}
88107

89-
var sortedItems = items.OrderBy(item => item.ProjectName)
90-
.ThenBy(item => item.ModuleName)
91-
.ThenByDescending(item => item.Priority)
92-
.ThenBy(item => item.LineNumber);
108+
var sortedItems = items.OrderByDescending(item => item.Priority)
109+
.ThenBy(item => item.ProjectName)
110+
.ThenBy(item => item.ModuleName)
111+
.ThenBy(item => item.LineNumber);
93112

94113
return sortedItems;
95114
}
@@ -115,8 +134,11 @@ private void NavigateToDoItem(object sender, ToDoItemClickEventArgs e)
115134
return;
116135
}
117136

118-
var component = projects.FirstOrDefault().VBComponents.Cast<VBComponent>()
119-
.First(c => c.Name == e.SelectedItem.ModuleName);
137+
var firstOrDefault = projects.FirstOrDefault();
138+
if (firstOrDefault == null) { return; }
139+
140+
var component = firstOrDefault.VBComponents.Cast<VBComponent>()
141+
.First(c => c.Name == e.SelectedItem.ModuleName);
120142

121143
if (component == null)
122144
{

RetailCoder.VBE/UI/ToDoItems/ToDoExplorerWindow.Designer.cs

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

RetailCoder.VBE/UI/ToDoItems/ToDoExplorerWindow.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ private void RefreshButtonClicked(object sender, EventArgs e)
8787
}
8888
}
8989

90+
public event EventHandler RemoveToDoMarker;
91+
private void RemoveButtonClicked(object sender, EventArgs e)
92+
{
93+
var handler = RemoveToDoMarker;
94+
if (handler != null)
95+
{
96+
handler(this, EventArgs.Empty);
97+
}
98+
}
99+
90100
public event EventHandler<DataGridViewCellMouseEventArgs> SortColumn;
91101
private void ColumnHeaderMouseClicked(object sender, DataGridViewCellMouseEventArgs e)
92102
{

RetailCoder.VBE/UI/ToDoItems/ToDoExplorerWindow.resx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,20 @@
124124
<data name="refreshButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
125125
<value>
126126
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
127-
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALgSURBVDhPY6AKsJ/3cqbd3Bdn0DFI3H7+cwW7ea9UbWe8
128-
ktRadYUNqgUV2Mx+FmM74/GZKQ/+/++9+Q+MJ975/x8k1nvrn33N6R8hcdvf+TnOe+5kO+OBJFQbKrCc
129-
9qDFctrDM303/vxvOvPzf9fVP/9B/PbLvx1az//Kbj37K7fn+p9c53lP4m2mPVSCaoMAw8nXpSw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X9GzeAmqrKWaM24gKMmoMqOUNnwCimlDSE8
130+
KxtZ4V57M5989ul04nHtRBxHbfenamthV9iL2BWjsPzDEiqEC0j+fgnhc7Hld6x0YDFL2r8oLh1aEvO0
131+
Y2nRFaOhVG2Vg/eGAthKW5e034UKXjqR3LKAsI8qH4ZMpY2VWE3kS3qdyus9vxSyd3MKtupjfuTdTzSq
132+
DkCkbFCUYhgjrpi/oRu9MyiyZBDKLS7yiffMEivzgMwiy+ucasozT7Wk6gnd/mILnyxjGLegXmRyzF5u
133+
daB4jdUWcbtfxSjsh1hUBEQUvk2I14x0uDNWkWliwJ0ppVYAhBW8htltDiRqGUfY41m4pEcQfrW3kgxQ
134+
hEpedV+oJ2ay24gZ7KkxAEE5nd0Z7kW6W9hTY5LAHHNlUI5ZgH1wbidMb/yCLrZMIOzJAMY/y1SapLcP
135+
8A2ElSnt6/DLNCVQK7yDpDJNqqg7fbZEA4GSqodn/S616qkIAL5CI58ph7pjBkcLT/+5iS5skNHP1TPx
136+
jp5hhILnPxB+nngyhdwZxCyDxDZhg4gsY3zSjDRfYV0+r82pYNR+Vxw2jCuDJV35Pmk1rK0CPWQ3OxHv
137+
2U+0xzCNsKel13f5ntcFUPVVvM5Uh9KEtWmsDpc40DgrDmp0Ze1tdsV6p1ZBhmke0evm0KH2eYTPm1Oq
138+
iqjaOjgF/l6nq+J23OxJ3PmISA5pX+R6Jt2H+8zLaFfbEinWi2WEZ54nNeSH/ZstboUAbx8WCGTHgIhT
139+
vI27ebEeR3N1G/hquF4eR3Ifu/PBZJMC3zT8e+LLgt/vX8KZ7QAA2h8x9n74W7p/MgAAAABJRU5ErkJg
140+
gg==
141141
</value>
142142
</data>
143143
</root>

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private IEnumerable<CommentNode> ParseComments(QualifiedModuleName qualifiedName
199199
if (!continuing)
200200
{
201201
commentBuilder.Append(line.Substring(index, commentLength).TrimStart());
202-
var selection = new Selection(startLine + 1, startColumn + 1, i + 1, line.Length);
202+
var selection = new Selection(startLine + 1, startColumn + 1, i + 1, line.Length + 1);
203203

204204
var result = new CommentNode(commentBuilder.ToString(), new QualifiedSelection(qualifiedName, selection));
205205
commentBuilder.Clear();

0 commit comments

Comments
 (0)