Browse Source

Merge branch 'csformatter'

pull/478/head
Andreas Weizel 11 years ago
parent
commit
b4eb6bee0e
  1. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionBinding.cs
  2. 3
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpInsightItem.cs
  3. 44
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsContainer.cs
  4. 10
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsPersistence.cs
  5. 116
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs
  6. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormsDesigner/CSharpDesignerGenerator.cs
  7. 29
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingEditor.xaml
  8. 31
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingEditor.xaml.cs
  9. 12
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml
  10. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml.cs
  11. 5
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/InsertCtorDialog.xaml.cs
  12. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/MoveTypeToFileContextAction.cs
  13. 7
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpCompletionBinding.cs

@ -31,6 +31,7 @@ using ICSharpCode.NRefactory.TypeSystem; @@ -31,6 +31,7 @@ using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using CSharpBinding.FormattingStrategy;
namespace CSharpBinding.Completion
{
@ -98,7 +99,8 @@ namespace CSharpBinding.Completion @@ -98,7 +99,8 @@ namespace CSharpBinding.Completion
completionContext.ProjectContent,
completionContext.TypeResolveContextAtCaret
);
cce.FormattingPolicy = FormattingOptionsFactory.CreateSharpDevelop();
var formattingOptions = CSharpFormattingOptionsPersistence.GetProjectOptions(completionContext.Compilation.GetProject());
cce.FormattingPolicy = formattingOptions.OptionsContainer.GetEffectiveOptions();
cce.EolMarker = DocumentUtilities.GetLineTerminator(completionContext.Document, currentLocation.Line);
cce.IndentString = editor.Options.IndentationString;

3
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Completion/CSharpInsightItem.cs

@ -28,6 +28,7 @@ using ICSharpCode.NRefactory.TypeSystem; @@ -28,6 +28,7 @@ using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.Xml;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using CSharpBinding.FormattingStrategy;
namespace CSharpBinding.Completion
{
@ -71,7 +72,7 @@ namespace CSharpBinding.Completion @@ -71,7 +72,7 @@ namespace CSharpBinding.Completion
ambience.ConversionFlags = ConversionFlags.StandardConversionFlags;
var stringBuilder = new StringBuilder();
var formatter = new ParameterHighlightingOutputFormatter(stringBuilder, highlightedParameterIndex);
ambience.ConvertSymbol(Method, formatter, FormattingOptionsFactory.CreateSharpDevelop());
ambience.ConvertSymbol(Method, formatter, CSharpFormattingOptionsPersistence.GlobalOptions.OptionsContainer.GetEffectiveOptions());
var documentation = XmlDocumentationElement.Get(Method);
ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList;

44
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsContainer.cs

@ -34,13 +34,10 @@ namespace CSharpBinding.FormattingStrategy @@ -34,13 +34,10 @@ namespace CSharpBinding.FormattingStrategy
/// </summary>
internal class CSharpFormattingOptionsContainer : INotifyPropertyChanged
{
private const string AutoFormattingOptionName = "AutoFormatting";
CSharpFormattingOptionsContainer parent;
CSharpFormattingOptions cachedOptions;
readonly HashSet<string> activeOptions;
bool? autoFormatting;
public CSharpFormattingOptionsContainer(CSharpFormattingOptionsContainer parent = null)
: this(parent, new HashSet<string>())
@ -71,34 +68,6 @@ namespace CSharpBinding.FormattingStrategy @@ -71,34 +68,6 @@ namespace CSharpBinding.FormattingStrategy
}
}
public bool? AutoFormatting
{
get {
return autoFormatting;
}
set {
autoFormatting = value;
OnPropertyChanged("AutoFormatting");
}
}
public bool EffectiveAutoFormatting
{
get {
// Get "effective" option, i.e. walk up all parents to find a defined value
CSharpFormattingOptionsContainer container = this;
do
{
if (container.autoFormatting.HasValue) {
return container.autoFormatting.Value;
}
container = container.parent;
} while (container != null);
return true;
}
}
/// <summary>
/// Resets all container's options to given <see cref="ICSharpCode.NRefactory.CSharp.CSharpFormattingOptions"/> instance.
/// </summary>
@ -112,7 +81,6 @@ namespace CSharpBinding.FormattingStrategy @@ -112,7 +81,6 @@ namespace CSharpBinding.FormattingStrategy
foreach (var property in typeof(CSharpFormattingOptions).GetProperties()) {
activeOptions.Add(property.Name);
}
autoFormatting = true;
}
OnPropertyChanged(null);
}
@ -138,7 +106,6 @@ namespace CSharpBinding.FormattingStrategy @@ -138,7 +106,6 @@ namespace CSharpBinding.FormattingStrategy
foreach (var activeOption in options.activeOptions)
activeOptions.Add(activeOption);
cachedOptions = options.cachedOptions.Clone();
autoFormatting = options.autoFormatting;
OnPropertyChanged(null);
}
@ -308,11 +275,6 @@ namespace CSharpBinding.FormattingStrategy @@ -308,11 +275,6 @@ namespace CSharpBinding.FormattingStrategy
// Silently ignore loading error, then this property will be "as parent" automatically
}
}
if (formatProperties.Contains(AutoFormattingOptionName)) {
autoFormatting = formatProperties.Get(AutoFormattingOptionName, true);
} else {
autoFormatting = null;
}
}
}
@ -329,12 +291,6 @@ namespace CSharpBinding.FormattingStrategy @@ -329,12 +291,6 @@ namespace CSharpBinding.FormattingStrategy
formatProperties.Set(activeOption, val);
}
}
if (formatProperties.Contains(AutoFormattingOptionName) && !autoFormatting.HasValue) {
// AutoFormatting options was activated previously, remove it now
formatProperties.Remove(AutoFormattingOptionName);
} else {
formatProperties.Set(AutoFormattingOptionName, autoFormatting);
}
parentProperties.SetNestedProperties("CSharpFormatting", formatProperties);
}

10
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsPersistence.cs

@ -71,6 +71,16 @@ namespace CSharpBinding.FormattingStrategy @@ -71,6 +71,16 @@ namespace CSharpBinding.FormattingStrategy
}
}
public static bool AutoFormatting
{
get {
return SD.PropertyService.Get("CSharpBinding.Formatting.AutoFormatting", true);
}
set {
SD.PropertyService.Set("CSharpBinding.Formatting.AutoFormatting", value);
}
}
public static CSharpFormattingOptionsPersistence GlobalOptions
{
get;

116
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs

@ -155,7 +155,7 @@ namespace CSharpBinding.FormattingStrategy @@ -155,7 +155,7 @@ namespace CSharpBinding.FormattingStrategy
if ((inString && !verbatim) || inChar)
++i; // skip next character
break;
}
}
}
return curlyCounter > 0;
}
@ -269,16 +269,43 @@ namespace CSharpBinding.FormattingStrategy @@ -269,16 +269,43 @@ namespace CSharpBinding.FormattingStrategy
public override void FormatLines(ITextEditor textArea)
{
// Format current selection or whole document
int formattedTextOffset = 0;
int formattedTextLength = textArea.Document.TextLength;
if (textArea.SelectionLength != 0) {
formattedTextOffset = textArea.SelectionStart;
formattedTextLength = textArea.SelectionLength;
}
FormatCode(textArea, formattedTextOffset, formattedTextLength, false);
}
/// <summary>
/// Formats a code section according to currently effective formatting settings.
/// </summary>
/// <param name="textArea">Text editor instance to format code in.</param>
/// <param name="offset">Start offset of formatted code.</param>
/// <param name="length">Length of formatted code.</param>
/// <param name="respectAutoFormattingSetting">
/// Set to <c>true</c> to perform formatting only if auto-formatting setting is active.
/// If <c>false</c>, formatting will be performed in any case.
/// </param>
/// <returns><c>True</c>, if code has been formatted, <c>false</c> if auto-formatting is currently forbidden.</returns>
private bool FormatCode(ITextEditor textArea, int offset, int length, bool respectAutoFormattingSetting)
{
if ((offset > textArea.Document.TextLength) || ((offset + length) > textArea.Document.TextLength))
return false;
if (respectAutoFormattingSetting && !CSharpFormattingOptionsPersistence.AutoFormatting)
return false;
using (textArea.Document.OpenUndoGroup()) {
// In any other case: Simply format selection or whole document
var formattingOptions = CSharpFormattingOptionsPersistence.GetProjectOptions(SD.ProjectService.CurrentProject);
int formattedTextOffset = 0;
int formattedTextLength = textArea.Document.TextLength;
if (textArea.SelectionLength != 0) {
formattedTextOffset = textArea.SelectionStart;
formattedTextLength = textArea.SelectionLength;
try {
CSharpFormatterHelper.Format(textArea, offset, length, formattingOptions.OptionsContainer);
} catch (Exception) {
// Exceptions in formatting might happen if code contains syntax errors, we have to catch them
return false;
}
CSharpFormatterHelper.Format(textArea, formattedTextOffset, formattedTextLength, formattingOptions.OptionsContainer);
return true;
}
}
@ -289,6 +316,24 @@ namespace CSharpBinding.FormattingStrategy @@ -289,6 +316,24 @@ namespace CSharpBinding.FormattingStrategy
}
}
bool FormatStatement(ITextEditor textArea, int cursorOffset, int formattingStartOffset)
{
var line = textArea.Document.GetLineByOffset(formattingStartOffset);
int lineOffset = line.Offset;
// Walk up the lines until we arrive at previous statement, block, comment or preprocessor directive
while (line.PreviousLine != null) {
line = line.PreviousLine;
string lineText = textArea.Document.GetText(line.Offset, line.Length);
if (IsLineEndOfStatement(lineText)) {
// Previous line is another statement, don't format it
break;
}
lineOffset = line.Offset;
}
return FormatCode(textArea, lineOffset, cursorOffset - lineOffset, true);
}
void FormatLineInternal(ITextEditor textArea, int lineNr, int cursorOffset, char ch)
{
IDocumentLine curLine = textArea.Document.GetLineByNumber(lineNr);
@ -375,12 +420,29 @@ namespace CSharpBinding.FormattingStrategy @@ -375,12 +420,29 @@ namespace CSharpBinding.FormattingStrategy
case ':':
case ')':
case ']':
case '}':
case '{':
//if (textArea.Document.TextEditorProperties.IndentStyle == IndentStyle.Smart) {
IndentLine(textArea, curLine);
//}
break;
case '}':
// Try to get corresponding block beginning brace
var bracketSearchResult = textArea.Language.BracketSearcher.SearchBracket(textArea.Document, cursorOffset);
if (bracketSearchResult != null) {
// Format the block
if (!FormatStatement(textArea, cursorOffset, bracketSearchResult.OpeningBracketOffset)) {
// No auto-formatting seems to be active, at least indent the line
IndentLine(textArea, curLine);
}
}
break;
case ';':
// Format this line
if (!FormatStatement(textArea, cursorOffset, cursorOffset)) {
// No auto-formatting seems to be active, at least indent the line
IndentLine(textArea, curLine);
}
break;
case '\n':
string lineAboveText = lineAbove == null ? "" : textArea.Document.GetText(lineAbove);
// curLine might have some text which should be added to indentation
@ -445,7 +507,41 @@ namespace CSharpBinding.FormattingStrategy @@ -445,7 +507,41 @@ namespace CSharpBinding.FormattingStrategy
}
}
return;
}
}
bool IsLineEndOfStatement(string lineText)
{
string normalizedLine = null;
// Look if there is a comment at the end of line
int indexOfSingleLineComment = lineText.LastIndexOf("//");
if (indexOfSingleLineComment > -1) {
normalizedLine = lineText.Substring(0, indexOfSingleLineComment);
} else {
normalizedLine = lineText;
}
normalizedLine = normalizedLine.Trim(' ', '\t');
if (normalizedLine.EndsWith("*/")) {
int indexOfMultiLineCommentStart = normalizedLine.LastIndexOf("/*");
if (indexOfMultiLineCommentStart > -1) {
normalizedLine = normalizedLine.Substring(0, indexOfMultiLineCommentStart);
} else {
// Seems to be a multiline comment (no comment start on this line)
return true;
}
}
// Usual statement endings
if (normalizedLine.StartsWith("#")
|| normalizedLine.EndsWith(";")
|| normalizedLine.EndsWith("{")
|| normalizedLine.EndsWith("}"))
return true;
return false;
}
/// <summary>
@ -554,7 +650,7 @@ namespace CSharpBinding.FormattingStrategy @@ -554,7 +650,7 @@ namespace CSharpBinding.FormattingStrategy
if ((inString && !verbatim) || inChar)
++i; // skip next character
break;
}
}
}
return (inString || inChar) ? 2 : 0;
}

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormsDesigner/CSharpDesignerGenerator.cs

@ -35,6 +35,7 @@ using ICSharpCode.SharpDevelop; @@ -35,6 +35,7 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
using Microsoft.CSharp;
using CSharpBinding.FormattingStrategy;
using CSharpBinding.Parser;
using CSharpBinding.Refactoring;
@ -154,7 +155,8 @@ namespace CSharpBinding.FormsDesigner @@ -154,7 +155,8 @@ namespace CSharpBinding.FormsDesigner
IDocument document = context.GetDocument(fileNameObj);
var ctx = SDRefactoringContext.Create(fileNameObj, document);
script = new DocumentScript(document, FormattingOptionsFactory.CreateSharpDevelop(), new TextEditorOptions());
var formattingOptions = CSharpFormattingOptionsPersistence.GetProjectOptions(compilation.GetProject());
script = new DocumentScript(document, formattingOptions.OptionsContainer.GetEffectiveOptions(), new TextEditorOptions());
scripts.Add(fileNameObj, script);
return script;
}

29
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingEditor.xaml

@ -297,24 +297,17 @@ @@ -297,24 +297,17 @@
</UserControl.Resources>
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Vertical">
<CheckBox
Name="autoFormattingCheckBox"
Content="{core:Localize CSharpBinding.Formatting.AutoFormat}"
IsThreeState="True" IsChecked="{Binding AutoFormatting}"
Margin="0,0,0,10"
Visibility="Collapsed"/>
<Grid
Visibility="{Binding Path=AllowPresets, Converter={StaticResource boolToVisibilityConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="{core:Localize CSharpBinding.Formatting.ResetTo}" Click="ResetButton_Click" />
<ComboBox Name="presetComboBox" Grid.Column="1" Margin="3,0,0,0" ItemsSource="{Binding Presets}" />
</Grid>
</StackPanel>
<Grid
Visibility="{Binding Path=AllowPresets, Converter={StaticResource boolToVisibilityConverter}}"
DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="{core:Localize CSharpBinding.Formatting.ResetTo}" Click="ResetButton_Click" />
<ComboBox Name="presetComboBox" Grid.Column="1" Margin="3,0,0,0" ItemsSource="{Binding Presets}" />
</Grid>
<sd:RestrictDesiredSize Margin="0,4,0,0">
<ScrollViewer VerticalScrollBarVisibility="Auto">

31
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingEditor.xaml.cs

@ -133,48 +133,17 @@ namespace CSharpBinding.OptionPanels @@ -133,48 +133,17 @@ namespace CSharpBinding.OptionPanels
set { SetValue(AllowPresetsProperty, value); }
}
public static readonly DependencyProperty AutoFormattingProperty =
DependencyProperty.Register("AutoFormatting", typeof(bool?), typeof(CSharpFormattingEditor),
new FrameworkPropertyMetadata());
public bool? AutoFormatting {
get { return (bool?)GetValue(AutoFormattingProperty); }
set { SetValue(AutoFormattingProperty, value); }
}
static void OnOptionsContainerPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
var editor = o as CSharpFormattingEditor;
if (editor != null) {
var newContainer = e.NewValue as CSharpFormattingOptionsContainer;
if (newContainer != null) {
newContainer.PropertyChanged += (sender, eventArgs) =>
{
if (eventArgs.PropertyName == "AutoFormatting") {
// Update AutoFormatting special option
if (editor.AutoFormatting != newContainer.AutoFormatting)
editor.AutoFormatting = newContainer.AutoFormatting;
}
};
editor.autoFormattingCheckBox.IsThreeState = (newContainer.Parent != null);
editor.AutoFormatting = newContainer.AutoFormatting;
editor.FillPresetList(newContainer);
}
}
}
static void OnAutoFormattingPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
var editor = o as CSharpFormattingEditor;
if (editor != null) {
var container = editor.OptionsContainer;
if (container != null) {
if (container.AutoFormatting != (bool?) e.NewValue)
container.AutoFormatting = (bool?) e.NewValue;
}
}
}
private void FillPresetList(CSharpFormattingOptionsContainer container)
{
presets["(default)"] = () => null;

12
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml

@ -7,10 +7,20 @@ @@ -7,10 +7,20 @@
xmlns:core="http://icsharpcode.net/sharpdevelop/core"
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"
xmlns:project="clr-namespace:ICSharpCode.SharpDevelop.Project;assembly=ICSharpCode.SharpDevelop"
xmlns:fstrategy="clr-namespace:CSharpBinding.FormattingStrategy"
xmlns:local="clr-namespace:CSharpBinding.OptionPanels"
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets">
<Grid>
<local:CSharpFormattingEditor x:Name="formattingEditor" Margin="0,0,0,0" />
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<CheckBox
Name="autoFormattingCheckBox"
Content="{core:Localize CSharpBinding.Formatting.AutoFormat}"
IsChecked="{sd:OptionBinding fstrategy:CSharpFormattingOptionsPersistence.AutoFormatting}"
Margin="0,0,0,10" />
<local:CSharpFormattingEditor x:Name="formattingEditor" Grid.Row="1" Margin="0,0,0,0" />
</Grid>
</gui:OptionPanel>

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml.cs

@ -42,6 +42,7 @@ namespace CSharpBinding.OptionPanels @@ -42,6 +42,7 @@ namespace CSharpBinding.OptionPanels
public CSharpGlobalFormattingOptionPanel()
: base(CSharpFormattingOptionsPersistence.GlobalOptions, true)
{
autoFormattingCheckBox.Visibility = Visibility.Visible;
}
}
@ -53,6 +54,7 @@ namespace CSharpBinding.OptionPanels @@ -53,6 +54,7 @@ namespace CSharpBinding.OptionPanels
public CSharpSolutionFormattingOptionPanel()
: base(CSharpFormattingOptionsPersistence.SolutionOptions, true)
{
autoFormattingCheckBox.Visibility = Visibility.Collapsed;
}
}
@ -83,7 +85,7 @@ namespace CSharpBinding.OptionPanels @@ -83,7 +85,7 @@ namespace CSharpBinding.OptionPanels
public override bool SaveOptions()
{
return persistenceHelper.Save();
return persistenceHelper.Save() && base.SaveOptions();
}
}
}

5
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/InsertCtorDialog.xaml.cs

@ -38,6 +38,7 @@ using ICSharpCode.NRefactory.TypeSystem; @@ -38,6 +38,7 @@ using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Parser;
using CSharpBinding.FormattingStrategy;
namespace CSharpBinding.Refactoring
{
@ -170,8 +171,8 @@ namespace CSharpBinding.Refactoring @@ -170,8 +171,8 @@ namespace CSharpBinding.Refactoring
using (StringWriter textWriter = new StringWriter(pList)) {
// Output parameter list as string
var formattingOptions = FormattingOptionsFactory.CreateMono();
CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor(textWriter, formattingOptions);
var formattingOptions = CSharpFormattingOptionsPersistence.GetProjectOptions(refactoringContext.Compilation.GetProject());
CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor(textWriter, formattingOptions.OptionsContainer.GetEffectiveOptions());
for (int i = 0; i < parameters.Count; i++) {
if (i > 0)
textWriter.Write(",");

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/MoveTypeToFileContextAction.cs

@ -36,6 +36,7 @@ using ICSharpCode.SharpDevelop.Parser; @@ -36,6 +36,7 @@ using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.SharpDevelop.Workbench;
using CSharpBinding.FormattingStrategy;
using CSharpBinding.Parser;
namespace CSharpBinding.Refactoring
@ -108,7 +109,8 @@ namespace CSharpBinding.Refactoring @@ -108,7 +109,8 @@ namespace CSharpBinding.Refactoring
|| ch is UsingAliasDeclaration
|| ch is ExternAliasDeclaration);
StringBuilder newCode = new StringBuilder(header);
CSharpOutputVisitor visitor = new CSharpOutputVisitor(new StringWriter(newCode), FormattingOptionsFactory.CreateSharpDevelop());
var formattingOptions = CSharpFormattingOptionsPersistence.GetProjectOptions(compilation.GetProject());
CSharpOutputVisitor visitor = new CSharpOutputVisitor(new StringWriter(newCode), formattingOptions.OptionsContainer.GetEffectiveOptions());
foreach (var topLevelUsing in topLevelUsings)
topLevelUsing.AcceptVisitor(visitor);

7
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/SDRefactoringContext.cs

@ -21,6 +21,7 @@ using System.ComponentModel.Design; @@ -21,6 +21,7 @@ using System.ComponentModel.Design;
using System.Threading;
using ICSharpCode.NRefactory.Utils;
using CSharpBinding.FormattingStrategy;
using CSharpBinding.Parser;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
@ -118,13 +119,13 @@ namespace CSharpBinding.Refactoring @@ -118,13 +119,13 @@ namespace CSharpBinding.Refactoring
public Script StartScript()
{
var formattingOptions = FormattingOptionsFactory.CreateSharpDevelop();
var formattingOptions = CSharpFormattingOptionsPersistence.GetProjectOptions(resolver.Compilation.GetProject());
if (editor != null)
return new EditorScript(editor, this, formattingOptions);
return new EditorScript(editor, this, formattingOptions.OptionsContainer.GetEffectiveOptions());
else if (document == null || document is ReadOnlyDocument)
throw new InvalidOperationException("Cannot start a script in a read-only context");
else
return new DocumentScript(document, formattingOptions, this.TextEditorOptions);
return new DocumentScript(document, formattingOptions.OptionsContainer.GetEffectiveOptions(), this.TextEditorOptions);
}
public IDocument Document {

Loading…
Cancel
Save