| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<000001424a084d7a-2a03c999-1108-44db-a518-65fd6ad1c16a-000000@email.amazonses.com> |
Branch: refs/heads/cleanups
Home: https://github.com/mono/monodevelop
Compare: https://github.com/mono/monodevelop/compare/3178f20d6411^...10aeefdaf780
Commit: 3178f20d6411ae0fd2111a25d57eee991bd77f69
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 00:52:20 GMT
URL: https://github.com/mono/monodevelop/commit/3178f20d6411ae0fd2111a25d57eee991bd77f69
[Cleanup] mdhost cleanup
Changed paths:
M main/src/tools/mdhost/src/AssemblyInfo.cs
M main/src/tools/mdhost/src/mdhost.cs
Modified: main/src/tools/mdhost/src/AssemblyInfo.cs
===================================================================
@@ -1,6 +1,5 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
Modified: main/src/tools/mdhost/src/mdhost.cs
===================================================================
@@ -33,14 +33,12 @@
using MonoDevelop.Core.Logging;
using MonoDevelop.Core.Execution;
using System.IO;
-using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Ipc;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Remoting.Lifetime;
using System.Reflection;
using System.Collections;
-using Mono.Remoting.Channels.Unix;
using Mono.Addins;
using System.Runtime.Remoting.Channels.Tcp;
@@ -51,7 +49,7 @@ public class MonoDevelopProcessHost
public static int Main (string[] args)
{
string tmpFile = null;
- TextReader input = null;
+ TextReader input;
try {
// The first parameter is the task id
// The second parameter is the temp file that contains the data
@@ -84,13 +82,13 @@ public static int Main (string[] args)
string unixPath = RegisterRemotingChannel ();
byte[] data = Convert.FromBase64String (sref);
- MemoryStream ms = new MemoryStream (data);
- BinaryFormatter bf = new BinaryFormatter ();
- IProcessHostController pc = (IProcessHostController) bf.Deserialize (ms);
+ var ms = new MemoryStream (data);
+ var bf = new BinaryFormatter ();
+ var pc = (IProcessHostController) bf.Deserialize (ms);
LoggingService.AddLogger (new LocalLogger (pc.GetLogger (), args[0]));
- ProcessHost rp = new ProcessHost (pc);
+ var rp = new ProcessHost (pc);
pc.RegisterHost (rp);
try {
pc.WaitForExit ();
@@ -119,8 +117,8 @@ static string RegisterRemotingChannel ()
formatterProps ["strictBinding"] = false;
IDictionary dict = new Hashtable ();
- BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(formatterProps, null);
- BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(formatterProps, null);
+ var clientProvider = new BinaryClientFormatterSinkProvider(formatterProps, null);
+ var serverProvider = new BinaryServerFormatterSinkProvider(formatterProps, null);
serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
// Mono's and .NET's IPC channels have interoperability issues, so use TCP in this case
@@ -143,14 +141,13 @@ static string RegisterRemotingChannel ()
get {
if (Type.GetType ("Mono.Runtime") != null)
return "Mono";
- else
- return ".NET";
+ return ".NET";
}
}
static void WatchParentProcess (int pid)
{
- Thread t = new Thread (delegate () {
+ var t = new Thread (delegate () {
while (true) {
try {
// Throws exception if process is not running.
@@ -174,8 +171,8 @@ static void WatchParentProcess (int pid)
class LocalLogger: ILogger
{
- ILogger wrapped;
- string id;
+ readonly ILogger wrapped;
+ readonly string id;
public LocalLogger (ILogger wrapped, string id)
{
@@ -205,13 +202,13 @@ public void Log (LogLevel level, string message)
public class ProcessHost: MarshalByRefObject, IProcessHost, ISponsor
{
- IProcessHostController controller;
+ readonly IProcessHostController controller;
public ProcessHost (IProcessHostController controller)
{
this.controller = controller;
- MarshalByRefObject mbr = (MarshalByRefObject) controller;
- ILease lease = mbr.GetLifetimeService () as ILease;
+ var mbr = (MarshalByRefObject) controller;
+ var lease = mbr.GetLifetimeService () as ILease;
lease.Register (this);
}
@@ -259,8 +256,8 @@ public TimeSpan Renewal (ILease lease)
public void Dispose ()
{
- MarshalByRefObject mbr = (MarshalByRefObject) controller;
- ILease lease = mbr.GetLifetimeService () as ILease;
+ var mbr = (MarshalByRefObject) controller;
+ var lease = mbr.GetLifetimeService () as ILease;
lease.Unregister (this);
}
Commit: 7255db060bc3a40f8f325c1d4bce400c9897249c
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 00:52:21 GMT
URL: https://github.com/mono/monodevelop/commit/7255db060bc3a40f8f325c1d4bce400c9897249c
[Cleanup] TestRunner cleanup
Changed paths:
M main/tests/TestRunner/Properties/AssemblyInfo.cs
M main/tests/TestRunner/Runner.cs
Modified: main/tests/TestRunner/Properties/AssemblyInfo.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Reflection;
-using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
Modified: main/tests/TestRunner/Runner.cs
===================================================================
@@ -31,7 +31,6 @@
using Mono.Addins;
using System.Linq;
using Mono.Addins.Description;
-using System.Diagnostics;
namespace MonoDevelop.Tests.TestRunner
{
Commit: 73b72f1eb988e2cb8ccac450a03954c6e6ac2a2a
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 00:52:22 GMT
URL: https://github.com/mono/monodevelop/commit/73b72f1eb988e2cb8ccac450a03954c6e6ac2a2a
[Cleanup] Startup cleanup
Changed paths:
M main/src/core/MonoDevelop.Startup/AssemblyInfo.cs
M main/src/core/MonoDevelop.Startup/MonoDevelop.Startup/MonoDevelopMain.cs
Modified: main/src/core/MonoDevelop.Startup/AssemblyInfo.cs
===================================================================
@@ -6,7 +6,6 @@
// </file>
using System.Reflection;
-using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("MonoDevelop")]
[assembly: AssemblyDescription("A full-featured IDE for Mono and Gtk#.")]
Modified: main/src/core/MonoDevelop.Startup/MonoDevelop.Startup/MonoDevelopMain.cs
===================================================================
@@ -1,10 +1,5 @@
using System;
-using System.IO;
-
-using MonoDevelop.Core;
-using MonoDevelop.Core.ProgressMonitoring;
-using Mono.Addins;
using MonoDevelop.Ide;
namespace MonoDevelop.Startup
Commit: e6443677847509be4ccfc9fe667cf93f124f7e26
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 00:52:23 GMT
URL: https://github.com/mono/monodevelop/commit/e6443677847509be4ccfc9fe667cf93f124f7e26
[Cleanup] NUnitTestRunner cleanup
Changed paths:
M main/src/addins/NUnit/NUnitRunner/NUnitTestRunner.cs
Modified: main/src/addins/NUnit/NUnitRunner/NUnitTestRunner.cs
===================================================================
@@ -30,23 +30,12 @@
using System;
using System.Linq;
using System.Reflection;
-using System.IO;
-using System.Collections;
using System.Collections.Generic;
-using System.Threading;
-
using NUnit.Core;
-using NUnit.Framework;
-using NUnit.Core.Filters;
-
namespace MonoDevelop.NUnit.External
{
public class NUnitTestRunner: MarshalByRefObject
{
- public NUnitTestRunner ()
- {
- }
-
public void PreloadAssemblies (string nunitPath, string nunitCorePath, string nunitCoreInterfacesPath)
{
// Note: We need to load all nunit.*.dll assemblies before we do *anything* else in this class
@@ -98,7 +87,7 @@ public TestResult Run (EventListener listener, ITestFilter filter, string path,
} else
tr = new RemoteTestRunner ();
- TestPackage package = new TestPackage (path);
+ var package = new TestPackage (path);
if (!string.IsNullOrEmpty (suiteName))
package.TestName = suiteName;
tr.Load (package);
@@ -115,7 +104,7 @@ public NunitTestInfo GetTestInfo (string path, List<string> supportAssemblies)
NunitTestInfo BuildTestInfo (Test test)
{
- NunitTestInfo ti = new NunitTestInfo ();
+ var ti = new NunitTestInfo ();
// The name of inherited tests include the base class name as prefix.
// That prefix has to be removed
string tname = test.TestName.Name;
@@ -134,11 +123,10 @@ NunitTestInfo BuildTestInfo (Test test)
// Trim short name from end of full name to get the path
string testNameWithDelimiter = "." + tname;
- if (test.TestName.FullName.EndsWith (testNameWithDelimiter)) {
+ if (test.TestName.FullName.EndsWith (testNameWithDelimiter, StringComparison.Ordinal)) {
int pathLength = test.TestName.FullName.Length - testNameWithDelimiter.Length;
- ti.PathName = test.TestName.FullName.Substring(0, pathLength );
- }
- else
+ ti.PathName = test.TestName.FullName.Substring (0, pathLength);
+ } else
ti.PathName = null;
if (test.Tests != null && test.Tests.Count > 0) {
@@ -176,7 +164,7 @@ public class NunitTestInfo
[Serializable]
public class TestNameFilter: ITestFilter
{
- string[] names;
+ readonly string[] names;
public TestNameFilter (params string[] names)
{
Commit: cdb9dac39f455eef9741200deb1cb14da1269b4a
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 00:52:23 GMT
URL: https://github.com/mono/monodevelop/commit/cdb9dac39f455eef9741200deb1cb14da1269b4a
[Cleanup] TextTransform cleanup
Changed paths:
M main/src/addins/TextTemplating/TextTransform/AssemblyInfo.cs
M main/src/addins/TextTemplating/TextTransform/Options.cs
M main/src/addins/TextTemplating/TextTransform/TextTransform.cs
Modified: main/src/addins/TextTemplating/TextTransform/AssemblyInfo.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Reflection;
-using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
Modified: main/src/addins/TextTemplating/TextTransform/Options.cs
===================================================================
@@ -128,7 +128,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
-using System.Globalization;
using System.IO;
using System.Runtime.Serialization;
using System.Security.Permissions;
@@ -151,8 +150,8 @@ namespace Mono.Options
{
public class OptionValueCollection : IList, IList<string> {
- List<string> values = new List<string> ();
- OptionContext c;
+ readonly List<string> values = new List<string> ();
+ readonly OptionContext c;
internal OptionValueCollection (OptionContext c)
{
@@ -199,7 +198,7 @@ internal OptionValueCollection (OptionContext c)
public void Insert (int index, string item) {values.Insert (index, item);}
public void RemoveAt (int index) {values.RemoveAt (index);}
- private void AssertValid (int index)
+ void AssertValid (int index)
{
if (c.Option == null)
throw new InvalidOperationException ("OptionContext.Option is null.");
@@ -240,39 +239,36 @@ public override string ToString ()
}
public class OptionContext {
- private Option option;
- private string name;
- private int index;
- private OptionSet set;
- private OptionValueCollection c;
+ readonly OptionSet set;
+ readonly OptionValueCollection c;
public OptionContext (OptionSet set)
{
this.set = set;
- this.c = new OptionValueCollection (this);
+ c = new OptionValueCollection (this);
}
public Option Option {
- get {return option;}
- set {option = value;}
+ get;
+ set;
}
- public string OptionName {
- get {return name;}
- set {name = value;}
+ public string OptionName {
+ get;
+ set;
}
public int OptionIndex {
- get {return index;}
- set {index = value;}
+ get;
+ set;
}
public OptionSet OptionSet {
- get {return set;}
+ get { return set; }
}
public OptionValueCollection OptionValues {
- get {return c;}
+ get { return c; }
}
}
@@ -284,9 +280,9 @@ public enum OptionValueType {
public abstract class Option {
string prototype, description;
- string[] names;
- OptionValueType type;
- int count;
+ readonly string[] names;
+ readonly OptionValueType type;
+ readonly int count;
string[] separators;
protected Option (string prototype, string description)
@@ -304,23 +300,23 @@ protected Option (string prototype, string description, int maxValueCount)
throw new ArgumentOutOfRangeException ("maxValueCount");
this.prototype = prototype;
- this.names = prototype.Split ('|');
+ names = prototype.Split ('|');
this.description = description;
- this.count = maxValueCount;
- this.type = ParsePrototype ();
+ count = maxValueCount;
+ type = ParsePrototype ();
- if (this.count == 0 && type != OptionValueType.None)
+ if (count == 0 && type != OptionValueType.None)
throw new ArgumentException (
"Cannot provide maxValueCount of 0 for OptionValueType.Required or " +
"OptionValueType.Optional.",
"maxValueCount");
- if (this.type == OptionValueType.None && maxValueCount > 1)
+ if (type == OptionValueType.None && maxValueCount > 1)
throw new ArgumentException (
string.Format ("Cannot provide maxValueCount of {0} for OptionValueType.None.", maxValueCount),
"maxValueCount");
if (Array.IndexOf (names, "<>") >= 0 &&
- ((names.Length == 1 && this.type != OptionValueType.None) ||
- (names.Length > 1 && this.MaxValueCount > 1)))
+ ((names.Length == 1 && type != OptionValueType.None) ||
+ (names.Length > 1 && MaxValueCount > 1)))
throw new ArgumentException (
"The default option handler '<>' cannot require values.",
"prototype");
@@ -338,9 +334,7 @@ public string[] GetNames ()
public string[] GetValueSeparators ()
{
- if (separators == null)
- return new string [0];
- return (string[]) separators.Clone ();
+ return separators == null ? new string[0] : (string[])separators.Clone ();
}
protected static T Parse<T> (string value, OptionContext c)
@@ -369,12 +363,12 @@ protected static T Parse<T> (string value, OptionContext c)
internal string[] Names {get {return names;}}
internal string[] ValueSeparators {get {return separators;}}
- static readonly char[] NameTerminator = new char[]{'=', ':'};
+ static readonly char[] NameTerminator = {'=', ':'};
- private OptionValueType ParsePrototype ()
+ OptionValueType ParsePrototype ()
{
char type = '\0';
- List<string> seps = new List<string> ();
+ var seps = new List<string> ();
for (int i = 0; i < names.Length; ++i) {
string name = names [i];
if (name.Length == 0)
@@ -402,17 +396,17 @@ private OptionValueType ParsePrototype ()
"prototype");
if (count > 1) {
if (seps.Count == 0)
- this.separators = new string[]{":", "="};
+ separators = new []{ ":", "=" };
else if (seps.Count == 1 && seps [0].Length == 0)
- this.separators = null;
+ separators = null;
else
- this.separators = seps.ToArray ();
+ separators = seps.ToArray ();
}
return type == '=' ? OptionValueType.Required : OptionValueType.Optional;
}
- private static void AddSeparators (string name, int end, ICollection<string> seps)
+ static void AddSeparators (string name, int end, ICollection<string> seps)
{
int start = -1;
for (int i = end+1; i < name.Length; ++i) {
@@ -462,7 +456,7 @@ public override string ToString ()
[Serializable]
public class OptionException : Exception {
- private string option;
+ readonly string option;
public OptionException ()
{
@@ -471,23 +465,23 @@ public OptionException ()
public OptionException (string message, string optionName)
: base (message)
{
- this.option = optionName;
+ option = optionName;
}
public OptionException (string message, string optionName, Exception innerException)
: base (message, innerException)
{
- this.option = optionName;
+ option = optionName;
}
protected OptionException (SerializationInfo info, StreamingContext context)
: base (info, context)
{
- this.option = info.GetString ("OptionName");
+ option = info.GetString ("OptionName");
}
public string OptionName {
- get {return this.option;}
+ get { return option;}
}
[SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
@@ -503,7 +497,7 @@ public override void GetObjectData (SerializationInfo info, StreamingContext con
public class OptionSet : KeyedCollection<string, Option>
{
public OptionSet ()
- : this (delegate (string f) {return f;})
+ : this (f => f)
{
}
@@ -512,7 +506,7 @@ public OptionSet (Converter<string, string> localizer)
this.localizer = localizer;
}
- Converter<string, string> localizer;
+ readonly Converter<string, string> localizer;
public Converter<string, string> MessageLocalizer {
get {return localizer;}
@@ -521,7 +515,7 @@ public OptionSet (Converter<string, string> localizer)
protected override string GetKeyForItem (Option item)
{
if (item == null)
- throw new ArgumentNullException ("option");
+ throw new ArgumentNullException ("item", "Option is null");
if (item.Names != null && item.Names.Length > 0)
return item.Names [0];
// This should never happen, as it's invalid for Option to be
@@ -565,11 +559,11 @@ protected override void SetItem (int index, Option item)
AddImpl (item);
}
- private void AddImpl (Option option)
+ void AddImpl (Option option)
{
if (option == null)
throw new ArgumentNullException ("option");
- List<string> added = new List<string> (option.Names.Length);
+ var added = new List<string> (option.Names.Length);
try {
// KeyedCollection.InsertItem/SetItem handle the 0th name.
for (int i = 1; i < option.Names.Length; ++i) {
@@ -591,7 +585,7 @@ public new OptionSet Add (Option option)
}
sealed class ActionOption : Option {
- Action<OptionValueCollection> action;
+ readonly Action<OptionValueCollection> action;
public ActionOption (string prototype, string description, int count, Action<OptionValueCollection> action)
: base (prototype, description, count)
@@ -616,8 +610,7 @@ public OptionSet Add (string prototype, string description, Action<string> actio
{
if (action == null)
throw new ArgumentNullException ("action");
- Option p = new ActionOption (prototype, description, 1,
- delegate (OptionValueCollection v) { action (v [0]); });
+ Option p = new ActionOption (prototype, description, 1, v => action (v [0]));
base.Add (p);
return this;
}
@@ -631,14 +624,13 @@ public OptionSet Add (string prototype, string description, OptionAction<string,
{
if (action == null)
throw new ArgumentNullException ("action");
- Option p = new ActionOption (prototype, description, 2,
- delegate (OptionValueCollection v) {action (v [0], v [1]);});
+ Option p = new ActionOption (prototype, description, 2, v => action (v [0], v [1]));
base.Add (p);
return this;
}
sealed class ActionOption<T> : Option {
- Action<T> action;
+ readonly Action<T> action;
public ActionOption (string prototype, string description, Action<T> action)
: base (prototype, description, 1)
@@ -655,7 +647,7 @@ protected override void OnParseComplete (OptionContext c)
}
sealed class ActionOption<TKey, TValue> : Option {
- OptionAction<TKey, TValue> action;
+ readonly OptionAction<TKey, TValue> action;
public ActionOption (string prototype, string description, OptionAction<TKey, TValue> action)
: base (prototype, description, 2)
@@ -732,7 +724,7 @@ public List<string> Parse (IEnumerable<string> arguments)
OptionContext c = CreateOptionContext ();
c.OptionIndex = -1;
bool process = true;
- List<string> unprocessed = new List<string> ();
+ var unprocessed = new List<string> ();
Option def = Contains ("<>") ? this ["<>"] : null;
foreach (string argument in arguments) {
++c.OptionIndex;
@@ -753,7 +745,7 @@ public List<string> Parse (IEnumerable<string> arguments)
}
#endif
- private static bool Unprocessed (ICollection<string> extra, Option def, OptionContext c, string argument)
+ static bool Unprocessed (ICollection<string> extra, Option def, OptionContext c, string argument)
{
if (def == null) {
extra.Add (argument);
@@ -765,8 +757,8 @@ private static bool Unprocessed (ICollection<string> extra, Option def, OptionCo
return false;
}
- private readonly Regex ValueOption = new Regex (
- @"^(?<flag>--|-|/)(?<name>[^:=]+)((?<sep>[:=])(?<value>.*))?$");
+ readonly Regex ValueOption = new Regex (
+ @"^(?<flag>--|-|/)(?<name>[^:=]+)((?<sep>[:=])(?<value>.*))?$", RegexOptions.Compiled);
protected bool GetOptionParts (string argument, out string flag, out string name, out string sep, out string value)
{
@@ -816,21 +808,17 @@ protected virtual bool Parse (string argument, OptionContext c)
return true;
}
// no match; is it a bool option?
- if (ParseBool (argument, n, c))
- return true;
+ return ParseBool (argument, n, c) || ParseBundledValue (f, string.Concat (n + s + v), c);
// is it a bundled option?
- if (ParseBundledValue (f, string.Concat (n + s + v), c))
- return true;
- return false;
}
- private void ParseValue (string option, OptionContext c)
+ void ParseValue (string option, OptionContext c)
{
if (option != null)
foreach (string o in c.Option.ValueSeparators != null
? option.Split (c.Option.ValueSeparators, StringSplitOptions.None)
- : new string[]{option}) {
+ : new []{option}) {
c.OptionValues.Add (o);
}
if (c.OptionValues.Count == c.Option.MaxValueCount ||
@@ -844,7 +832,7 @@ private void ParseValue (string option, OptionContext c)
}
}
- private bool ParseBool (string option, string n, OptionContext c)
+ bool ParseBool (string option, string n, OptionContext c)
{
Option p;
string rn;
@@ -861,13 +849,13 @@ private bool ParseBool (string option, string n, OptionContext c)
return false;
}
- private bool ParseBundledValue (string f, string n, OptionContext c)
+ bool ParseBundledValue (string f, string n, OptionContext c)
{
if (f != "-")
return false;
for (int i = 0; i < n.Length; ++i) {
Option p;
- string opt = f + n [i].ToString ();
+ string opt = f + n [i];
string rn = n [i].ToString ();
if (!Contains (rn)) {
if (i == 0)
@@ -895,7 +883,7 @@ private bool ParseBundledValue (string f, string n, OptionContext c)
return true;
}
- private static void Invoke (OptionContext c, string name, string value, Option option)
+ static void Invoke (OptionContext c, string name, string value, Option option)
{
c.OptionName = name;
c.Option = option;
@@ -903,7 +891,7 @@ private static void Invoke (OptionContext c, string name, string value, Option o
option.Invoke (c);
}
- private const int OptionWidth = 29;
+ const int OptionWidth = 29;
public void WriteOptionDescriptions (TextWriter o)
{
@@ -986,23 +974,23 @@ static void Write (TextWriter o, ref int n, string s)
o.Write (s);
}
- private static string GetArgumentName (int index, int maxIndex, string description)
+ static string GetArgumentName (int index, int maxIndex, string description)
{
if (description == null)
return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1);
string[] nameStart;
if (maxIndex == 1)
- nameStart = new string[]{"{0:", "{"};
+ nameStart = new []{"{0:", "{"};
else
- nameStart = new string[]{"{" + index + ":"};
+ nameStart = new []{"{" + index + ":"};
for (int i = 0; i < nameStart.Length; ++i) {
int start, j = 0;
do {
- start = description.IndexOf (nameStart [i], j);
- } while (start >= 0 && j != 0 ? description [j++ - 1] == '{' : false);
+ start = description.IndexOf (nameStart [i], j, StringComparison.Ordinal);
+ } while (start >= 0 && j != 0 && description [j++ - 1] == '{');
if (start == -1)
continue;
- int end = description.IndexOf ("}", start);
+ int end = description.IndexOf ("}", start, StringComparison.Ordinal);
if (end == -1)
continue;
return description.Substring (start + nameStart [i].Length, end - start - nameStart [i].Length);
@@ -1010,11 +998,11 @@ private static string GetArgumentName (int index, int maxIndex, string descripti
return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1);
}
- private static string GetDescription (string description)
+ static string GetDescription (string description)
{
if (description == null)
return string.Empty;
- StringBuilder sb = new StringBuilder (description.Length);
+ var sb = new StringBuilder (description.Length);
int start = -1;
for (int i = 0; i < description.Length; ++i) {
switch (description [i]) {
@@ -1052,14 +1040,14 @@ private static string GetDescription (string description)
return sb.ToString ();
}
- private static List<string> GetLines (string description)
+ static List<string> GetLines (string description)
{
- List<string> lines = new List<string> ();
+ var lines = new List<string> ();
if (string.IsNullOrEmpty (description)) {
lines.Add (string.Empty);
return lines;
}
- int length = 80 - OptionWidth - 2;
+ const int length = 80 - OptionWidth - 2;
int start = 0, end;
do {
end = GetLineEnd (start, length, description);
@@ -1084,9 +1072,9 @@ private static List<string> GetLines (string description)
return lines;
}
- private static int GetLineEnd (int start, int length, string description)
+ static int GetLineEnd (int start, int length, string description)
{
- int end = System.Math.Min (start + length, description.Length);
+ int end = Math.Min (start + length, description.Length);
int sep = -1;
for (int i = start; i < end; ++i) {
switch (description [i]) {
Modified: main/src/addins/TextTemplating/TextTransform/TextTransform.cs
===================================================================
@@ -49,7 +49,7 @@ public static int Main (string[] args)
// var session = new Microsoft.VisualStudio.TextTemplating.TextTemplatingSession ();
string preprocess = null;
- optionSet = new OptionSet () {
+ optionSet = new OptionSet {
{ "o=|out=", "The name of the output {file}", s => outputFile = s },
{ "r=", "Assemblies to reference", s => generator.Refs.Add (s) },
{ "u=", "Namespaces to import <{0:namespace}>", s => generator.Imports.Add (s) },
@@ -59,7 +59,7 @@ public static int Main (string[] args)
{ "a=", "Parameters ([processorName]![directiveName]!name!value)", s => parameters.Add (s) },
{ "h|?|help", "Show help", s => ShowHelp (false) },
// { "k=,", "Session {key},{value} pairs", (s, t) => session.Add (s, t) },
- { "c=", "Preprocess the template into {0:class}", (s) => preprocess = s },
+ { "c=", "Preprocess the template into {0:class}", s => preprocess = s },
};
var remainingArgs = optionSet.Parse (args);
@@ -165,7 +165,7 @@ static void ShowHelp (bool concise)
Console.WriteLine ("Use --help to display options.");
} else {
Console.WriteLine ("Options:");
- optionSet.WriteOptionDescriptions (System.Console.Out);
+ optionSet.WriteOptionDescriptions (Console.Out);
}
Console.WriteLine ();
Environment.Exit (0);
Commit: 1554f8a24780e05bad88a17764ca36400d1419a4
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 01:07:09 GMT
URL: https://github.com/mono/monodevelop/commit/1554f8a24780e05bad88a17764ca36400d1419a4
[Cleanup] MonoDevelop.TextTemplating cleanup
Changed paths:
M main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs
M main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelopTemplatingHost.cs
M main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs
M main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4Parser.cs
M main/src/addins/TextTemplating/MonoDevelop.TextTemplating/ProjectFileTemplatingHost.cs
M main/src/addins/TextTemplating/MonoDevelop.TextTemplating/TextTemplatingFilePreprocessor.cs
M main/src/addins/TextTemplating/MonoDevelop.TextTemplating/TextTemplatingService.cs
Modified: main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs
===================================================================
@@ -39,11 +39,7 @@ public class T4EditorExtension : CompletionTextEditorExtension, IOutlinedDocumen
{
bool disposed;
T4ParsedDocument parsedDoc;
-
- public T4EditorExtension ()
- {
- }
-
+
public override void Initialize ()
{
base.Initialize ();
@@ -90,13 +86,12 @@ public override void Dispose ()
protected string GetBufferText (DomRegion region)
{
- MonoDevelop.Ide.Gui.Content.ITextBuffer buf = Buffer;
+ ITextBuffer buf = Buffer;
int start = buf.GetPositionFromLineColumn (region.BeginLine, region.BeginColumn);
int end = buf.GetPositionFromLineColumn (region.EndLine, region.EndColumn);
if (end > start && start >= 0)
return buf.GetText (start, end);
- else
- return null;
+ return null;
}
#endregion
@@ -109,7 +104,7 @@ public override ICompletionDataList CodeCompletionCommand (CodeCompletionContext
if (pos <= 0)
return null;
int triggerWordLength = 0;
- return HandleCodeCompletion ((CodeCompletionContext) completionContext, true, ref triggerWordLength);
+ return HandleCodeCompletion (completionContext, true, ref triggerWordLength);
}
public override ICompletionDataList HandleCodeCompletion (
@@ -117,8 +112,7 @@ public override ICompletionDataList CodeCompletionCommand (CodeCompletionContext
{
int pos = completionContext.TriggerOffset;
if (pos > 0 && Editor.GetCharAt (pos - 1) == completionChar) {
- return HandleCodeCompletion ((CodeCompletionContext) completionContext,
- false, ref triggerWordLength);
+ return HandleCodeCompletion (completionContext, false, ref triggerWordLength);
}
return null;
}
@@ -134,7 +128,7 @@ public override ICompletionDataList CodeCompletionCommand (CodeCompletionContext
#region Outline
- bool refreshingOutline = false;
+ bool refreshingOutline;
MonoDevelop.Ide.Gui.Components.PadTreeView outlineTreeView;
Gtk.TreeStore outlineTreeStore;
@@ -161,7 +155,7 @@ Gtk.Widget IOutlinedDocument.GetOutlineWidget ()
};
RefillOutlineStore ();
- var sw = new MonoDevelop.Components.CompactScrolledWindow ();;
+ var sw = new MonoDevelop.Components.CompactScrolledWindow ();
sw.Add (outlineTreeView);
sw.ShowAll ();
return sw;
@@ -192,21 +186,21 @@ void RefillOutlineStore (T4ParsedDocument doc, Gtk.TreeStore store)
if (doc == null)
return;
- Gdk.Color normal = new Gdk.Color (0x00, 0x00, 0x00);
- Gdk.Color blue = new Gdk.Color (0x10, 0x40, 0xE0);
- Gdk.Color green = new Gdk.Color (0x08, 0xC0, 0x30);
- Gdk.Color orange = new Gdk.Color (0xFF, 0xA0, 0x00);
- Gdk.Color red = new Gdk.Color (0xC0, 0x00, 0x20);
+ var normal = new Gdk.Color (0x00, 0x00, 0x00);
+ var blue = new Gdk.Color (0x10, 0x40, 0xE0);
+ var green = new Gdk.Color (0x08, 0xC0, 0x30);
+ var orange = new Gdk.Color (0xFF, 0xA0, 0x00);
+ var red = new Gdk.Color (0xC0, 0x00, 0x20);
Gtk.TreeIter parent = Gtk.TreeIter.Zero;
foreach (Mono.TextTemplating.ISegment segment in doc.TemplateSegments) {
- Mono.TextTemplating.Directive dir = segment as Mono.TextTemplating.Directive;
+ var dir = segment as Mono.TextTemplating.Directive;
if (dir != null) {
parent = Gtk.TreeIter.Zero;
store.AppendValues ("<#@ " + dir.Name + " #>", red, segment);
continue;
}
- Mono.TextTemplating.TemplateSegment ts = segment as Mono.TextTemplating.TemplateSegment;
+ var ts = segment as Mono.TextTemplating.TemplateSegment;
if (ts != null) {
string name;
if (ts.Text.Length > 40) {
@@ -262,7 +256,7 @@ void IOutlinedDocument.ReleaseOutlineWidget ()
if (outlineTreeView == null)
return;
- Gtk.ScrolledWindow w = (Gtk.ScrolledWindow) outlineTreeView.Parent;
+ var w = (Gtk.ScrolledWindow) outlineTreeView.Parent;
w.Destroy ();
outlineTreeView.Destroy ();
outlineTreeStore.Dispose ();
Modified: main/src/addins/TextTemplating/MonoDevelop.TextTemplating/MonoDevelopTemplatingHost.cs
===================================================================
@@ -33,10 +33,6 @@ namespace MonoDevelop.TextTemplating
public class MonoDevelopTemplatingHost : TemplateGenerator, IDisposable
{
TemplatingAppDomainRecycler.Handle domainHandle;
-
- public MonoDevelopTemplatingHost ()
- {
- }
public void AddMonoDevelopHostImport ()
{
Modified: main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
using Mono.TextTemplating;
using MonoDevelop.Ide.TypeSystem;
@@ -36,8 +35,8 @@ namespace MonoDevelop.TextTemplating.Parser
public class T4ParsedDocument : ParsedDocument
{
- string fileName;
- IList<Error> errors;
+ readonly string fileName;
+ readonly IList<Error> errors;
public override string FileName {
get {
@@ -63,7 +62,7 @@ public T4ParsedDocument (string fileName, List<ISegment> segments, IList<Error>
public IEnumerable<Directive> TemplateDirectives {
get {
foreach (ISegment seg in TemplateSegments) {
- Directive dir = seg as Directive;
+ var dir = seg as Directive;
if (dir != null)
yield return dir;
}
@@ -73,7 +72,7 @@ public T4ParsedDocument (string fileName, List<ISegment> segments, IList<Error>
public IEnumerable<TemplateSegment> TemplateContent {
get {
foreach (ISegment seg in TemplateSegments) {
- TemplateSegment ts = seg as TemplateSegment;
+ var ts = seg as TemplateSegment;
if (ts != null)
yield return ts;
}
@@ -89,11 +88,12 @@ public T4ParsedDocument (string fileName, List<ISegment> segments, IList<Error>
continue;
string name;
- TemplateSegment ts = seg as TemplateSegment;
+ var ts = seg as TemplateSegment;
if (ts != null) {
if (ts.Type == SegmentType.Content) {
continue;
- } else if (ts.Type == SegmentType.Expression) {
+ }
+ if (ts.Type == SegmentType.Expression) {
name = "<#=...#>";
} else if (ts.Type == SegmentType.Helper) {
name = "<#+...#>";
@@ -101,11 +101,11 @@ public T4ParsedDocument (string fileName, List<ISegment> segments, IList<Error>
name = "<#...#>";
}
} else {
- Directive dir = (Directive)seg;
+ var dir = (Directive)seg;
name = "<#@" + dir.Name + "...#>";
}
- DomRegion region = new DomRegion (seg.TagStartLocation.Line, seg.TagStartLocation.Column,
+ var region = new DomRegion (seg.TagStartLocation.Line, seg.TagStartLocation.Column,
seg.EndLocation.Line, seg.EndLocation.Column);
yield return new FoldingRegion (name, region, false);
Modified: main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4Parser.cs
===================================================================
@@ -38,7 +38,7 @@ public class T4Parser : TypeSystemParser
{
public override ParsedDocument Parse (bool storeAst, string fileName, TextReader content, Project project = null)
{
- ParsedTemplate template = new ParsedTemplate (fileName);
+ var template = new ParsedTemplate (fileName);
try {
var tk = new Tokeniser (fileName, content.ReadToEnd ());
template.ParseWithoutIncludes (tk);
Modified: main/src/addins/TextTemplating/MonoDevelop.TextTemplating/ProjectFileTemplatingHost.cs
===================================================================
@@ -32,17 +32,17 @@ namespace MonoDevelop.TextTemplating
{
class ProjectFileTemplatingHost : MonoDevelopTemplatingHost
{
- ProjectFile file;
+ readonly ProjectFile file;
public ProjectFileTemplatingHost (ProjectFile file)
{
this.file = file;
}
- protected override string SubstitutePlaceholders (string s)
+ protected override string SubstitutePlaceholders (string value)
{
var model = file.Project.ParentSolution.GetStringTagModel ();
- return StringParserService.Parse (s, model);
+ return StringParserService.Parse (value, model);
}
}
}
Modified: main/src/addins/TextTemplating/MonoDevelop.TextTemplating/TextTemplatingFilePreprocessor.cs
===================================================================
@@ -57,7 +57,7 @@ public IAsyncOperation Generate (IProgressMonitor monitor, ProjectFile file, Sin
result.Errors.Add (new CompilerError (file.Name, -1, -1, null, msg));
monitor.Log.WriteLine (msg);
return;
- };
+ }
var outputFile = file.FilePath.ChangeExtension (provider.FileExtension);
var encoding = System.Text.Encoding.UTF8;
@@ -73,14 +73,14 @@ public IAsyncOperation Generate (IProgressMonitor monitor, ProjectFile file, Sin
result.GeneratedFilePath = outputFile;
result.Errors.AddRange (host.Errors);
foreach (var err in host.Errors)
- monitor.Log.WriteLine (err.ToString ());
+ monitor.Log.WriteLine (err);
}, result);
}
static bool warningLogged;
internal static void LogicalSetData (string name, object value,
- System.CodeDom.Compiler.CompilerErrorCollection errors)
+ CompilerErrorCollection errors)
{
if (warningLogged)
return;
Modified: main/src/addins/TextTemplating/MonoDevelop.TextTemplating/TextTemplatingService.cs
===================================================================
@@ -24,16 +24,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
using Mono.TextTemplating;
-using Microsoft.VisualStudio.TextTemplating;
-using MonoDevelop.Ide.Gui;
-using MonoDevelop.Ide.Gui.Pads;
using MonoDevelop.Ide.Tasks;
using System.CodeDom.Compiler;
-using System.IO;
-using MonoDevelop.Core;
namespace MonoDevelop.TextTemplating
{
Commit: 412d5771035cf6ce07bd554195e31df4f3eee384
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 01:47:44 GMT
URL: https://github.com/mono/monodevelop/commit/412d5771035cf6ce07bd554195e31df4f3eee384
[Cleanup] MonoDevelop.VersionControl.Subversion cleanup
Changed paths:
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/ClientCertificateDialog.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/ClientCertificatePasswordDialog.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/SslServerTrustDialog.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/UserPasswordDialog.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SvnRevision.cs
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/ClientCertificateDialog.cs
===================================================================
@@ -34,7 +34,7 @@ internal static bool Show (string realm, bool may_save, out string cert_file, ou
object monitor = new Object ();
EventHandler del = delegate {
- ClientCertificateDialog dlg = new ClientCertificateDialog (realm, may_save);
+ var dlg = new ClientCertificateDialog (realm, may_save);
try {
res = (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok);
if (res) {
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/ClientCertificatePasswordDialog.cs
===================================================================
@@ -34,7 +34,7 @@ internal static bool Show (string realm, bool may_save, out string password, out
object monitor = new Object ();
EventHandler del = delegate {
- ClientCertificatePasswordDialog dlg = new ClientCertificatePasswordDialog (realm, may_save);
+ var dlg = new ClientCertificatePasswordDialog (realm, may_save);
try {
res = (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok);
if (res) {
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/SslServerTrustDialog.cs
===================================================================
@@ -21,8 +21,7 @@ internal SslServerTrustDialog (string realm, SslFailure failures, CertficateInfo
labelUntil.Text = cert_info.ValidUntil;
labelFprint.Text = cert_info.Fingerprint;
- if (!may_save)
- radioAccept.Visible = false;
+ radioAccept.Visible &= may_save;
string reason = "";
if ((failures & SslFailure.NotYetValid) != 0)
@@ -44,10 +43,7 @@ internal SslServerTrustDialog (string realm, SslFailure failures, CertficateInfo
public SslFailure AcceptedFailures {
get {
- if (radioNotAccept.Active)
- return SslFailure.None;
- else
- return failures;
+ return radioNotAccept.Active ? SslFailure.None : failures;
}
}
@@ -61,7 +57,7 @@ internal static bool Show (string realm, SslFailure failures, bool may_save, Cer
EventHandler del = delegate {
try {
- SslServerTrustDialog dlg = new SslServerTrustDialog (realm, failures, certInfo, may_save);
+ var dlg = new SslServerTrustDialog (realm, failures, certInfo, may_save);
res = (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok);
if (res) {
local_save = dlg.Save;
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/UserPasswordDialog.cs
===================================================================
@@ -11,20 +11,19 @@ public UserPasswordDialog (string user, string realm, bool mayRemember, bool sho
{
Build ();
- if (user != null && user.Length > 0) {
+ if (!string.IsNullOrEmpty (user)) {
entryUser.Text = user;
entryPwd.HasFocus = true;
}
labelRealm.Text = GettextCatalog.GetString ("Authentication realm: ") + realm;
- if (!mayRemember)
- checkSavePwd.Visible = false;
+ checkSavePwd.Visible &= mayRemember;
if (!showPassword) {
- entryUser.Activated += new EventHandler (OnPasswdActivated);
+ entryUser.Activated += OnPasswdActivated;
entryPwd.Visible = labelPwd.Visible = false;
} else
- entryPwd.Activated += new EventHandler (OnPasswdActivated);
+ entryPwd.Activated += OnPasswdActivated;
}
public string User {
@@ -41,7 +40,7 @@ public UserPasswordDialog (string user, string realm, bool mayRemember, bool sho
void OnPasswdActivated (object o, EventArgs e)
{
- this.Respond ((int) Gtk.ResponseType.Ok);
+ Respond ((int)Gtk.ResponseType.Ok);
}
internal static bool Show (bool showPwd, string realm, bool may_save, ref string user_name, out string password, out bool save)
@@ -54,7 +53,7 @@ internal static bool Show (bool showPwd, string realm, bool may_save, ref string
EventHandler del = delegate {
try {
- UserPasswordDialog dlg = new UserPasswordDialog (user, realm, may_save, showPwd);
+ var dlg = new UserPasswordDialog (user, realm, may_save, showPwd);
res = (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok);
if (res) {
s = dlg.SavePassword ? 1 : 0;
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionRepository.cs
===================================================================
@@ -26,7 +26,7 @@ public SubversionRepository (SubversionVersionControl vcs, string url, FilePath
public override string[] SupportedProtocols {
get {
- return new string[] {"svn", "svn+ssh", "http", "https", "file"};
+ return new [] {"svn", "svn+ssh", "http", "https", "file"};
}
}
@@ -37,11 +37,11 @@ public SubversionRepository (SubversionVersionControl vcs, string url, FilePath
public override IEnumerable<Repository> ChildRepositories {
get {
- List<Repository> list = new List<Repository> ();
+ var list = new List<Repository> ();
foreach (DirectoryEntry ent in Svn.ListUrl (Url, false)) {
if (ent.IsDirectory) {
- SubversionRepository rep = new SubversionRepository (VersionControlSystem, Url + "/" + ent.Name, null);
+ var rep = new SubversionRepository (VersionControlSystem, Url + "/" + ent.Name, null);
rep.Name = ent.Name;
list.Add (rep);
}
@@ -85,7 +85,7 @@ protected override Revision[] OnGetHistory (FilePath localFile, Revision since)
protected override RevisionPath[] OnGetRevisionChanges (Revision revision)
{
- SvnRevision rev = (SvnRevision) revision;
+ var rev = (SvnRevision) revision;
return rev.ChangedFiles ?? new RevisionPath [0];
}
@@ -112,7 +112,7 @@ public override bool RequestFileWritePermission (FilePath path)
return true;
if ((File.GetAttributes (path) & FileAttributes.ReadOnly) == 0)
return true;
- AlertButton but = new AlertButton ("Lock File");
+ var but = new AlertButton ("Lock File");
if (!MessageService.Confirm (GettextCatalog.GetString ("File locking required"), GettextCatalog.GetString ("The file '{0}' must be locked before editing.", path), but))
return false;
try {
@@ -142,13 +142,13 @@ protected override Repository OnPublish (string serverPath, FilePath localPath,
url += "/";
url += serverPath;
- string[] paths = new string[] {url};
+ string[] paths = { url };
CreateDirectory (paths, message, monitor);
- Svn.Checkout (this.Url + "/" + serverPath, localPath, null, true, monitor);
+ Svn.Checkout (Url + "/" + serverPath, localPath, null, true, monitor);
RootPath = localPath;
- Set<FilePath> dirs = new Set<FilePath> ();
+ var dirs = new Set<FilePath> ();
PublishDir (dirs, localPath, false, monitor);
foreach (FilePath file in files) {
@@ -156,7 +156,7 @@ protected override Repository OnPublish (string serverPath, FilePath localPath,
Add (file, false, monitor);
}
- Svn.Commit (new FilePath[] { localPath }, message, monitor);
+ Svn.Commit (new [] { localPath }, message, monitor);
return new SubversionRepository (VersionControlSystem, paths[0], localPath);
}
@@ -179,7 +179,7 @@ protected override void OnUpdate (FilePath[] localPaths, bool recurse, IProgress
protected override void OnCommit (ChangeSet changeSet, IProgressMonitor monitor)
{
- List<FilePath> list = new List<FilePath> ();
+ var list = new List<FilePath> ();
foreach (ChangeSetItem it in changeSet.Items)
list.Add (it.LocalPath);
Svn.Commit (list.ToArray (), changeSet.GlobalComment, monitor);
@@ -192,7 +192,7 @@ void CreateDirectory (string[] paths, string message, IProgressMonitor monitor)
protected override void OnCheckout (FilePath targetLocalPath, Revision rev, bool recurse, IProgressMonitor monitor)
{
- Svn.Checkout (this.Url, targetLocalPath, rev, recurse, monitor);
+ Svn.Checkout (Url, targetLocalPath, rev, recurse, monitor);
}
protected override void OnRevert (FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
@@ -247,7 +247,7 @@ protected override void OnAdd (FilePath[] localPaths, bool recurse, IProgressMon
if (!path.IsChildPathOf (RootPath))
throw new InvalidOperationException ("File outside the repository directory");
- List<FilePath> dirChain = new List<FilePath> ();
+ var dirChain = new List<FilePath> ();
FilePath parentDir = path.CanonicalPath;
do {
parentDir = parentDir.ParentDirectory;
@@ -259,7 +259,7 @@ protected override void OnAdd (FilePath[] localPaths, bool recurse, IProgressMon
// Found all parent unversioned dirs. Versin them now.
dirChain.Reverse ();
- FileUpdateEventArgs args = new FileUpdateEventArgs ();
+ var args = new FileUpdateEventArgs ();
foreach (var d in dirChain) {
Svn.Add (d, false, monitor);
args.Add (new FileUpdateEventInfo (this, d, true));
@@ -274,7 +274,7 @@ protected override void OnAdd (FilePath[] localPaths, bool recurse, IProgressMon
public string Root {
get {
try {
- UriBuilder ub = new UriBuilder (Url);
+ var ub = new UriBuilder (Url);
ub.Path = string.Empty;
ub.Query = string.Empty;
return ub.ToString ();
@@ -341,16 +341,16 @@ protected override void OnMoveDirectory (FilePath localSrcPath, FilePath localDe
Revert (localDestPath, true, monitor);
// Get the list of files in the directory to be replaced
- ArrayList oldFiles = new ArrayList ();
+ var oldFiles = new ArrayList ();
GetDirectoryFiles (localDestPath, oldFiles);
// Get the list of files to move
- ArrayList newFiles = new ArrayList ();
+ var newFiles = new ArrayList ();
GetDirectoryFiles (localSrcPath, newFiles);
// Move all new files to the new destination
- Hashtable copiedFiles = new Hashtable ();
- Hashtable copiedFolders = new Hashtable ();
+ var copiedFiles = new Hashtable ();
+ var copiedFolders = new Hashtable ();
foreach (string file in newFiles) {
string src = Path.GetFullPath (file);
string dst = Path.Combine (localDestPath, src.Substring (((string)localSrcPath).Length + 1));
@@ -374,7 +374,7 @@ protected override void OnMoveDirectory (FilePath localSrcPath, FilePath localDe
}
// Delete all old files which have not been replaced
- ArrayList foldersToDelete = new ArrayList ();
+ var foldersToDelete = new ArrayList ();
foreach (string oldFile in oldFiles) {
if (!copiedFiles.Contains (oldFile)) {
DeleteFile (oldFile, true, monitor, false);
@@ -511,7 +511,7 @@ public override DiffInfo GenerateDiff (FilePath baseLocalPath, VersionInfo versi
{
string diff = Svn.GetUnifiedDiff (versionInfo.LocalPath, false, false);
if (!string.IsNullOrEmpty (diff))
- return GenerateUnifiedDiffInfo (diff, baseLocalPath, new FilePath[] { versionInfo.LocalPath }).FirstOrDefault ();
+ return GenerateUnifiedDiffInfo (diff, baseLocalPath, new [] { versionInfo.LocalPath }).FirstOrDefault ();
return null;
}
@@ -524,7 +524,7 @@ public override DiffInfo[] PathDiff (FilePath localPath, Revision fromRevision,
public override DiffInfo[] PathDiff (FilePath baseLocalPath, FilePath[] localPaths, bool remoteDiff)
{
if (localPaths != null) {
- ArrayList list = new ArrayList ();
+ var list = new ArrayList ();
foreach (string path in localPaths) {
string diff = Svn.GetUnifiedDiff (path, false, remoteDiff);
if (string.IsNullOrEmpty (diff))
@@ -540,8 +540,8 @@ public override DiffInfo[] PathDiff (FilePath baseLocalPath, FilePath[] localPat
public override Annotation[] GetAnnotations (FilePath repositoryPath)
{
- List<Annotation> annotations = new List<Annotation> (Svn.GetAnnotations (this, repositoryPath, SvnRevision.First, SvnRevision.Base));
- Annotation nextRev = new Annotation (GettextCatalog.GetString ("working copy"), "<uncommitted>", DateTime.MinValue);
+ var annotations = new List<Annotation> (Svn.GetAnnotations (this, repositoryPath, SvnRevision.First, SvnRevision.Base));
+ var nextRev = new Annotation (GettextCatalog.GetString ("working copy"), "<uncommitted>", DateTime.MinValue);
var baseDocument = new Mono.TextEditor.TextDocument (GetBaseText (repositoryPath));
var workingDocument = new Mono.TextEditor.TextDocument (File.ReadAllText (repositoryPath));
@@ -561,7 +561,7 @@ public override Annotation[] GetAnnotations (FilePath repositoryPath)
public override string CreatePatch (IEnumerable<DiffInfo> diffs)
{
- StringBuilder patch = new StringBuilder ();
+ var patch = new StringBuilder ();
if (null != diffs) {
foreach (DiffInfo diff in diffs) {
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SubversionVersionControl.cs
===================================================================
@@ -29,10 +29,8 @@ public override string Name
public override Repository GetRepositoryReference (FilePath path, string id)
{
string svnPath = GetDirectoryDotSvn (path);
- if (!String.IsNullOrEmpty (svnPath))
- return new SubversionRepository (this, null, svnPath);
+ return !String.IsNullOrEmpty (svnPath) ? new SubversionRepository (this, null, svnPath) : null;
- return null;
}
protected override Repository OnCreateRepositoryInstance ()
@@ -57,7 +55,7 @@ internal static string GetDirectoryDotSvn (SubversionVersionControl vcs, FilePat
public Revision[] GetHistory (Repository repo, FilePath sourcefile, Revision since)
{
- List<Revision> revs = new List<Revision>();
+ var revs = new List<Revision>();
SvnRevision startrev = SvnRevision.Working;
SvnRevision sincerev = SvnRevision.First;
@@ -109,17 +107,17 @@ public VersionInfo GetVersionInfo (Repository repo, FilePath localPath, bool get
return VersionInfo.CreateUnversioned (localPath, false);
}
- private VersionInfo GetFileStatus (Repository repo, FilePath sourcefile, bool getRemoteStatus)
+ VersionInfo GetFileStatus (Repository repo, FilePath sourcefile, bool getRemoteStatus)
{
- SubversionRepository srepo = (SubversionRepository)repo;
- SubversionVersionControl vcs = (SubversionVersionControl)repo.VersionControlSystem;
+ var srepo = (SubversionRepository)repo;
+ var vcs = (SubversionVersionControl)repo.VersionControlSystem;
// If the directory is not versioned, there is no version info
if (!Directory.Exists (GetDirectoryDotSvn (vcs, sourcefile.ParentDirectory)))
return VersionInfo.CreateUnversioned (sourcefile, false);
if (!sourcefile.IsChildPathOf (srepo.RootPath))
return VersionInfo.CreateUnversioned (sourcefile, false);
- List<VersionInfo> statuses = new List<VersionInfo> ();
+ var statuses = new List<VersionInfo> ();
statuses.AddRange (Status (repo, sourcefile, SvnRevision.Head, false, false, getRemoteStatus));
if (statuses.Count == 0)
@@ -128,16 +126,16 @@ private VersionInfo GetFileStatus (Repository repo, FilePath sourcefile, bool ge
if (statuses.Count != 1)
return VersionInfo.CreateUnversioned (sourcefile, false);
- VersionInfo ent = (VersionInfo) statuses[0];
+ VersionInfo ent = statuses [0];
if (ent.IsDirectory)
return VersionInfo.CreateUnversioned (sourcefile, false);
return ent;
}
- private VersionInfo GetDirStatus (Repository repo, FilePath localPath, bool getRemoteStatus)
+ VersionInfo GetDirStatus (Repository repo, FilePath localPath, bool getRemoteStatus)
{
- SubversionVersionControl vcs = (SubversionVersionControl)repo.VersionControlSystem;
+ var vcs = (SubversionVersionControl)repo.VersionControlSystem;
// If the directory is not versioned, there is no version info
if (!Directory.Exists (GetDirectoryDotSvn (vcs, localPath)))
return VersionInfo.CreateUnversioned (localPath, true);
@@ -151,7 +149,7 @@ private VersionInfo GetDirStatus (Repository repo, FilePath localPath, bool getR
public VersionInfo[] GetDirectoryVersionInfo (Repository repo, FilePath sourcepath, bool getRemoteStatus, bool recursive)
{
- List<VersionInfo> list = new List<VersionInfo> ();
+ var list = new List<VersionInfo> ();
list.AddRange (Status (repo, sourcepath, SvnRevision.Head, recursive, true, getRemoteStatus));
return list.ToArray ();
}
@@ -212,10 +210,7 @@ public void Move (FilePath srcPath, FilePath destPath, bool force, IProgressMoni
public string GetUnifiedDiff (FilePath path, bool recursive, bool remoteDiff)
{
- if (remoteDiff)
- return GetUnifiedDiff (path, SvnRevision.Head, path, SvnRevision.Working, recursive);
- else
- return GetUnifiedDiff (path, SvnRevision.Base, path, SvnRevision.Working, recursive);
+ return GetUnifiedDiff (path, remoteDiff ? SvnRevision.Head : SvnRevision.Base, path, SvnRevision.Working, recursive);
}
public abstract string GetUnifiedDiff (FilePath path1, SvnRevision revision1, FilePath path2, SvnRevision revision2, bool recursive);
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion/SvnRevision.cs
===================================================================
@@ -49,7 +49,7 @@ public SvnRevision (Repository repo, int rev): base (repo)
public SvnRevision (Repository repo, int rev, DateTime time, string author, string message, RevisionPath[] changedFiles)
: base (repo, time, author, message)
{
- this.ChangedFiles = changedFiles;
+ ChangedFiles = changedFiles;
Rev = rev;
Kind = 1;
}
Commit: 8270221ada718ae6d07b4a2762ab574419ebfc74
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 01:47:55 GMT
URL: https://github.com/mono/monodevelop/commit/8270221ada718ae6d07b4a2762ab574419ebfc74
[Cleanup] MonoDevelop.HexEditor cleanup
Changed paths:
M main/src/addins/MonoDevelop.HexEditor/AddinInfo.cs
M main/src/addins/MonoDevelop.HexEditor/AssemblyInfo.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Buffer.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Caret.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/EditMode.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/HexEditorData.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/ISegment.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/PieceTable.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/RedBlackTree.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/ReplaceEventArgs.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Segment.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/UpdateRequest.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/EmptySpaceMargin.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/GutterMargin.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/HexEditorMargin.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/HexEditorStyle.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/IconMargin.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/Margin.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/TextEditorMargin.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex/BookmarkActions.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex/CaretMoveActions.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex/DeleteActions.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex/HexEditor.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex/HexEditorOptions.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex/MiscActions.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex/ScrollActions.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex/SelectionActions.cs
M main/src/addins/MonoDevelop.HexEditor/Mono.MHex/SimpleEditMode.cs
M main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/DisplayBinding.cs
M main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorNodeExtension.cs
M main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs
M main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs
M main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/MonoDevelopHexEditorStyle.cs
Modified: main/src/addins/MonoDevelop.HexEditor/AddinInfo.cs
===================================================================
@@ -1,8 +1,5 @@
-using System;
using Mono.Addins;
-using Mono.Addins.Description;
-
[assembly:Addin ("HexEditor",
Namespace = "MonoDevelop",
Version = MonoDevelop.BuildInfo.Version,
Modified: main/src/addins/MonoDevelop.HexEditor/AssemblyInfo.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Reflection;
-using System.Runtime.CompilerServices;
[assembly: AssemblyProduct ("MonoDevelop")]
[assembly: AssemblyTitle ("MonoDevelop Hex Editor")]
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Buffer.cs
===================================================================
@@ -43,7 +43,7 @@ interface IBuffer
class ArrayBuffer : IBuffer
{
- byte[] content;
+ readonly byte[] content;
public ArrayBuffer (byte[] buffer)
{
@@ -64,7 +64,7 @@ public ArrayBuffer (byte[] buffer)
public byte[] GetBytes (long offset, int count)
{
- byte[] result = new byte[count];
+ var result = new byte[count];
for (int i = 0; i < result.Length; i++) {
result[i] = content[offset + i];
}
@@ -74,7 +74,7 @@ public byte[] GetBytes (long offset, int count)
public static IBuffer Load (Stream stream)
{
int count = (int) stream.Length;
- byte[] buf= new byte[count];
+ var buf= new byte[count];
stream.Read (buf, 0, count);
@@ -109,7 +109,7 @@ class FileBuffer : IBuffer
public byte[] GetBytes (long offset, int count)
{
stream.Position = offset;
- byte[] result = new byte[(int)count];
+ var result = new byte[count];
if (count != stream.Read (result, 0, count))
throw new IOException ("can't read enough bytes from input stream");
return result;
@@ -117,7 +117,7 @@ public byte[] GetBytes (long offset, int count)
public static IBuffer Load (string fileName)
{
- FileBuffer result = new FileBuffer ();
+ var result = new FileBuffer ();
result.stream = File.OpenRead (fileName);
return result;
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Caret.cs
===================================================================
@@ -30,7 +30,7 @@ namespace Mono.MHex.Data
{
class Caret
{
- HexEditorData data;
+ readonly HexEditorData data;
long offset;
public long Offset {
@@ -38,7 +38,7 @@ class Caret
return offset;
}
set {
- value = System.Math.Min (data.Length, System.Math.Max (0, value));
+ value = Math.Min (data.Length, Math.Max (0, value));
if (offset != value) {
long old = offset;
offset = value;
@@ -116,7 +116,7 @@ public Caret (HexEditorData data)
protected virtual void OnOffsetChanged (CaretLocationEventArgs e)
{
- EventHandler<CaretLocationEventArgs> handler = this.OffsetChanged;
+ EventHandler<CaretLocationEventArgs> handler = OffsetChanged;
if (handler != null)
handler (this, e);
}
@@ -125,7 +125,7 @@ protected virtual void OnOffsetChanged (CaretLocationEventArgs e)
protected virtual void OnChanged (EventArgs e)
{
- EventHandler handler = this.Changed;
+ EventHandler handler = Changed;
if (handler != null)
handler (this, e);
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/EditMode.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Mono.MHex.Data;
using Xwt;
@@ -42,12 +41,12 @@ abstract class EditMode
internal void InternalHandleKeypress (HexEditor editor, Key key, uint unicodeChar, ModifierKeys modifier)
{
- this.Editor = editor;
+ Editor = editor;
HandleKeypress (key, unicodeChar, modifier);
//make sure that nothing funny goes on when the mode should have finished
- this.Editor = null;
+ Editor = null;
}
protected abstract void HandleKeypress (Key key, uint unicodeChar, ModifierKeys modifier);
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/HexEditorData.cs
===================================================================
@@ -62,7 +62,7 @@ class HexEditorData
set;
}
- List<long> bookmarks = new List<long> ();
+ readonly List<long> bookmarks = new List<long> ();
public List<long> Bookmarks {
get {
return bookmarks;
@@ -94,7 +94,7 @@ public byte[] GetBytes (long offset, int count)
return node.value.GetBytes (this, nodeOffset, offset, count);
byte[] nodeBytes = node.value.GetBytes (this, nodeOffset, offset, (int)(nodeEndOffset - offset));
- byte[] result = new byte[count];
+ var result = new byte[count];
if (nodeBytes.Length > 0) {
nodeBytes.CopyTo (result, 0);
GetBytes (offset + nodeBytes.Length, count - nodeBytes.Length).CopyTo (result, nodeBytes.Length);
@@ -114,15 +114,15 @@ public HexEditorData ()
HAdjustment = new ScrollAdjustment ();
}
- PieceTable pieceTable = new PieceTable ();
+ readonly PieceTable pieceTable = new PieceTable ();
internal IBuffer buffer;
public IBuffer Buffer {
get {
- return this.buffer;
+ return buffer;
}
set {
- this.buffer = value;
+ buffer = value;
pieceTable.SetBuffer (buffer);
OnBufferChanged (EventArgs.Empty);
}
@@ -132,7 +132,7 @@ public HexEditorData ()
protected virtual void OnBufferChanged (EventArgs e)
{
- EventHandler handler = this.BufferChanged;
+ EventHandler handler = BufferChanged;
if (handler != null)
handler (this, e);
}
@@ -202,7 +202,7 @@ public void UpdateMargin (Type marginType, long line)
protected virtual void OnUpdateRequested (EventArgs e)
{
- EventHandler handler = this.UpdateRequested;
+ EventHandler handler = UpdateRequested;
if (handler != null)
handler (this, e);
}
@@ -233,7 +233,7 @@ protected virtual void OnReplaced (ReplaceEventArgs args)
}
}
- Selection mainSelection = null;
+ Selection mainSelection;
public Selection MainSelection {
get {
return mainSelection;
@@ -255,7 +255,7 @@ protected virtual void OnReplaced (ReplaceEventArgs args)
public void ClearSelection ()
{
- if (!this.IsSomethingSelected)
+ if (!IsSomethingSelected)
return;
MainSelection = null;
OnSelectionChanged (EventArgs.Empty);
@@ -263,14 +263,14 @@ public void ClearSelection ()
public void SetSelection (long anchor, long lead)
{
- anchor = System.Math.Min (Length, System.Math.Max (0, anchor));
- lead = System.Math.Min (Length, System.Math.Max (0, lead));
+ anchor = Math.Min (Length, Math.Max (0, anchor));
+ lead = Math.Min (Length, Math.Max (0, lead));
MainSelection = new Selection (anchor, lead);
}
public void DeleteSelection ()
{
- if (!this.IsSomethingSelected)
+ if (!IsSomethingSelected)
return;
long start = MainSelection.Segment.Offset;
switch (MainSelection.SelectionMode) {
@@ -289,7 +289,7 @@ public void DeleteSelection ()
public void ExtendSelectionTo (long offset)
{
- offset = System.Math.Min (Length, System.Math.Max (0, offset));
+ offset = Math.Min (Length, Math.Max (0, offset));
if (MainSelection == null)
MainSelection = new Selection (offset, offset);
MainSelection.Lead = offset;
@@ -357,8 +357,8 @@ public virtual void Redo (HexEditorData data)
}
}
- Stack<UndoOperation> undoStack = new Stack<UndoOperation> ();
- Stack<UndoOperation> redoStack = new Stack<UndoOperation> ();
+ readonly Stack<UndoOperation> undoStack = new Stack<UndoOperation> ();
+ readonly Stack<UndoOperation> redoStack = new Stack<UndoOperation> ();
UndoOperation currentAtomicOperation;
public bool EnableUndo {
@@ -373,7 +373,7 @@ public virtual void Redo (HexEditorData data)
}
}
- bool isInUndo = false;
+ bool isInUndo;
int atomicUndoLevel;
public void BeginAtomicUndo ()
{
@@ -423,7 +423,7 @@ public void Undo ()
internal protected virtual void OnUndone (UndoOperationEventArgs e)
{
- EventHandler<UndoOperationEventArgs> handler = this.Undone;
+ EventHandler<UndoOperationEventArgs> handler = Undone;
if (handler != null)
handler (this, e);
}
@@ -444,7 +444,7 @@ public void Redo ()
internal protected virtual void OnRedone (UndoOperationEventArgs e)
{
- EventHandler<UndoOperationEventArgs> handler = this.Redone;
+ EventHandler<UndoOperationEventArgs> handler = Redone;
if (handler != null)
handler (this, e);
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/ISegment.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
namespace Mono.MHex.Data
{
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/PieceTable.cs
===================================================================
@@ -67,7 +67,7 @@ public TreeNode (long length)
public TreeNode SplitRight (long leftLength)
{
- return InternalSplitRight (System.Math.Min (Length, System.Math.Max (0, leftLength)));
+ return InternalSplitRight (Math.Min (Length, Math.Max (0, leftLength)));
}
protected abstract TreeNode InternalSplitRight (long leftLength);
@@ -102,7 +102,7 @@ public override string ToString ()
public object Clone ()
{
- OriginalTreeNode result = new OriginalTreeNode (BufferOffset, Length);
+ var result = new OriginalTreeNode (BufferOffset, Length);
result.TotalLength = TotalLength;
return result;
}
@@ -122,7 +122,7 @@ public DataTreeNode (int addBufferOffset, long length) : base (length)
public override byte[] GetBytes (HexEditorData hexEditorData, long myOffset, long offset, int count)
{
- byte[] result = new byte[count];
+ var result = new byte[count];
for (int i = 0, j = (int)(AddBufferOffset + offset - myOffset); i < result.Length; i++, j++) {
result[i] = hexEditorData.addBuffer [j];
}
@@ -140,7 +140,7 @@ public override string ToString ()
}
public object Clone ()
{
- DataTreeNode result = new DataTreeNode (AddBufferOffset, Length);
+ var result = new DataTreeNode (AddBufferOffset, Length);
result.TotalLength = TotalLength;
return result;
}
@@ -161,9 +161,7 @@ public object Clone ()
public PieceTable ()
{
- tree.ChildrenChanged += delegate (object sender, RedBlackTree<TreeNode>.RedBlackTreeNodeEventArgs args) {
- UpdateNode (args.Node);
- };
+ tree.ChildrenChanged += (sender, args) => UpdateNode (args.Node);
tree.NodeRotateLeft += delegate (object sender, RedBlackTree<TreeNode>.RedBlackTreeNodeEventArgs args) {
UpdateNode (args.Node);
UpdateNode (args.Node.parent);
@@ -211,9 +209,9 @@ void RemoveNode (RedBlackTree<TreeNode>.RedBlackTreeNode node)
RedBlackTree<TreeNode>.RedBlackTreeNode InsertAfter (RedBlackTree<TreeNode>.RedBlackTreeNode node, TreeNode nodeToInsert)
{
- RedBlackTree<TreeNode>.RedBlackTreeNode newNode = new RedBlackTree<TreeNode>.RedBlackTreeNode (nodeToInsert);
+ var newNode = new RedBlackTree<TreeNode>.RedBlackTreeNode (nodeToInsert);
- RedBlackTree<TreeNode>.RedBlackTreeIterator iter = new RedBlackTree<TreeNode>.RedBlackTreeIterator (node);
+ var iter = new RedBlackTree<TreeNode>.RedBlackTreeIterator (node);
if (iter.node.right == null) {
tree.Insert (iter.node, newNode, false);
@@ -273,7 +271,7 @@ public void Remove (long offset, long length)
return;
}
long endSegmentLength = endNode != null ? offset + length - endNode.value.CalcOffset (endNode) : 0;
- RedBlackTree<TreeNode>.RedBlackTreeIterator iter = new RedBlackTree<TreeNode>.RedBlackTreeIterator (startNode);
+ var iter = new RedBlackTree<TreeNode>.RedBlackTreeIterator (startNode);
RedBlackTree<TreeNode>.RedBlackTreeNode node;
do {
node = iter.CurrentNode;
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/RedBlackTree.cs
===================================================================
@@ -79,7 +79,7 @@ public void Insert (RedBlackTreeNode parent, RedBlackTreeNode node, bool insertL
node.parent = parent;
node.color = red;
- this.OnChildrenChanged (new RedBlackTreeNodeEventArgs (parent));
+ OnChildrenChanged (new RedBlackTreeNodeEventArgs (parent));
FixTreeOnInsert (node);
Count++;
}
@@ -122,13 +122,13 @@ void FixTreeOnInsert (RedBlackTreeNode node)
void RotateLeft (RedBlackTreeNode node)
{
RedBlackTreeNode right = node.right;
- this.Replace (node, right);
+ Replace (node, right);
node.right = right.left;
if (node.right != null)
node.right.parent = node;
right.left = node;
node.parent = right;
- this.OnNodeRotateLeft (new RedBlackTreeNodeEventArgs (node));
+ OnNodeRotateLeft (new RedBlackTreeNodeEventArgs (node));
}
void RotateRight (RedBlackTreeNode node)
@@ -140,7 +140,7 @@ void RotateRight (RedBlackTreeNode node)
node.left.parent = node;
left.right = node;
node.parent = left;
- this.OnNodeRotateRight (new RedBlackTreeNodeEventArgs (node));
+ OnNodeRotateRight (new RedBlackTreeNodeEventArgs (node));
}
public void RemoveAt (RedBlackTreeIterator iter)
@@ -149,7 +149,7 @@ public void RemoveAt (RedBlackTreeIterator iter)
RemoveNode (iter.node);
} catch (Exception e) {
string s1 = "remove:" + iter.node.value;
- string s2 = this.ToString ();
+ string s2 = ToString ();
Console.WriteLine (s1);
Console.WriteLine (s2);
Console.WriteLine ("----");
@@ -168,7 +168,7 @@ void Replace (RedBlackTreeNode oldNode, RedBlackTreeNode newNode)
oldNode.parent.left = newNode;
else
oldNode.parent.right = newNode;
- this.OnChildrenChanged (new RedBlackTreeNodeEventArgs (oldNode.parent));
+ OnChildrenChanged (new RedBlackTreeNodeEventArgs (oldNode.parent));
}
}
@@ -187,7 +187,7 @@ public void RemoveNode (RedBlackTreeNode node)
outerLeft.right = node.right;
if (outerLeft.right != null)
outerLeft.right.parent = outerLeft;
- this.OnChildrenChanged (new RedBlackTreeNodeEventArgs (outerLeft));
+ OnChildrenChanged (new RedBlackTreeNodeEventArgs (outerLeft));
return;
}
Count--;
@@ -309,7 +309,7 @@ public void Clear()
public bool Contains(T item)
{
- RedBlackTreeIterator iter = new RedBlackTreeIterator (Root.OuterLeft);
+ var iter = new RedBlackTreeIterator (Root.OuterLeft);
while (iter.IsValid) {
if (iter.Current.Equals (item))
return true;
@@ -320,10 +320,10 @@ public bool Contains(T item)
public bool Remove(T item)
{
- RedBlackTreeIterator iter = new RedBlackTreeIterator (Root.OuterLeft);
+ var iter = new RedBlackTreeIterator (Root.OuterLeft);
while (iter.IsValid) {
if (iter.Current.Equals (item)) {
- this.RemoveAt (iter);
+ RemoveAt (iter);
return true;
}
iter.MoveNext ();
@@ -359,7 +359,7 @@ public RedBlackTreeIterator GetEnumerator()
{
if (Root == null)
return null;
- RedBlackTreeNode dummyNode = new RedBlackTreeNode (default(T));
+ var dummyNode = new RedBlackTreeNode (default(T));
dummyNode.right = Root;
return new RedBlackTreeIterator (dummyNode);
}
@@ -406,7 +406,7 @@ string GetIndent (int level)
void AppendNode (StringBuilder builder, RedBlackTreeNode node, int indent)
{
- builder.Append (GetIndent (indent) + "Node (" + (node.color == red ? "r" : "b" ) + "):" + node.value.ToString () + Environment.NewLine);
+ builder.Append (GetIndent (indent) + "Node (" + (node.color == red ? "r" : "b") + "):" + node.value + Environment.NewLine);
builder.Append (GetIndent (indent) + "Left: ");
if (node.left != null) {
builder.Append (Environment.NewLine);
@@ -427,7 +427,7 @@ void AppendNode (StringBuilder builder, RedBlackTreeNode node, int indent)
public override string ToString ()
{
- StringBuilder result = new StringBuilder ();
+ var result = new StringBuilder ();
AppendNode (result, Root, 0);
return result.ToString ();
}
@@ -449,7 +449,7 @@ public RedBlackTreeNode (T value)
public RedBlackTreeNode Clone ()
{
- RedBlackTreeNode result = new RedBlackTreeNode ((T)(value as ICloneable).Clone ());
+ var result = new RedBlackTreeNode ((T)(value as ICloneable).Clone ());
if (left != null) {
result.left = left.Clone ();
result.left.parent = result;
@@ -522,7 +522,7 @@ public RedBlackTreeIterator (RedBlackTreeNode node)
public RedBlackTreeIterator Clone ()
{
- return new RedBlackTreeIterator (this.startNode);
+ return new RedBlackTreeIterator (startNode);
}
public bool IsValid {
@@ -543,13 +543,13 @@ public RedBlackTreeIterator Clone ()
object System.Collections.IEnumerator.Current {
get {
- return this.Current;
+ return Current;
}
}
public void Reset ()
{
- this.node = this.startNode;
+ node = startNode;
}
public void Dispose ()
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/ReplaceEventArgs.cs
===================================================================
@@ -28,7 +28,7 @@
namespace Mono.MHex.Data
{
- class ReplaceEventArgs : System.EventArgs
+ class ReplaceEventArgs : EventArgs
{
public long Offset {
get;
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/Segment.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
namespace Mono.MHex.Data
{
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Data/UpdateRequest.cs
===================================================================
@@ -50,7 +50,7 @@ public LineUpdateRequest (long line)
public override void AddRedraw (HexEditor editor)
{
- editor.RepaintArea (0, (int)(Line * editor.LineHeight - editor.HexEditorData.VAdjustment.Value), editor.Bounds.Width, editor.LineHeight);
+ editor.RepaintArea (0, (Line * editor.LineHeight - editor.HexEditorData.VAdjustment.Value), editor.Bounds.Width, editor.LineHeight);
}
}
@@ -77,7 +77,7 @@ public override void AddRedraw (HexEditor editor)
if (margin != null)
editor.RepaintMarginArea (margin,
margin.XOffset,
- (int)(Line * editor.LineHeight - editor.HexEditorData.VAdjustment.Value),
+ (Line * editor.LineHeight - editor.HexEditorData.VAdjustment.Value),
margin.Width,
editor.LineHeight);
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/EmptySpaceMargin.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Xwt.Drawing;
using Xwt;
@@ -51,11 +50,11 @@ internal protected override void OptionsChanged ()
{
}
- protected internal override void Draw (Context drawable, Rectangle area, long line, double x, double y)
+ protected internal override void Draw (Context ctx, Rectangle area, long line, double x, double y)
{
- drawable.Rectangle (x, y, Width, Editor.LineHeight);
- drawable.SetColor (Style.HexDigitBg);
- drawable.Fill ();
+ ctx.Rectangle (x, y, Width, Editor.LineHeight);
+ ctx.SetColor (Style.HexDigitBg);
+ ctx.Fill ();
}
}
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/GutterMargin.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Xwt.Drawing;
using Xwt;
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/HexEditorMargin.cs
===================================================================
@@ -88,9 +88,9 @@ protected override LayoutWrapper RenderLine (long line)
var layout = new TextLayout (Editor);
layout.Font = Editor.Options.Font;
// layout.Tabs = tabArray;
- StringBuilder sb = new StringBuilder ();
+ var sb = new StringBuilder ();
long startOffset = line * Editor.BytesInRow;
- long endOffset = System.Math.Min (startOffset + Editor.BytesInRow, Data.Length);
+ long endOffset = Math.Min (startOffset + Editor.BytesInRow, Data.Length);
byte[] lineBytes = Data.GetBytes (startOffset, (int)(endOffset - startOffset));
for (int i = 0; i < lineBytes.Length; i++) {
sb.Append (string.Format ("{0:X2}", lineBytes[i]));
@@ -148,7 +148,7 @@ public double CalculateCaretXPos (out char ch)
int caretIndex = groupNumber * (Editor.Options.GroupBytes * 2 + 1) + groupByte * 2;
if (useSubPositon)
caretIndex += Caret.SubPosition;
- LayoutWrapper layout = GetLayout ((int)Caret.Line);
+ LayoutWrapper layout = GetLayout (Caret.Line);
var rectangle = layout.Layout.GetCoordinateFromIndex (caretIndex);
var text = layout.Layout.Text;
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/HexEditorStyle.cs
===================================================================
@@ -24,8 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using Xwt;
using Xwt.Drawing;
namespace Mono.MHex.Rendering
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/IconMargin.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Xwt.Drawing;
using Xwt;
@@ -54,25 +53,25 @@ internal protected override void OptionsChanged ()
layout.Font = Editor.Options.Font;
layout.Text = "!";
// int tmp;
- this.marginWidth = layout.GetSize ().Height;
+ marginWidth = layout.GetSize ().Height;
marginWidth *= 12;
marginWidth /= 10;
layout.Dispose ();
}
- internal protected override void Draw (Context win, Rectangle area, long line, double x, double y)
+ internal protected override void Draw (Context ctx, Rectangle area, long line, double x, double y)
{
- win.Rectangle (x, y, Width, Editor.LineHeight);
- win.SetColor (Style.IconBarBg);
- win.Fill ();
- win.MoveTo (x + Width - 1, y);
- win.LineTo (x + Width - 1, y + Editor.LineHeight);
- win.SetColor (Style.IconBarSeperator);
- win.Stroke ();
+ ctx.Rectangle (x, y, Width, Editor.LineHeight);
+ ctx.SetColor (Style.IconBarBg);
+ ctx.Fill ();
+ ctx.MoveTo (x + Width - 1, y);
+ ctx.LineTo (x + Width - 1, y + Editor.LineHeight);
+ ctx.SetColor (Style.IconBarSeperator);
+ ctx.Stroke ();
foreach (long bookmark in Data.Bookmarks) {
if (line * Editor.BytesInRow <= bookmark && bookmark < line * Editor.BytesInRow + Editor.BytesInRow) {
- DrawBookmark (win, x, y);
+ DrawBookmark (ctx, x, y);
return;
}
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/Margin.cs
===================================================================
@@ -40,7 +40,7 @@ abstract class Margin : IDisposable
private set;
}
- protected Mono.MHex.Data.HexEditorData Data {
+ protected HexEditorData Data {
get {
return Editor.HexEditorData;
}
@@ -121,7 +121,7 @@ public void Dispose ()
}
}
- Dictionary<long, LayoutWrapper> layoutCache = new Dictionary<long, LayoutWrapper> ();
+ readonly Dictionary<long, LayoutWrapper> layoutCache = new Dictionary<long, LayoutWrapper> ();
protected virtual LayoutWrapper RenderLine (long line)
{
return null;
@@ -143,7 +143,7 @@ internal protected void PurgeLayoutCache (long line)
public void SetVisibleWindow (long startLine, long endLine)
{
- List<long> toRemove = new List<long> ();
+ var toRemove = new List<long> ();
foreach (long lineNumber in layoutCache.Keys) {
if (lineNumber < startLine || lineNumber > endLine)
toRemove.Add (lineNumber);
@@ -198,7 +198,7 @@ protected static uint TranslateToUTF8Index (char[] charArray, uint textIndex, re
if (textIndex < curIndex) {
byteIndex = (uint)Encoding.UTF8.GetByteCount (charArray, 0, (int)textIndex);
} else {
- int count = System.Math.Min ((int)(textIndex - curIndex), charArray.Length - (int)curIndex);
+ int count = Math.Min ((int)(textIndex - curIndex), charArray.Length - (int)curIndex);
if (count > 0)
byteIndex += (uint)Encoding.UTF8.GetByteCount (charArray, (int)curIndex, count);
@@ -253,7 +253,7 @@ public virtual void Dispose ()
class MarginMouseEventArgs : EventArgs
{
- Margin margin;
+ readonly Margin margin;
public double X {
get {
@@ -327,7 +327,7 @@ class MarginMouseMovedEventArgs : EventArgs
}
}
- Margin margin;
+ readonly Margin margin;
public MarginMouseMovedEventArgs (HexEditor editor, Margin margin, MouseMovedEventArgs args)
{
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex.Rendering/TextEditorMargin.cs
===================================================================
@@ -64,16 +64,16 @@ protected override LayoutWrapper RenderLine (long line)
{
var layout = new TextLayout (Editor);
layout.Font = Editor.Options.Font;
- StringBuilder sb = new StringBuilder ();
+ var sb = new StringBuilder ();
long startOffset = line * Editor.BytesInRow;
- long endOffset = System.Math.Min (startOffset + Editor.BytesInRow, Data.Length);
+ long endOffset = Math.Min (startOffset + Editor.BytesInRow, Data.Length);
byte[] lineBytes = Data.GetBytes (startOffset, (int)(endOffset - startOffset));
- for (int i = 0; i < lineBytes.Length; i++) {
- byte b = lineBytes[i];
+ foreach (var b in lineBytes) {
char ch = (char)b;
if (b < 128 && (Char.IsLetterOrDigit (ch) || Char.IsPunctuation (ch))) {
sb.Append (ch);
- } else {
+ }
+ else {
sb.Append (".");
}
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex/BookmarkActions.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Mono.MHex.Data;
using Mono.MHex.Rendering;
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex/CaretMoveActions.cs
===================================================================
@@ -39,12 +39,12 @@ public static void SwitchSide (HexEditorData data)
public static void Up (HexEditorData data)
{
- data.Caret.Offset = System.Math.Max (0, data.Caret.Offset - data.BytesInRow);
+ data.Caret.Offset = Math.Max (0, data.Caret.Offset - data.BytesInRow);
}
public static void Down (HexEditorData data)
{
- data.Caret.Offset = System.Math.Min (data.Length, data.Caret.Offset + data.BytesInRow);
+ data.Caret.Offset = Math.Min (data.Length, data.Caret.Offset + data.BytesInRow);
}
public static void Left (HexEditorData data)
@@ -53,7 +53,7 @@ public static void Left (HexEditorData data)
data.Caret.SubPosition--;
return;
}
- long newOffset = System.Math.Max (0, data.Caret.Offset - 1);
+ long newOffset = Math.Max (0, data.Caret.Offset - 1);
if (newOffset != data.Caret.Offset) {
data.Caret.Offset = newOffset;
data.Caret.SubPosition = data.Caret.MaxSubPosition;
@@ -66,7 +66,7 @@ public static void Right (HexEditorData data)
data.Caret.SubPosition++;
return;
}
- long newOffset = System.Math.Min (data.Length, data.Caret.Offset + 1);
+ long newOffset = Math.Min (data.Length, data.Caret.Offset + 1);
if (newOffset != data.Caret.Offset) {
data.Caret.Offset = newOffset;
}
@@ -74,7 +74,7 @@ public static void Right (HexEditorData data)
public static void LineEnd (HexEditorData data)
{
- data.Caret.Offset = System.Math.Min (data.Length - 1, data.Caret.Offset + data.BytesInRow - 1 - data.Caret.Offset % data.BytesInRow);
+ data.Caret.Offset = Math.Min (data.Length - 1, data.Caret.Offset + data.BytesInRow - 1 - data.Caret.Offset % data.BytesInRow);
data.Caret.SubPosition = 0;
}
@@ -96,16 +96,16 @@ public static void ToDocumentEnd (HexEditorData data)
public static void PageUp (HexEditorData data)
{
- data.VAdjustment.Value = System.Math.Max (data.VAdjustment.LowerValue, data.VAdjustment.Value - data.VAdjustment.PageSize);
+ data.VAdjustment.Value = Math.Max (data.VAdjustment.LowerValue, data.VAdjustment.Value - data.VAdjustment.PageSize);
int pageLines = (int)(data.VAdjustment.PageSize + ((int)data.VAdjustment.Value % data.LineHeight) / data.LineHeight);
- data.Caret.Offset = (long)System.Math.Max (0, data.Caret.Offset - data.BytesInRow * pageLines);
+ data.Caret.Offset = Math.Max (0, data.Caret.Offset - data.BytesInRow * pageLines);
}
public static void PageDown (HexEditorData data)
{
- data.VAdjustment.Value = System.Math.Min (data.VAdjustment.UpperValue - data.VAdjustment.PageSize, data.VAdjustment.Value + data.VAdjustment.PageSize);
+ data.VAdjustment.Value = Math.Min (data.VAdjustment.UpperValue - data.VAdjustment.PageSize, data.VAdjustment.Value + data.VAdjustment.PageSize);
int pageLines = (int)(data.VAdjustment.PageSize + ((int)data.VAdjustment.Value % data.LineHeight) / data.LineHeight);
- data.Caret.Offset = (long)System.Math.Min (data.Length, data.Caret.Offset + data.BytesInRow * pageLines);
+ data.Caret.Offset = Math.Min (data.Length, data.Caret.Offset + data.BytesInRow * pageLines);
}
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex/DeleteActions.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Mono.MHex.Data;
namespace Mono.MHex
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex/HexEditor.cs
===================================================================
@@ -26,10 +26,7 @@
using System;
using System.Linq;
-using System.Diagnostics;
using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using System.Text;
using System.Timers;
using Xwt;
@@ -54,14 +51,14 @@ class HexEditor : Canvas
set;
}
- IconMargin iconMargin;
+ readonly IconMargin iconMargin;
internal HexEditorMargin hexEditorMargin;
- GutterMargin gutterMargin;
+ readonly GutterMargin gutterMargin;
internal TextEditorMargin textEditorMargin;
- List<Margin> margins = new List<Margin> ();
+ readonly List<Margin> margins = new List<Margin> ();
public List<Margin> Margins {
- get { return this.margins; }
+ get { return margins; }
}
public int LineHeight {
@@ -166,7 +163,7 @@ public void PurgeLayoutCaches ()
margins.ForEach (margin => margin.PurgeLayoutCache ());
}
- ISegment oldSelection = null;
+ ISegment oldSelection;
void HexEditorDataSelectionChanged (object sender, EventArgs e)
{
ISegment selection = HexEditorData.IsSomethingSelected ? HexEditorData.MainSelection.Segment : null;
@@ -186,8 +183,8 @@ void HexEditorDataSelectionChanged (object sender, EventArgs e)
if (selection != null && oldSelection != null) {
if (startLine != oldStartLine && endLine != oldEndLine) {
- from = System.Math.Min (startLine, oldStartLine);
- to = System.Math.Max (endLine, oldEndLine);
+ from = Math.Min (startLine, oldStartLine);
+ to = Math.Max (endLine, oldEndLine);
} else if (startLine != oldStartLine) {
from = startLine;
to = oldStartLine;
@@ -196,12 +193,12 @@ void HexEditorDataSelectionChanged (object sender, EventArgs e)
to = oldEndLine;
} else if (startLine == oldStartLine && endLine == oldEndLine) {
if (selection.Offset == oldSelection.Offset) {
- this.RepaintLine (endLine);
+ RepaintLine (endLine);
} else if (selection.EndOffset == oldSelection.EndOffset) {
- this.RepaintLine (startLine);
+ RepaintLine (startLine);
} else { // 3rd case - may happen when changed programmatically
- this.RepaintLine (endLine);
- this.RepaintLine (startLine);
+ RepaintLine (endLine);
+ RepaintLine (startLine);
}
from = to = -1;
}
@@ -217,8 +214,8 @@ void HexEditorDataSelectionChanged (object sender, EventArgs e)
oldSelection = selection;
if (from >= 0 && to >= 0) {
- long start = System.Math.Max (0, System.Math.Min (from, to)) - 1;
- long end = System.Math.Max (from, to) + 1;
+ long start = Math.Max (0, Math.Min (from, to)) - 1;
+ long end = Math.Max (from, to) + 1;
RepaintLines (start, end);
}
}
@@ -234,14 +231,14 @@ void OptionsChanged (object sender, EventArgs e)
margin.OptionsChanged ();
});
- this.CalculateBytesInRow ();
+ CalculateBytesInRow ();
SetAdjustments (Bounds);
OnBytesInRowChanged (EventArgs.Empty);
}
protected virtual void OnBytesInRowChanged (EventArgs e)
{
- EventHandler handler = this.BytesInRowChanged;
+ EventHandler handler = BytesInRowChanged;
if (handler != null)
handler (this, e);
}
@@ -252,8 +249,8 @@ protected virtual void OnBytesInRowChanged (EventArgs e)
int oldHAdjustment = -1;
void HAdjustmentValueChanged (object sender, EventArgs args)
{
- if (HexEditorData.HAdjustment.Value != System.Math.Ceiling (HexEditorData.HAdjustment.Value)) {
- HexEditorData.HAdjustment.Value = System.Math.Ceiling (HexEditorData.HAdjustment.Value);
+ if (HexEditorData.HAdjustment.Value != Math.Ceiling (HexEditorData.HAdjustment.Value)) {
+ HexEditorData.HAdjustment.Value = Math.Ceiling (HexEditorData.HAdjustment.Value);
return;
}
@@ -261,28 +258,28 @@ void HAdjustmentValueChanged (object sender, EventArgs args)
if (oldHAdjustment == curHAdjustment)
return;
-// this.RepaintArea (this.textViewMargin.XOffset, 0, this.Bounds.Width - this.textViewMargin.XOffset, this.Bounds.Height);
+// RepaintArea (textViewMargin.XOffset, 0, Bounds.Width - textViewMargin.XOffset, Bounds.Height);
oldHAdjustment = curHAdjustment;
}
// double oldVadjustment = -1;
void VAdjustmentValueChanged (object sender, EventArgs args)
{
- if (HexEditorData.VAdjustment.Value != System.Math.Ceiling (HexEditorData.VAdjustment.Value)) {
- HexEditorData.VAdjustment.Value = System.Math.Ceiling (HexEditorData.VAdjustment.Value);
+ if (HexEditorData.VAdjustment.Value != Math.Ceiling (HexEditorData.VAdjustment.Value)) {
+ HexEditorData.VAdjustment.Value = Math.Ceiling (HexEditorData.VAdjustment.Value);
return;
}
long firstVisibleLine = (long)(HexEditorData.VAdjustment.Value / LineHeight);
long lastVisibleLine = (long)((HexEditorData.VAdjustment.Value + Bounds.Height) / LineHeight);
margins.ForEach (margin => margin.SetVisibleWindow (firstVisibleLine, lastVisibleLine));
-// int delta = (int)(HexEditorData.VAdjustment.Value - this.oldVadjustment);
+// int delta = (int)(HexEditorData.VAdjustment.Value - oldVadjustment);
// oldVadjustment = HexEditorData.VAdjustment.Value;
// update pending redraws
-// if (System.Math.Abs (delta) >= Bounds.Height - this.LineHeight * 2) {
-// this.Repaint ();
+// if (System.Math.Abs (delta) >= Bounds.Height - LineHeight * 2) {
+// Repaint ();
// return;
// }
//
@@ -307,17 +304,17 @@ void VAdjustmentValueChanged (object sender, EventArgs args)
ResetCaretBlink ();
}
- protected override void SetScrollAdjustments (ScrollAdjustment hAdjustement, ScrollAdjustment vAdjustement)
+ protected override void SetScrollAdjustments (ScrollAdjustment horizontal, ScrollAdjustment vertical)
{
if (HexEditorData.HAdjustment != null)
HexEditorData.HAdjustment.ValueChanged -= HAdjustmentValueChanged;
if (HexEditorData.VAdjustment != null)
HexEditorData.VAdjustment.ValueChanged -= VAdjustmentValueChanged;
- HexEditorData.HAdjustment = hAdjustement;
- HexEditorData.VAdjustment = vAdjustement;
+ HexEditorData.HAdjustment = horizontal;
+ HexEditorData.VAdjustment = vertical;
- if (hAdjustement == null || vAdjustement == null)
+ if (horizontal == null || vertical == null)
return;
HexEditorData.HAdjustment.ValueChanged += HAdjustmentValueChanged;
@@ -326,7 +323,7 @@ protected override void SetScrollAdjustments (ScrollAdjustment hAdjustement, Scr
/* void UpdateAdjustments ()
{
- SetAdjustments (this.Bounds);
+ SetAdjustments (Bounds);
}
*/
@@ -340,13 +337,13 @@ void SetHAdjustment ()
if (HexEditorData.HAdjustment == null)
return;
/* textEditorData.HAdjustment.ValueChanged -= HAdjustmentValueChanged;
- if (longestLine != null && this.textEditorData.HAdjustment != null) {
- int maxX = longestLineWidth + 2 * this.textViewMargin.CharWidth;
- int width = Bounds.Width - this.TextViewMargin.XOffset;
+ if (longestLine != null && textEditorData.HAdjustment != null) {
+ int maxX = longestLineWidth + 2 * textViewMargin.CharWidth;
+ int width = Bounds.Width - TextViewMargin.XOffset;
- this.textEditorData.HAdjustment.SetBounds (0, maxX, this.textViewMargin.CharWidth, width, width);
+ textEditorData.HAdjustment.SetBounds (0, maxX, textViewMargin.CharWidth, width, width);
if (maxX < width)
- this.textEditorData.HAdjustment.Value = 0;
+ textEditorData.HAdjustment.Value = 0;
}
textEditorData.HAdjustment.ValueChanged += HAdjustmentValueChanged;*/
}
@@ -375,47 +372,47 @@ internal void SetAdjustments (Rectangle allocation)
#region Drawing
- protected override void OnDraw (Context ctx, Rectangle area)
+ protected override void OnDraw (Context ctx, Rectangle dirtyRect)
{
- int reminder = (int)HexEditorData.VAdjustment.Value % (int)LineHeight;
+ int reminder = (int)HexEditorData.VAdjustment.Value % LineHeight;
long firstLine = (long)(HexEditorData.VAdjustment.Value / (long)LineHeight);
- long startLine = (long)(area.Top + reminder) / (int)this.LineHeight;
- long endLine = (long)(area.Bottom + reminder) / (int)this.LineHeight - 1;
- if ((area.Bottom + reminder) % (int)this.LineHeight != 0)
+ long startLine = (long)(dirtyRect.Top + reminder) / (int)LineHeight;
+ long endLine = (long)(dirtyRect.Bottom + reminder) / (int)LineHeight - 1;
+ if ((dirtyRect.Bottom + reminder) % (int)LineHeight != 0)
endLine++;
// Initialize the rendering of the margins. Determine wether each margin has to be
// rendered or not and calculate the X offset.
- List<Margin> marginsToRender = new List<Margin> ();
+ var marginsToRender = new List<Margin> ();
double curX = 0;
- foreach (Margin margin in this.margins) {
+ foreach (Margin margin in margins) {
if (margin.IsVisible) {
margin.XOffset = curX;
- if (curX >= area.X || margin.Width < 0)
+ if (curX >= dirtyRect.X || margin.Width < 0)
marginsToRender.Add (margin);
curX += margin.Width;
}
}
- int curY = (int)(startLine * this.LineHeight - reminder);
+ int curY = (int)(startLine * LineHeight - reminder);
for (long visualLineNumber = startLine; visualLineNumber <= endLine; visualLineNumber++) {
long logicalLineNumber = visualLineNumber + firstLine;
foreach (Margin margin in marginsToRender) {
try {
- margin.Draw (ctx, area, logicalLineNumber, margin.XOffset, curY);
+ margin.Draw (ctx, dirtyRect, logicalLineNumber, margin.XOffset, curY);
} catch (Exception e) {
- System.Console.WriteLine (e);
+ Console.WriteLine (e);
}
}
curY += LineHeight;
- if (curY > area.Bottom)
+ if (curY > dirtyRect.Bottom)
break;
}
if (requestResetCaretBlink) {
ResetCaretBlink ();
requestResetCaretBlink = false;
}
- DrawCaret (ctx, area);
+ DrawCaret (ctx, dirtyRect);
}
public void RepaintLine (long line)
@@ -424,7 +421,7 @@ public void RepaintLine (long line)
long lastVisibleLine = (long)(HexEditorData.VAdjustment.Value + Bounds.Height) / LineHeight;
margins.ForEach (margin => margin.PurgeLayoutCache (line));
if (firstVisibleLine <= line && line <= lastVisibleLine)
- QueueDraw (new Rectangle (0, (int)(line * LineHeight - HexEditorData.VAdjustment.Value), Bounds.Width, LineHeight));
+ QueueDraw (new Rectangle (0, (line * LineHeight - HexEditorData.VAdjustment.Value), Bounds.Width, LineHeight));
}
public void RepaintLines (long start, long end)
@@ -432,12 +429,12 @@ public void RepaintLines (long start, long end)
long firstVisibleLine = (long)(HexEditorData.VAdjustment.Value / LineHeight);
long lastVisibleLine = (long)(HexEditorData.VAdjustment.Value + Bounds.Height) / LineHeight;
- start = System.Math.Max (start, firstVisibleLine);
- end = System.Math.Min (end, lastVisibleLine);
+ start = Math.Max (start, firstVisibleLine);
+ end = Math.Min (end, lastVisibleLine);
for (long line = start; line <= end; line++)
margins.ForEach (margin => margin.PurgeLayoutCache (line));
- RepaintArea (0, (int)(start * LineHeight - HexEditorData.VAdjustment.Value), Bounds.Width, (int)((end - start) * LineHeight));
+ RepaintArea (0, (start * LineHeight - HexEditorData.VAdjustment.Value), Bounds.Width, (int)((end - start) * LineHeight));
}
public void RepaintArea (double x, double y, double width, double height)
@@ -456,8 +453,8 @@ public void Repaint ()
QueueDraw ();
}
- Timer caretTimer = null;
- object lockObject = new object ();
+ Timer caretTimer;
+ readonly object lockObject = new object ();
public void ResetCaretBlink ()
{
@@ -499,7 +496,7 @@ void UpdateCaret (object sender, EventArgs args)
#endregion
#region Caret
- bool requestResetCaretBlink = false;
+ bool requestResetCaretBlink;
bool caretBlink = true;
public void RequestResetCaretBlink ()
{
@@ -544,7 +541,7 @@ public void DrawCaret (Context ctx, Rectangle area)
public void ScrollToCaret ()
{
double caretY = HexEditorData.Caret.Offset / BytesInRow * LineHeight;
- HexEditorData.VAdjustment.Value = System.Math.Max (caretY - HexEditorData.VAdjustment.PageSize + LineHeight, System.Math.Min (caretY, HexEditorData.VAdjustment.Value));
+ HexEditorData.VAdjustment.Value = Math.Max (caretY - HexEditorData.VAdjustment.PageSize + LineHeight, Math.Min (caretY, HexEditorData.VAdjustment.Value));
}
#endregion
@@ -553,7 +550,7 @@ public void ScrollToCaret ()
protected override void OnBoundsChanged ()
{
base.OnBoundsChanged ();
- this.CalculateBytesInRow ();
+ CalculateBytesInRow ();
OptionsChanged (this, EventArgs.Empty);
SetAdjustments (Bounds);
OnBytesInRowChanged (EventArgs.Empty);
@@ -601,7 +598,7 @@ protected override bool OnScrollEvent (EventScroll evnt)
Options.ZoomIn ();
else
Options.ZoomOut ();
- this.Repaint ();
+ Repaint ();
return true;
}
return base.OnScrollEvent (evnt);
@@ -638,44 +635,44 @@ protected override void OnRealized ()
}*/
internal int pressedButton = -1;
- protected override void OnButtonPressed (ButtonEventArgs e)
+ protected override void OnButtonPressed (ButtonEventArgs args)
{
- base.OnButtonPressed (e);
- this.SetFocus ();
- if (e.Button != PointerButton.Left)
+ base.OnButtonPressed (args);
+ SetFocus ();
+ if (args.Button != PointerButton.Left)
return;
- pressedButton = (int)e.Button;
- Margin margin = GetMarginAtX ((int)e.X);
+ pressedButton = (int)args.Button;
+ Margin margin = GetMarginAtX ((int)args.X);
if (margin != null)
- margin.MousePressed (new MarginMouseEventArgs (this, margin, e));
+ margin.MousePressed (new MarginMouseEventArgs (this, margin, args));
}
- protected override void OnButtonReleased (ButtonEventArgs e)
+ protected override void OnButtonReleased (ButtonEventArgs args)
{
- base.OnButtonReleased (e);
+ base.OnButtonReleased (args);
- if (e.Button != PointerButton.Left)
+ if (args.Button != PointerButton.Left)
return;
pressedButton = -1;
- Margin margin = GetMarginAtX ((int)e.X);
+ Margin margin = GetMarginAtX ((int)args.X);
if (margin != null)
- margin.MouseReleased (new MarginMouseEventArgs (this, margin, e));
+ margin.MouseReleased (new MarginMouseEventArgs (this, margin, args));
}
- protected override void OnMouseMoved (MouseMovedEventArgs e)
+ protected override void OnMouseMoved (MouseMovedEventArgs args)
{
- base.OnMouseMoved (e);
+ base.OnMouseMoved (args);
- Margin margin = GetMarginAtX ((int)e.X);
+ Margin margin = GetMarginAtX ((int)args.X);
if (margin != null)
- margin.MouseHover (new MarginMouseMovedEventArgs (this, margin, e));
+ margin.MouseHover (new MarginMouseMovedEventArgs (this, margin, args));
}
Margin GetMarginAtX (int x)
{
- return this.margins.FirstOrDefault (margin => margin.XOffset <= x && x < margin.XOffset + margin.Width);
+ return margins.FirstOrDefault (margin => margin.XOffset <= x && x < margin.XOffset + margin.Width);
}
#endregion
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex/HexEditorOptions.cs
===================================================================
@@ -32,7 +32,7 @@ namespace Mono.MHex
class HexEditorOptions : IHexEditorOptions, IDisposable
{
public const string DEFAULT_FONT = "Mono 10";
- static HexEditorOptions options = new HexEditorOptions ();
+ static readonly HexEditorOptions options = new HexEditorOptions ();
public static HexEditorOptions DefaultOptions {
get {
return options;
@@ -67,12 +67,12 @@ class HexEditorOptions : IHexEditorOptions, IDisposable
public void ZoomIn ()
{
zoom *= 1.1;
- Zoom = System.Math.Min (8.0, System.Math.Max (0.7, zoom));
+ Zoom = Math.Min (8.0, Math.Max (0.7, zoom));
}
public void ZoomOut ()
{
zoom *= 0.9;
- Zoom = System.Math.Min (8.0, System.Math.Max (0.7, zoom));
+ Zoom = Math.Min (8.0, Math.Max (0.7, zoom));
}
public void ZoomReset ()
{
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex/MiscActions.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Mono.MHex.Data;
namespace Mono.MHex
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex/ScrollActions.cs
===================================================================
@@ -33,13 +33,13 @@ static class ScrollActions
{
public static void Up (HexEditorData data)
{
- data.VAdjustment.Value = System.Math.Max (data.VAdjustment.LowerValue,
+ data.VAdjustment.Value = Math.Max (data.VAdjustment.LowerValue,
data.VAdjustment.Value - data.VAdjustment.StepIncrement);
}
public static void Down (HexEditorData data)
{
- data.VAdjustment.Value = System.Math.Min (data.VAdjustment.UpperValue - data.VAdjustment.PageSize,
+ data.VAdjustment.Value = Math.Min (data.VAdjustment.UpperValue - data.VAdjustment.PageSize,
data.VAdjustment.Value + data.VAdjustment.StepIncrement);
}
}
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex/SelectionActions.cs
===================================================================
@@ -67,7 +67,7 @@ public static void EndSelection (HexEditorData data)
public static void Select (HexEditorData data, Action<HexEditorData> caretMoveAction)
{
- PositionChangedHandler handler = new PositionChangedHandler (data);
+ var handler = new PositionChangedHandler (data);
data.Caret.OffsetChanged += handler.DataCaretPositionChanged;
StartSelection (data);
@@ -79,7 +79,7 @@ public static void Select (HexEditorData data, Action<HexEditorData> caretMoveAc
class PositionChangedHandler
{
- HexEditorData data;
+ readonly HexEditorData data;
public PositionChangedHandler (HexEditorData data)
{
Modified: main/src/addins/MonoDevelop.HexEditor/Mono.MHex/SimpleEditMode.cs
===================================================================
@@ -33,7 +33,7 @@ namespace Mono.MHex
{
class SimpleEditMode : EditMode
{
- Dictionary<int, Action<HexEditorData>> keyBindings = new Dictionary<int, Action<HexEditorData>> ();
+ readonly Dictionary<int, Action<HexEditorData>> keyBindings = new Dictionary<int, Action<HexEditorData>> ();
public SimpleEditMode ()
Modified: main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/DisplayBinding.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System.IO;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Projects;
Modified: main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorNodeExtension.cs
===================================================================
@@ -53,9 +53,9 @@ class HexEditorCommandHandler: NodeCommandHandler
[CommandHandler (Commands.ShowHexEditor)]
protected void OnShowHexEditor ()
{
- HexEditorView view = new HexEditorView ();
+ var view = new HexEditorView ();
- ProjectFile file = CurrentNode.DataItem as ProjectFile;
+ var file = CurrentNode.DataItem as ProjectFile;
if (file != null)
view.Load (file.FilePath);
Modified: main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorView.cs
===================================================================
@@ -36,10 +36,10 @@ namespace MonoDevelop.HexEditor
{
class HexEditorView : AbstractXwtViewContent, IUndoHandler, IBookmarkBuffer, IZoomable
{
- Mono.MHex.HexEditor hexEditor = new Mono.MHex.HexEditor ();
- ScrollView window ;
+ readonly Mono.MHex.HexEditor hexEditor = new Mono.MHex.HexEditor ();
+ readonly ScrollView window;
- public override Xwt.Widget Widget {
+ public override Widget Widget {
get {
return window;
}
@@ -69,7 +69,7 @@ public override void Save (string fileName)
{
File.WriteAllBytes (fileName, hexEditor.HexEditorData.Bytes);
ContentName = fileName;
- this.IsDirty = false;
+ IsDirty = false;
}
public override void Load (string fileName)
@@ -79,7 +79,7 @@ public override void Load (string fileName)
}
ContentName = fileName;
- this.IsDirty = false;
+ IsDirty = false;
hexEditor.SetFocus ();
}
Modified: main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs
===================================================================
@@ -40,10 +40,6 @@ public class HexEditorVisualizer : ValueVisualizer
{
Mono.MHex.HexEditor hexEditor;
- public HexEditorVisualizer ()
- {
- }
-
#region IValueVisualizer implementation
public override string Name {
@@ -143,7 +139,7 @@ public override bool CanEdit (ObjectValue val)
#endregion
}
- class RawStringBuffer : Mono.MHex.Data.IBuffer
+ class RawStringBuffer : IBuffer
{
readonly RawValueString array;
long offset;
@@ -204,7 +200,7 @@ public byte[] GetBytes (long index, int count)
#endregion
}
- abstract class RawArrayBuffer : Mono.MHex.Data.IBuffer
+ abstract class RawArrayBuffer : IBuffer
{
readonly RawValueArray array;
protected long Offset;
Modified: main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/MonoDevelopHexEditorStyle.cs
===================================================================
@@ -24,13 +24,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using Mono.TextEditor.Highlighting;
using Mono.MHex.Rendering;
-using Xwt;
-using MonoDevelop.Core;
using MonoDevelop.Ide;
-using Mono.TextEditor;
using Xwt.Drawing;
namespace MonoDevelop.HexEditor
@@ -38,7 +34,7 @@ namespace MonoDevelop.HexEditor
class MonoDevelopHexEditorStyle : HexEditorStyle
{
ColorScheme colorStyle;
- Mono.MHex.HexEditor hexEditor;
+ readonly Mono.MHex.HexEditor hexEditor;
public MonoDevelopHexEditorStyle (Mono.MHex.HexEditor hexEditor)
{
Commit: ce790ab7004fa32d3d78abfe202b6e5a74b7080a
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 01:47:56 GMT
URL: https://github.com/mono/monodevelop/commit/ce790ab7004fa32d3d78abfe202b6e5a74b7080a
[Cleanup] Mono.TextTemplating.Tests cleanup
Changed paths:
M main/src/addins/TextTemplating/Mono.TextTemplating.Tests/DummyHost.cs
M main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs
M main/src/addins/TextTemplating/Mono.TextTemplating.Tests/ParsingTests.cs
M main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs
M main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplatingEngineHelper.cs
Modified: main/src/addins/TextTemplating/Mono.TextTemplating.Tests/DummyHost.cs
===================================================================
@@ -37,8 +37,8 @@ public class DummyHost : ITextTemplatingEngineHost
public readonly Dictionary<string, string> Locations = new Dictionary<string, string> ();
public readonly Dictionary<string, string> Contents = new Dictionary<string, string> ();
public readonly Dictionary<string, object> HostOptions = new Dictionary<string, object> ();
- List<string> standardAssemblyReferences = new List<string> ();
- List<string> standardImports = new List<string> ();
+ readonly List<string> standardAssemblyReferences = new List<string> ();
+ readonly List<string> standardImports = new List<string> ();
public readonly CompilerErrorCollection Errors = new CompilerErrorCollection ();
public readonly Dictionary<string, Type> DirectiveProcessors = new Dictionary<string, Type> ();
@@ -68,7 +68,7 @@ public virtual AppDomain ProvideTemplatingAppDomain (string content)
public virtual string ResolveAssemblyReference (string assemblyReference)
{
- throw new System.NotImplementedException();
+ throw new NotImplementedException();
}
public virtual Type ResolveDirectiveProcessor (string processorName)
@@ -80,22 +80,22 @@ public virtual Type ResolveDirectiveProcessor (string processorName)
public virtual string ResolveParameterValue (string directiveId, string processorName, string parameterName)
{
- throw new System.NotImplementedException();
+ throw new NotImplementedException();
}
public virtual string ResolvePath (string path)
{
- throw new System.NotImplementedException();
+ throw new NotImplementedException();
}
public virtual void SetFileExtension (string extension)
{
- throw new System.NotImplementedException();
+ throw new NotImplementedException();
}
public virtual void SetOutputEncoding (System.Text.Encoding encoding, bool fromOutputDirective)
{
- throw new System.NotImplementedException();
+ throw new NotImplementedException();
}
public virtual IList<string> StandardAssemblyReferences {
Modified: main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs
===================================================================
@@ -25,7 +25,6 @@
// THE SOFTWARE.
using System;
-using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using Microsoft.VisualStudio.TextTemplating;
@@ -49,7 +48,7 @@ public void Generate ()
public void GenerateMacNewlines ()
{
string MacInput = ParsingTests.ParseSample1.Replace ("\n", "\r");
- string MacOutput = OutputSample1.Replace ("\\n", "\\r").Replace ("\n", "\r");;
+ string MacOutput = OutputSample1.Replace ("\\n", "\\r").Replace ("\n", "\r");
Generate (MacInput, MacOutput, "\r");
}
@@ -65,7 +64,7 @@ public void GenerateWindowsNewlines ()
// in order to match the newlines in the verbatim code blocks
void Generate (string input, string expectedOutput, string newline)
{
- DummyHost host = new DummyHost ();
+ var host = new DummyHost ();
string className = "GeneratedTextTransformation4f504ca0";
string code = GenerateCode (host, input, className, newline);
Assert.AreEqual (0, host.Errors.Count);
@@ -100,7 +99,7 @@ string GenerateCode (ITextTemplatingEngineHost host, string content, string name
}
var opts = new System.CodeDom.Compiler.CodeGeneratorOptions ();
- using (var writer = new System.IO.StringWriter ()) {
+ using (var writer = new StringWriter ()) {
writer.NewLine = generatorNewline;
settings.Provider.GenerateCodeFromCompileUnit (ccu, writer, opts);
return writer.ToString ();
Modified: main/src/addins/TextTemplating/Mono.TextTemplating.Tests/ParsingTests.cs
===================================================================
@@ -24,7 +24,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
using NUnit.Framework;
@@ -53,7 +52,7 @@ Line Four
public void TokenTest ()
{
string tf = "test.input";
- Tokeniser tk = new Tokeniser (tf, ParseSample1);
+ var tk = new Tokeniser (tf, ParseSample1);
//line 1
Assert.IsTrue (tk.Advance ());
@@ -138,9 +137,9 @@ public void ParseTest ()
{
string tf = "test.input";
- ParsedTemplate pt = new ParsedTemplate ("test.input");
- Tokeniser tk = new Tokeniser (tf, ParseSample1);
- DummyHost host = new DummyHost ();
+ var pt = new ParsedTemplate ("test.input");
+ var tk = new Tokeniser (tf, ParseSample1);
+ var host = new DummyHost ();
pt.Parse (host, tk);
Assert.AreEqual (0, pt.Errors.Count);
Modified: main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs
===================================================================
@@ -26,11 +26,7 @@
using System;
using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using System.IO;
using NUnit.Framework;
-using Microsoft.VisualStudio.TextTemplating;
-
namespace Mono.TextTemplating.Tests
{
[TestFixture]
@@ -65,7 +61,7 @@ public void Preprocess_ControlBlockAfterIncludedTemplateWithClassFeatureBlock_Re
string Preprocess (string input)
{
- DummyHost host = new DummyHost ();
+ var host = new DummyHost ();
return Preprocess (input, host);
}
@@ -73,16 +69,13 @@ string Preprocess (string input, DummyHost host)
{
string className = "PreprocessedTemplate";
string classNamespace = "Templating";
- string language = null;
- string[] references = null;
+ string language;
+ string[] references;
- TemplatingEngine engine = new TemplatingEngine ();
+ var engine = new TemplatingEngine ();
string output = engine.PreprocessTemplate (input, host, className, classNamespace, out language, out references);
ReportErrors (host.Errors);
- if (output != null) {
- return TemplatingEngineHelper.CleanCodeDom (output, "\n");
- }
- return null;
+ return output != null ? TemplatingEngineHelper.CleanCodeDom (output, "\n") : null;
}
void ReportErrors(CompilerErrorCollection errors)
@@ -94,7 +87,7 @@ void ReportErrors(CompilerErrorCollection errors)
DummyHost CreateDummyHostForControlBlockAfterIncludedTemplateWithClassFeatureBlockTest()
{
- DummyHost host = new DummyHost ();
+ var host = new DummyHost ();
string includeTemplateFileName = @"d:\test\IncludedFile.tt";
host.Locations.Add (includeTemplateFileName, includeTemplateFileName);
Modified: main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplatingEngineHelper.cs
===================================================================
@@ -57,9 +57,7 @@ public static string CleanCodeDom (string input, string newLine)
afterLineDirective = false;
}
- if (line.Contains ("#line")) {
- afterLineDirective = true;
- }
+ afterLineDirective |= line.Contains ("#line");
writer.Write (line);
writer.Write (newLine);
Commit: 10aeefdaf780d81bd03c0c3005fdfe22da14f439
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-12 01:47:57 GMT
URL: https://github.com/mono/monodevelop/commit/10aeefdaf780d81bd03c0c3005fdfe22da14f439
[Cleanup] MonoDevelop.RegexToolkit cleanup
Changed paths:
M main/src/addins/MonoDevelop.RegexToolkit/AddinInfo.cs
M main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/Commands.cs
M main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/ElementHelpWidget.cs
M main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexToolkitWidget.cs
M main/src/addins/MonoDevelop.RegexToolkit/gtk-gui/gui.stetic
Modified: main/src/addins/MonoDevelop.RegexToolkit/AddinInfo.cs
===================================================================
@@ -1,8 +1,5 @@
-using System;
using Mono.Addins;
-using Mono.Addins.Description;
-
[assembly:Addin ("RegexToolkit",
Namespace = "MonoDevelop",
Version = MonoDevelop.BuildInfo.Version,
Modified: main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/Commands.cs
===================================================================
@@ -42,7 +42,7 @@ enum Commands
class ViewOnlyContent : AbstractViewContent
{
- Widget widget;
+ readonly Widget widget;
public override Widget Control {
get {
@@ -53,27 +53,27 @@ class ViewOnlyContent : AbstractViewContent
public ViewOnlyContent (Widget widget, string contentName)
{
this.widget = widget;
- this.ContentName = contentName;
+ ContentName = contentName;
IsViewOnly = true;
}
public override void Load (string fileName)
{
- throw new System.NotImplementedException ();
+ throw new NotImplementedException ();
}
}
class DefaultAttachableViewContent : AbstractAttachableViewContent
{
- Widget widget;
+ readonly Widget widget;
public override Widget Control {
get {
return widget;
}
}
- string tabPageLabel;
+ readonly string tabPageLabel;
public override string TabPageLabel {
get {
return tabPageLabel;
Modified: main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/ElementHelpWidget.cs
===================================================================
@@ -25,17 +25,15 @@
// THE SOFTWARE.
using System;
using Gtk;
-using System.Text.RegularExpressions;
using System.IO;
using System.Xml;
using MonoDevelop.Core;
-using MonoDevelop.Ide;
using MonoDevelop.Ide.Gui;
namespace MonoDevelop.RegexToolkit
{
[System.ComponentModel.ToolboxItem(true)]
- partial class ElementHelpWidget : Gtk.Bin
+ partial class ElementHelpWidget : Bin
{
TreeStore elementsStore;
// IWorkbenchWindow workbenchWindow;
@@ -47,7 +45,7 @@ public ElementHelpWidget (IWorkbenchWindow workbenchWindow, RegexToolkitWidget r
// this.regexWidget = regexWidget;
this.Build ();
- elementsStore = new Gtk.TreeStore (typeof(string), typeof(string), typeof(string), typeof(string));
+ elementsStore = new TreeStore (typeof(string), typeof(string), typeof(string), typeof(string));
this.elementsTreeview.Model = this.elementsStore;
this.elementsTreeview.HeadersVisible = false;
this.elementsTreeview.Selection.Mode = SelectionMode.Browse;
@@ -74,10 +72,10 @@ public ElementHelpWidget (IWorkbenchWindow workbenchWindow, RegexToolkitWidget r
// this.elementsTreeview.MotionNotifyEvent += HandleMotionNotifyEvent;
this.elementsTreeview.RowActivated += delegate (object sender, RowActivatedArgs e) {
- Gtk.TreeIter iter;
+ TreeIter iter;
if (elementsStore.GetIter (out iter, e.Path)) {
string text = elementsStore.GetValue (iter, 3) as string;
- if (!System.String.IsNullOrEmpty (text)) {
+ if (!String.IsNullOrEmpty (text)) {
regexWidget.InsertText (text);
workbenchWindow.SwitchView (0);
}
@@ -97,7 +95,7 @@ void ElementDescriptionFunc (TreeViewColumn column, CellRenderer cell, TreeModel
cell.Visible = false;
return;
}
- CellRendererText txtRenderer = (CellRendererText)cell;
+ var txtRenderer = (CellRendererText)cell;
txtRenderer.Visible = true;
txtRenderer.Text = str;
}
@@ -115,14 +113,14 @@ void FillElementsBox ()
continue;
switch (reader.LocalName) {
case "Group":
- TreeIter groupIter = this.elementsStore.AppendValues (Gtk.Stock.Info,
+ TreeIter groupIter = elementsStore.AppendValues (Gtk.Stock.Info,
GettextCatalog.GetString (reader.GetAttribute ("_name")), "", "");
while (reader.Read ()) {
if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "Group")
break;
switch (reader.LocalName) {
case "Element":
- this.elementsStore.AppendValues (groupIter, null,
+ elementsStore.AppendValues (groupIter, null,
GettextCatalog.GetString (reader.GetAttribute ("_name")),
GettextCatalog.GetString (reader.GetAttribute ("_description")),
reader.ReadElementString ());
Modified: main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit/RegexToolkitWidget.cs
===================================================================
@@ -29,13 +29,10 @@
using System.Threading;
using MonoDevelop.Core;
using MonoDevelop.Ide;
-using System.IO;
-using System.Xml;
-
namespace MonoDevelop.RegexToolkit
{
[System.ComponentModel.ToolboxItem(true)]
- partial class RegexToolkitWidget : Gtk.Bin
+ partial class RegexToolkitWidget : Bin
{
ListStore optionsStore;
TreeStore resultStore;
@@ -46,7 +43,7 @@ public RegexToolkitWidget ()
{
this.Build ();
optionsStore = new ListStore (typeof(bool), typeof(string), typeof(Options));
- resultStore = new Gtk.TreeStore (typeof(string), typeof(string), typeof(int), typeof(int));
+ resultStore = new TreeStore (typeof(string), typeof(string), typeof(int), typeof(int));
FillOptionsBox ();
@@ -63,9 +60,7 @@ public RegexToolkitWidget ()
return;
}
- regexThread = new Thread (delegate() {
- PerformQuery (inputTextview.Buffer.Text, this.entryRegEx.Text, this.entryReplace.Text, GetOptions ());
- });
+ regexThread = new Thread (() => PerformQuery (inputTextview.Buffer.Text, this.entryRegEx.Text, this.entryReplace.Text, GetOptions ()));
regexThread.IsBackground = true;
regexThread.Name = "regex thread";
@@ -101,7 +96,7 @@ public RegexToolkitWidget ()
col.AddAttribute (cellRendText, "text", 1);
this.resultsTreeview.RowActivated += delegate(object sender, RowActivatedArgs e) {
- Gtk.TreeIter iter;
+ TreeIter iter;
if (resultStore.GetIter (out iter, e.Path)) {
int index = (int)resultStore.GetValue (iter, 2);
int length = (int)resultStore.GetValue (iter, 3);
@@ -126,46 +121,46 @@ public RegexToolkitWidget ()
public void InsertText (string text)
{
- this.entryRegEx.InsertText (text);
+ entryRegEx.InsertText (text);
}
void PerformQuery (string input, string pattern, string replacement, RegexOptions options)
{
try {
- Regex regex = new Regex (pattern, options);
+ var regex = new Regex (pattern, options);
Application.Invoke (delegate {
- this.resultStore.Clear ();
+ resultStore.Clear ();
var matches = regex.Matches (input);
foreach (Match match in matches) {
- TreeIter iter = this.resultStore.AppendValues (Stock.Find, String.Format (GettextCatalog.GetString ("Match '{0}'"), match.Value), match.Index, match.Length);
+ TreeIter iter = resultStore.AppendValues (Stock.Find, String.Format (GettextCatalog.GetString ("Match '{0}'"), match.Value), match.Index, match.Length);
int i = 0;
foreach (Group group in match.Groups) {
TreeIter groupIter;
if (group.Success) {
- groupIter = this.resultStore.AppendValues (iter, Stock.Apply, String.Format (GettextCatalog.GetString ("Group '{0}':'{1}'"), regex.GroupNameFromNumber (i), group.Value), group.Index, group.Length);
+ groupIter = resultStore.AppendValues (iter, Stock.Apply, String.Format (GettextCatalog.GetString ("Group '{0}':'{1}'"), regex.GroupNameFromNumber (i), group.Value), group.Index, group.Length);
foreach (Capture capture in match.Captures) {
- this.resultStore.AppendValues (groupIter, null, String.Format (GettextCatalog.GetString ("Capture '{0}'"), capture.Value), capture.Index, capture.Length);
+ resultStore.AppendValues (groupIter, null, String.Format (GettextCatalog.GetString ("Capture '{0}'"), capture.Value), capture.Index, capture.Length);
}
} else {
- groupIter = this.resultStore.AppendValues (iter, Stock.Cancel, String.Format (GettextCatalog.GetString ("Group '{0}' not found"), regex.GroupNameFromNumber (i)), -1, -1);
+ groupIter = resultStore.AppendValues (iter, Stock.Cancel, String.Format (GettextCatalog.GetString ("Group '{0}' not found"), regex.GroupNameFromNumber (i)), -1, -1);
}
i++;
}
}
if (matches.Count == 0) {
- this.resultStore.AppendValues (Stock.Find, GettextCatalog.GetString ("No matches"));
+ resultStore.AppendValues (Stock.Find, GettextCatalog.GetString ("No matches"));
}
- if (this.expandMatches.Active) {
- this.resultsTreeview.ExpandAll ();
+ if (expandMatches.Active) {
+ resultsTreeview.ExpandAll ();
}
if (!String.IsNullOrEmpty (replacement))
- this.replaceResultTextview.Buffer.Text = regex.Replace (input, replacement);
+ replaceResultTextview.Buffer.Text = regex.Replace (input, replacement);
});
} catch (ThreadAbortException) {
Thread.ResetAbort ();
} catch (ArgumentException) {
Application.Invoke (delegate {
- Ide.IdeApp.Workbench.StatusBar.ShowError (GettextCatalog.GetString ("Invalid expression"));
+ IdeApp.Workbench.StatusBar.ShowError (GettextCatalog.GetString ("Invalid expression"));
});
} finally {
regexThread = null;
@@ -177,23 +172,23 @@ void PerformQuery (string input, string pattern, string replacement, RegexOption
void SetButtonStart (string text, string icon)
{
- ((Gtk.Label)((Gtk.HBox)((Gtk.Alignment)this.buttonStart.Child).Child).Children [1]).Text = text;
- ((Gtk.Label)((Gtk.HBox)((Gtk.Alignment)this.buttonStart.Child).Child).Children [1]).UseUnderline = true;
- ((Gtk.Image)((Gtk.HBox)((Gtk.Alignment)this.buttonStart.Child).Child).Children [0]).Pixbuf = global::Stetic.IconLoader.LoadIcon (this, icon, global::Gtk.IconSize.Menu);
+ ((Label)((HBox)((Alignment)buttonStart.Child).Child).Children [1]).Text = text;
+ ((Label)((HBox)((Alignment)buttonStart.Child).Child).Children [1]).UseUnderline = true;
+ ((Image)((HBox)((Alignment)buttonStart.Child).Child).Children [0]).Pixbuf = global::Stetic.IconLoader.LoadIcon (this, icon, IconSize.Menu);
}
void SetFindMode (bool findMode)
{
- this.notebook2.ShowTabs = !findMode;
+ notebook2.ShowTabs = !findMode;
if (findMode)
- this.notebook2.Page = 0;
+ notebook2.Page = 0;
}
void UpdateStartButtonSensitivity (object sender, EventArgs args)
{
- this.buttonStart.Sensitive = this.entryRegEx.Text.Length > 0 && inputTextview.Buffer.CharCount > 0;
- Ide.IdeApp.Workbench.StatusBar.ShowReady ();
+ buttonStart.Sensitive = entryRegEx.Text.Length > 0 && inputTextview.Buffer.CharCount > 0;
+ IdeApp.Workbench.StatusBar.ShowReady ();
}
protected override void OnDestroyed ()
@@ -213,14 +208,14 @@ protected override void OnDestroyed ()
RegexOptions GetOptions ()
{
RegexOptions result = RegexOptions.None;
- Gtk.TreeIter iter;
- if (this.optionsStore.GetIterFirst (out iter)) {
+ TreeIter iter;
+ if (optionsStore.GetIterFirst (out iter)) {
do {
- bool toggled = (bool)this.optionsStore.GetValue (iter, 0);
+ bool toggled = (bool)optionsStore.GetValue (iter, 0);
if (toggled) {
- result |= ((Options)this.optionsStore.GetValue (iter, 2)).RegexOptions;
+ result |= ((Options)optionsStore.GetValue (iter, 2)).RegexOptions;
}
- } while (this.optionsStore.IterNext (ref iter));
+ } while (optionsStore.IterNext (ref iter));
}
return result;
}
@@ -228,16 +223,16 @@ RegexOptions GetOptions ()
void OptionToggled (object sender, ToggledArgs e)
{
TreeIter iter;
- if (this.optionsStore.GetIterFromString (out iter, e.Path)) {
- bool toggled = (bool)this.optionsStore.GetValue (iter, 0);
- this.optionsStore.SetValue (iter, 0, !toggled);
+ if (optionsStore.GetIterFromString (out iter, e.Path)) {
+ bool toggled = (bool)optionsStore.GetValue (iter, 0);
+ optionsStore.SetValue (iter, 0, !toggled);
}
}
class Options
{
- RegexOptions options;
- string name;
+ readonly RegexOptions options;
+ readonly string name;
public string Name {
get {
@@ -269,7 +264,7 @@ void FillOptionsBox ()
new Options (RegexOptions.RightToLeft, GettextCatalog.GetString ("Right to left"))
};
foreach (Options option in options) {
- this.optionsStore.AppendValues (false, option.Name, option);
+ optionsStore.AppendValues (false, option.Name, option);
}
}
Modified: main/src/addins/MonoDevelop.RegexToolkit/gtk-gui/gui.stetic
===================================================================
@@ -355,6 +355,7 @@
<widget class="Gtk.Bin" id="MonoDevelop.RegexToolkit.ElementHelpWidget" design-size="300 300">
<property name="MemberName" />
<property name="Visible">False</property>
+ <property name="GeneratePublic">False</property>
<child>
<widget class="Gtk.VBox" id="vbox4">
<property name="MemberName" />
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches