[svn] r6882: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
Nemerle....
phantom
svnadmin at nemerle.org
Mon Nov 13 21:39:51 CET 2006
Log:
Author: phantom
Date: Mon Nov 13 21:39:48 2006
New Revision: 6882
Modified:
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.VsIntegration/GUI/GoToTypeForm.cs
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
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 Mon Nov 13 21:39:48 2006
@@ -262,6 +262,48 @@
}
}
+ // TODO: implement get usages behaviour, this is a stub yet
+ private FindUsages(
+ typeDecl : Decl.Type,
+ fileIndex : int,
+ line : int,
+ col : int
+ )
+ : list [GotoInfo]
+ {
+ def (_, _, declarationObject) = FindObject(typeDecl, fileIndex, line, col);
+ // TODO: implement other type usages finding, not only variables
+ def (declaration, _) = match (declarationObject)
+ {
+ | localValue is LocalValue => (localValue, GotoInfo(localValue))
+ | _ => (null, null)
+ }
+ if (declaration == null)
+ []
+ else
+ {
+ // TODO: use lexer output for quick search, cache it if it is not cached yet
+ def findPossibleUsages(declaration)
+ {
+ mutable entries = [];
+ foreach ((path, code) in _engine.Sources._sources.KeyValuePairs)
+ {
+ Debug.WriteLine(path);
+ def position = code.IndexOf(declaration.Name);
+ unless (position < 0)
+ entries ::= Location(path, 10, 1, 12, 2);
+ }
+ entries
+ }
+ // TODO: check the symbol found
+ def onlyRightUsages(_)
+ {
+ true
+ }
+ findPossibleUsages(declaration).Filter(onlyRightUsages).Map(GotoInfo(_));
+ }
+ }
+
GetMethodTip(
typeDecl : Decl.Type,
fileIndex : int,
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 Mon Nov 13 21:39:48 2006
@@ -139,6 +139,19 @@
}
}
+ public GetUsages([NotNull] filePath : string, line : int, col : int) : array [GotoInfo]
+ {
+ def fileIndex = _compileUnits.GetFileIndex(filePath);
+ def decl = GetActiveDecl(fileIndex, line, col);
+
+ match (decl)
+ {
+ | Type as type' => FindUsages(type', fileIndex, line, col).ToArray();
+ | None => throw System.Exception()
+ | _ => null
+ }
+ }
+
private _Debug[T](obj : T) : void
{
_ = obj.ToString();
Modified: vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.cs Mon Nov 13 21:39:48 2006
@@ -33,6 +33,7 @@
{
base.OnLoad(e);
+ // TODO: when the list is large, the form is out of a screen (bound it)
// Adjust size
//
_listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs Mon Nov 13 21:39:48 2006
@@ -87,7 +87,22 @@
{
span = new TextSpan();
- GotoInfo[] info = _project.GetGoto(_filePath, line, col, _sourceText);
+ GotoInfo[] info;
+ switch (cmd)
+ {
+ case VSConstants.VSStd97CmdID.GotoDecl:
+ case VSConstants.VSStd97CmdID.GotoDefn:
+ info = _project.GetGoto(_filePath, line, col, _sourceText);
+ break;
+ case VSConstants.VSStd97CmdID.GotoRef:
+ info = _project.GetUsages(_filePath, line, col, _sourceText);
+ break;
+ default:
+ // phantom: don't know what other command ids possible,
+ // let it be goto declaration by default
+ info = _project.GetGoto(_filePath, line, col, _sourceText);
+ break;
+ }
if (info == null || info.Length == 0)
{
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 Mon Nov 13 21:39:48 2006
@@ -375,6 +375,12 @@
return Project.GetGotoInfo(filePath, line + 1, col + 1);
}
+ public GotoInfo[] GetUsages(string filePath, int line, int col, ISource source)
+ {
+ ErrorHelper.ThrowIfPathNullOrEmpty(filePath, "filePath");
+ return Project.GetUsages(filePath, line + 1, col + 1);
+ }
+
public NemerleMethods GetMethodTip(string filePath, int line, int col, ISource source)
{
ErrorHelper.ThrowIfPathNullOrEmpty(filePath, "filePath");
More information about the svn
mailing list