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
8 changes: 5 additions & 3 deletions RetailCoder.VBE/Inspections/QuickFixes/IgnoreOnceQuickFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ namespace Rubberduck.Inspections.QuickFixes
public class IgnoreOnceQuickFix : QuickFixBase
{
private readonly string _annotationText;
private readonly string _inspectionName;

public IgnoreOnceQuickFix(ParserRuleContext context, QualifiedSelection selection, string inspectionName)
: base(context, selection, InspectionsUI.IgnoreOnce)
{
_inspectionName = inspectionName;
_annotationText = "'" + Annotations.AnnotationMarker +
Annotations.IgnoreInspection + ' ' + inspectionName;
}
Expand All @@ -39,7 +37,11 @@ public override void Fix()
int commentStart;
if (codeLine.HasComment(out commentStart) && codeLine.Substring(commentStart).StartsWith(ignoreAnnotation))
{
annotationText = codeLine + ", " + _inspectionName;
var indentation = codeLine.Length - codeLine.TrimStart().Length;
annotationText = string.Format("{0}{1},{2}",
new string(' ', indentation),
_annotationText,
codeLine.Substring(indentation + ignoreAnnotation.Length));
module.ReplaceLine(insertLine - 1, annotationText);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private string GetPropertyText()
(_model.ImplementSetSetterType ? setterText : string.Empty)).TrimEnd() + Environment.NewLine;

var propertyTextLines = propertyText.Split(new[] {Environment.NewLine}, StringSplitOptions.None);
return string.Join(Environment.NewLine, _indenter.Indent(propertyTextLines, "test"));
return string.Join(Environment.NewLine, _indenter.Indent(propertyTextLines, true));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ private void AddInterface()
{
interfaceComponent.Name = _model.InterfaceName;

interfaceModule.InsertLines(1, Tokens.Option + ' ' + Tokens.Explicit + Environment.NewLine);
var optionPresent = interfaceModule.CountOfLines > 1;
if (!optionPresent)
{
interfaceModule.InsertLines(1, Tokens.Option + ' ' + Tokens.Explicit + Environment.NewLine);
}
interfaceModule.InsertLines(3, GetInterfaceModuleBody());

var module = _model.TargetDeclaration.QualifiedSelection.QualifiedName.Component.CodeModule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void GeneratePreview(IExtractMethodModel extractMethodModel,IExtractMeth
*/
var extractedMethod = extractMethodProc.createProc(extractMethodModel);
var code = extractedMethod.Split(new[]{Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
code = _indenter.Indent(code, "Preview").ToArray();
code = _indenter.Indent(code).ToArray();
_view.Preview = string.Join(Environment.NewLine, code);
}
}
Expand Down
2 changes: 1 addition & 1 deletion RetailCoder.VBE/UI/Refactorings/EncapsulateFieldDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private string GetPropertyText()
(MustImplementSetSetterType ? setterText : string.Empty);

var propertyTextLines = propertyText.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
return string.Join(Environment.NewLine, _indenter.Indent(propertyTextLines, "test"));
return string.Join(Environment.NewLine, _indenter.Indent(propertyTextLines));
}

private void ValidatePropertyName()
Expand Down
20 changes: 19 additions & 1 deletion RetailCoder.VBE/UI/RubberduckUI.Designer.cs

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

6 changes: 6 additions & 0 deletions RetailCoder.VBE/UI/RubberduckUI.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1902,4 +1902,10 @@ End Sub</value>
<value>Smart Indenter settings were found in your registry.
Would you like to import them to Rubberduck?</value>
</data>
<data name="IndenterSettings_VerticalSpacing" xml:space="preserve">
<value>Maintain vertical spacing</value>
</data>
<data name="IndenterSettings_VerticalSpacingLabel" xml:space="preserve">
<value>Vertical Spacing</value>
</data>
</root>
17 changes: 17 additions & 0 deletions RetailCoder.VBE/UI/Settings/IndenterSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,23 @@
NumValue="{Binding IndentSpaces, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
MinNumber="0"/>
</StackPanel>
<Label Content="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=IndenterSettings_VerticalSpacingLabel}"
FontWeight="SemiBold" />
<WrapPanel Orientation="Horizontal">
<CheckBox Name="SpaceProcedures"
IsChecked="{Binding VerticallySpaceProcedures, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="5,0,0,5"
HorizontalAlignment="Left">
<AccessText Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=IndenterSettings_VerticalSpacing}"
TextWrapping="WrapWithOverflow" />
</CheckBox>
<controls:NumberPicker Margin="0,-6,0,0"
IsEnabled="{Binding ElementName=SpaceProcedures, Path=IsChecked}"
NumValue="{Binding LinesBetweenProcedures, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Left"
MinNumber="0"
MaxNumber="2"/>
</WrapPanel>
</StackPanel>
</Grid>
</StackPanel>
Expand Down
42 changes: 39 additions & 3 deletions RetailCoder.VBE/UI/Settings/IndenterSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public IndenterSettingsViewModel(Configuration config)
_indentFirstCommentBlock = config.UserSettings.IndenterSettings.IndentFirstCommentBlock;
_indentFirstDeclarationBlock = config.UserSettings.IndenterSettings.IndentFirstDeclarationBlock;
_indentSpaces = config.UserSettings.IndenterSettings.IndentSpaces;
_spaceProcedures = config.UserSettings.IndenterSettings.VerticallySpaceProcedures;
_procedureSpacing = config.UserSettings.IndenterSettings.LinesBetweenProcedures;

PropertyChanged += IndenterSettingsViewModel_PropertyChanged;
ExportButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ExportSettings());
Expand Down Expand Up @@ -269,14 +271,42 @@ public int IndentSpaces
}
}

private bool _spaceProcedures;
public bool VerticallySpaceProcedures
{
get { return _spaceProcedures; }
set
{
if (_spaceProcedures != value)
{
_spaceProcedures = value;
OnPropertyChanged();
}
}
}

private int _procedureSpacing;
public int LinesBetweenProcedures
{
get { return _procedureSpacing; }
set
{
if (_procedureSpacing != value)
{
_procedureSpacing = value;
OnPropertyChanged();
}
}
}

public string PreviewSampleCode
{
get
{
var indenter = new Indenter(null, GetCurrentSettings);

var lines = RubberduckUI.IndenterSettings_PreviewCode.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
lines = indenter.Indent(lines, "TestModule").ToArray();
lines = indenter.Indent(lines).ToArray();
return string.Join(Environment.NewLine, lines);
}
}
Expand All @@ -300,7 +330,9 @@ private IIndenterSettings GetCurrentSettings()
IndentEntireProcedureBody = IndentEntireProcedureBody,
IndentFirstCommentBlock = IndentFirstCommentBlock,
IndentFirstDeclarationBlock = IndentFirstDeclarationBlock,
IndentSpaces = IndentSpaces
IndentSpaces = IndentSpaces,
VerticallySpaceProcedures = VerticallySpaceProcedures,
LinesBetweenProcedures = LinesBetweenProcedures
};
}

Expand All @@ -324,6 +356,8 @@ public void UpdateConfig(Configuration config)
config.UserSettings.IndenterSettings.IndentFirstCommentBlock = IndentFirstCommentBlock;
config.UserSettings.IndenterSettings.IndentFirstDeclarationBlock = IndentFirstDeclarationBlock;
config.UserSettings.IndenterSettings.IndentSpaces = IndentSpaces;
config.UserSettings.IndenterSettings.VerticallySpaceProcedures = VerticallySpaceProcedures;
config.UserSettings.IndenterSettings.LinesBetweenProcedures = LinesBetweenProcedures;
}

public void SetToDefaults(Configuration config)
Expand All @@ -348,7 +382,9 @@ private void TransferSettingsToView(IIndenterSettings toLoad)
IndentEntireProcedureBody = toLoad.IndentEntireProcedureBody;
IndentFirstCommentBlock = toLoad.IndentFirstCommentBlock;
IndentFirstDeclarationBlock = toLoad.IndentFirstDeclarationBlock;
IndentSpaces = toLoad.IndentSpaces;
IndentSpaces = toLoad.IndentSpaces;
VerticallySpaceProcedures = toLoad.VerticallySpaceProcedures;
LinesBetweenProcedures = toLoad.LinesBetweenProcedures;
}

private void ImportSettings()
Expand Down
Loading