Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@novell.com>2009-07-07 11:50:04 +0400
committerMike Krüger <mkrueger@novell.com>2009-07-07 11:50:04 +0400
commit3118bab56fe9dd554f37a2f60664c8d175b09022 (patch)
tree1b8eb2310253c7e456cb26797b01650b005cea4f /main/contrib
parente11980f9a4a9e5ad802e2cab37daf1748f65a02c (diff)
* Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs: Improved
collection initializer output. svn path=/trunk/monodevelop/; revision=137482
Diffstat (limited to 'main/contrib')
-rw-r--r--main/contrib/NRefactory/Project/ChangeLog5
-rw-r--r--main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs35
2 files changed, 31 insertions, 9 deletions
diff --git a/main/contrib/NRefactory/Project/ChangeLog b/main/contrib/NRefactory/Project/ChangeLog
index e552184df7..41e9bf416d 100644
--- a/main/contrib/NRefactory/Project/ChangeLog
+++ b/main/contrib/NRefactory/Project/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-07 Mike Krüger <mkrueger@novell.com>
+
+ * Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs: Improved
+ collection initializer output.
+
2009-06-23 Mike Krüger <mkrueger@novell.com>
* Src/PrettyPrinter/CSharp/PrettyPrintOptions.cs:
diff --git a/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs b/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
index efefc84f25..0560b38e35 100644
--- a/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
+++ b/main/contrib/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
@@ -2,7 +2,7 @@
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
-// <version>$Revision: 4342 $</version>
+// <version>$Revision: 4349 $</version>
// </file>
using System;
@@ -2793,10 +2793,22 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitCollectionInitializerExpression(CollectionInitializerExpression arrayInitializerExpression, object data)
{
- outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
- outputFormatter.Space();
- this.AppendCommaSeparatedList(arrayInitializerExpression.CreateExpressions);
- outputFormatter.Space();
+ outputFormatter.PrintToken (Tokens.OpenCurlyBrace);
+ if (arrayInitializerExpression.CreateExpressions.Count == 1) {
+ outputFormatter.Space ();
+ } else {
+ outputFormatter.IndentationLevel++;
+ outputFormatter.NewLine ();
+ outputFormatter.Indent ();
+ }
+ this.AppendCommaSeparatedList (arrayInitializerExpression.CreateExpressions, true);
+ if (arrayInitializerExpression.CreateExpressions.Count == 1) {
+ outputFormatter.Space ();
+ } else {
+ outputFormatter.IndentationLevel--;
+ outputFormatter.NewLine();
+ outputFormatter.Indent();
+ }
outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
return null;
}
@@ -2917,16 +2929,21 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public void AppendCommaSeparatedList<T>(ICollection<T> list) where T : class, INode
{
+ AppendCommaSeparatedList(list, false);
+ }
+
+ public void AppendCommaSeparatedList<T>(ICollection<T> list, bool alwaysBreakLine) where T : class, INode
+ {
if (list != null) {
int i = 0;
foreach (T node in list) {
node.AcceptVisitor(this, null);
if (i + 1 < list.Count) {
PrintFormattedComma();
- }
- if ((i + 1) % 10 == 0) {
- outputFormatter.NewLine();
- outputFormatter.Indent();
+ if (alwaysBreakLine || (i + 1) % 10 == 0) {
+ outputFormatter.NewLine();
+ outputFormatter.Indent();
+ }
}
i++;
}