Skip to content

Commit d64428a

Browse files
committed
minor cleanups
1 parent 9629e82 commit d64428a

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

Rubberduck.SmartIndenter/IIndenter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public interface IIndenter
99
void IndentCurrentProcedure();
1010
void IndentCurrentModule();
1111
void Indent(VBProject project);
12-
void Indent(VBComponent module, bool reportProgress = true, int linesAlreadyRebuilt = 0);
13-
void Indent(VBComponent module, string procedureName, Selection selection, bool reportProgress = true, int linesAlreadyRebuilt = 0);
12+
void Indent(VBComponent component, bool reportProgress = true, int linesAlreadyRebuilt = 0);
13+
void Indent(VBComponent component, string procedureName, Selection selection, bool reportProgress = true, int linesAlreadyRebuilt = 0);
1414
void Indent(string[] lines, string moduleName, bool reportProgress = true, int linesAlreadyRebuilt = 0);
1515
}
1616
}

Rubberduck.SmartIndenter/Indenter.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public Indenter(VBE vbe, Func<IIndenterSettings> settings)
2626
{
2727
foreach (var token in ProcedureLevelTypeTokens)
2828
{
29-
_inProcedure.Add(string.Join(" ", (new [] {scope, modifier, token}).Where(x => !string.IsNullOrEmpty(x))));
29+
_inProcedure.Add(string.Join(" ", new [] {scope, modifier, token}.Where(x => !string.IsNullOrEmpty(x))));
3030
}
3131
}
3232
}
@@ -48,21 +48,22 @@ private void OnReportProgress(string moduleName, int progress, int max)
4848
public void IndentCurrentProcedure()
4949
{
5050
var pane = _vbe.ActiveCodePane;
51+
var module = pane.CodeModule;
5152
var selection = GetSelection(pane);
5253

5354
vbext_ProcKind procKind;
54-
var procName = pane.CodeModule.get_ProcOfLine(selection.StartLine, out procKind);
55+
var procName = module.ProcOfLine[selection.StartLine, out procKind];
5556

5657
if (string.IsNullOrEmpty(procName))
5758
{
5859
return;
5960
}
6061

61-
var startLine = pane.CodeModule.get_ProcStartLine(procName, procKind);
62-
var endLine = startLine + pane.CodeModule.get_ProcCountLines(procName, procKind);
62+
var startLine = module.ProcStartLine[procName, procKind];
63+
var endLine = startLine + module.ProcCountLines[procName, procKind];
6364

6465
selection = new Selection(startLine, 1, endLine, 1);
65-
Indent(pane.CodeModule.Parent, procName, selection);
66+
Indent(module.Parent, procName, selection);
6667
}
6768

6869
public void IndentCurrentModule()
@@ -107,7 +108,7 @@ private static bool HasCode(CodeModule module, ref int lineCount)
107108
lineCount += module.CountOfLines;
108109
for (var i = 0; i < module.CountOfLines; i++)
109110
{
110-
if (!string.IsNullOrWhiteSpace(module.get_Lines(i, 1)))
111+
if (!string.IsNullOrWhiteSpace(module.Lines[i, 1]))
111112
{
112113
return true;
113114
}
@@ -119,7 +120,7 @@ private static bool HasCode(CodeModule module)
119120
{
120121
for (var i = 0; i < module.CountOfLines; i++)
121122
{
122-
if (!string.IsNullOrWhiteSpace(module.get_Lines(i, 1)))
123+
if (!string.IsNullOrWhiteSpace(module.Lines[i, 1]))
123124
{
124125
return true;
125126
}
@@ -138,42 +139,44 @@ private static Selection GetSelection(CodePane codePane)
138139
return new Selection(startLine, startColumn, endLine, endColumn);
139140
}
140141

141-
public void Indent(VBComponent module, bool reportProgress = true, int linesAlreadyRebuilt = 0)
142+
public void Indent(VBComponent component, bool reportProgress = true, int linesAlreadyRebuilt = 0)
142143
{
143-
var lineCount = module.CodeModule.CountOfLines;
144+
var module = component.CodeModule;
145+
var lineCount = module.CountOfLines;
144146
if (lineCount == 0)
145147
{
146148
return;
147149
}
148150

149-
var codeLines = module.CodeModule.get_Lines(1, lineCount).Replace("\r", string.Empty).Split('\n');
150-
Indent(codeLines, module.Name, reportProgress, linesAlreadyRebuilt);
151+
var codeLines = module.Lines[1, lineCount].Replace("\r", string.Empty).Split('\n');
152+
Indent(codeLines, component.Name, reportProgress, linesAlreadyRebuilt);
151153

152154
for (var i = 0; i < lineCount; i++)
153155
{
154-
if (module.CodeModule.get_Lines(i + 1, 1) != codeLines[i])
156+
if (module.Lines[i + 1, 1] != codeLines[i])
155157
{
156-
module.CodeModule.ReplaceLine(i + 1, codeLines[i]);
158+
component.CodeModule.ReplaceLine(i + 1, codeLines[i]);
157159
}
158160
}
159161
}
160162

161-
public void Indent(VBComponent module, string procedureName, Selection selection, bool reportProgress = true, int linesAlreadyRebuilt = 0)
163+
public void Indent(VBComponent component, string procedureName, Selection selection, bool reportProgress = true, int linesAlreadyRebuilt = 0)
162164
{
163-
var lineCount = module.CodeModule.CountOfLines;
165+
var module = component.CodeModule;
166+
var lineCount = module.CountOfLines;
164167
if (lineCount == 0)
165168
{
166169
return;
167170
}
168171

169-
var codeLines = module.CodeModule.get_Lines(selection.StartLine, selection.LineCount).Replace("\r", string.Empty).Split('\n');
172+
var codeLines = module.Lines[selection.StartLine, selection.LineCount].Replace("\r", string.Empty).Split('\n');
170173
Indent(codeLines, procedureName, reportProgress, linesAlreadyRebuilt);
171174

172175
for (var i = 0; i < selection.EndLine - selection.StartLine; i++)
173176
{
174-
if (module.CodeModule.get_Lines(selection.StartLine + i, 1) != codeLines[i])
177+
if (module.Lines[selection.StartLine + i, 1] != codeLines[i])
175178
{
176-
module.CodeModule.ReplaceLine(selection.StartLine + i, codeLines[i]);
179+
component.CodeModule.ReplaceLine(selection.StartLine + i, codeLines[i]);
177180
}
178181
}
179182
}

0 commit comments

Comments
 (0)