From 6a93e919fb61922c8e692f975e0f008941f57e36 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 22 Feb 2013 18:18:23 +0100 Subject: [PATCH] Merge changes from SharpDevelop repository to NRefactory: - SemanticHighlightingVisitor: bugfix - TextLocation: add TypeConverter - CecilLoader: remove incorrect FullName implementation (it was broken for generic types) --- .../Analysis/SemanticHighlightingVisitor.cs | 1 - ICSharpCode.NRefactory/TextLocation.cs | 35 +++++++++++++++++++ .../TypeSystem/CecilLoader.cs | 5 --- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs b/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs index 5dee09f2f0..a2f0d60f3b 100644 --- a/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Analysis/SemanticHighlightingVisitor.cs @@ -201,7 +201,6 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis VisitChildrenUntil(memberReferenceExpression, memberNameToken); ResolveResult rr = resolver.Resolve(memberReferenceExpression); Colorize(memberNameToken, rr); - VisitChildren(memberReferenceExpression); VisitChildrenAfter(memberReferenceExpression, memberNameToken); } diff --git a/ICSharpCode.NRefactory/TextLocation.cs b/ICSharpCode.NRefactory/TextLocation.cs index 6580cd2f13..ef1b553d09 100644 --- a/ICSharpCode.NRefactory/TextLocation.cs +++ b/ICSharpCode.NRefactory/TextLocation.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.ComponentModel; using System.Globalization; namespace ICSharpCode.NRefactory @@ -30,6 +31,7 @@ namespace ICSharpCode.NRefactory /// to convert between offsets and TextLocations. /// [Serializable] + [TypeConverter(typeof(TextLocationConverter))] public struct TextLocation : IComparable, IEquatable { /// @@ -185,4 +187,37 @@ namespace ICSharpCode.NRefactory return 1; } } + + public class TextLocationConverter : TypeConverter + { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + return destinationType == typeof(TextLocation) || base.CanConvertTo(context, destinationType); + } + + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + if (value is string) { + string[] parts = ((string)value).Split(';', ','); + if (parts.Length == 2) { + return new TextLocation(int.Parse(parts[0]), int.Parse(parts[1])); + } + } + return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (value is TextLocation) { + var loc = (TextLocation)value; + return loc.Line + ";" + loc.Column; + } + return base.ConvertTo(context, culture, value, destinationType); + } + } } diff --git a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs index 82b03f67d3..8127935e3a 100644 --- a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs +++ b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs @@ -1798,11 +1798,6 @@ namespace ICSharpCode.NRefactory.TypeSystem set { throw new NotSupportedException(); } } - public override string FullName { - // This works because LazyCecilTypeDefinition is only used for top-level types - get { return cecilTypeDef.FullName; } - } - public override string ReflectionName { get { return cecilTypeDef.FullName; } }