Revision: 8421
Author:
v...@rsdn.ru
Date: Tue Nov 3 07:48:08 2009
Log: Working on Integration: Implementing code hints. Type hint improved.
http://code.google.com/p/nemerle/source/detail?r=8421
Added:
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Hints
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Hints/Convert.n
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Hints/SubHintForType.n
Deleted:
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Convert.n
Modified:
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.nproj
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Utils.n
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Hint.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
=======================================
--- /dev/null
+++ /nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Hints/Convert.n Tue
Nov 3 07:48:08 2009
@@ -0,0 +1,182 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Nemerle.Imperative;
+using Nemerle.Collections;
+
+namespace Nemerle.Compiler.Utils
+{
+ [Record]
+ public class Convert
+ {
+ public ExpandTypeArgs : bool { get; set; }
+ public ConvertTypeName : MType * string -> string { get; set; }
+ public AddNamespaces : bool { get; set; }
+
+ [RecordIgnore] mutable _recursionLevel : int;
+
+ public this() { AddNamespaces = true; ExpandTypeArgs = true; }
+
+ CheckRecursionLevel() : void
+ {
+ assert(_recursionLevel < 20);
+ _recursionLevel++;
+ }
+
+ LookupName(ty : MType, name : string) : string
+ {
+ if (ConvertTypeName == null) name
+ else ConvertTypeName(ty, name)
+ }
+
+ public TypeVarToString(typeVar : TyVar, expandTypeArgs : bool) : string
+ {
+ def oldValue = ExpandTypeArgs;
+ ExpandTypeArgs = expandTypeArgs;
+ def res = TypeVarToString(typeVar);
+ ExpandTypeArgs = oldValue;
+ res
+ }
+
+ public FixedTypeToString(fixedType : MType, expandTypeArgs : bool) :
string
+ {
+ def oldValue = ExpandTypeArgs;
+ ExpandTypeArgs = expandTypeArgs;
+ def res = FixedTypeToString(fixedType);
+ ExpandTypeArgs = oldValue;
+ res
+ }
+
+ public FixedClassTypeToString(fixedType : MType.Class,
expandTypeArgs : bool) : string
+ {
+ def oldValue = ExpandTypeArgs;
+ ExpandTypeArgs = expandTypeArgs;
+ def res = FixedClassTypeToString(fixedType);
+ ExpandTypeArgs = oldValue;
+ res
+ }
+
+ public TypeVarToString(typeVar : TyVar) : string
+ {
+ | mTy is MType => FixedTypeToString(mTy)
+ | ty =>
+ match (ty.Hint)
+ {
+ | Some(mTy) => FixedTypeToString(mTy)
+ | None => "?"
+ }
+ }
+
+ public FixedTypeToString(fixedType : MType) : string
+ {
+ CheckRecursionLevel();
+ try
+ {
+ match(fixedType)
+ {
+ | Class as cls => FixedClassTypeToString(cls)
+ | TyVarRef(s) => s.ToString()
+ | Fun(t1, t2) => $ "$(TypeVarToString(t1)) ->
$(TypeVarToString(t2))"
+ | Tuple(lst) => $<#(..$(lst; " * "; TypeVarToString))#>
+ | Ref(t) => $ "ref $(TypeVarToString(t))"
+ | Out(t) => $ "out $(TypeVarToString(t))"
+ | Array(t, 1) =>
$<#$(LookupName(fixedType, "array"))[$(TypeVarToString(t))]#>
+ | Array(t, n) =>
$<#$(LookupName(fixedType, "array")).$n[$(TypeVarToString(t))]#>
+ | Void => LookupName(fixedType, "void")
+ | Intersection(lst) => $<#(ambiguity: ..$(lst; " | ";
TypeVarToString))#>
+ }
+ }
+ finally { _recursionLevel--; }
+ }
+
+ public FixedClassTypeToString(fixedType : MType.Class) : string
+ {
+ CheckRecursionLevel();
+ try
+ {
+ def (ti, tyArgs) = fixedType;
+ def simpleTypeToStr(ti, fixedType) : string
+ {
+ def trim = ti.FullName.Replace ("Nemerle.Core.", "");
+ def res =
+ match (trim)
+ {
+ | "System.Byte" => "byte"
+ | "System.SByte" => "sbyte"
+ | "System.Int16" => "short"
+ | "System.UInt16" => "ushort"
+ | "System.Int32" => "int"
+ | "System.UInt32" => "uint"
+ | "System.Int64" => "long"
+ | "System.UInt64" => "ulong"
+ | "System.Single" => "float"
+ | "System.Double" => "double"
+ | "System.Decimal" => "decimal"
+ | "System.String" => "string"
+ | "System.Object" => "object"
+ | "System.Boolean" => "bool"
+ | "System.Char" => "char"
+ | _ => null
+ };
+
+ if (res == null || ConvertTypeName == null) res
+ else ConvertTypeName(fixedType, res)
+ }
+
+ when (tyArgs.IsEmpty)
+ {
+ def simple = simpleTypeToStr(ti, fixedType);
+ when (simple != null)
+ return simple;
+ }
+
+ def getNamespace(ti : TypeInfo) : string
+ {
+ //ti.NamespaceNode.Parent.GetDisplayName()
+ match (ti.NamespaceNode.Parent.FullName)
+ {
+ | ["Nemerle", "Core", "list"]
+ | ["Nemerle", "Core", "list", "Nil"]
+ | ["Nemerle", "Core", "list", "Cons"] => "list"
+ | "Nemerle" :: "Core" :: name | name => $<#..$(name; ".")#>
+ }
+ }
+
+ def tyMap = Utils.MakeTyParamsToTyArgsMap(ti.Typarms, tyArgs,
Hashtable());
+ def tyToStr(tyParamBame : string)
+ {
+ TypeVarToString(tyMap[tyParamBame])
+ }
+ def makeStrForType(curTi : TypeInfo) : string * _
+ {
+ def (prefix, usedTyParams) =
+ if (curTi.DeclaringType != null)
makeStrForType(curTi.DeclaringType)
+ else if (AddNamespaces) (getNamespace(curTi),
List()); // (ns, [])
+ else ("", List()); // (ns, [])
+ def tyParmsNames = curTi.Typarms.MapLazy(_.Name);
+ def unusdTyParams = tyParmsNames.ExcludeLazy(usedTyParams);
+ def name =
+ if (ConvertTypeName == null) curTi.Name
+ else if (curTi.Equals(ti)) ConvertTypeName(fixedType,
curTi.Name)
+ else ConvertTypeName(MType.Class(curTi, unusdTyParams.Map(x =>
tyMap[x])), curTi.Name);
+ def nameWithTyArg =
+ if (unusdTyParams.IsEmpty()) name
+ else if (ExpandTypeArgs) $<#$name[..$(unusdTyParams; ", ";
tyToStr)]#>
+ else $<#$name[..$unusdTyParams]#>;
+
+ usedTyParams.AddRange(tyParmsNames);
+
+ if (prefix.IsNullOrEmpty())
+ (nameWithTyArg, usedTyParams)
+ else
+ ($"$prefix.$nameWithTyArg", usedTyParams)
+ }
+
+ makeStrForType(ti)[0]
+ }
+ finally { _recursionLevel--; }
+ }
+ }
+}
=======================================
--- /dev/null
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Hints/SubHintForType.n
Tue Nov 3 07:48:08 2009
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Nemerle.Collections;
+
+namespace Nemerle.Compiler.Utils
+{
+ class SubHintForType : Nemerle.Compiler.Utils.Convert
+ {
+ public this()
+ {
+ base(true, null, false);
+ ConvertTypeName = ConvertTypeNameImpl;
+ }
+
+ mutable _currentId = 1;
+ _idToTypeMap : Hashtable[int, MType] = Hashtable();
+
+ GetTypeId(ty : MType) : int
+ {
+ _currentId++;
+ _idToTypeMap.Add(_currentId, ty);
+ _currentId
+ }
+
+ ConvertTypeNameImpl(ty : MType, name : string) : string
+ {
+ $"<font color='DarkCyan'><hint value='$name' key='$(GetTypeId(ty))'
/></font>"
+ }
+
+ public GetDelayedHintHendler() : Func[string, string]
+ {
+ def makeTypeStr(key : string) : string
+ {
+ AddNamespaces = true;
+ ExpandTypeArgs = false;
+ def ty = _idToTypeMap[int.Parse(key)];
+
+ def makeDelegateExt(ti)
+ {
+ def m = ti.LookupMember("Invoke").Head;
+ "<lb/>Signature: " + FixedTypeToString(m.GetMemType()) + "<lb/>"
+ + "Inferred: " + TypeVarToString(ty.TypeOfMember(m))
+ }
+
+ def baseTypesInfo(ti : TypeInfo) : string
+ {
+ def implementsInfo(itfs : list[MType.Class]) : string
+ {
+ def plural = if (itfs.Length > 1) "s" else "";
+ def prompt = if (ti.IsInterface) $"Base interface$plural"
else "Implements";
+ if (itfs.IsEmpty) ""
+ else $<#<lb/>$prompt:<lb/> ..$(itfs; "<lb/> ";
FixedClassTypeToString)#>
+ }
+ def itfs1 = ti.GetDirectSuperTypes();
+ def baseType = ti.BaseType;
+ def itfs = if (baseType == null) itfs1 else itfs1.Tail;
+ if (baseType != null)
+ "<lb/>Base type: " +
TypeVarToString(ty.GetInstantiatedSuperType(baseType)) +
implementsInfo(itfs)
+ else implementsInfo(itfs)
+ }
+
+ def (kind, ext) =
+ match (ty)
+ {
+ | Class(ti, _args) =>
+ if (ti.IsInterface) ("interface ", baseTypesInfo(ti))
+ else if (ti.IsDelegate) ("delegate ", makeDelegateExt(ti))
+ else if (ti.IsEnum) ("enum ", "")
+ else if (ti.IsModule) ("module ", "")
+ else if (ti.IsValueType) ("value type ", "")
+ else
+ {
+ def text = "class ";
+ def text = if (ti.IsSealed) "sealed " + text else text;
+ def text = if (ti.IsAbstract) "abstract " + text else text;
+ def text = if (ti.IsObsolete) "obsolete " + text else text;
+ (text, baseTypesInfo(ti))
+ }
+
+ | TyVarRef => ("type parameter ", "")
+ | Fun => ("function type ", "")
+ | Tuple => ("tuple ", "")
+ | Array(_, rank) => ($"$rank dimention ", "")
+ | Ref => ("ref parameter ", "")
+ | Out => ("out parameter ", "")
+ | Void => ("", "")
+ | Intersection => ("", "")
+ };
+
+ $"<hint>$kind$(FixedTypeToString(ty))$ext</hint>"
+ }
+
+ makeTypeStr
+ }
+ }
+}
=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Convert.n Mon Nov
2 09:09:59 2009
+++ /dev/null
@@ -1,182 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Nemerle.Imperative;
-using Nemerle.Collections;
-
-namespace Nemerle.Compiler.Utils
-{
- [Record]
- public class Convert
- {
- public ExpandTypeArgs : bool { get; set; }
- public ConvertTypeName : MType * string -> string { get; set; }
- public AddNamespaces : bool { get; set; }
-
- [RecordIgnore] mutable _recursionLevel : int;
-
- public this() { AddNamespaces = true; ExpandTypeArgs = true; }
-
- CheckRecursionLevel() : void
- {
- assert(_recursionLevel < 20);
- _recursionLevel++;
- }
-
- LookupName(ty : MType, name : string) : string
- {
- if (ConvertTypeName == null) name
- else ConvertTypeName(ty, name)
- }
-
- public TypeVarToString(typeVar : TyVar, expandTypeArgs : bool) : string
- {
- def oldValue = ExpandTypeArgs;
- ExpandTypeArgs = expandTypeArgs;
- def res = TypeVarToString(typeVar);
- ExpandTypeArgs = oldValue;
- res
- }
-
- public FixedTypeToString(fixedType : MType, expandTypeArgs : bool) :
string
- {
- def oldValue = ExpandTypeArgs;
- ExpandTypeArgs = expandTypeArgs;
- def res = FixedTypeToString(fixedType);
- ExpandTypeArgs = oldValue;
- res
- }
-
- public FixedClassTypeToString(fixedType : MType.Class,
expandTypeArgs : bool) : string
- {
- def oldValue = ExpandTypeArgs;
- ExpandTypeArgs = expandTypeArgs;
- def res = FixedClassTypeToString(fixedType);
- ExpandTypeArgs = oldValue;
- res
- }
-
- public TypeVarToString(typeVar : TyVar) : string
- {
- | mTy is MType => FixedTypeToString(mTy)
- | ty =>
- match (ty.Hint)
- {
- | Some(mTy) => FixedTypeToString(mTy)
- | None => "?"
- }
- }
-
- public FixedTypeToString(fixedType : MType) : string
- {
- CheckRecursionLevel();
- try
- {
- match(fixedType)
- {
- | Class as cls => FixedClassTypeToString(cls)
- | TyVarRef(s) => s.ToString()
- | Fun(t1, t2) => $ "$(TypeVarToString(t1)) ->
$(TypeVarToString(t2))"
- | Tuple(lst) => $<#(..$(lst; " * "; TypeVarToString))#>
- | Ref(t) => $ "ref $(TypeVarToString(t))"
- | Out(t) => $ "out $(TypeVarToString(t))"
- | Array(t, 1) =>
$<#$(LookupName(fixedType, "array"))[$(TypeVarToString(t))]#>
- | Array(t, n) =>
$<#$(LookupName(fixedType, "array")).$n[$(TypeVarToString(t))]#>
- | Void => LookupName(fixedType, "void")
- | Intersection(lst) => $<#(ambiguity: ..$(lst; " | ";
TypeVarToString))#>
- }
- }
- finally { _recursionLevel--; }
- }
-
- public FixedClassTypeToString(fixedType : MType.Class) : string
- {
- CheckRecursionLevel();
- try
- {
- def (ti, tyArgs) = fixedType;
- def simpleTypeToStr(ti, fixedType) : string
- {
- def trim = ti.FullName.Replace ("Nemerle.Core.", "");
- def res =
- match (trim)
- {
- | "System.Byte" => "byte"
- | "System.SByte" => "sbyte"
- | "System.Int16" => "short"
- | "System.UInt16" => "ushort"
- | "System.Int32" => "int"
- | "System.UInt32" => "uint"
- | "System.Int64" => "long"
- | "System.UInt64" => "ulong"
- | "System.Single" => "float"
- | "System.Double" => "double"
- | "System.Decimal" => "decimal"
- | "System.String" => "string"
- | "System.Object" => "object"
- | "System.Boolean" => "bool"
- | "System.Char" => "char"
- | _ => null
- };
-
- if (res == null || ConvertTypeName == null) res
- else ConvertTypeName(fixedType, res)
- }
-
- when (tyArgs.IsEmpty)
- {
- def simple = simpleTypeToStr(ti, fixedType);
- when (simple != null)
- return simple;
- }
-
- def getNamespace(ti : TypeInfo) : string
- {
- //ti.NamespaceNode.Parent.GetDisplayName()
- match (ti.NamespaceNode.Parent.FullName)
- {
- | ["Nemerle", "Core", "list"]
- | ["Nemerle", "Core", "list", "Nil"]
- | ["Nemerle", "Core", "list", "Cons"] => "list"
- | "Nemerle" :: "Core" :: name | name => $<#..$(name; ".")#>
- }
- }
-
- def tyMap = Utils.MakeTyParamsToTyArgsMap(ti.Typarms, tyArgs,
Hashtable());
- def tyToStr(tyParamBame : string)
- {
- TypeVarToString(tyMap[tyParamBame])
- }
- def makeStrForType(curTi : TypeInfo) : string * _
- {
- def (prefix, usedTyParams) =
- if (curTi.DeclaringType != null)
makeStrForType(curTi.DeclaringType)
- else if (AddNamespaces) (getNamespace(curTi),
List()); // (ns, [])
- else ("", List()); // (ns, [])
- def tyParmsNames = curTi.Typarms.MapLazy(_.Name);
- def unusdTyParams = tyParmsNames.ExcludeLazy(usedTyParams);
- def name =
- if (ConvertTypeName == null) curTi.Name
- else if (curTi.Equals(ti)) ConvertTypeName(fixedType,
curTi.Name)
- else ConvertTypeName(MType.Class(curTi, unusdTyParams.Map(x =>
tyMap[x])), curTi.Name);
- def nameWithTyArg =
- if (unusdTyParams.IsEmpty()) name
- else if (ExpandTypeArgs) $<#$name[..$(unusdTyParams; ", ";
tyToStr)]#>
- else $<#$name[..$unusdTyParams]#>;
-
- usedTyParams.AddRange(tyParmsNames);
-
- if (prefix.IsNullOrEmpty())
- (nameWithTyArg, usedTyParams)
- else
- ($"$prefix.$nameWithTyArg", usedTyParams)
- }
-
- makeStrForType(ti)[0]
- }
- finally { _recursionLevel--; }
- }
- }
-}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
Mon Nov 2 09:09:59 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
Tue Nov 3 07:48:08 2009
@@ -289,9 +289,12 @@
<Compile
Include="Nemerle.Completion2\CodeModel\InterfaceMemberImplSourceGenerator.n"
/>
</ItemGroup>
<ItemGroup>
- <Compile Include="Convert.n" />
+ <Compile Include="Hints\Convert.n" />
<Compile
Include="Nemerle.Completion2\Engine\BackgroundWorks\Engine-FindMethodsToOverride.n"
/>
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Hints\SubHintForType.n" />
+ </ItemGroup>
<Import Project="$(Nemerle)\Nemerle.MSBuild.targets" />
<!-- To modify your build process, add your task inside one of the
targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.nproj
Sun Oct 11 19:03:13 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.nproj
Tue Nov 3 07:48:08 2009
@@ -9,6 +9,7 @@
<Folder Include="Async\" />
<Folder Include="Async\AsyncRequest\" />
<Folder Include="CompilerMessage\" />
+ <Folder Include="Hints\" />
<Folder Include="Nemerle.Completion2\" />
<Folder Include="Nemerle.Completion2\CodeFormatting\" />
<Folder Include="Nemerle.Completion2\CodeModel\" />
=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Utils.n Mon Nov 2
09:09:59 2009
+++ /nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Utils.n Tue Nov 3
07:48:08 2009
@@ -767,20 +767,7 @@
tyArgs2 : list[TyVar]
) : string * Func[string, string]
{
- mutable currentId = 1;
- def idToTypeMap = Hashtable();
- def getTyId(ty) : int
- {
- currentId++;
- idToTypeMap.Add(currentId, ty);
- currentId
- }
-
- def convertTypeName(ty, name)
- {
- $"<font color='DarkCyan'><hint value='$name' key='$(getTyId(ty))'
/></font>"
- }
- def cnv = Convert(true, convertTypeName, false);
+ def cnv = SubHintForType();
//FIXME: Для функции makeMethodInfo не создается фолдинг-регион!
// def makeMethodInfo(cnv : Utils.Convert, inferred : bool,
declTy : MType.Class, method : IMethod, (argsTypes, retType) : list[TyVar]
* TyVar) : string { null }
def methodType() : string
@@ -817,16 +804,7 @@
def doc = GetDocText(method, method.Location);
def res = (methodInfo + if (doc.IsNullOrEmpty()) ""
else $"<b><hint
value='Documetnation'>$doc</hint></b>").Trim();
- /// Эта функция вызывается когда пользователь пытается посмотреть
вложенный хинт.
- def makeTypeStr(key : string) : string
- {
- def ty = idToTypeMap[int.Parse(key)];
- def cnv = Convert();
- cnv.ConvertTypeName = convertTypeName;
- $"<hint>$(cnv.FixedTypeToString(ty))</hint>"
- }
-
- (res, Func(makeTypeStr))
+ (res, cnv.GetDelayedHintHendler())
}
public MakeTextHintForTExprMethodRef(
@@ -837,20 +815,7 @@
_notvirtual : bool
) : string * Func[string, string]
{
- mutable currentId = 1;
- def idToTypeMap = Hashtable();
- def getTyId(ty) : int
- {
- currentId++;
- idToTypeMap.Add(currentId, ty);
- currentId
- }
-
- def convertTypeName(ty, name)
- {
- $"<font color='DarkCyan'><hint value='$name' key='$(getTyId(ty))'
/></font>"
- }
- def cnv = Convert(true, convertTypeName, false);
+ def cnv = SubHintForType();
def (_ti, tyArgs1) =
match(obj.Type.Hint)
@@ -880,55 +845,18 @@
//+ tyParamsInfo
;
- def makeTypeStr(key : string) : string
- {
- def ty = idToTypeMap[int.Parse(key)];
- def cnv = Convert();
- cnv.ConvertTypeName = convertTypeName;
- $"<hint>$(cnv.FixedTypeToString(ty))</hint>"
- }
-
- (res, Func(makeTypeStr))
+ (res, cnv.GetDelayedHintHendler())
}
public MakeTextHintForTExprFieldMember(obj : TExpr, fld : IField) :
string * Func[string, string]
{
- mutable currentId = 1;
- def idToTypeMap = Hashtable();
- def getTyId(ty) : int
- {
- currentId++;
- idToTypeMap.Add(currentId, ty);
- currentId
- }
-
- def convertTypeName(ty, name)
- {
- $"<font color='DarkCyan'><hint value='$name' key='$(getTyId(ty))'
/></font>"
- }
- def cnv = Convert(true, convertTypeName, false);
-
- def (_ti, tyArgs1) =
- match(obj.Type.Hint)
- {
- | Some(MType.Class(ti, arg)) => (ti, arg)
- | Some(MType.Array(ty, _)) => (null, [ty])
- | _ => (null, [])
- };
+ def cnv = SubHintForType();
def ty = obj.Type.Fix().TypeOfMember(fld);
def res = "Instace field: " + cnv.TypeVarToString(obj.Type) + ".<b>"
+ fld.Name + "</b> : "
+ cnv.TypeVarToString(ty);
- def makeTypeStr(key : string) : string
- {
- def ty = idToTypeMap[int.Parse(key)];
- def cnv = Convert();
- cnv.ConvertTypeName = convertTypeName;
- $"<hint>$(cnv.FixedTypeToString(ty))</hint>"
- }
-
- (res, Func(makeTypeStr))
+ (res, cnv.GetDelayedHintHendler())
}
public MakeTextHintForReferenceTExpr(expr : TExpr) : string *
Func[string, string]
=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Hint.cs
Mon Nov 2 13:36:32 2009
+++ /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Hint.cs
Tue Nov 3 07:48:08 2009
@@ -1,6 +1,7 @@
using System;
using System.Windows;
using System.Windows.Interop;
+using System.Diagnostics;
namespace WpfHint
{
@@ -110,8 +111,16 @@
internal string RaiseGetHintContent(string key)
{
- if (_getHintContent != null)
- return _getHintContent(key);
+ try
+ {
+ if (_getHintContent != null)
+ return _getHintContent(key);
+ }
+ catch (Exception ex)
+ {
+ Trace.WriteLine(ex);
+ return "<hint><font color=\"Red\"><b>Exception throw when do hint
text lookup:</b></font><lb/>" + ex.Message + "</hint>";
+ }
return key;
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
Mon Nov 2 09:09:59 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
Tue Nov 3 07:48:08 2009
@@ -13,6 +13,7 @@
using System.Windows.Threading;
using WpfHint.Parsing;
using WpfHint.UIBuilding;
+using System.Diagnostics;
namespace WpfHint
{
@@ -33,9 +34,17 @@
set
{
text = value;
- var root = HintParser.Parse(value);
- var fe = HintBuilder.Build(root, hint);
- border.Child = fe;
+
+ try
+ {
+ var root = HintParser.Parse(value);
+ var fe = HintBuilder.Build(root, hint);
+ border.Child = fe;
+ }
+ catch (Exception ex)
+ {
+ Trace.WriteLine(ex);
+ }
}
}