[svn] r6671: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
Nemerle.Compiler.Utils/...
VladD2
svnadmin at nemerle.org
Thu Sep 21 03:24:12 CEST 2006
Log:
Work on relocation.
Author: VladD2
Date: Thu Sep 21 03:24:07 2006
New Revision: 6671
Added:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Debug.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Relocation.n
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprFinder.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Relocation.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Decl.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-Relocation.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.ParseEvents.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleSource.cs
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj Thu Sep 21 03:24:07 2006
@@ -112,6 +112,13 @@
<ItemGroup>
<Compile Include="Nemerle.Completion2\CodeModel\MethodTipInfo.n" />
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\Relocation.n" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CodeModel\Project.Debug.n" />
+ <Compile Include="Nemerle.Completion2\CompiledUnitAstBrowser.n" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
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 Thu Sep 21 03:24:07 2006
@@ -629,7 +629,7 @@
_counter = 0;
_stop = false;
_retObject = null;
- _retLocation = Location();
+ _retLocation = Location.Default;
}
IsIn(location : Location) : bool
@@ -714,6 +714,7 @@
#endif
ignore(obj);
+ ignore(loc);
}
//#endregion
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Debug.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Debug.n Thu Sep 21 03:24:07 2006
@@ -0,0 +1,14 @@
+//using Nemerle.Completion2;
+
+namespace Nemerle.Completion2
+{
+ public partial class Project
+ {
+ UpdateDebugTree(fileIndex : int) : void
+ {
+ def decl = CompileUnits[fileIndex];
+ def tree = CompiledUnitAstBrowser.Instance;
+ tree.Root = decl;
+ }
+ }
+}
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 Thu Sep 21 03:24:07 2006
@@ -18,8 +18,6 @@
{
public partial class Project
{
- public static mutable TmpLocation : Location; //TODO: Remove this field if relocation working properly
-
/// This method add relocation information, if changes made in
/// methode/property accessor body or in fields initialisation expression.
/// If relocation added this method return true. Otherwise false.
@@ -44,28 +42,22 @@
}
}
- def member1 = getMember(fileIndex, startLine, startChar);
- if (member1 == null)
- false
- else
- {
- def member2 = getMember(fileIndex, oldEndLine, oldEndChar);
- if (member2 == null || !object.ReferenceEquals(member1, member2))
+ def member = getMember(fileIndex, startLine, startChar);
+ if (member == null)
false
- else match (member1)
+ else match (member) // Editing in only one member.
{
| method is MethodBuilder =>
def loc = method.BodyLocation;
- if (loc.Contains(startLine, startChar) && loc.Contains(startLine, startChar))
+ def isAllEditingInMethodBody = loc.Contains(startLine, startChar)
+ && loc.Contains(newEndLine, newEndChar)
+ && loc.Contains(startLine, startChar);
+
+ if (isAllEditingInMethodBody)
{
this.Engine.AddRelocation(fileIndex, newEndChar, newEndLine, oldEndChar, oldEndLine);
- assert(1 == 1);
- //this.Engine.Output.WriteLine(loc);
- def l = loc.EndLine;
- def c = loc.EndColumn;
- _ = l + c;
- TmpLocation = loc;
+ UpdateDebugTree(fileIndex);
true
}
else
@@ -73,7 +65,6 @@
| _ => false
}
- }
} // AddRelocation
} // end class Engine
} // end namespace
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n Thu Sep 21 03:24:07 2006
@@ -0,0 +1,144 @@
+using System;
+using System.Windows.Forms;
+using Nemerle.Compiler;
+using Nemerle.Compiler.Utils;
+
+namespace Nemerle.Completion2
+{
+ public delegate ShowLocation(_ : Location) : void;
+
+ public class CompiledUnitAstBrowser : Form
+ {
+ FillTree(root : Decl) : void
+ {
+ def addLocation(nodes, kind, name, location)
+ {
+ when (!name.IsNullOrEmpty())
+ {
+ def newNode = nodes.Add($"$kind: $name");
+ newNode.Tag = location;
+ }
+ }
+
+ def addName(nodes, name, locations)
+ {
+ when (!name.IsNullOrEmpty())
+ {
+ def newNode = nodes.Add($"Name: $name");
+ mutable locAll = Nemerle.Compiler.Location.Default;
+
+ foreach (loc in locations)
+ {
+ locAll += loc;
+ def newSubNode = newNode.Nodes.Add("name part");
+ newSubNode.Tag = loc;
+ }
+
+ newNode.Tag = locAll;
+ }
+ }
+
+ def addType(builder)
+ {
+ _ = builder;
+ }
+
+ def add(nodes, astNode)
+ {
+ def newNode = nodes.Add($"$(astNode.GetType().Name): $astNode");
+ newNode.Tag = astNode;
+
+ match (astNode : Decl)
+ {
+ | Using as x =>
+ addName(newNode.Nodes, x.Name, x.NameLocations);
+ addLocation(newNode.Nodes, "Alias", x.Alias, x.AliasLocation);
+
+ | Namespace as x =>
+ addName(newNode.Nodes, x.Name, x.NameLocations);
+ addLocation(newNode.Nodes, "BodyLocation", "{}", x.BodyLocation);
+ foreach (decl in x.Decls)
+ add(newNode.Nodes, decl)
+
+ | Type(builder) => addType(builder);
+
+ | GlobalAttribute => ()
+ | None => ()
+ }
+ }
+
+ try
+ {
+ Tree.BeginUpdate();
+ Tree.Nodes.Clear();
+ add(Tree.Nodes, root);
+ }
+ finally
+ {
+ Tree.EndUpdate();
+ }
+ Tree.Nodes[0].Expand();
+ }
+
+ static mutable _instance : CompiledUnitAstBrowser;
+
+ public static Instance : CompiledUnitAstBrowser
+ {
+ get
+ {
+ when (_instance == null)
+ {
+ _instance = CompiledUnitAstBrowser();
+ _instance.Show();
+ }
+
+ _instance;
+ }
+ }
+
+ public mutable _root : Decl;
+
+ public Root : Decl
+ {
+ get { _root }
+ set
+ {
+ _root = value;
+ FillTree(value);
+ }
+ }
+
+ Tree : TreeView;
+
+ public static event ShowLocation : ShowLocation;
+
+ public this()
+ {
+ //def scrBnds = Screen.PrimaryScreen.Bounds;
+ Tree = TreeView();
+ TopMost = true;
+ Tree.Dock = DockStyle.Fill;
+ Controls.Add(Tree);
+ Bounds = System.Drawing.Rectangle(858, 641, 300, 161);
+ Top = 600;
+ Left = 1000;
+ Tree.AfterSelect += fun(_, arg : TreeViewEventArgs)
+ {
+ def node = arg.Node;
+ when (CompiledUnitAstBrowser.ShowLocation != null)
+ match (node.Tag)
+ {
+ | loc is Location => CompiledUnitAstBrowser.ShowLocation(loc);
+ | _ => ()
+ }
+ _ = node;
+ };
+ }
+
+ protected override OnClosed(e : EventArgs) : void
+ {
+ _instance = null;
+ base.OnClosed(e);
+ }
+ }
+}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Decl.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Decl.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Decl.n Thu Sep 21 03:24:07 2006
@@ -9,27 +9,27 @@
| GlobalAttribute { }
| Using
{
- Name : list [string];
- NameLocations : list [Location];
+ Name : list[string];
+ mutable NameLocations : list[Location];
Alias : string;
- AliasLocation : Location;
+ mutable AliasLocation : Location;
BeforeEnv : GlobalEnv;
AfterEnv : GlobalEnv;
}
| Namespace
{
mutable Decls : list[Decl];
- Name : list [string];
- NameLocations : list [Location];
+ Name : list[string];
+ mutable NameLocations : list[Location];
OutsideEnv : GlobalEnv;
InsideEnv : GlobalEnv;
- BodyLocation : Location;
+ mutable BodyLocation : Location;
}
| Type { Builder : TypeBuilder; }
| None
- [Accessor]
- _location : Location;
+ [Accessor (flags = WantSetter)]
+ mutable _location : Location;
public override ToString() : string
{
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-Relocation.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-Relocation.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-Relocation.n Thu Sep 21 03:24:07 2006
@@ -12,6 +12,7 @@
using Nemerle.Compiler.Utils;
using Typed = Nemerle.Compiler.Typedtree;
using SR = System.Reflection;
+using Nemerle.Completion2;
namespace Nemerle.Completion2
{
@@ -23,53 +24,11 @@
oldEndChar : int, oldEndLine : int
) : void
{
- def a = oldEndLine; //Math.Max(oldEndLine, newEndLine);
- def firstLine = a;
- def firstChar = if (newEndLine == oldEndLine && newEndChar > oldEndChar) newEndChar else oldEndChar;
- def lineOffset = newEndLine - oldEndLine;
- def charOffset = newEndChar - oldEndChar;
+ _ = newEndChar + newEndLine + oldEndChar + oldEndLine;
- //assert(firstLine == Math.Max(oldEndLine, newEndLine));
-
- def relMap = Location.RelocationMaps[fileIndex];
-
- if (relMap == null) // no relocations
- {
- def newMap = SCG.List();
- Location.RelocationMaps[fileIndex] = newMap;
- newMap.Add(Relocation(firstLine, firstChar, lineOffset, charOffset));
- }
- else // exists some relocations
- {
- def res = relMap.BinarySearch (elem => elem.Line - firstLine);
- def index = if (res < 0) ~res else res;
-
- def prevLineOffset = if (index > 0) relMap[index - 1].LineOffset else 0;
-
- if (res < 0)
- relMap.Insert(index, Relocation(firstLine - prevLineOffset, firstChar,
- lineOffset + prevLineOffset, charOffset));
- else
- {
- def rel = relMap[index];
- def newLineOffset = rel.LineOffset + lineOffset;
- def newCharOffset = rel.ColumnOffset + charOffset;
-
- if (newLineOffset == 0 && newCharOffset == 0)
- _ = relMap.RemoveAt(index);
- else
- relMap[index] = Relocation(firstLine, Math.Min(firstChar, rel.Column),
- newLineOffset, newCharOffset)
- }
-
- for (mutable i = index + 1; i < relMap.Count; i++)
- {
- def rel = relMap[i];
- def newRel = Relocation(rel.Line, rel.Column + lineOffset,
- rel.LineOffset + lineOffset, rel.ColumnOffset);
- relMap[i] = newRel;
- }
- }
+ def prj = this.Project;
+ def unit = prj.CompileUnits[fileIndex] : Decl;
+ unit.Relocate(oldEndLine, oldEndChar, newEndLine - oldEndLine, newEndChar - oldEndChar);
}
} // end class Engine
} // end namespace
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-main.n Thu Sep 21 03:24:07 2006
@@ -120,7 +120,9 @@
when (_fileInfos[i] != null)
AddTypeBilders(_fileInfos[i], i, nsTree);
- Project(this, CompileUnitCollection(this, _fileInfos), nsTree)
+ _project = Project(this, CompileUnitCollection(this, _fileInfos), nsTree);
+
+ _project
}
protected ClearRelocationMaps() : void
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.ParseEvents.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.ParseEvents.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.ParseEvents.n Thu Sep 21 03:24:07 2006
@@ -41,7 +41,7 @@
EndParseFile(fileIndex : int) : void
{
- def loc = Location(fileIndex, 0, 0, 1000000, 0);
+ def loc = Location(fileIndex, 1, 1, 1000000, 1);
_fileInfos[fileIndex] = Decl.Namespace(loc, _decls.Rev(), [],
[], CoreEnv, CoreEnv, loc);
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine.Properties.n Thu Sep 21 03:24:07 2006
@@ -24,6 +24,7 @@
[Accessor] mutable _references : ReferenceCollection;
[Accessor] _sources : SourceCollection;
[Accessor] mutable _state : EngineState;
+ [Accessor] mutable _project : Project;
// If you want to recover the messages done by the parser/typer
public Output : System.IO.TextWriter
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Relocation.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Relocation.n Thu Sep 21 03:24:07 2006
@@ -0,0 +1,67 @@
+using Nemerle.Compiler;
+using Nemerle.Utility;
+
+namespace Nemerle.Completion2
+{
+ module Relocation
+ {
+ public Relocate(this decl : Decl, line : int, ch : int, lineOffset : int, chOffset : int) : void
+ {
+ def loc = decl.Location;
+ def isLocationChanged = loc.EndLine > line || loc.EndLine == line && loc.EndColumn >= ch;
+ def relocateChildren(_ : Decl) : void
+ {
+ | GlobalAttribute => ()
+ | Using as x =>
+ x.NameLocations = x.NameLocations.Map(Relocate(_, line, ch, lineOffset, chOffset));
+ x.AliasLocation = Relocate(x.AliasLocation, line, ch, lineOffset, chOffset);
+
+ | Namespace as x =>
+ x.Decls.Iter(Relocate(_, line, ch, lineOffset, chOffset));
+ x.NameLocations = x.NameLocations.Map(Relocate(_, line, ch, lineOffset, chOffset));
+ x.BodyLocation = Relocate(x.BodyLocation, line, ch, lineOffset, chOffset);
+
+ | Type(builder) => builder.Relocate(loc.FileIndex, line, ch, lineOffset, chOffset);
+ | None => ()
+ }
+
+ when (isLocationChanged)
+ {
+ relocateChildren(decl);
+ decl.Location = Relocate(loc, line, ch, lineOffset, chOffset);
+ }
+ }
+
+ public Relocate(
+ this typeBuilder : TypeBuilder,
+ fileIndex : int,
+ line : int,
+ ch : int,
+ lineOffset : int,
+ chOffset : int
+ )
+ : void
+ {
+ _ = typeBuilder;
+ _ = fileIndex + line + ch + lineOffset + chOffset;
+ }
+
+ /// Ńäâčăŕĺň Location íŕ îďđĺäĺëĺííîĺ ęîëč÷ĺńňâî ńňđîę č ńčěâîëîâ.
+ public static Relocate(loc : Location, line : int, ch : int, lineOffset : int, chOffset : int) : Location
+ {
+ def relocatePoint(oldLn, oldCh)
+ {
+ if (oldLn > line) (oldLn + lineOffset, oldCh)
+ else if (oldLn == line && oldCh >= ch)
+ if (lineOffset == 0) (oldLn, oldCh + chOffset)
+ else (oldLn + lineOffset, chOffset)
+ else (oldLn, oldCh)
+ }
+
+ def (newLn, newCh) = relocatePoint(loc.Line, loc.Column);
+ def (newEndLn, newEndCh) = relocatePoint(loc.EndLine, loc.EndColumn);
+
+ Location(loc.FileIndex, newLn, newCh, newEndLn, newEndCh);
+ }
+ }
+}
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 Thu Sep 21 03:24:07 2006
@@ -11,11 +11,16 @@
{
public module Utils
{
- public IsNullOrEmpty1(this value : string) : bool
+ public IsNullOrEmpty(this value : string) : bool
{
if (value == null) true else value.Length == 0
}
+ public IsNullOrEmpty[T](this value : list[T]) : bool
+ {
+ if (value == null) true else value.IsEmpty
+ }
+
public IsVariantType(sysType : Type) : bool
{
sysType.GetCustomAttributes(Const.VariantType, false).Length == 1
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleLanguage.cs Thu Sep 21 03:24:07 2006
@@ -29,6 +29,8 @@
using Nemerle.VsIntegration;
using System.Security.Permissions;
using PR = Microsoft.VisualStudio.Package.ParseReason;
+using VsShell = Microsoft.VisualStudio.Shell.VsShellUtilities;
+using Microsoft.VisualStudio.Shell.Interop;
namespace Microsoft.Samples.VisualStudio.NemerleLanguageService
{
@@ -36,6 +38,44 @@
[Guid(GlobalConstants.LanguageServiceGuidString)]
public class NemerleLanguage : LanguageService
{
+ public NemerleLanguage()
+ {
+ CompiledUnitAstBrowser.ShowLocation += CompiledUnitAstBrowser_ShowLocation;
+ }
+
+ void CompiledUnitAstBrowser_ShowLocation(Location loc)
+ {
+ TextSpan span = new TextSpan();
+ span.iStartLine = loc.Line - 1;
+ span.iStartIndex = loc.Column - 1;
+ span.iEndLine = loc.EndLine - 1;
+ span.iEndIndex = loc.EndColumn - 1;
+
+ string fileName = loc.File;
+ IVsUIHierarchy hierarchy;
+ uint itemID;
+ IVsWindowFrame docFrame;
+ IVsTextView textView;
+ VsShell.OpenDocument(Site, fileName,
+ NativeMethods.LOGVIEWID_Code, out hierarchy, out itemID, out docFrame, out textView);
+
+ NativeMethods.ThrowOnFailure(docFrame.Show());
+ if (textView != null)
+ {
+ try
+ {
+ NativeMethods.ThrowOnFailure(textView.SetCaretPos(span.iStartLine, span.iStartIndex));
+ TextSpanHelper.MakePositive(ref span);
+ NativeMethods.ThrowOnFailure(textView.SetSelection(span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex));
+ NativeMethods.ThrowOnFailure(textView.EnsureSpanVisible(span));
+ }
+ catch (Exception ex)
+ {
+ Trace.WriteLine(ex.Message);
+ }
+ }
+ }
+
LanguagePreferences _preferences;
NemerleScanner _scanner;
//Modules modules = new Modules();
@@ -60,7 +100,7 @@
new NemerleColorableItem("String", COLORINDEX.CI_DARKBLUE, COLORINDEX.CI_USERTEXT_BK),
new NemerleColorableItem("Number", COLORINDEX.CI_DARKBLUE, COLORINDEX.CI_USERTEXT_BK),
new NemerleColorableItem("Text", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK),
- new NemerleColorableItem("Operator", COLORINDEX.CI_RED, COLORINDEX.CI_USERTEXT_BK)
+ new NemerleColorableItem("Operator", COLORINDEX.CI_DARKBLUE, COLORINDEX.CI_USERTEXT_BK)
};
public override void Dispose()
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs Thu Sep 21 03:24:07 2006
@@ -19,6 +19,9 @@
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Package;
using NP = Nemerle.VsIntegration.Project;
+using Nemerle.Completion2;
+using Nemerle.Compiler;
+using Microsoft.VisualStudio.TextManager.Interop;
namespace Microsoft.Samples.VisualStudio.NemerleLanguageService
{
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleSource.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleSource.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleSource.cs Thu Sep 21 03:24:07 2006
@@ -76,161 +76,6 @@
}
base.OnChangeLineText(lineChange, last);
-
-
- // Debug
- ListBox relocs = TestForm.GetInstance(this).Relocs;
- relocs.BeginUpdate();
-
- try
- {
- relocs.Items.Clear();
-
- List<Relocation> relocations = Location.RelocationMaps[Location.GetFileIndex(GetFilePath())];
-
- Location loc = Project.TmpLocation;
-
- if (!loc.Equals(Location.Default))
- relocs.Items.Add(new Relocation(loc.Line, loc.Column,
- loc.EndLine - loc.Line, loc.EndColumn - loc.Column));
-
- if (relocations != null)
- foreach (Relocation relo in relocations)
- relocs.Items.Add(relo);
- }
- finally
- {
- relocs.EndUpdate();
- }
- }
-
- internal static void DebugClear()
- {
- TestForm.GetInstance(null).Relocs.Items.Clear();
- }
-
- internal class TestForm : Form
- {
- public TestForm()
- {
- Bounds = new System.Drawing.Rectangle(858, 641, 300, 161);
- TopMost = true;
- Relocs.Dock = DockStyle.Fill;
- Controls.Add(Relocs);
- Relocs.SelectedIndexChanged += Relocs_SelectedIndexChanged;
- }
-
- new object GetService(Type serviceType)
- {
- return _source.LanguageService.Site.GetService(serviceType);
- }
-
- [ComImport, Guid("6D5140C1-7436-11CE-8034-00AA006009FA"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- public interface IOleServiceProvider
- {
- [PreserveSig]
- int QueryService([In] ref Guid guidService, [In] ref Guid riid, out IntPtr ppvObject);
- }
-
- void Relocs_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (Relocs.SelectedItem == null)
- return;
-
- Relocation reloc = (Relocation)Relocs.SelectedItem;
-
- TextSpan span = new TextSpan();
- span.iStartLine = reloc.Line - 1;
- span.iStartIndex = reloc.Column - 1;
- span.iEndLine = span.iStartLine + reloc.LineOffset;
- span.iEndIndex = span.iStartIndex + reloc.ColumnOffset;
-
- string fileName = _source.GetFilePath();
- IVsUIHierarchy hierarchy;
- uint itemID;
- IVsWindowFrame docFrame;
- IVsTextView textView;
- VsShell.OpenDocument(_source.LanguageService.Site, fileName,
- NativeMethods.LOGVIEWID_Code, out hierarchy, out itemID, out docFrame, out textView);
-
- NativeMethods.ThrowOnFailure(docFrame.Show());
- if (textView != null)
- {
- NativeMethods.ThrowOnFailure(textView.SetCaretPos(span.iStartLine, span.iStartIndex));
- TextSpanHelper.MakePositive(ref span);
- NativeMethods.ThrowOnFailure(textView.SetSelection(span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex));
- NativeMethods.ThrowOnFailure(textView.EnsureSpanVisible(span));
- }
-
-
- //IVsUIShellOpenDocument openDoc = GetService(
- // typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
-
- //if (openDoc == null)
- // return;
-
- //IVsWindowFrame frame;
- //IOleServiceProvider sp;
- //IVsUIHierarchy hier;
- //uint itemid;
- //Guid logView = logicalView;
-
- //if (NativeMethods.Failed(openDoc.OpenDocumentViaProject(task.Document, ref logView, out sp, out hier, out itemid, out frame)) || frame == null)
- // return;
-
- //object docData;
- //frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData);
-
- //VsTextBuffer buffer = docData as VsTextBuffer;
- //if (buffer == null)
- //{
- // IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider;
- // if (bufferProvider != null)
- // {
- // IVsTextLines lines;
- // NativeMethods.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines));
- // buffer = lines as VsTextBuffer;
- // Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer");
- // if (buffer == null)
- // return;
- // }
- //}
-
- //IVsTextManager mgr = GetService(
- // typeof(VsTextManagerClass)) as IVsTextManager;
-
- //if (mgr == null)
- // return;
-
- //int line = 0;
-
- //mgr.NavigateToLineAndColumn(buffer, ref logicalView, line, 0, line, 0);
- }
-
- NemerleSource _source;
-
- public static TestForm GetInstance(NemerleSource source)
- {
- if (_instance == null)
- {
- _instance = new TestForm();
- _instance.Show();
- }
-
- _instance._source = source;
-
- return _instance;
- }
-
- protected override void OnClosed(EventArgs e)
- {
- _instance = null;
- base.OnClosed(e);
- }
-
- static TestForm _instance;
-
- public ListBox Relocs = new ListBox();
}
private static TextLineChange ConvertToLocation(TextLineChange changes)
More information about the svn
mailing list