Revision: 8419
Author:
v...@rsdn.ru
Date: Mon Nov 2 09:09:59 2009
Log: Working on Integration: Implementing members hints.
http://code.google.com/p/nemerle/source/detail?r=8419
Added:
/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.Completion2/CodeModel/QuickTipInfo.n
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Utils.n
/nemerle/trunk/VsIntegration/Nemerle.VSIP.n.sln
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.Designer.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.resx
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Hint.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/ElementToken.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintBuilder.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintControl.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/WpfHint.csproj
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleLanguageService.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleSource.cs
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Nemerle.VisualStudio.vsct
/nemerle/trunk/VsIntegration/build_dev.cmd
/nemerle/trunk/ncc/misc/ExprWalker.n
=======================================
--- /dev/null
+++ /nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Convert.n Mon Nov
2 09:09:59 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--; }
+ }
+ }
+}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
Mon Oct 26 02:38:15 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
Mon Nov 2 09:09:59 2009
@@ -289,6 +289,7 @@
<Compile
Include="Nemerle.Completion2\CodeModel\InterfaceMemberImplSourceGenerator.n"
/>
</ItemGroup>
<ItemGroup>
+ <Compile Include="Convert.n" />
<Compile
Include="Nemerle.Completion2\Engine\BackgroundWorks\Engine-FindMethodsToOverride.n"
/>
</ItemGroup>
<Import Project="$(Nemerle)\Nemerle.MSBuild.targets" />
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/QuickTipInfo.n
Mon Aug 31 14:24:47 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/QuickTipInfo.n
Mon Nov 2 09:09:59 2009
@@ -13,6 +13,7 @@
public class QuickTipInfo
{
public Text : string { get; private set; }
+ public GetHintContent : Func[string, string] { get; private set; }
public Location : Location { get; private set; }
public IsExpr : bool { get; private set; }
@@ -25,7 +26,9 @@
public this(location : Location, parsed : object, tExpr : TExpr,
_manager : ManagerClass)
{
SetLocation(location);
- Text = Utils.MakeTextHintForReferenceTExpr(tExpr);
+ def (text, getHintContent) =
Utils.MakeTextHintForReferenceTExpr(tExpr);
+ Text = text;
+ GetHintContent = getHintContent;
Parsed = parsed;
this.TExpr = tExpr;
IsExpr = true;
=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Utils.n Fri Oct 30
14:43:56 2009
+++ /nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Utils.n Mon Nov 2
09:09:59 2009
@@ -683,7 +683,7 @@
}
}
- private MakeTyParamsToTyArgsMap(
+ internal MakeTyParamsToTyArgsMap(
tyParams : list[StaticTyVar],
tyArgs : list[TyVar],
tyMap : Hashtable[string, TyVar]
@@ -692,7 +692,14 @@
NList.FoldLeft2(tyParams, tyArgs, tyMap,
fun(tyParam, tyArg, tyMap){ tyMap[tyParam.Name] = tyArg; tyMap });
}
-
+
+ /*[Flags]
+ enum TypeFormat
+ {
+ | Normal
+ | NoExpandTypeArgs
+ }*/
+
public MakeTextForType(ti : TypeInfo, tyArgs : list[TyVar]) : string *
string * string
{
def tyMap = MakeTyParamsToTyArgsMap(ti.Typarms, tyArgs, Hashtable());
@@ -700,7 +707,6 @@
{
tyMap[tyParamBame].ToString()
}
-
def makeStrForType(ti : TypeInfo) : string * string * string * _
{
def (prefix1, prefix2, prefix3, usedTyParams) =
@@ -728,6 +734,30 @@
(str1, str2, str3)
}
+
+ MakeMethodHint(cnv : Utils.Convert, inferred : bool, declTy : TyVar,
method : IMethod, sign : list[TyVar] * TyVar) : string
+ {
+ def (argsTypes, retType) = sign;
+ def parms = method.Header.parms;
+ def retTyStr = cnv.TypeVarToString(retType);
+ mutable counter = -1;
+ def ext()
+ {
+ counter++;
+ if (counter == 0 && method.IsExtension) "<keyword>this</keyword> "
+ else ""
+ }
+ def argsStrs = parms.Map2Lazy(argsTypes,
+ (a, t) => $"<pname>$(ext())$(a.Name)</pname> <ptype>:
$(cnv.TypeVarToString(t))</ptype>");
+ def name = "<b>" + method.Name + "</b>";
+ //def isCtor = name.Contains(".ctor");
+ def tyShort = cnv.TypeVarToString(declTy);
+ def tyParams = method.Header.typarms;
+ def methodTyParams = if (inferred || tyParams.IsEmpty) "" else
$<#[..$tyParams]#>;
+
+ $<#$tyShort.$name$methodTyParams(<params>..$argsStrs</params>) :
$retTyStr#>;
+ }
+
public MakeTextHintForTExprStaticRef(
expr : TExpr,
@@ -735,9 +765,36 @@
tyArgs1 : list[TyVar],
method : IMethod,
tyArgs2 : list[TyVar]
- ) : string
- {
- def tyParams = ti.Typarms + method.Header.typarms;
+ ) : 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);
+ //FIXME: Для функции makeMethodInfo не создается фолдинг-регион!
+ // def makeMethodInfo(cnv : Utils.Convert, inferred : bool,
declTy : MType.Class, method : IMethod, (argsTypes, retType) : list[TyVar]
* TyVar) : string { null }
+ def methodType() : string
+ {
+ MakeMethodHint(cnv, false, ti.GetMemType(), method,
+ method.GetMemType().FunReturnTypeAndParms(method));
+ }
+ def inferredType() : string
+ {
+ MakeMethodHint(cnv, true, MType.Class(ti, tyArgs1), method,
+ expr.ty.FixedValue.FunReturnTypeAndParms(method));
+ }
+
+
def makeTyParamsInfo()
{
def makeTyParamsToTyArgsMap()
@@ -746,45 +803,30 @@
MakeTyParamsToTyArgsMap(method.Header.typarms, tyArgs2, tyMap);
}
- def tyMap = makeTyParamsToTyArgsMap();
- $<#..$(tyParams; "\n"; p => $" $p is $(tyMap[p.ToString()])")#>
+ def tyParams = ti.Typarms + method.Header.typarms;
+ def tyMap = makeTyParamsToTyArgsMap();
+ def f = p => $"<pname>$p</pname> <ptype>is
$(cnv.TypeVarToString(tyMap[p.ToString()]))</ptype>";
+ $<#<params>..$(tyParams; ", "; f)</params>#>
}
def tyParamsInfo = makeTyParamsInfo();
- def parms = method.Header.parms;
- def (argsTypes, retType) =
expr.ty.FixedValue.FunReturnTypeAndParms(method);
- def toStr(x)
- {
- x.ToString()
- }
- def argsStrs = parms.Map2Lazy(argsTypes, (a, t) => $"$(a.Name) :
$(toStr(t))");
- def name = method.Name;
- def isCtor = name.Contains(".ctor");
- def (tyStr1, tyStr2, tyStr3) = MakeTextForType(ti, tyArgs1);
- def tyStr1 = if (isCtor || parms.IsEmpty) tyStr1 else tyStr3;
- def tyShort = ti.Name;
- def methodTyParams = if (method.Header.typarms.IsEmpty) ""
- else $<#[..$(method.Header.typarms)]#>;
- def ext = if (method.IsExtension) "this " else "";
-
- def NL = "\n ";
- def NLS = ",\n ";
- def methodType = $<#<ref handler='X'
hint='$tyStr2'>$tyShort</ref>.$name$methodTyParams($ext..$parms) :
$(method.ReturnType)#>;
- def methodType =
- if (methodType.Length > 100 && parms.Length > 0)
- $<#<ref handler='X'
hint='$tyStr2'>$tyShort</ref>.$name$methodTyParams($NL$ext..$(parms;
NLS)$NLS) : $(method.ReturnType)#>
- else methodType;
- def callType = $<#$tyStr1.$name($ext..$argsStrs) : $retType#>;
- def callType =
- if (callType.Length > 100 && parms.Length > 0)
- $<#$tyStr1.$name($NL$ext..$(argsStrs; NLS)$NLS) : $retType#>;
- else callType;
-
- def methodInfo = if (tyParams.IsEmpty) "The static method call:\n" +
methodType
- else "The generic static method call. Source method
type is:\n"
- + methodType + "\n\nInferred type:\n" + callType
+ "\n\nType parameters info:\n"
- + tyParamsInfo.Replace("-", "").Replace("+", "");
- (methodInfo + GetDocText(method, method.Location)).Trim()
+ def methodInfo = if (tyArgs1.IsEmpty && tyArgs2.IsEmpty) "The
<b>static method</b> call:\n" + methodType()
+ else "The generic <b>static method</b> call. Source
method type is:\n"
+ + methodType() + "\n\nInferred type:\n" +
inferredType() + "\n\nType parameters: "
+ + tyParamsInfo;
+ 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))
}
public MakeTextHintForTExprMethodRef(
@@ -793,18 +835,103 @@
method : IMethod,
typeArgs : list [TyVar],
_notvirtual : bool
- ) : string
- {
- def name = method.Name;
- def parms = method.Header.parms;
+ ) : 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, [])
+ };
+
_ = typeArgs;
- //_ = _notvirtual;
- def (argsTypes, retType) =
expr.ty.FixedValue.FunReturnTypeAndParms(method);
- def argsStrs = parms.Map2Lazy(argsTypes, (a, t) => $"$(a.Name) :
$t");
- $"$(obj.ty).$name(..$argsStrs) : $retType"
+
+ def methodType() : string
+ {
+ //MakeMethodHint(cnv, false, ti.GetMemType(), method,
+ // method.GetMemType().FunReturnTypeAndParms(method));
+ MakeMethodHint(cnv, false, method.DeclaringType.GetMemType(),
method,
+ method.GetMemType().FunReturnTypeAndParms(method))
+ }
+ def inferredType() : string
+ {
+ MakeMethodHint(cnv, true, obj.Type, method,
expr.ty.FixedValue.FunReturnTypeAndParms(method))
+ }
+
+ def res = if (tyArgs1.IsEmpty && typeArgs.IsEmpty) "The <b>instance
method</b> call:\n" + methodType()
+ else "The generic <b>instance method</b> call. Source
method type is:\n"
+ + methodType() + "\n\nInferred type:\n" + inferredType()
+ "\n\nType parameters: "
+ //+ 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))
}
- public MakeTextHintForReferenceTExpr(expr : TExpr) : string
+ 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 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))
+ }
+
+ public MakeTextHintForReferenceTExpr(expr : TExpr) : string *
Func[string, string]
{
def makeText(expr : TExpr)
{
@@ -812,6 +939,9 @@
//| TExpr.StaticPropertyRef(_, _o)
//| TExpr.FieldMember (_, _o)
//| TExpr.PropertyMember (_, _o)
+ | FieldMember(obj, fld) =>
+ MakeTextHintForTExprFieldMember(obj, fld)
+
| TExpr.MethodRef(obj, method, typeArgs, notvirtual) =>
MakeTextHintForTExprMethodRef(expr, obj, method, typeArgs,
notvirtual)
@@ -821,7 +951,7 @@
| TExpr.StaticRef(MType.Class(ti, tyArgs1), method is IMethod,
tyArgs2) =>
MakeTextHintForTExprStaticRef(expr, ti, tyArgs1, method, tyArgs2)
- | _ => expr.ToString()
+ | _ => (expr.ToString(), null)
}
makeText(expr)
=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.VSIP.n.sln Wed Oct 7 19:07:07 2009
+++ /nemerle/trunk/VsIntegration/Nemerle.VSIP.n.sln Mon Nov 2 09:09:59 2009
@@ -17,6 +17,8 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "ComInteropHelper", "ComInteropHelper\ComInteropHelper.csproj", "{DE3545CB-73C6-4BE0-9ED7-30A0DF1DEB3C}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
= "WpfHint", "Nemerle.VisualStudio\GUI\WpfHint\WpfHint.csproj", "{7670DE22-B023-4783-BA19-BB2DB50E1762}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -43,6 +45,10 @@
{DE3545CB-73C6-4BE0-9ED7-30A0DF1DEB3C}.Debug|Any CPU.Build.0 = Debug|Any
CPU
{DE3545CB-73C6-4BE0-9ED7-30A0DF1DEB3C}.Release|Any CPU.ActiveCfg =
Release|Any CPU
{DE3545CB-73C6-4BE0-9ED7-30A0DF1DEB3C}.Release|Any CPU.Build.0 = Release|
Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Debug|Any CPU.ActiveCfg = Debug|
Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Debug|Any CPU.Build.0 = Debug|Any
CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Release|Any CPU.ActiveCfg =
Release|Any CPU
+ {7670DE22-B023-4783-BA19-BB2DB50E1762}.Release|Any CPU.Build.0 = Release|
Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.Designer.cs
Fri Oct 30 10:58:03 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.Designer.cs
Mon Nov 2 09:09:59 2009
@@ -28,93 +28,93 @@
/// </summary>
private void InitializeComponent()
{
- System.ComponentModel.ComponentResourceManager resources = new
System.ComponentModel.ComponentResourceManager(typeof(Form1));
- this.button1 = new System.Windows.Forms.Button();
- this.richTextBox1 = new System.Windows.Forms.RichTextBox();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.checkBox2 = new System.Windows.Forms.CheckBox();
- this.SuspendLayout();
- //
- // button1
- //
- this.button1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
- this.button1.Location = new System.Drawing.Point(255, 333);
-
this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(278, 41);
- this.button1.TabIndex = 0;
- this.button1.Text = "test button";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.MouseEnter += new
System.EventHandler(this.button1_MouseEnter);
- //
- // richTextBox1
- //
- this.richTextBox1.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.richTextBox1.Location = new System.Drawing.Point(10, 11);
-
this.richTextBox1.Name = "richTextBox1";
- this.richTextBox1.Size = new System.Drawing.Size(538, 307);
- this.richTextBox1.TabIndex = 4;
- this.richTextBox1.Text =
resources.GetString("richTextBox1.Text");
- //
- // checkBox1
- //
- this.checkBox1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(10, 333);
-
this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(136, 17);
- this.checkBox1.TabIndex = 5;
- this.checkBox1.Text = "Change hint after 2 sec";
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // textBox1
- //
- this.textBox1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
- this.textBox1.Location = new System.Drawing.Point(77, 351);
-
this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(62, 20);
- this.textBox1.TabIndex = 6;
- this.textBox1.Text = "600";
- //
- // label1
- //
- this.label1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(10, 353);
-
this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(61, 13);
- this.label1.TabIndex = 7;
- this.label1.Text = "Wrap width";
- //
- // checkBox2
- //
- this.checkBox2.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
- this.checkBox2.AutoSize = true;
- this.checkBox2.Location = new System.Drawing.Point(10, 377);
-
this.checkBox2.Name = "checkBox2";
- this.checkBox2.Size = new System.Drawing.Size(203, 17);
- this.checkBox2.TabIndex = 8;
- this.checkBox2.Text = "Change wrap width to 200 after 2 sec";
- this.checkBox2.UseVisualStyleBackColor = true;
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(569, 420);
- this.Controls.Add(this.checkBox2);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.checkBox1);
- this.Controls.Add(this.richTextBox1);
- this.Controls.Add(this.button1);
- this.Name = "Form1";
- this.Text = "Form1";
- this.ResumeLayout(false);
- this.PerformLayout();
+ System.ComponentModel.ComponentResourceManager resources = new
System.ComponentModel.ComponentResourceManager(typeof(Form1));
+ this.button1 = new System.Windows.Forms.Button();
+ this.richTextBox1 = new System.Windows.Forms.RichTextBox();
+ this.checkBox1 = new System.Windows.Forms.CheckBox();
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.checkBox2 = new System.Windows.Forms.CheckBox();
+ this.SuspendLayout();
+ //
+ // button1
+ //
+ this.button1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.button1.Location = new System.Drawing.Point(255, 333);
+
this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(278, 41);
+ this.button1.TabIndex = 0;
+ this.button1.Text = "test button";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.MouseEnter += new
System.EventHandler(this.button1_MouseEnter);
+ //
+ // richTextBox1
+ //
+ this.richTextBox1.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.richTextBox1.Location = new System.Drawing.Point(10, 11);
+
this.richTextBox1.Name = "richTextBox1";
+ this.richTextBox1.Size = new System.Drawing.Size(538, 307);
+ this.richTextBox1.TabIndex = 4;
+ this.richTextBox1.Text = resources.GetString("richTextBox1.Text");
+ //
+ // checkBox1
+ //
+ this.checkBox1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.checkBox1.AutoSize = true;
+ this.checkBox1.Location = new System.Drawing.Point(10, 331);
+
this.checkBox1.Name = "checkBox1";
+ this.checkBox1.Size = new System.Drawing.Size(151, 19);
+ this.checkBox1.TabIndex = 5;
+ this.checkBox1.Text = "Change hint after 2 sec";
+ this.checkBox1.UseVisualStyleBackColor = true;
+ //
+ // textBox1
+ //
+ this.textBox1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.textBox1.Location = new System.Drawing.Point(77, 351);
+
this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(62, 20);
+ this.textBox1.TabIndex = 6;
+ this.textBox1.Text = "600";
+ //
+ // label1
+ //
+ this.label1.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(10, 353);
+
this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(68, 15);
+ this.label1.TabIndex = 7;
+ this.label1.Text = "Wrap width";
+ //
+ // checkBox2
+ //
+ this.checkBox2.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left)));
+ this.checkBox2.AutoSize = true;
+ this.checkBox2.Location = new System.Drawing.Point(10, 375);
+
this.checkBox2.Name = "checkBox2";
+ this.checkBox2.Size = new System.Drawing.Size(227, 19);
+ this.checkBox2.TabIndex = 8;
+ this.checkBox2.Text = "Change wrap width to 200 after 2 sec";
+ this.checkBox2.UseVisualStyleBackColor = true;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(569, 420);
+ this.Controls.Add(this.checkBox2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.textBox1);
+ this.Controls.Add(this.checkBox1);
+ this.Controls.Add(this.richTextBox1);
+ this.Controls.Add(this.button1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.ResumeLayout(false);
+ this.PerformLayout();
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.cs
Fri Oct 30 10:58:03 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.cs
Mon Nov 2 09:09:59 2009
@@ -38,8 +38,19 @@
var rt = but.RectangleToScreen(but.ClientRectangle);
hint.WrapWidth = Int32.Parse(textBox1.Text);
- hint.Show(IntPtr.Zero, new Rect(rt.Left, rt.Top, rt.Width,
rt.Height), richTextBox1.Text);
- }
+ var rect = new Rect(rt.Left, rt.Top, rt.Width, rt.Height);
+ hint.Show(IntPtr.Zero, rect, GetHintContent, richTextBox1.Text);
+ }
+
+ string GetHintContent(string key)
+ {
+ switch (key)
+ {
+ case "int": return "<hint>System.<b>Int32</b>!!!</hint>";
+ case "string": return "<hint>System.String!!!</hint>";
+ default: return "<hint>key '" + key + "' not found!</hint>";
+ }
+ }
void timer_Tick(object sender, EventArgs e)
{
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.resx
Fri Oct 30 10:58:03 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WinFormTestHint/Form1.resx
Mon Nov 2 09:09:59 2009
@@ -120,7 +120,8 @@
<data name="richTextBox1.Text" xml:space="preserve">
<value><hint>
<code>
-<pre><keyword>static internal </keyword><ref
handler='GoToDef'>RunErrorOccured</ref>(<params><pname>[NotNull]
location</pname><ptype> : <ref handler='GoToTypeDef1'
hint='Nemerle.Compiler.Location'>Location</ref></ptype>,
<pname>msg</pname><ptype> : <keyword><span
hint='System.String'>string</span></keyword></ptype></params>) :
<keyword>void</keyword>,
+<pre><keyword>static internal </keyword><ref
handler='GoToDef'>RunErrorOccured</ref>(<params><pname>[NotNull]
location</pname><ptype> : <ref handler='GoToTypeDef1'
hint='Nemerle.Compiler.Location'>Location</ref></ptype>,
<pname>msg</pname><ptype> : <keyword><hint
value='string'><hint value='System'>namespace
System</hint>.String</hint></keyword></ptype></params>) :
<keyword>void</keyword>,
+<hint value="Inner" handler="1:10:5:10:8">class <hint
value="NamespaceA">namespace NamespaceA</hint>.<hint
value="NamespaceB">namespace NamespaceB</hint>.<hint value="A"
handler="1:6:2:6:5">class A</hint>.[<hint
value="int">System.Int32</hint>].Inner[<hint
value="string">System.String</hint>]</hint>
<b>
bold </b>,
@@ -139,7 +140,6 @@
</hint>
-
</value>
</data>
</root>
=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Hint.cs
Fri Oct 30 10:58:03 2009
+++ /nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Hint.cs
Mon Nov 2 09:09:59 2009
@@ -10,8 +10,9 @@
private HintSource _hintSource;
private string _text;
private double _wrapWidth = 400.0;
-
- public event Action<Hint, string> Click;
+ private Func<string, string> _getHintContent;
+
+ public event Action<Hint, string> Click;
public event Action<Hint> Closed;
/// <summary>
@@ -58,14 +59,22 @@
_hintWindow.Close();
}
- public void Show(IntPtr owner, Rect placementRect, string text)
- {
- PlacementRect = placementRect;
- Text = text;
- Show(owner);
+ public void Show(IntPtr owner, Rect placementRect, Func<string, string>
getHintContent, string text)
+ {
+ PlacementRect = placementRect;
+ Text = text;
+ _getHintContent = getHintContent;
+
+ try
+ {
+ Show(owner);
+ }
+ catch
+ {
+ }
}
- public void Show(IntPtr owner)
+ private void Show(IntPtr owner)
{
if (_hintWindow != null)
throw new NotSupportedException("Hint already shown");
@@ -80,6 +89,7 @@
_hintWindow = new HintWindow(this, ht) { Text = _text };
new WindowInteropHelper(_hintWindow) { Owner = _hintSource.Owner };
_hintWindow.Closed += HintWindowClosed;
+ _hintWindow.MaxHeight =
1000.0;//System.Windows.Forms.Screen.FromRectangle(PlacementRect).WorkingArea.
_hintWindow.WrapWidth = _wrapWidth;
_hintWindow.Show();
@@ -93,9 +103,18 @@
if (Closed != null) Closed(this);
}
- internal void RaiseClick(string handler)
- {
- if (Click != null) Click(this, handler);
+ internal string RaiseGetHintContent(string key)
+ {
+ if (_getHintContent != null)
+ return _getHintContent(key);
+
+ return key;
+ }
+
+ internal void RaiseClick(string handler)
+ {
+ if (Click != null)
+ Click(this, handler);
}
}
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
Fri Oct 30 12:03:58 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
Mon Nov 2 09:09:59 2009
@@ -34,7 +34,7 @@
{
text = value;
var root = HintParser.Parse(value);
- var fe = HintBuilder.Build(root);
+ var fe = HintBuilder.Build(root, hint);
border.Child = fe;
}
}
@@ -89,23 +89,33 @@
private void OnClick(object sender, RoutedEventArgs e)
{
var hc = e.Source as HintControl;
- if (hc == null) return;
- if (hc.Handler != null) hint.RaiseClick(hc.Handler);
+
+ if (hc == null)
+ return;
+
+ if (hc.Handler != null)
+ hint.RaiseClick(hc.Handler);
}
private void OnMouseHover(object sender, RoutedEventArgs e)
{
var hc = e.Source as HintControl;
- if (hc == null) return;
- if (hc.Hint != null) ShowSubHint(hc, hc.Hint);
+ if (hc == null)
+ return;
+
+ if (hc.Hint != null)
+ ShowSubHint(hc, hc.Hint);
}
private void ShowSubHint(FrameworkElement el, string hintText)
{
var ht = HintRoot.Create(el);
+
foreach (HintWindow window in OwnedWindows)
{
- if (!window.hintRoot.Equals(ht)) continue;
+ if (!window.hintRoot.Equals(ht))
+ continue;
+
ht.Dispose();
return;
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/ElementToken.cs
Fri Oct 30 10:58:03 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/Parsing/ElementToken.cs
Mon Nov 2 09:09:59 2009
@@ -42,7 +42,12 @@
public override string ToString()
{
- return "<" + Name + ">" + Tokens.Aggregate("", (a, o) => a + o)
+ "</" + Name + ">";
+ var attrs = Attributes.Count <= 0 ? "" : Attributes.Aggregate(" ",
+ (acc, e) => acc + " " + e.Key + "='" + e.Value + "'");
+ return
+ "<" + Name + attrs + ">"
+ + Tokens.Aggregate("", (a, o) => a + o)
+ + "</" + Name + ">";
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintBuilder.cs
Fri Oct 30 10:58:03 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintBuilder.cs
Mon Nov 2 09:09:59 2009
@@ -5,37 +5,38 @@
using System.Windows.Media;
using WpfHint.Parsing;
using System.Linq;
+using System.Diagnostics;
namespace WpfHint.UIBuilding
{
internal static class HintBuilder
{
- public static FrameworkElement Build(RootToken rootToken)
- {
- return new HintDecorator { Child = new TextBlock().Fill(rootToken) };
+ public static FrameworkElement Build(RootToken rootToken, Hint hint)
+ {
+ return new HintDecorator { Child = new TextBlock().Fill(rootToken,
hint) };
}
- private static Span Fill(this Span span, ElementToken token)
- {
- Fill(span.Inlines, token);
+ private static Span Fill(this Span span, ElementToken token, Hint hint)
+ {
+ Fill(span.Inlines, token, hint);
return span;
}
- private static TextBlock Fill(this TextBlock tb, ElementToken token)
- {
- Fill(tb.Inlines, token);
+ private static TextBlock Fill(this TextBlock tb, ElementToken token,
Hint hint)
+ {
+ Fill(tb.Inlines, token, hint);
return tb;
}
- private static void Fill(InlineCollection inlines, ElementToken token)
+ private static void Fill(InlineCollection inlines, ElementToken token,
Hint hint)
{
foreach (var t in token.Tokens)
{
- inlines.Add(GetInline(t));
+ inlines.Add(GetInline(t, hint));
}
}
- private static Inline GetInline(ParseToken token)
+ private static Inline GetInline(ParseToken token, Hint hint)
{
if (token is TextToken)
{
@@ -48,25 +49,26 @@
switch (et.Name)
{
case "b":
- return new Bold().Fill(et);
+ return new Bold().Fill(et, hint);
case "u":
- return new Underline().Fill(et);
+ return new Underline().Fill(et, hint);
case "i":
- return new Italic().Fill(et);
+ return new Italic().Fill(et, hint);
case "lb":
return new LineBreak();
case "code":
- return new Span { FontFamily = new FontFamily("Consolas"),
FontSize = 12.0d * (96d / 72d) }.Fill(et);
+ return new Span { FontFamily = new FontFamily("Consolas"), FontSize
= 12.0d * (96d / 72d) }.Fill(et, hint);
case "font":
- return BuildFont(et);
+ return BuildFont(et, hint);
case "keyword":
- return new Span { Foreground = Brushes.Blue }.Fill(et);
- case "span":
- return BuildHint(et);
+ return new Span { Foreground = Brushes.Blue }.Fill(et, hint);
+ //case "span":
+ case "hint":
+ return BuildHint(et, hint);
case "ref":
- return BuildRef(et);
+ return BuildRef(et, hint);
case "params":
- return BuildParam(et);
+ return BuildParam(et, hint);
default:
throw new NotSupportedException(et.Name);
}
@@ -74,7 +76,7 @@
throw new NotSupportedException();
}
- private static Inline BuildFont(ElementToken token)
+ private static Inline BuildFont(ElementToken token, Hint hint)
{
var span = new Span();
@@ -99,33 +101,45 @@
var br = (Brush)bc.ConvertFromString(color);
span.Foreground = br;
}
- return span.Fill(token);
+ return span.Fill(token, hint);
}
- private static Inline BuildHint(ElementToken token)
- {
- string hint;
- token.Attributes.TryGetValue("hint", out hint);
- return hint == null ? new Span().Fill(token) : BuildRef(token);
- }
-
- private static Inline BuildRef(ElementToken token)
+ private static Inline BuildHint(ElementToken token, Hint hint)
+ {
+ Trace.Assert(token.Name == "hint");
+
+ string handler;
+ token.Attributes.TryGetValue("handler", out handler);
+
+ string key;
+ token.Attributes.TryGetValue("key", out key);
+
+ string value = token.Attributes["value"];
+
+ var hc = key == null ? new HintControl(token.ToString(), handler)
+ : new HintControl(key, hint.RaiseGetHintContent, handler);
+ //Fill(hc.Inlines, token);
+ hc.Inlines.Add(new Run(value));
+ return new InlineUIContainer { Child = hc };
+ }
+
+ private static Inline BuildRef(ElementToken token, Hint hint)
{
string handler;
token.Attributes.TryGetValue("handler", out handler);
- string hint;
- token.Attributes.TryGetValue("hint", out hint);
- if (hint != null)
- {
- hint = "<code>" + hint + "</code>";
- }
- var hc = new HintControl(hint, handler);
- Fill(hc.Inlines, token);
+ string hintStr;
+ token.Attributes.TryGetValue("hint", out hintStr);
+ if (hintStr != null)
+ {
+ hintStr = "<code>" + hintStr + "</code>";
+ }
+ var hc = new HintControl(hintStr, handler);
+ Fill(hc.Inlines, token, hint);
return new InlineUIContainer { Child = hc };
}
- private static Inline BuildParam(ElementToken token)
+ private static Inline BuildParam(ElementToken token, Hint hint)
{
var pp = new ParamPanel();
foreach (ParseToken pt in token.Tokens)
@@ -133,7 +147,7 @@
var et = pt as ElementToken;
if (et != null)
{
- var tb = new TextBlock().Fill(et);
+ var tb = new TextBlock().Fill(et, hint);
pp.Children.Add(tb);
if (et.Name == "pname")
ParamPanel.SetNameColumn(tb, true);
@@ -146,7 +160,7 @@
{
var elem = pp.Children[pp.Children.Count - 1] as TextBlock;
if (elem != null)
- elem.Inlines.Add(GetInline(tt));
+ elem.Inlines.Add(GetInline(tt, hint));
continue;
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintControl.cs
Fri Oct 30 10:58:03 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/UIBuilding/HintControl.cs
Mon Nov 2 09:09:59 2009
@@ -1,81 +1,97 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
+using System;
namespace WpfHint.UIBuilding
{
- internal class HintControl : TextBlock
- {
- #region ClickEvent
-
- public static readonly RoutedEvent ClickEvent =
- EventManager.RegisterRoutedEvent(
- "Click",
- RoutingStrategy.Bubble,
- typeof (RoutedEventHandler),
- typeof (HintControl));
-
- public static void AddClickHandler(DependencyObject d,
RoutedEventHandler handler)
- {
- var element = d as UIElement;
- if (element != null) element.AddHandler(ClickEvent, handler);
- }
+ internal class HintControl : TextBlock
+ {
+ #region ClickEvent
+
+ public static readonly RoutedEvent ClickEvent =
+ EventManager.RegisterRoutedEvent(
+ "Click",
+ RoutingStrategy.Bubble,
+ typeof(RoutedEventHandler),
+ typeof(HintControl));
+
+ public static void AddClickHandler(DependencyObject d,
RoutedEventHandler handler)
+ {
+ var element = d as UIElement;
+ if (element != null)
+ element.AddHandler(ClickEvent, handler);
+ }
- public static void RemoveClickHandler(DependencyObject d,
RoutedEventHandler handler)
- {
- var element = d as UIElement;
- if (element != null) element.RemoveHandler(ClickEvent,
handler);
- }
-
- #endregion
-
- #region MouseHover
-
- public static readonly RoutedEvent MouseHoverEvent =
- EventManager.RegisterRoutedEvent(
- "MouseHover",
- RoutingStrategy.Bubble,
- typeof (RoutedEventHandler),
- typeof (HintControl));
-
- public static void AddMouseHoverHandler(DependencyObject d,
RoutedEventHandler handler)
- {
- var element = d as UIElement;
- if (element != null) element.AddHandler(MouseHoverEvent,
handler);
- }
-
- public static void RemoveMouseHoverHandler(DependencyObject d,
RoutedEventHandler handler)
- {
- var element = d as UIElement;
- if (element != null) element.RemoveHandler(MouseHoverEvent,
handler);
- }
-
- #endregion
-
- private readonly Span span;
- public string Handler { get; private set; }
- public string Hint { get; private set; }
- public new InlineCollection Inlines { get { return span.Inlines; }
}
-
- public HintControl(string hintText, string handler)
- {
- Hint = hintText;
- Handler = handler;
-
- MouseEnter += delegate { RaiseEvent(new
RoutedEventArgs(MouseHoverEvent)); };
-
- if (handler != null)
- {
- var hLink = new Hyperlink { Focusable = false };
- hLink.Click += delegate { RaiseEvent(new
RoutedEventArgs(ClickEvent)); };
- span = hLink;
- }
- else
- {
- span = new Span();
- }
- base.Inlines.Add(span);
- }
- }
-}
+ public static void RemoveClickHandler(DependencyObject d,
RoutedEventHandler handler)
+ {
+ var element = d as UIElement;
+
+ if (element != null)
+ element.RemoveHandler(ClickEvent, handler);
+ }
+
+ #endregion
+
+ #region MouseHover
+
+ public static readonly RoutedEvent MouseHoverEvent =
+ EventManager.RegisterRoutedEvent(
+ "MouseHover",
+ RoutingStrategy.Bubble,
+ typeof(RoutedEventHandler),
+ typeof(HintControl));
+
+ public static void AddMouseHoverHandler(DependencyObject d,
RoutedEventHandler handler)
+ {
+ var element = d as UIElement;
+ if (element != null) element.AddHandler(MouseHoverEvent, handler);
+ }
+
+ public static void RemoveMouseHoverHandler(DependencyObject d,
RoutedEventHandler handler)
+ {
+ var element = d as UIElement;
+ if (element != null) element.RemoveHandler(MouseHoverEvent, handler);
+ }
+
+ #endregion
+
+ private readonly Span span;
+ public string Handler { get; private set; }
+ private string _hintKey;
+ public string Hint
+ {
+ get { return HintTextLookup(_hintKey); }
+ }
+ public new InlineCollection Inlines { get { return span.Inlines; } }
+ private Func<string, string> HintTextLookup;
+
+ public HintControl(string hintKey, Func<string, string> hintTextLookup,
string handler)
+ {
+ HintTextLookup = hintTextLookup;
+ _hintKey = hintKey;
+ Handler = handler;
+
+ MouseEnter += delegate { RaiseEvent(new
RoutedEventArgs(MouseHoverEvent)); };
+
+ if (handler != null)
+ {
+ var hLink = new Hyperlink { Focusable = false };
+ hLink.Click +=
+ delegate
+ {
+ RaiseEvent(new RoutedEventArgs(ClickEvent));
+ };
+ span = hLink;
+ }
+ else
+ {
+ span = new Span();
+ }
+ base.Inlines.Add(span);
+ }
+
+ public HintControl(string hintText, string handler) : this(hintText, x
=> x, handler) { }
+ }
+}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/WpfHint.csproj
Fri Oct 30 10:58:03 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/WpfHint.csproj
Mon Nov 2 09:09:59 2009
@@ -41,6 +41,7 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
+ <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleLanguageService.cs
Fri Oct 30 10:58:03 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleLanguageService.cs
Mon Nov 2 09:09:59 2009
@@ -65,6 +65,7 @@
DefaultEngine = new Engine(EngineCallbackStub.Default, new
TraceWriter(), true);
Hint = new Hint();
+ Hint.WrapWidth = 900.1;
}
///<summary>
@@ -744,7 +745,7 @@
public Hint Hint { get; private set; }
- public bool ShowHint(IVsTextView view, TextSpan hintSpan, string
hintText)
+ public bool ShowHint(IVsTextView view, TextSpan hintSpan, Func<string,
string> getHintContent, string hintText)
{
var hWnd = view.GetWindowHandle();
@@ -775,7 +776,7 @@
Hint.Close();
}
- Hint.Show(hWnd, rect, hintXml);
+ Hint.Show(hWnd, rect, getHintContent, hintXml);
return true;
}
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleSource.cs
Fri Oct 30 10:58:03 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/LanguageService/NemerleSource.cs
Mon Nov 2 09:09:59 2009
@@ -1557,7 +1557,7 @@
//Debug.WriteLine(Utils.LocationFromSpan(FileIndex,
span).ToVsOutputStringFormat() + "result GetDataTipText() text:");
//Debug.WriteLine(hintText);
- if (Service.ShowHint(view, hintSpan, hintText))
+ if (Service.ShowHint(view, hintSpan, tipInfo.GetHintContent, hintText))
return (int)TipSuccesses2.TIP_S_NODEFAULTTIP;
return VSConstants.S_OK;
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Nemerle.VisualStudio.vsct
Mon Oct 19 13:56:25 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/Nemerle.VisualStudio.vsct
Mon Nov 2 09:09:59 2009
@@ -41,7 +41,7 @@
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<Strings>
- <ButtonText>Refactor</ButtonText>
+ <ButtonText>&Refactor</ButtonText>
<CommandName>Refactor</CommandName>
</Strings>
</Menu>
=======================================
--- /nemerle/trunk/VsIntegration/build_dev.cmd Fri Jul 24 18:34:22 2009
+++ /nemerle/trunk/VsIntegration/build_dev.cmd Mon Nov 2 09:09:59 2009
@@ -1,4 +1,4 @@
-%SystemRoot%\Microsoft.NET\Framework\v3.5\MSBuild.exe %1 Nemerle.VSIP.n.sln
+%SystemRoot%\Microsoft.NET\Framework\v3.5\MSBuild.exe %1 Nemerle.VSIP.sln
cd bin\Debug
copy ComInteropHelper.dll "%ProgramFiles%\Nemerle\*.*"
copy Nemerle*.dll "%ProgramFiles%\Nemerle\*.*"
=======================================
--- /nemerle/trunk/ncc/misc/ExprWalker.n Mon Aug 31 14:24:47 2009
+++ /nemerle/trunk/ncc/misc/ExprWalker.n Mon Nov 2 09:09:59 2009
@@ -253,7 +253,7 @@
protected Go(splicable : P.Splicable) : void
{
- when (_info.Push(splicable))
+ when (splicable is P.Splicable.Expression && _info.Push(splicable))
{
match (splicable)
{