[svn] r7296: vs-plugin/trunk/Nemerle.Compiler.Utils:
CodeDomHelper.n FormCodeDomGenerator.n Nemerle.Comple...
VladD2
svnadmin at nemerle.org
Fri Jan 19 20:48:36 CET 2007
Log:
Sync with compiler.
Author: VladD2
Date: Fri Jan 19 20:48:32 2007
New Revision: 7296
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomHelper.n
vs-plugin/trunk/Nemerle.Compiler.Utils/FormCodeDomGenerator.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n
vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomHelper.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomHelper.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/CodeDomHelper.n Fri Jan 19 20:48:32 2007
@@ -2,12 +2,13 @@
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
-using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Nemerle.Compiler;
using Nemerle.Compiler.Typedtree;
+using Nemerle.Collections;
+using SCG = System.Collections.Generic;
namespace Nemerle.Compiler.Utils
{
@@ -79,30 +80,30 @@
public MapFilterByType[T1,T2](this collection: IEnumerable[T1]) : list[T2]
{
- mutable res = [];
+ def res = SCG.List();
foreach(e is T2 in collection)
- res = e :: res;
+ res.Add(e);
- res.Reverse()
+ res.ToList()
}
public MapFilterByType[T2](this collection: IEnumerable) : list[T2]
{
- mutable res = [];
+ def res = SCG.List();
foreach(e is T2 in collection)
- res = e :: res;
+ res.Add(e);
- res.Reverse()
+ res.ToList()
}
- public StringToListOfLines(s: string) : List[string]
+ public StringToListOfLines(s: string) : SCG.List[string]
{
- def res = List.[string]();
+ def res = SCG.List();
+
using(def sr = StringReader(s))
- {
for(mutable s1 = sr.ReadLine(); s1 != null; s1 = sr.ReadLine())
res.Add(s1);
- }
+
res
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/FormCodeDomGenerator.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/FormCodeDomGenerator.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/FormCodeDomGenerator.n Fri Jan 19 20:48:32 2007
@@ -133,9 +133,9 @@
protected MergeClassDecl(classDecl: CodeTypeDeclaration, typeBuilder: TypeBuilder) : void
{
- _oldMethods = typeBuilder.GetMembers(allDeclaredFlags)
- .Filter( m => (m.MemberType == MemberTypes.Method || m.MemberType == MemberTypes.Constructor) &&
- !m.Name.StartsWith("_N_field_initialiser") )
+ _oldMethods = typeBuilder.GetMembers(allDeclaredFlags).Filter(
+ m => match(m.MemberKind) { | MemberKinds.Method | Constructor => true | _ => false }
+ && !m.Name.OrdinalStartsWith("_N_field_initialiser"))
.MapFilterByType.[MethodBuilder]();
_codeDomMethods = classDecl.Members.MapFilterByType.[CodeMemberMethod]();
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 Fri Jan 19 20:48:32 2007
@@ -96,7 +96,7 @@
{
| StaticRef(from, mem, _) => // { from : MType.Class; mem : IMember; type_parms : list [TyVar]; }
- if (mem.MemberType != MemberTypes.Constructor && from.tycon.Name == PExprName)
+ if (mem.MemberKind != MemberKinds.Constructor && from.tycon.Name == PExprName)
from
else
mem : object
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/MethodTipInfo.n Fri Jan 19 20:48:32 2007
@@ -163,7 +163,7 @@
{
def method = _overloads[index].Member :> IMethod;
- match (method.GetFunKind())
+ match (method.MemberKind)
{
| Constructor => method.DeclaringType.Name;
| _ => method.Name;
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n Fri Jan 19 20:48:32 2007
@@ -80,7 +80,8 @@
FindCorrespondMethod(isAccessor);
| method is MethodBuilder => scanMethod(method)
- | null => TopKeywords
+ | null => this.Engine.CompleteDeclarationBase(
+ @type.Builder.Ast, fileIndex, line, col, source);
| field is FieldBuilder =>
if (field.InitializerLocation.Contains(fileIndex, line, col))
scanMethod(field.LookupInitializerMethod());
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Completion.n Fri Jan 19 20:48:32 2007
@@ -41,7 +41,7 @@
Trace.Assert(!IsProjectAvailable);
def decls = _decls.Rev();
- def scan(decls)
+ def scanDecls(decls)
{
| decl :: tail =>
if (decl.Location.Contains(line, col))
@@ -53,7 +53,7 @@
| Type => throw System.Exception();
| None => throw System.Exception();
}
- else scan(tail)
+ else scanDecls(tail)
| _ => TopKeywords
}
def scanTopDecls(topDecls : list[TopDeclaration]) : DeclarationBase
@@ -92,9 +92,22 @@
}
def decl = scanTopDecls(topDecls);
- match (decl)
+ if (decl == null) scanDecls(decls)
+ else CompleteDeclarationBase(decl, fileIndex, line, col, source);
+ }
+ }
+
+ internal CompleteDeclarationBase(
+ ast : DeclarationBase,
+ fileIndex : int,
+ line : int,
+ col : int,
+ /*[NotNull]*/ source : ISource
+ )
+ : array[CompletionElem]
+ {
+ match (ast)
{
- | null => scan(decls)
| fn is ClassMember.Function =>
def bodyLocation = fn.body.CalcExclusiveBodyLocation();
if (bodyLocation.Contains(line, col))
@@ -102,10 +115,13 @@
else
ComplateWordInMethodHeader(fn, fileIndex, line, col, source)
+ | cls is TopDeclaration.Class =>
+ _ = cls;
+ TopKeywords
+
| _ => TopKeywords
}
}
- }
internal ComplateWordInMethodHeader(
/*[NotNull]*/ methodAst : ClassMember.Function,
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/NemerleCodeParser.n Fri Jan 19 20:48:32 2007
@@ -180,10 +180,10 @@
Debug.Print($"CreateMethod : from $method");
def methodDecl : CodeMemberMethod =
- match(method.GetFunKind())
+ match(method.MemberKind)
{
- | FunKind.Constructor => CodeConstructor()
- | FunKind.StaticConstructor => CodeTypeConstructor()
+ | Constructor when method.IsStatic => CodeTypeConstructor()
+ | Constructor => CodeConstructor()
| _ when method.Name == "Main" => CodeEntryPointMethod()
| _ when method.Name == ".ctor" => // TODO
throw CodeDomSerializerException($"Didn't expect that method: $method",
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n Fri Jan 19 20:48:32 2007
@@ -187,20 +187,14 @@
public static GetGlyphIndex(this member : IMember) : int
{
- def glyphType = match (member.GetKind ())
+ def glyphType = match (member.MemberKind)
{
- | Field => GlyphType.Field // IField
- | Method(method) => // IMethod
- match (method.GetFunKind())
- {
- | Method | BoundMethod => GlyphType.Method
- | Function => GlyphType.Method
- | Constructor | StaticConstructor => GlyphType.Class
- }
-
- | Property => GlyphType.Property // IProperty
- | Type => GlyphType.Class // TypeInfo
- | Event => GlyphType.Event // IEvent
+ | Field => GlyphType.Field
+ | Method => GlyphType.Method
+ | Constructor => GlyphType.Class
+ | Property => GlyphType.Property
+ | TypeInfo | NestedType => GlyphType.Class
+ | Event => GlyphType.Event
| _ => GlyphType.Class
};
More information about the svn
mailing list