[nemerle] r8424 committed - Working on Integration: Implementing code hints. Type hint improved.

0 views
Skip to first unread message

codesite...@google.com

unread,
Nov 3, 2009, 5:17:25 PM11/3/09
to nemer...@googlegroups.com
Revision: 8424
Author: v...@rsdn.ru
Date: Tue Nov 3 14:16:52 2009
Log: Working on Integration: Implementing code hints. Type hint improved.
http://code.google.com/p/nemerle/source/detail?r=8424

Modified:
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Hints/SubHintForType.n

/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Utils.n

/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs

=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Hints/SubHintForType.n
Tue Nov 3 08:42:10 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Hints/SubHintForType.n
Tue Nov 3 14:16:52 2009
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using Nemerle.Collections;
+using BFlg = System.Reflection.BindingFlags;

namespace Nemerle.Compiler.Utils
{
@@ -28,12 +29,6 @@
{
$"<font color='DarkCyan'><hint value='$name' key='$(GetTypeId(ty))'
/></font>"
}
-
- public static MakeAccessModifiers(ti : IMember) : string
- {
- def mods = ti.Attributes.ToString().ToLower().Replace(",", "");
- $"<keyword>$mods</keyword> "
- }

public GetDelayedHintHendler() : Func[string, string]
{
@@ -50,21 +45,28 @@
+ "Inferred: " + TypeVarToString(ty.TypeOfMember(m))
}

- def baseTypesExt(ti : TypeInfo) : string
+ def baseTypesExt(ti : TypeInfo, baseTypeName = "Base type") :
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)#>
- }
+ else $<#<lb/>$prompt: ..$(itfs; ", "; FixedClassTypeToString)#>
+ }
+ def old = AddNamespaces;
+ AddNamespaces = false;
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 res =
+ if (baseType != null)
+ $"<lb/>$baseTypeName: " +
TypeVarToString(ty.GetInstantiatedSuperType(baseType)) +
implementsInfo(itfs)
+ else implementsInfo(itfs);
+
+ AddNamespaces = old;
+
+ res
}

def (kind, ext) =
@@ -72,19 +74,36 @@
{
| Class(ti, _args) =>
def (kind, ext) =
- if (ti.IsInterface) ("interface ", baseTypesExt(ti))
- else if (ti.IsDelegate) ("delegate ", makeDelegateExt(ti))
- else if (ti.IsEnum) ("enum ", "")
+ if (ti.IsDelegate) ("delegate ", makeDelegateExt(ti))
else if (ti.IsModule) ("module ", "")
else if (ti.IsValueType) ("value type ", "")
- else
- {
- def text = "class ";
- def text = if (ti.IsObsolete) "obsolete " + text else
text;
- (text, baseTypesExt(ti))
+ else match (ti.GetTydecl())
+ {
+ | Class with kind = "class "
+ | Interface with kind = "interface " => (kind,
baseTypesExt(ti))
+ | VariantOption =>
+ def old = AddNamespaces;
+ AddNamespaces = false;
+ def flds = ti.GetFields(BFlg.DeclaredOnly |
BFlg.Instance | BFlg.Public)
+ .Map(f => $"$(f.Name) :
$(TypeVarToString(ty.TypeOfMember(f)));");
+ def flds = if (flds.IsEmpty) "" else
$<#<lb/>Fields: ..$flds#>;
+ AddNamespaces = old;
+ ("variant option ", flds + baseTypesExt(ti, "Declaring
variant"))
+
+ | Variant(members) when members.IsEmpty => ("variant ",
baseTypesExt(ti))
+ | Variant(members) =>
+ def old = AddNamespaces;
+ AddNamespaces = false;
+ def ops = members.Map(o =>
FixedClassTypeToString(o.GetMemType()));
+ AddNamespaces = old;
+ ("variant ", $<#<lb/>Variant
options: ..$ops<lb/>$(baseTypesExt(ti))#>)
+
+ | Enum => ("enum ", "")
+ | Alias => assert(false);
};
-
- ("<keyword>" + MakeAccessModifiers(ti) + kind
+ "</keyword>", ext)
+ def obsolete = if (ti.IsObsolete) "[Obsolete] " else "";
+
+ (obsolete + "<keyword>" + Utils.MakeAccessModifiers(ti) +
kind + "</keyword>", ext)

| TyVarRef => ("type parameter ", "")
| Fun => ("function type ", "")
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
Fri Oct 2 17:39:38 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
Tue Nov 3 14:16:52 2009
@@ -456,7 +456,7 @@
def col = _col;
def line = _line;
//walker.Walk(expendedPExpr, handler);
- def res = Find(expendedPExpr, expandedTExpr, line, col,
handler);
+ def res = Find(expendedPExpr, expandedTExpr, line, col,
handler, unpackMemberRefs);
when (res[1] != null || res[2] != null)
return res;
_texprObject = texprObject;
=======================================
--- /nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Utils.n Tue Nov 3
08:42:10 2009
+++ /nemerle/trunk/VsIntegration/Nemerle.Compiler.Utils/Utils.n Tue Nov 3
14:16:52 2009
@@ -754,11 +754,16 @@
def tyShort = cnv.TypeVarToString(declTy);
def tyParams = method.Header.typarms;
def methodTyParams = if (inferred || tyParams.IsEmpty) "" else
$<#[..$tyParams]#>;
- def mods = SubHintForType.MakeAccessModifiers(method);
+ def mods = MakeAccessModifiers(method);


$<#$mods$tyShort.$name$methodTyParams(<params>..$argsStrs</params>) :
$retTyStr#>;
}

+ public static MakeAccessModifiers(ti : IMember) : string
+ {
+ def mods = ti.Attributes.ToString().ToLower().Replace(",", "");
+ $"<keyword>$mods</keyword> "
+ }

public MakeTextHintForTExprStaticRef(
expr : TExpr,
=======================================
---
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
Tue Nov 3 11:23:41 2009
+++
/nemerle/trunk/VsIntegration/Nemerle.VisualStudio/GUI/WpfHint/HintWindow.xaml.cs
Tue Nov 3 14:16:52 2009
@@ -64,6 +64,7 @@
// window props
Left = 0;
Top = 0;
+ MaxHeight = 800;
SizeToContent = SizeToContent.WidthAndHeight;
Opacity = 1;

@@ -186,16 +187,13 @@
SystemParameters.VirtualScreenHeight * dy);

var pos = rect.BottomLeft;
+
if (rect.Bottom + size.Height > scrSize.Height)
- {
pos.Y = rect.Top - size.Height;
- }

if (rect.Left + size.Width > scrSize.Width)
- {
pos.X = scrSize.Width - size.Width;
- }
-
+
if (pos.Y < 0) pos.Y = 0;
if (pos.X < 0) pos.X = 0;

Reply all
Reply to author
Forward
0 new messages