[svn] r7423: nemerle/trunk/ncc/parsing/ParseTree.n nemerle/trunk/ncc/typing/OverloadPossibility.n nemerle/...

IT svnadmin at nemerle.org
Wed Feb 14 06:11:28 CET 2007


Log:
1. TExpr location rollback.
2. Added TypedObject to parsetree classes.

Author: IT
Date: Wed Feb 14 06:11:21 2007
New Revision: 7423

Modified:
   nemerle/trunk/ncc/parsing/ParseTree.n
   nemerle/trunk/ncc/typing/OverloadPossibility.n
   nemerle/trunk/ncc/typing/TypedTree.n
   nemerle/trunk/ncc/typing/Typer.n
   vs-plugin/trunk/ConsoleTest/Program.cs
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n

Modified: nemerle/trunk/ncc/parsing/ParseTree.n
==============================================================================
--- nemerle/trunk/ncc/parsing/ParseTree.n	(original)
+++ nemerle/trunk/ncc/parsing/ParseTree.n	Wed Feb 14 06:11:21 2007
@@ -366,7 +366,7 @@
     }
   }
 
-  [Record]
+  [Record (Exclude = [typed_object])]
   public variant PExpr : Located 
   {
     | Wildcard        // `_' used mainly in patterns, but also in `_ = ignored'
@@ -416,18 +416,24 @@
     | TypedPattern    { body : Typedtree.Pattern; }  
     | TypedType       { body : TyVar; }
 
+    [Accessor (flags = WantSetter)]
+    mutable typed_object : Typedtree.TExpr;
+
     public override ToString () : string {
       PrettyPrint.SprintExpr (None (), this);
     }
   }
 
-  [Record]
+  [Record (Exclude = [typed_object])]
   public variant Splicable : Located 
   {
     | Name { body : Parsetree.Name; }
     | Expression { expr : PExpr; }
     | HalfId { prefix : Parsetree.Name; }
 
+    [Accessor (flags = WantSetter)]
+    mutable typed_object : IMember;
+
     public GetName () : Parsetree.Name {
       match (this) {
         | Splicable.Name (x) => x
@@ -469,6 +475,9 @@
     // it generates a dummy name and puts the pattern in this field
     internal mutable pattern_hack : PExpr;
     
+    [Accessor (flags = WantSetter)]
+    mutable typed_object : Typedtree.Fun_parm;
+
     public this (name : Splicable, ty : PExpr, modifiers : Modifiers) 
     {
       base (Location_stack.top (), name, modifiers);
@@ -527,6 +536,9 @@
     public ret_type : PExpr;
     public parms : list [Fun_parm];
 
+    [Accessor (flags = WantSetter)]
+    mutable typed_object : Typedtree.Fun_header;
+
     public ParsedName : Name {
       get { name.GetName () }
     }

Modified: nemerle/trunk/ncc/typing/OverloadPossibility.n
==============================================================================
--- nemerle/trunk/ncc/typing/OverloadPossibility.n	(original)
+++ nemerle/trunk/ncc/typing/OverloadPossibility.n	Wed Feb 14 06:11:21 2007
@@ -132,7 +132,7 @@
                   | OpCode (ch, unch) =>
                     TExpr.OpCode (if (local_context.IsChecked) ch else unch)
                   | _ =>
-                    TExpr.StaticRef (this.Location, null, from, meth, method_typarms)
+                    TExpr.StaticRef (from, meth, method_typarms)
                 }
               else
                 TExpr.MethodRef (expr, meth, method_typarms, notvirtual = expr is TExpr.This && !(meth.Attributes %&& NemerleAttributes.Virtual))
@@ -203,13 +203,6 @@
         this.method_typarms = method_typarms;
     }
 
-    public this (loc : Location, typer : Typer, ty : TyVar, expr : TExpr, from : MType.Class, 
-                 member : IMember, method_typarms : list [TyVar] = null)
-    {
-      this(typer, ty, expr, from, member, method_typarms);
-      this.loc = loc;
-    }
-
     [Nemerle.OverrideObjectEquals]
     public Equals (o : OverloadPossibility) : bool
     {

Modified: nemerle/trunk/ncc/typing/TypedTree.n
==============================================================================
--- nemerle/trunk/ncc/typing/TypedTree.n	(original)
+++ nemerle/trunk/ncc/typing/TypedTree.n	Wed Feb 14 06:11:21 2007
@@ -258,10 +258,6 @@
       id - other.id
     }
 
-    debug() : void
-    {
-    }
-
     public this (loc          : Location,
                  name         : string,
        [NotNull] ret_type     : TyVar,
@@ -272,9 +268,6 @@
     {
       base (loc);
 
-      unless (loc.IsGenerated)
-        debug();
-
       this.name         = name;
       this.ret_type     = ret_type;
       this.ret_type_loc = ret_type_loc;
@@ -1198,7 +1191,6 @@
 
     public static TrueLiteral (mgr : ManagerClass) : TExpr { BoolLiteral (mgr, true) }
     public static FalseLiteral (mgr : ManagerClass) : TExpr { BoolLiteral (mgr, false) }
-    [Accessor] internal mutable _sourceExpr : Parsetree.PExpr;
   }
 
   public enum ParmKind {

Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n	(original)
+++ nemerle/trunk/ncc/typing/Typer.n	Wed Feb 14 06:11:21 2007
@@ -342,7 +342,7 @@
           def e' = AddCastTo (e', current_fun.ret_type, "function return value");
           def e' =
             if (skip_n_return) e' 
-            else TExpr.Block (e'.Location, current_fun.ret_type, local, e');
+            else TExpr.Block (current_fun.ret_type, local, e');
           current_fun.body = FunBody.Typed (e');
 
         | FunBody.Abstract => ()
@@ -598,19 +598,19 @@
         Wrong node is not [StillPossible] node, or one type of which
         cannot unify with [expected].  
       */
-    MakeOverloadedNode (overloads : list [OverloadPossibility], expected : TyVar) : TExpr
+    MakeOverloadedNode (overloads : list [OverloadPossibility], expected : TyVar) : TExpr * IMember
     {
       def res = OverloadPossibility.Unique (overloads);
       match (OverloadPossibility.OnlyPossible (res, expected)) {
-        | [] => TExpr.Error ()
+        | [] => (TExpr.Error (), null)
 
         | [o] when o.ExtensionMethodObject == null =>
           def expr = o.Compile ();
           _ = Expect (expected, expr.Type, "overloaded symbol");
-          expr
+          (expr, o.Member)
         
         | lst =>
-          Delay (DelayedTyping.Kind.Overloaded (lst), expected)
+          (Delay (DelayedTyping.Kind.Overloaded (lst), expected), null)
       }
     }
 
@@ -919,7 +919,7 @@
       if (del_tc != null) {
         log (TYPING, $ "delegate conversion, $(expr.Type) ---> $del_tc");
         // we don't want any delegate named del_tc, we want this specific delegate
-        def con = MakeOverloadedNode (TypeToConstructor (null, del_tc), FreshTyVar ());
+        def (con, _) = MakeOverloadedNode (TypeToConstructor (null, del_tc), FreshTyVar ());
         def expr = TryTyping (fun () {
           TypeExpr (<[ $(con : typed) ($(expr : typed)) ]>)
         });
@@ -1052,7 +1052,8 @@
     public TypeExpr (e : PT.PExpr, expected : TyVar, is_toplevel_in_seq : bool) : TExpr
     {
       log (TYPING, e.loc, $ "(typing expression: $e, exp=$expected");
-      Util.locate (e.loc, {
+
+      def texpr = Util.locate (e.loc, {
         def e' = InterceptSpecialMacros (e, expected);
         def e' = 
           try {
@@ -1100,7 +1101,10 @@
           _ = Expect (expected, e'.ty, "previously typed expression");
           
         e'
-      })
+      });
+
+      e.TypedObject = texpr;
+      texpr;
     }
 
     
@@ -1236,11 +1240,11 @@
         | PT.PExpr.DefFunctions (functions) =>
           if (Expect (expected, InternalType.Void, "definition ``result''"))
             if (is_toplevel_in_seq)
-              TypeLocalFunction (expression.Location, functions)
+              TypeLocalFunction (functions)
             else
               try {
                 PushLocals ();
-                TypeLocalFunction (expression.Location, functions)
+                TypeLocalFunction (functions)
               } finally {
                 PopLocals ()
               }
@@ -1431,8 +1435,8 @@
           }
           
 
-        | PT.PExpr.Member (obj, PT.Splicable.Name (name)) =>
-          def mem_name = name.Id;
+        | PT.PExpr.Member (obj, PT.Splicable.Name as name) =>
+          def mem_name = name.body.Id;
           if (CanBeTypeName (obj))
             match (TryTyping (fun () { TypeName (expression, expected) })) {
               | TExpr.Error =>
@@ -1722,7 +1726,7 @@
           Util.ice ("The completion tokens allowed only if Manager.IsCompletioInProgress is true.")
       }
 
-      texpr._sourceExpr = expression;
+      expression.TypedObject = texpr;
       texpr
     }
 
@@ -1790,7 +1794,7 @@
     }
 
 
-    TypeLocalFunction (loc : Location, functions : list [PT.Function_decl]) : TExpr
+    TypeLocalFunction (functions : list [PT.Function_decl]) : TExpr
     {
       mutable headers = [];
 
@@ -1813,6 +1817,7 @@
                         kind = ParmKind.Normal,
                         modifiers = p.modifiers);
             fp.GetLocalDefaultValueFromModifiers (this);
+            p.TypedObject = fp;
             fp
           });
         def name_obj = fn.header.name.GetName ();
@@ -1825,6 +1830,8 @@
            tenv         = tenv,
            loc          = fn.header.loc);
 
+        fn.header.TypedObject = header;
+
         def parm_types = List.Map (parms, fun (p : Fun_parm) { p.ty });
         def fun_type = ConstructFunctionType (parm_types, header.ret_type);
         def parents = current_fun :: current_fun.GetParents ();
@@ -1846,7 +1853,7 @@
         _ = Manager.ComponentsFactory.CreateTyper (this, hd);
       }
 
-      TExpr.DefFunctionsIn (loc, null, headers, null)
+      TExpr.DefFunctionsIn (headers, null)
     }
 
 
@@ -2242,19 +2249,13 @@
     public ConstructMethodOverload (m : IMethod, pt_from : PT.PExpr = null, 
                                     maybe_varargs = false) : list [OverloadPossibility]
     {
-      ConstructMethodOverload (Location_stack.top(), m, pt_from, maybe_varargs)
-    }
-
-    ConstructMethodOverload (loc : Location, m : IMethod, pt_from : PT.PExpr = null, 
-                             maybe_varargs = false) : list [OverloadPossibility]
-    {
       def bounds = m.GetHeader ().typarms.Map (fun (tv) { tv.LowerBound });
 
       def make_overload () {
         def from = ConstructEnclosingType (pt_from, m, bounds);
 
         def (ty, vars) = from.TypeOfMethodWithTyparms (m);
-        OverloadPossibility (loc, this, ty, null, from, m,
+        OverloadPossibility (this, ty, null, from, m,
                              method_typarms = vars)
       }
 
@@ -2269,7 +2270,7 @@
     }
 
 
-    InterpretGlobal (loc : Location, pt_from : PT.PExpr, symbol : IMember) : list [OverloadPossibility]
+    InterpretGlobal (pt_from : PT.PExpr, symbol : IMember) : list [OverloadPossibility]
     {
       def single (mem) {
         //Message.Debug ($"access of $mem");
@@ -2309,7 +2310,7 @@
               TypeToConstructor (pt_from, mem :> TypeInfo)
 
             | MemberKinds.Method | MemberKinds.Constructor =>
-              ConstructMethodOverload (loc, mem :> IMethod, pt_from, maybe_varargs = true)
+              ConstructMethodOverload (mem :> IMethod, pt_from, maybe_varargs = true)
 
             | MemberKinds.Property
             | MemberKinds.Field =>
@@ -2329,8 +2330,7 @@
     }
 
 
-    InterpretGlobals (loc : Location,
-                      pt_from : PT.PExpr,
+    InterpretGlobals (pt_from : PT.PExpr,
                       symbols : list [IMember], 
                       expected : TyVar, 
                       dump_errors : bool) 
@@ -2340,7 +2340,7 @@
 
       foreach (symbol in symbols) {
         if (dump_errors) {
-          foreach (op in InterpretGlobal (loc, pt_from, symbol)) {
+          foreach (op in InterpretGlobal (pt_from, symbol)) {
             try {
               solver.PushState ();
               messenger.NeedMessage = true;
@@ -2353,12 +2353,12 @@
           def not_ok =
             try {
               solver.PushState ();
-              InterpretGlobal (loc, pt_from, symbol).IsEmpty;
+              InterpretGlobal (pt_from, symbol).IsEmpty;
             } finally {
               solver.PopState ();
             }
           unless (not_ok)
-            foreach (op in InterpretGlobal (loc, pt_from, symbol)) {
+            foreach (op in InterpretGlobal (pt_from, symbol)) {
               def ok =
                 try {
                   solver.PushState ();
@@ -2376,24 +2376,28 @@
     }
 
 
-    TypeMemberExpr (obj : TExpr, name : PT.Name, expected : TyVar) : TExpr
+    TypeMemberExpr (obj : TExpr, name : PT.Splicable.Name, expected : TyVar) : TExpr
     {
-      match (TypeMember (obj, name, expected)) {
+      def mem_name = name.body;
+
+      match (TypeMember (obj, mem_name, expected)) {
         | Some ([]) =>
             if (Manager.IsIntelliSenseMode) {
               TExpr.Error()
             }
             else
             {
-              ReportError (messenger, $ "there is no member named `$(name.Id)' "
+              ReportError (messenger, $ "there is no member named `$(mem_name.Id)' "
                                     "in $(TypeOf (obj)) with type $expected");
               TExpr.Error ()
             }
 
         | Some (lst) =>
-          MakeOverloadedNode (lst, expected)
+          def (expr, mem) = MakeOverloadedNode (lst, expected);
+          name.TypedObject = mem;
+          expr;
         | None =>
-          Delay (DelayedTyping.Kind.MemberAccess (obj, name), expected)
+          Delay (DelayedTyping.Kind.MemberAccess (obj, mem_name), expected)
       }
     }
 
@@ -2660,7 +2664,7 @@
               []
           }
         
-      def from_global = InterpretGlobals (expr.Location, pt_from, globals, expected, dump_errors = false);
+      def from_global = InterpretGlobals (pt_from, globals, expected, dump_errors = false);
       //Message.Debug ($ "type name g: $globals $from_global");
 
       match (from_this + from_global) {
@@ -2676,7 +2680,7 @@
                          $ "none of the meanings of "
                            "`$expr' meets the type "
                            "$expected:");
-            _ = InterpretGlobals (expr.Location, pt_from, globals, expected, dump_errors = true);
+            _ = InterpretGlobals (pt_from, globals, expected, dump_errors = true);
           }
           []
         | overloads => overloads
@@ -2689,12 +2693,8 @@
       match (TypeNameFull (expr, expected)) {
         | [] => TExpr.Error ()
         | overloads =>
-          def texpr = MakeOverloadedNode (overloads, expected);
-          match (texpr) {
-            | Error => ()
-            | _     => texpr.loc = expr.Location;
-          }
-          texpr;
+          def (expr, _) = MakeOverloadedNode (overloads, expected);
+          expr;
       }
     }
     #endregion
@@ -2856,18 +2856,19 @@
                          $ "the type `$(lookup_in)' provides no accessible "
                            "constructor for $name (...)")
           | lst =>
-            MakeOverloadedNode (lst, FreshTyVar ())
+            def (expr, _) = MakeOverloadedNode (lst, FreshTyVar ());
+            expr;
         }
       }
     }
 
 
-    TypeCall (fnc : PT.PExpr,
+    TypeCall (pfnc : PT.PExpr,
               parms : list [PT.PExpr], 
               expected : TyVar, 
               is_property : bool) : TExpr
     {
-      log (TYPING, $ "type call to $fnc");
+      log (TYPING, $ "type call to $pfnc");
       def refout (name, expr) {
         def tv = FreshTyVar ();
         match (expr) {
@@ -2895,7 +2896,7 @@
       mutable parameters = List.Map (parms, compile_parm);
 
       def fnc =
-        match ((fnc, parameters)) {
+        match ((pfnc, parameters)) {
           | (PT.PExpr.Ref (name), _) when IsBlockReturn (name) =>
             TypeLocal (name, FreshTyVar (), allow_block_return = true)
 
@@ -2992,7 +2993,7 @@
           | (<[ base ]>, _) => GetBaseOverloads (is_base = true)
 
           | _ =>
-            def ex = TypeExpr (fnc, FreshTyVar ());
+            def ex = TypeExpr (pfnc, FreshTyVar ());
             match (ex.Type.Hint) {
               | Some (MType.Class (tc, _)) when tc.IsDelegate =>
                 TypeExpr (<[ $(ex : typed).Invoke ]>)
@@ -3007,6 +3008,8 @@
             def expr = TExpr.Call (expected, expr, parameters, false);
             dt.SetCallExpr (expr);
             dt.Resolve (); // just try
+            when (dt.IsResolved)
+              pfnc.TypedObject = dt.ResolutionResult;
             expr
 
           // special cases when call has been folded to something else
@@ -3034,6 +3037,8 @@
         | _ => ()
       }
 
+      when (pfnc.TypedObject == null)
+        pfnc.TypedObject = res;
       res
     }
     #endregion

Modified: vs-plugin/trunk/ConsoleTest/Program.cs
==============================================================================
--- vs-plugin/trunk/ConsoleTest/Program.cs	(original)
+++ vs-plugin/trunk/ConsoleTest/Program.cs	Wed Feb 14 06:11:21 2007
@@ -12,8 +12,7 @@
 			Test1 test = new Test1();
 			test.Init();
 
-			test.QuickTip002();
-			test.QuickTip001();
+			test.QuickTip();
 			test.Complete_in_return_type_1();
 			test.Complete_in_return_type_2();
 			test.Complete_in_return_type_3();

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n	Wed Feb 14 06:11:21 2007
@@ -19,30 +19,34 @@
     mutable _pexprObject   : object;
     mutable _texprObject   : object;
     mutable _pexprLocation : Location;
-    mutable _texprLocation : Location;
-    mutable _stop          : bool;
-
-    PExprName : string
-    {
-      get { if (_pexprObject == null) null else _pexprObject.ToString() }
-    }
 
     PFinder(info : ExprWalkInfo) : void
     {
-      when (info.Node is Located)
+      def find(obj : Located)
       {
-        def loc = (info.Node :> Located).Location;
+        def loc = obj.Location;
 
-        Print(info.Node, loc, info.Nodes.Length);
+        Print(obj, loc, info.Nodes.Length);
 
         if (IsIn(loc))
         {
+          def texpr = match (obj)
+          {
+          | pe is PExpr        => pe.TypedObject;
+          | fh is P.Fun_header => fh.TypedObject;
+          | sp is Splicable    => sp.TypedObject : object;
+          | _                  => null;
+          }
+
+          when (texpr != null)
+          {
           when (_pexprObject == null || _pexprLocation.Contains(loc))
           {
             PrintAdd(info.Nodes.Length);
 
             _pexprLocation = loc;
             _pexprObject   = info.Node;
+              _texprObject   = texpr;
           }
 
           match (info.Node)
@@ -52,135 +56,6 @@
           | _               => ()
           }
         }
-        else if (_line < loc.Line || _line == loc.Line && _col < loc.Column)
-          info.Stop()
-        else when (_line > loc.EndLine || _line == loc.EndLine && _col > loc.EndColumn)
-          info.Skip();
-      }
-    }
-
-    GetPattern(pattern : Pattern) : object
-    {
-//    | Application(name, _) =>      // { name : TypeInfo; arg : Pattern; }
-//
-//      def dt = name.DeclaringType;
-//      if (dt != null && dt.Name == PExprName) dt else name
-//
-//    | HasType(typ)         =>      // { typ : MType; }
-//
-//        match (typ)
-//        {
-//        | Class(tycon, _) =>
-//
-//          def dt = tycon.DeclaringType;
-//          if (dt != null && dt.Name == PExprName) dt else typ : object
-//
-//        | _ => typ
-//        }
-//
-//    | As      (_, decl)    => decl // { pat : Pattern; decl : LocalValue; }
-    | _                    => pattern
-    }
-
-    GetExpr(expression : TExpr) : object
-    {
-    | DefValIn      (name, _, _)     when IsIn(name.NameLocation) => name;
-    | TypeConversion(_, ty, _, tloc) when IsIn(tloc)              => ty : object;
-    | StaticRef(from, mem, _)          =>      // { from : MType.Class; mem : IMember; type_parms : list [TyVar]; }
-
-      if (mem.Name == PExprName || mem.MemberKind == MemberKinds.Constructor && from.tycon.Name == PExprName)
-        mem
-      else
-        from : object
-
-    | MacroEnvelope => expression;
-    | _             => null : object
-
-    //| TypeConversion(_, tt, _)         =>      // { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind; }
-//
-      //if (tt.IsFixed)
-      //{
-        //match (tt.FixedValue)
-        //{
-        //| Class(tycon, _) =>
-//
-          //def dt = tycon.DeclaringType;
-          //if (dt != null && dt.Name == PExprName) dt else tt : object
-//
-        //| _ => tt
-        //}
-      //}
-      //else
-        //tt
-//
-    //| Literal(Enum(value, ty, null))   => 
-//
-      //def members = ty.GetMembers();
-      //def field   = members.Find(f =>
-      //{
-        //match (f)
-        //{
-        //| f is IField when f.IsStatic && f.IsLiteral =>
-//
-          //match (f.GetValue())
-          //{
-          //| Integer as val
-          //| Literal.Enum(val, _, _) => val.ToString() == value.ToString()
-          //| _ => false
-          //}
-//
-        //| _ => false
-        //}
-      //});
-//
-      //match (field)
-      //{
-      //| Some(f) => f
-      //| None    => expression : object
-      //}
-//
-    //| Literal(Enum(_, _, field))       => field
-//
-    //| ConstantObjectRef(_, o : object)         // { from : MType.Class; mem : IField; }
-    //| StaticPropertyRef(_, o : object)         // { from : MType.Class; prop : IProperty; }
-    //| StaticEventRef   (_, o : object)         // { from : MType.Class; ev : IEvent; }
-    //| Base                (o : object)         // { base_ctor : IMethod; }
-    //| LocalFunRef         (o : object, _)      // { decl : LocalValue; type_parms : list [TyVar]; }
-    //| LocalRef            (o : object)         // { decl : LocalValue; }
-    //| MethodRef        (_, o : object, _, _)   // { obj : TExpr; meth : IMethod; type_parms : list [TyVar]; notvirtual : bool; }
-    //| EventMember      (_, o : object)         // { obj : TExpr; ev : IEvent; }
-    //| FieldMember      (_, o : object)         // { obj : TExpr; fld : IField; }
-    //| PropertyMember   (_, o : object)         // { obj : TExpr; prop : IProperty; }
-    //| HasType          (_, o : object)         // { expr : TExpr; test_ty : MType; }
-    //| TypeOf              (o : object) => o    // { target_type : TyVar; }
-    }
-
-    TFinder(info : ExprWalkInfo) : void
-    {
-      def find(obj : Located)
-      {
-        def loc = obj.Location;
-
-        Print(obj, loc, info.Nodes.Length);
-
-        if (IsIn(loc))
-        {
-          when (_texprObject == null || loc == _pexprLocation || _texprLocation.Contains(loc))
-          {
-            PrintAdd(info.Nodes.Length);
-
-            _texprLocation = loc;
-            _texprObject   = obj;
-
-            def isInExpr(expr)
-            {
-            | TExpr.DefValIn(name, _, _) => IsIn(name.NameLocation);
-            | _                          => false;
-            }
-
-            when (loc == _pexprLocation || isInExpr(obj))
-              info.Stop();
-          }
         }
         else if (_line < loc.Line || _line == loc.Line && _col < loc.Column)
           info.Stop()
@@ -190,55 +65,52 @@
 
       match (info.Node)
       {
-      | TExpr.Delayed(_susp) =>
-        // Сюда можно добавить "нечто" для выдачи сообщения о том, что нечто 
-        // не может быть распознано.
-        assert(true);
+      | PExpr.MacroCall as mc =>
 
-      | h is T.Fun_header =>
-
-        match (h.body)
-        {
-        | Typed(e) when IsIn(e.Location) => ()
-        | _ => find(h);
-        }
+        if (IsIn(mc.loc)) find(mc);
+        else              Print(mc, mc.loc, info.Nodes.Length);
 
       | l is Located => find(l);
       | _ => ()
       }
     }
 
-    public Find(pRoot : PExpr, tRoot : TExpr, line : int, col : int) : Location * object * object
+    public Find(pRoot : PExpr, _tRoot : TExpr, line : int, col : int) : Location * object * object
     {
-      if (pRoot != null && tRoot != null)
+      if (pRoot != null)
       {
         Init(line, col);
 
         ExprWalker().Walk(pRoot, PFinder);
 
-        if (_pexprObject != null)
+        if (_texprObject != null)
         {
 #if PRINT_AST && DEBUG
           Trace.WriteLine("");
-          Trace.WriteLine(
-            $"PExpr: $(_pexprLocation.Line):$(_pexprLocation.Column):"
-             "$(_pexprLocation.EndLine):$(_pexprLocation.EndColumn)"
-             "$(if (_pexprLocation.IsGenerated) '-' else '+') "
-             "$_line:$_col.");
+          Trace.WriteLine($"PExpr: $(_pexprObject.GetType())");
           Trace.WriteLine($"$_pexprObject");
-#endif
+          Trace.WriteLine("");
+          Trace.WriteLine($"TExpr: $(_texprObject.GetType())");
+          Trace.WriteLine($"$_texprObject");
+          Trace.WriteLine("");
 
-          ExprWalker().Walk(tRoot, TFinder);
+          ExprWalker().Walk(_tRoot, (info : ExprWalkInfo) => 
+          {
+            match (info.Node)
+            {
+            | l is Located => Print(info.Node, l.Location, info.Nodes.Length);
+            | _ => ()
+            }
+          });
+#endif
 
           (
             _pexprLocation,
             _pexprObject,
             match (_texprObject)
             {
-            | pat  is Pattern    => GetPattern(pat)
-            | expr is TExpr      => GetExpr   (expr);
-            | parm is T.Fun_parm => parm.decl;
-            | _                  => _texprObject
+            | TExpr.StaticRef(_, mem, _) => mem;
+            | o                          => o;
             }
           )
         }
@@ -257,11 +129,9 @@
 
       _line          = line;
       _col           = col;
-      _stop          = false;
       _pexprObject   = null;
       _pexprLocation = Location.Default;
       _texprObject   = null;
-      _texprLocation = Location.Default;
     }
 
     IsIn(location : Location) : bool

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/QuickTip2.n	Wed Feb 14 06:11:21 2007
@@ -4,6 +4,12 @@
 {
   public class Class1
   {
+    MacroTest() : void
+    {
+      if/*003:-1*/ ("".Length/*004:-1*/ == 0) {}
+      else {}
+    }
+
     WriteLineTest() : void
     {
       WriteLine/*002:-1*/("");
@@ -11,7 +17,7 @@
 
     Foo() : void
     {
-      def bar()
+      def bar/*005:-1*/()
       {
         _ = ReadLine/*001:-1*/();
       }

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n	Wed Feb 14 06:11:21 2007
@@ -16,25 +16,24 @@
   public partial class Test1
   {
     [Test]
-    public QuickTip002() : void
+    public QuickTip() : void
     {
       def file = FileQuickTip2;
-      def (line, col) = ReadLocation(file, "002");
-      def result = _project.GetQuickTipInfo(file, line, col);
-
-      Assert.IsNotNull(result, "result is null");
-      Assert.IsTrue   (result.Text.Split('\n')[0].IndexOf("WriteLine") > 0);
-    }
 
-    [Test]
-    public QuickTip001() : void
+      def test(testNumber, expected)
     {
-      def file = FileQuickTip2;
-      def (line, col) = ReadLocation(file, "001");
+        def (line, col) = ReadLocation(file, testNumber);
       def result = _project.GetQuickTipInfo(file, line, col);
 
       Assert.IsNotNull(result, "result is null");
-      Assert.IsTrue   (result.Text.Split('\n')[0].IndexOf("ReadLine") > 0);
+        Assert.IsTrue   (result.Text.Split('\n')[0].IndexOf(expected) > 0);
+      }
+
+      test("005", "bar");
+      test("004", "Length");
+      test("003", "Nemerle.Core.if");
+      test("002", "WriteLine");
+      test("001", "ReadLine");
     }
 
     [Test]



More information about the svn mailing list