[svn] r6918: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n
Nemerle.Compi...
IT
svnadmin at nemerle.org
Fri Nov 17 00:08:51 CET 2006
Log:
Outlining for properties.
Author: IT
Date: Fri Nov 17 00:08:47 2006
New Revision: 6918
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/CompileUnitCollection.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n Fri Nov 17 00:08:47 2006
@@ -66,7 +66,7 @@
col > 0 && str.Length >= col && str[col - 1] == ch
}
- FindNext(lineIndex : int, col : int, text : string) : int * int
+ FindNext(lineIndex : int, col : int, text : string, eatComments : bool) : int * int
{
def endLine = Math.Max(GetLineCount(), lineIndex + 10);
@@ -74,7 +74,7 @@
for (mutable l = lineIndex; l < endLine; l++)
{
- def line = GetLine(l);
+ mutable line = GetLine(l);
def peek () { if (c < line.Length) line[c] else '\0' }
def skip () { c++; }
@@ -85,12 +85,26 @@
{
match (peek())
{
- | '/' when l == lineIndex =>
+ | '/' when l == lineIndex || eatComments =>
match (peekn(+1))
{
| '/'
| '*' when line.IndexOf("*/", c) > 0 => c = int.MaxValue - 1;
+ | '*' when eatComments =>
+
+ for (l++; l < endLine; l++)
+ {
+ line = GetLine(l);
+ c = line.IndexOf("*/");
+
+ when (c >= 0)
+ {
+ skip();
+ break;
+ }
+ }
+
| _ => ()
}
@@ -185,11 +199,13 @@
| [(p, b)] =>
+ _debug((p, b));
+
def (line, col) = startLoc(p, b);
mutable eLine;
mutable eCol;
- (eLine, eCol) = FindNext(b.EndLine, b.EndColumn, "}");
+ (eLine, eCol) = FindNext(b.EndLine, b.EndColumn, "}", false);
if (eLine == b.EndLine)
{
@@ -197,7 +213,6 @@
{
def line = GetLine(eLine);
- _debug(line[eCol - 2]);
when (line[eCol - 2] == ' ' || line[eCol - 2] == '\t')
eCol--;
}
@@ -221,46 +236,8 @@
loop(locs);
}
- ProcessBuilder(builder : TypeBuilder) : void
- {
- when (builder.IsDelegate || builder.IsVariantOption)
- return;
-
- foreach (loc when loc.FileIndex == _fileIndex in builder.PartsLocation)
- {
- _addHiddenRegion(
- Location(
- _fileIndex,
- loc.Line,
- GetLine(loc.Line).Length + 1, // should be temporary solution until we get location for the type name.
- loc.EndLine,
- loc.EndColumn),
- null,
- true);
-
- CheckLine(loc.Line);
- }
-
- // Get regions and errors for methods.
- //
- def _start = Environment.TickCount;
-
- def isProcessed(m)
- {
- !(m.Attributes %&& (NemerleAttributes.SpecialName | NemerleAttributes.Abstract))
- && m.Location.FileIndex == _fileIndex
- }
-
- def members = builder.GetDirectMembers().Filter(isProcessed);
-
- foreach (member in members)
+ ProcessMethod(method : MethodBuilder) : void
{
- // TypeBuilder can contain methods from many parts of partial
- // class and super classes. We must process only memebers defined
- // in processed file only!
- //
- | method is MethodBuilder =>
-
#if !DEBUG
when (_start < Environment.TickCount - 2000)
break;
@@ -292,8 +269,78 @@
// Get the method region location.
//
AddRegion(method.Location.TrimStart(method.fun_header.ret_type_loc, false), true);
+ }
- | builder is TypeBuilder => ProcessBuilder(builder)
+ ProcessProperty(prop : PropertyBuilder) : void
+ {
+#if !DEBUG
+ when (_start < Environment.TickCount - 2000)
+ break;
+#endif
+
+ def loc = ExprWalker().GetLocation(prop.Ast);
+ def (line, col) = FindNext(loc.EndLine, loc.EndColumn, "}", true);
+ def loc = Location(loc.FileIndex, loc.Line, loc.Column, line, col + 1);
+
+ AddRegion(loc.TrimStart(prop.BodyLocation, false), true);
+
+ def add(f)
+ {
+ when (f != null)
+ AddRegion(
+ Location(
+ f.fun_header.Location.FileIndex,
+ f.fun_header.Location.EndLine,
+ f.fun_header.Location.EndColumn,
+ f.BodyLocation.EndLine,
+ f.BodyLocation.EndColumn + 1),
+ true);
+ }
+
+ add(prop.GetGetter() :> MethodBuilder);
+ add(prop.GetSetter() :> MethodBuilder);
+ }
+
+ mutable _start : int;
+
+ ProcessBuilder(builder : TypeBuilder) : void
+ {
+ when (builder.IsDelegate || builder.IsVariantOption)
+ return;
+
+ foreach (loc when loc.FileIndex == _fileIndex in builder.PartsLocation)
+ {
+ _addHiddenRegion(
+ Location(
+ _fileIndex,
+ loc.Line,
+ GetLine(loc.Line).Length + 1, // should be temporary solution until we get location for the type name.
+ loc.EndLine,
+ loc.EndColumn),
+ null,
+ true);
+
+ CheckLine(loc.Line);
+ }
+
+ // Get regions and errors for methods.
+ //
+ _start = Environment.TickCount;
+
+ def isProcessed(m)
+ {
+ _debug(m);
+ !(m.Attributes %&& (NemerleAttributes.SpecialName | NemerleAttributes.Abstract))
+ && m.Location.FileIndex == _fileIndex
+ }
+
+ def members = builder.GetDirectMembers().Filter(isProcessed);
+
+ foreach (member in members)
+ {
+ | method is MethodBuilder => ProcessMethod (method);
+ | prop is PropertyBuilder => ProcessProperty(prop);
+ | builder is TypeBuilder => ProcessBuilder (builder)
| _ => ()
}
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/CompileUnitCollection.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/CompileUnitCollection.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/CompileUnitCollection.n Fri Nov 17 00:08:47 2006
@@ -42,11 +42,11 @@
get
{
when (_fileInfos.Length < 0)
- throw System.Exception($"File '$fileIndex' not exists in project.");
+ throw System.Exception($"File '$fileIndex' does not exist in project.");
def fileInfo = _fileInfos[fileIndex];
when (fileInfo == null)
- throw System.Exception($"File '$fileIndex' contain empty declaration list.");
+ throw System.Exception($"File '$fileIndex' contains an empty declaration list.");
fileInfo
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n Fri Nov 17 00:08:47 2006
@@ -449,6 +449,12 @@
Go(pattern);
}
+ public Walk([NotNull] member : P.ClassMember, [NotNull] walkHandler : ExprWalkHandler) : void
+ {
+ _info.Init(walkHandler);
+ Go(member);
+ }
+
public Walk([NotNull] expression : TExpr, [NotNull] walkHandler : ExprWalkHandler) : void
{
_info.Init(walkHandler);
@@ -468,6 +474,19 @@
loc
}
+ public GetLocation(member : P.ClassMember) : Location
+ {
+ mutable loc = member.Location;
+
+ Walk(member, info =>
+ {
+ when (info.Node is Located)
+ loc = Utils.Combine(loc, (info.Node :> Located).Location);
+ });
+
+ loc
+ }
+
public Resolve(expression : TExpr) : void
{
Walk(expression, info =>
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n Fri Nov 17 00:08:47 2006
@@ -55,7 +55,7 @@
{
foreach (name in
["object", "bool", "byte", "float", "uint", "char", "ulong", "ushort",
- "decimal", "int", "sbyte", "short", "double", "long", "string", "void"])
+ "decimal", "int", "sbyte", "short", "double", "long", "string", "void", "get", "set"])
{
_types.Add(name, name);
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs Fri Nov 17 00:08:47 2006
@@ -385,7 +385,6 @@
string browseLocations = Path.GetDirectoryName(BaseURI.Uri.LocalPath);
Guid GUID_MruPage = new Guid("{19B97F03-9594-4c1c-BE28-25FF030113B3}");
-
// Add the .NET page.
//
tabInit[0].dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT));
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs Fri Nov 17 00:08:47 2006
@@ -72,7 +72,6 @@
private Engine _engine;
public Engine Engine
{
- [DebuggerStepThrough]
get { return _engine; }
}
More information about the svn
mailing list