[svn]
r7146: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2:
CodeModel/Project.Relocation.n Co...
VladD2
svnadmin at nemerle.org
Sun Dec 24 20:00:42 CET 2006
Log:
1. Sync relocation with compiler.
2. Add relocation support for field initializer expression.
3. Implement completion support for field initializer expression.
Author: VladD2
Date: Sun Dec 24 20:00:40 2006
New Revision: 7146
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Relocation.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Relocation.n
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Relocation.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Relocation.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Relocation.n Sun Dec 24 20:00:40 2006
@@ -31,41 +31,26 @@
: bool
{
def fileIndex = _compileUnits.GetFileIndex(filePath);
+ def isInclude(loc) { loc.Contains(startLine, startChar) && loc.Contains(oldEndLine, oldEndChar) }
- def getMember(fileIndex, line, col)
+ def member = match (GetActiveDecl(fileIndex, startLine, startChar))
{
- def decl = GetActiveDecl(fileIndex, line, col);
-
- match (decl)
- {
- | Decl.Type as ty => ty.Builder.GetActiveMember(fileIndex, line, col);
+ | Decl.Type as ty => ty.Builder.GetActiveMember(fileIndex, startLine, startChar);
| GlobalAttribute | Using | Namespace | None => null
- }
- }
+ };
- def member = getMember(fileIndex, startLine, startChar);
if (member == null)
false
else match (member) // Editing in only one member.
{
- | method is MethodBuilder =>
- def loc = method.BodyLocation;
-
- def isAllEditingInMethodBody = loc.Contains(startLine, startChar)
- && loc.Contains(startLine, startChar);
-
- if (isAllEditingInMethodBody)
- {
+ | method is MethodBuilder when isInclude(method.BodyLocation) with memberBuilder = method
+ | field is FieldBuilder when isInclude(field.InitializerLocation) with memberBuilder = field =>
+ memberBuilder.ResetCodeCache();
this.Engine.AddRelocation(fileIndex, newEndChar, newEndLine, oldEndChar, oldEndLine);
#if DebugLocations
UpdateDebugTree(fileIndex);
#endif
- method.ResetBody();
true
- }
- else
- false
-
| _ => false
}
} // AddRelocation
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 Sun Dec 24 20:00:40 2006
@@ -66,17 +66,15 @@
}
}
- match (member)
+ def FindCorrespondMethod(isMethodFound)
{
- | prop is PropertyBuilder =>
- def isAccessor(m : object) { prop.GetGetter() == m || prop.GetSetter() == m }
-
def result = typeBuilder.GetActiveMember(fileIndex, line, col,
fun(member1, member2)
{
- | (p is PropertyBuilder, m is MethodBuilder)
- | (m is MethodBuilder, p is PropertyBuilder) => if (isAccessor(m)) m else p
- | _ => def doIgnore(m) { | m is MethodBuilder => m.IsGenerated | _ => false }
+ | (p, m is MethodBuilder)
+ | (m is MethodBuilder, p) => if (isMethodFound(m)) m else p
+ | _ =>
+ def doIgnore(m) { | m is MethodBuilder => m.IsGenerated | _ => false }
if (doIgnore(member1)) if (doIgnore(member2)) null else member2
else if (doIgnore(member2)) null
else member2
@@ -84,9 +82,22 @@
});
match (result) { m is MethodBuilder => scanMethod(m) | _ => _topKeywords }
+ }
+
+ match (member)
+ {
+ | prop is PropertyBuilder =>
+ def isAccessor(m : MemberBuilder) { prop.GetGetter() == m : object || prop.GetSetter() == m : object }
+ FindCorrespondMethod(isAccessor);
| method is MethodBuilder => scanMethod(method)
| null => array(0)
+ | field is FieldBuilder =>
+ if (field.InitializerLocation.Contains(fileIndex, line, col))
+ scanMethod(field.LookupInitializerMethod());
+ else
+ _topKeywords
+
| _ => throw System.Exception($"Unknown member type '$member'.");
}
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n Sun Dec 24 20:00:40 2006
@@ -312,7 +312,6 @@
foreach (method when !skip(method) in GetAllMetodsDefinedInFile(fileIndex))
{
- //method.ResetBody(); //HACK!!!
#if !DEBUG
try
{
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Relocation.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Relocation.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Relocation.n Sun Dec 24 20:00:40 2006
@@ -7,31 +7,34 @@
{
public Relocate(this decl : Decl, fileIndex : int, line : int, ch : int, lineOffset : int, chOffset : int) : void
{
- def loc = decl.Location;
- assert(loc.FileIndex == fileIndex);
+ assert(decl.Location.FileIndex == fileIndex);
+ Relocate(decl, RelocationInfo (fileIndex, line, ch, lineOffset, chOffset));
+ }
- def isLocationChanged = loc.EndLine > line || loc.EndLine == line && loc.EndColumn >= ch;
- def relocateChildren(_ : Decl) : void
+ Relocate(decl : Decl, info : RelocationInfo) : void
+ {
+ def loc = decl.Location;
+ def isLocationChanged = loc.EndLine > info.Line
+ || loc.EndLine == info.Line && loc.EndColumn >= info.Char;
+ when (isLocationChanged)
+ {
+ match (decl)
{
- | GlobalAttribute => ()
+ | GlobalAttribute => () //TODO: Add attribute support.
| Using as x =>
- x.NameLocations = x.NameLocations.Map(Completion.Relocate(_, line, ch, lineOffset, chOffset));
- x.AliasLocation = Completion.Relocate(x.AliasLocation, line, ch, lineOffset, chOffset);
+ x.NameLocations = x.NameLocations.Map(Completion.Relocate(_, info));
+ x.AliasLocation = Completion.Relocate(x.AliasLocation, info);
| Namespace as x =>
- x.Decls.Iter(Relocate(_, fileIndex, line, ch, lineOffset, chOffset));
- x.NameLocations = x.NameLocations.Map(Completion.Relocate(_, fileIndex, line, ch, lineOffset, chOffset));
- x.BodyLocation = Completion.Relocate(x.BodyLocation, fileIndex, line, ch, lineOffset, chOffset);
+ x.Decls.Iter(Relocate(_, info));
+ x.NameLocations = x.NameLocations.Map(Completion.Relocate(_, info));
+ x.BodyLocation = Completion.Relocate(x.BodyLocation, info);
- | Type(builder) =>
- builder.Relocate(loc.FileIndex, line, ch, lineOffset, chOffset);
+ | Type(builder) => builder.Relocate(info);
| None => ()
}
- when (isLocationChanged)
- {
- relocateChildren(decl);
- decl.Location = Completion.Relocate(loc, fileIndex, line, ch, lineOffset, chOffset);
+ decl.Location = Completion.Relocate(loc, info);
}
}
} // module Relocation
More information about the svn
mailing list