[Monodevelop-patches-list] r2720 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Commands Gui/Completion Gui/ContentInterfaces Gui/Pads/ClassPad Gui/Workbench Internal/Parser Internal/Project/Project Services Services/ParserService Services/Project
Lluis Sanchez <lluis@ximian.com>
lluis at mono-cvs.ximian.com
Tue Aug 9 19:45:27 EDT 2005
Author: lluis
Date: 2005-08-09 19:45:27 -0400 (Tue, 09 Aug 2005)
New Revision: 2720
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/AutostartCommands.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CodeCompletionDataProvider.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CommentCompletionDataProvider.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CompletionListWindow.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/ICompletionDataProvider.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/TemplateCompletionDataProvider.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IEditable.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ClassPad/NamespaceNodeBuilder.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ClassPad/ProjectNodeBuilder.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/IParser.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/ProjectReference.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/AssemblyCodeCompletionDatabase.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/CodeCompletionDatabase.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/IParserService.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/ProjectCodeCompletionDatabase.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/SimpleCodeCompletionDatabase.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/IProjectService.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/SystemAssemblyService.cs
Log:
2005-08-09 Lluis Sanchez Gual <lluis at novell.com>
* MonoDevelopCore.addin.xml:
* Commands/AutostartCommands.cs: Remove useless autostart command.
* Services/Project/IProjectService.cs:
* Services/Project/ProjectService.cs: Added a parser database to store
information about the opened combine.
* Internal/Project/Project/ProjectReference.cs:
* Services/SystemAssemblyService.cs: Added GetAssemblyLocation method,
which returns the path to an assembly by loading it out-of-process.
* Internal/Parser/IParser.cs:
* Services/ParserService/IParserService.cs:
* Services/ParserService/CodeCompletionDatabase.cs:
* Services/ParserService/AssemblyCodeCompletionDatabase.cs:
* Services/ParserService/SimpleCodeCompletionDatabase.cs:
* Gui/Pads/ClassPad/ProjectNodeBuilder.cs:
* Gui/Pads/ClassPad/NamespaceNodeBuilder.cs:
* Services/ParserService/DefaultParserService.cs:
* Services/ParserService/ProjectCodeCompletionDatabase.cs:
Use the new IParserContext API.
* Gui/ContentInterfaces/IEditable.cs: Added TextChanged event.
* Gui/Workbench/DefaultWorkbench.cs: Reparse the active file when
the text changes.
* Gui/Completion/CommentCompletionDataProvider.cs:
* Gui/Completion/ICompletionDataProvider.cs:
* Gui/Completion/CodeCompletionDataProvider.cs:
* Gui/Completion/TemplateCompletionDataProvider.cs:
* Gui/Completion/CompletionListWindow.cs: Project and FileName have
now been moved into ICompletionDataProvider, so there is no need
to pass them to all methods.
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-08-09 23:45:27 UTC (rev 2720)
@@ -1,3 +1,39 @@
+2005-08-09 Lluis Sanchez Gual <lluis at novell.com>
+
+ * MonoDevelopCore.addin.xml:
+ * Commands/AutostartCommands.cs: Remove useless autostart command.
+
+ * Services/Project/IProjectService.cs:
+ * Services/Project/ProjectService.cs: Added a parser database to store
+ information about the opened combine.
+
+ * Internal/Project/Project/ProjectReference.cs:
+ * Services/SystemAssemblyService.cs: Added GetAssemblyLocation method,
+ which returns the path to an assembly by loading it out-of-process.
+
+ * Internal/Parser/IParser.cs:
+ * Services/ParserService/IParserService.cs:
+ * Services/ParserService/CodeCompletionDatabase.cs:
+ * Services/ParserService/AssemblyCodeCompletionDatabase.cs:
+ * Services/ParserService/SimpleCodeCompletionDatabase.cs:
+ * Gui/Pads/ClassPad/ProjectNodeBuilder.cs:
+ * Gui/Pads/ClassPad/NamespaceNodeBuilder.cs:
+ * Services/ParserService/DefaultParserService.cs:
+ * Services/ParserService/ProjectCodeCompletionDatabase.cs:
+ Use the new IParserContext API.
+
+ * Gui/ContentInterfaces/IEditable.cs: Added TextChanged event.
+ * Gui/Workbench/DefaultWorkbench.cs: Reparse the active file when
+ the text changes.
+
+ * Gui/Completion/CommentCompletionDataProvider.cs:
+ * Gui/Completion/ICompletionDataProvider.cs:
+ * Gui/Completion/CodeCompletionDataProvider.cs:
+ * Gui/Completion/TemplateCompletionDataProvider.cs:
+ * Gui/Completion/CompletionListWindow.cs: Project and FileName have
+ now been moved into ICompletionDataProvider, so there is no need
+ to pass them to all methods.
+
2005-08-08 Lluis Sanchez Gual <lluis at novell.com>
* Services/File/DefaultFileService.cs: Properly jump to the requested
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/AutostartCommands.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/AutostartCommands.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Commands/AutostartCommands.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -34,14 +34,6 @@
}
}
- internal class StartParserServiceThread : AbstractCommand
- {
- public override void Run()
- {
- ((DefaultParserService)Runtime.ParserService).StartParserThread();
- }
- }
-
internal class StartWorkbenchCommand : AbstractCommand
{
const string workbenchMemento = "SharpDevelop.Workbench.WorkbenchMemento";
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CodeCompletionDataProvider.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CodeCompletionDataProvider.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CodeCompletionDataProvider.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -41,19 +41,23 @@
int caretLineNumber;
int caretColumn;
bool ctrlspace;
+ IParserContext parserContext;
+ string fileName;
- public CodeCompletionDataProvider() : this (false)
+ public CodeCompletionDataProvider (IParserContext parserContext, string fileName) : this (parserContext, fileName, false)
{
}
- public CodeCompletionDataProvider (bool ctrl)
+ public CodeCompletionDataProvider (IParserContext parserContext, string fileName, bool ctrl)
{
+ this.fileName = fileName;
+ this.parserContext = parserContext;
this.ctrlspace = ctrl;
}
ArrayList completionData = null;
- public ICompletionData[] GenerateCompletionData(Project project, string fileName, ICompletionWidget widget, char charTyped)
+ public ICompletionData[] GenerateCompletionData (ICompletionWidget widget, char charTyped)
{
completionData = new ArrayList();
@@ -63,30 +67,29 @@
//string expression = TextUtilities.GetExpressionBeforeOffset (textArea, insertIter.Offset);
ResolveResult results;
- IParserService parserService = (IParserService)MonoDevelop.Core.Services.ServiceManager.GetService(typeof(IParserService));
- IExpressionFinder expressionFinder = parserService.GetExpressionFinder(fileName);
+ IExpressionFinder expressionFinder = parserContext.GetExpressionFinder(fileName);
string expression = expressionFinder == null ? TextUtilities.GetExpressionBeforeOffset(widget, widget.TriggerOffset) : expressionFinder.FindExpression(widget.GetText (0, widget.TriggerOffset), widget.TriggerOffset - 2);
if (expression == null) return null;
Console.WriteLine ("Expr: |{0}|", expression);
//FIXME: This chartyped check is a fucking *HACK*
if (expression == "is" || expression == "as") {
string expr = expressionFinder == null ? TextUtilities.GetExpressionBeforeOffset (widget, widget.TriggerOffset - 3) : expressionFinder.FindExpression (widget.GetText (0, widget.TriggerOffset), widget.TriggerOffset - 5);
- AddResolveResults (parserService.IsAsResolve (project, expr, caretLineNumber, caretColumn, fileName, widget.GetText (0, widget.TextLength)));
+ AddResolveResults (parserContext.IsAsResolve (expr, caretLineNumber, caretColumn, fileName, widget.GetText (0, widget.TextLength)));
return (ICompletionData[])completionData.ToArray (typeof (ICompletionData));
}
if (ctrlspace && charTyped != '.') {
- AddResolveResults (parserService.CtrlSpace (parserService, project, caretLineNumber, caretColumn, fileName));
+ AddResolveResults (parserContext.CtrlSpace (caretLineNumber, caretColumn, fileName));
return (ICompletionData[])completionData.ToArray (typeof (ICompletionData));
}
if (charTyped == ' ') {
if (expression == "using" || expression.EndsWith(" using") || expression.EndsWith("\tusing")|| expression.EndsWith("\nusing")|| expression.EndsWith("\rusing")) {
- string[] namespaces = parserService.GetNamespaceList(project, "", true, true);
+ string[] namespaces = parserContext.GetNamespaceList ("", true, true);
AddResolveResults(new ResolveResult(namespaces));
}
} else {
//FIXME: I added the null check, #D doesnt need it, why do we?
if (fileName != null) {
- results = parserService.Resolve(project, expression, caretLineNumber, caretColumn, fileName, widget.GetText (0, widget.TextLength));
+ results = parserContext.Resolve (expression, caretLineNumber, caretColumn, fileName, widget.GetText (0, widget.TextLength));
AddResolveResults(results);
}
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CommentCompletionDataProvider.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CommentCompletionDataProvider.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CommentCompletionDataProvider.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -52,7 +52,7 @@
new string[] {"value", "A description of a property"}
};
*/
- public ICompletionData[] GenerateCompletionData (Project project, string fileName, ICompletionWidget widget, char charTyped)
+ public ICompletionData[] GenerateCompletionData (ICompletionWidget widget, char charTyped)
{
/*caretLineNumber = textArea.Caret.Line;
caretColumn = textArea.Caret.Column;
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CompletionListWindow.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CompletionListWindow.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/CompletionListWindow.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -36,9 +36,9 @@
SizeAllocated += new SizeAllocatedHandler (ListSizeChanged);
}
- public static void ShowWindow (char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget, Project project, string fileName)
+ public static void ShowWindow (char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget)
{
- if (!wnd.ShowListWindow (firstChar, provider, completionWidget, project, fileName))
+ if (!wnd.ShowListWindow (firstChar, provider, completionWidget))
return;
// makes control-space in midle of words to work
@@ -58,11 +58,11 @@
wnd.PartialWord = wnd.CompleteWord;
}
- bool ShowListWindow (char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget, Project project, string fileName)
+ bool ShowListWindow (char firstChar, ICompletionDataProvider provider, ICompletionWidget completionWidget)
{
this.completionWidget = completionWidget;
- completionData = provider.GenerateCompletionData (project, fileName, completionWidget, firstChar);
+ completionData = provider.GenerateCompletionData (completionWidget, firstChar);
if (completionData == null || completionData.Length == 0) return false;
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/ICompletionDataProvider.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/ICompletionDataProvider.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/ICompletionDataProvider.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -13,8 +13,10 @@
using Gdk;
-namespace MonoDevelop.Gui.Completion {
- public interface ICompletionDataProvider {
- ICompletionData[] GenerateCompletionData(Project project, string fileName, ICompletionWidget widget, char charTyped);
+namespace MonoDevelop.Gui.Completion
+{
+ public interface ICompletionDataProvider
+ {
+ ICompletionData[] GenerateCompletionData (ICompletionWidget widget, char charTyped);
}
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/TemplateCompletionDataProvider.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/TemplateCompletionDataProvider.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Completion/TemplateCompletionDataProvider.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -19,6 +19,13 @@
{
public class TemplateCompletionDataProvider : ICompletionDataProvider
{
+ string fileName;
+
+ public TemplateCompletionDataProvider (string fileName)
+ {
+ this.fileName = fileName;
+ }
+
public Gdk.Pixbuf[] ImageList
{
get {
@@ -26,9 +33,9 @@
}
}
- public ICompletionData[] GenerateCompletionData(Project project, string fileName, ICompletionWidget widget, char charTyped)
+ public ICompletionData[] GenerateCompletionData (ICompletionWidget widget, char charTyped)
{
- CodeTemplateGroup templateGroup = CodeTemplateLoader.GetTemplateGroupPerFilename(fileName);
+ CodeTemplateGroup templateGroup = CodeTemplateLoader.GetTemplateGroupPerFilename (fileName);
if (templateGroup == null) {
return null;
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IEditable.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IEditable.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/ContentInterfaces/IEditable.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -5,6 +5,8 @@
// <version value="$version"/>
// </file>
+using System;
+
namespace MonoDevelop.Gui
{
public interface IEditable: ITextBuffer
@@ -22,5 +24,7 @@
void Redo();
new string SelectedText { get; set; }
+
+ event EventHandler TextChanged;
}
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ClassPad/NamespaceNodeBuilder.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ClassPad/NamespaceNodeBuilder.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ClassPad/NamespaceNodeBuilder.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -46,12 +46,12 @@
protected override void Initialize ()
{
changeClassInformationHandler = (ClassInformationEventHandler) Runtime.DispatchService.GuiDispatch (new ClassInformationEventHandler (OnClassInformationChanged));
- Runtime.ParserService.ClassInformationChanged += changeClassInformationHandler;
+ Runtime.ProjectService.ParserDatabase.ClassInformationChanged += changeClassInformationHandler;
}
public override void Dispose ()
{
- Runtime.ParserService.ClassInformationChanged -= changeClassInformationHandler;
+ Runtime.ProjectService.ParserDatabase.ClassInformationChanged -= changeClassInformationHandler;
}
public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
@@ -71,12 +71,14 @@
NamespaceData nsData = dataObject as NamespaceData;
if (nsData.Project != null) {
- ArrayList list = Runtime.ParserService.GetNamespaceContents (nsData.Project, nsData.FullName, false);
+ IParserContext ctx = Runtime.ProjectService.ParserDatabase.GetProjectParserContext (nsData.Project);
+ ArrayList list = ctx.GetNamespaceContents (nsData.FullName, false);
AddProjectContent (builder, nsData.Project, nsData, list);
}
else {
foreach (Project p in Runtime.ProjectService.CurrentOpenCombine.GetAllProjects ()) {
- ArrayList list = Runtime.ParserService.GetNamespaceContents (p, nsData.FullName, false);
+ IParserContext ctx = Runtime.ProjectService.ParserDatabase.GetProjectParserContext (p);
+ ArrayList list = ctx.GetNamespaceContents (nsData.FullName, false);
AddProjectContent (builder, p, nsData, list);
}
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ClassPad/ProjectNodeBuilder.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ClassPad/ProjectNodeBuilder.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Pads/ClassPad/ProjectNodeBuilder.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -85,7 +85,8 @@
{
bool publicOnly = builder.Options ["PublicApiOnly"];
- ArrayList list = Runtime.ParserService.GetNamespaceContents (project, "", false);
+ IParserContext ctx = Runtime.ProjectService.ParserDatabase.GetProjectParserContext (project);
+ ArrayList list = ctx.GetNamespaceContents ("", false);
foreach (object ob in list) {
if (ob is string) {
if (builder.Options ["NestedNamespaces"])
@@ -101,7 +102,8 @@
public static void FillNamespaces (ITreeBuilder builder, Project project, string ns)
{
- if (Runtime.ParserService.GetClassList (project, ns, false, true).Length > 0) {
+ IParserContext ctx = Runtime.ProjectService.ParserDatabase.GetProjectParserContext (project);
+ if (ctx.GetClassList (ns, false, true).Length > 0) {
if (builder.Options ["ShowProjects"])
builder.AddChild (new NamespaceData (project, ns));
else {
@@ -110,7 +112,7 @@
}
}
- string[] list = Runtime.ParserService.GetNamespaceList (project, ns, false, true);
+ string[] list = ctx.GetNamespaceList (ns, false, true);
foreach (string subns in list)
FillNamespaces (builder, project, ns + "." + subns);
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/DefaultWorkbench.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -250,6 +250,10 @@
content.WorkbenchWindow.SelectWindow();
RedrawAllComponents ();
+
+ if (content is IEditable) {
+ ((IEditable)content).TextChanged += new EventHandler (OnViewTextChanged);
+ }
}
public virtual void ShowPad (IPadContent content)
@@ -480,7 +484,60 @@
ActiveWorkbenchWindowChanged(this, e);
}
}
+
+ bool parsingFile;
+
+ void OnViewTextChanged (object sender, EventArgs e)
+ {
+ if (!parsingFile) {
+ parsingFile = true;
+ GLib.Timeout.Add (500, new TimeoutHandler (ParseCurrentFile));
+ }
+ }
+
+ bool ParseCurrentFile ()
+ {
+ parsingFile = false;
+
+ if (ActiveWorkbenchWindow == null || ActiveWorkbenchWindow.ActiveViewContent == null)
+ return false;
+ IEditable editable = ActiveWorkbenchWindow.ActiveViewContent as IEditable;
+ if (editable == null)
+ return false;
+
+ string fileName = null;
+
+ IViewContent viewContent = ActiveWorkbenchWindow.ViewContent;
+ IParseableContent parseableContent = ActiveWorkbenchWindow.ActiveViewContent as IParseableContent;
+
+ if (parseableContent != null) {
+ fileName = parseableContent.ParseableContentName;
+ } else {
+ fileName = viewContent.IsUntitled ? viewContent.UntitledName : viewContent.ContentName;
+ }
+
+ if (fileName == null || fileName.Length == 0)
+ return false;
+
+ if (Runtime.ParserService.GetParser (fileName) == null)
+ return false;
+
+ string text = editable.Text;
+ if (text == null)
+ return false;
+
+ System.Threading.ThreadPool.QueueUserWorkItem (new System.Threading.WaitCallback (AsyncParseCurrentFile), new object[] { viewContent.Project, fileName, text });
+
+ return false;
+ }
+
+ void AsyncParseCurrentFile (object ob)
+ {
+ object[] data = (object[]) ob;
+ Runtime.ProjectService.ParserDatabase.UpdateFile ((Project) data[0], (string) data[1], (string) data[2]);
+ }
+
public Gtk.Toolbar[] ToolBars {
get { return toolbars; }
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/IParser.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/IParser.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Parser/IParser.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -136,18 +136,17 @@
/// Resolves an expression.
/// The caretLineNumber and caretColumn is 1 based.
/// </summary>
- ResolveResult Resolve(IParserService parserService,
- Project_ project,
+ ResolveResult Resolve(IParserContext parserContext,
string expression,
int caretLineNumber,
int caretColumn,
string fileName,
string fileContent);
- string MonodocResolver (IParserService parserService, Project_ project, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
+ string MonodocResolver (IParserContext parserContext, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
- ArrayList IsAsResolve (IParserService parserService, Project_ project, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
+ ArrayList IsAsResolve (IParserContext parserContext, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
- ArrayList CtrlSpace(IParserService parserService, Project_ project, int caretLine, int caretColumn, string fileName);
+ ArrayList CtrlSpace(IParserContext parserContext, int caretLine, int caretColumn, string fileName);
}
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/ProjectReference.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/ProjectReference.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/ProjectReference.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -106,8 +106,8 @@
return reference;
case ReferenceType.Gac:
- string file = Runtime.ParserService.LoadAssemblyFromGac (GetPathToGACAssembly (this));
- return file == String.Empty ? reference : file;
+ string file = Runtime.SystemAssemblyService.GetAssemblyLocation (GetPathToGACAssembly (this));
+ return file == null ? reference : file;
case ReferenceType.Project:
Project p = Runtime.ProjectService.GetProject (reference);
return p != null ? p.GetOutputFileName () : null;
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/MonoDevelopCore.addin.xml 2005-08-09 23:45:27 UTC (rev 2720)
@@ -20,8 +20,6 @@
class = "MonoDevelop.Commands.InitializeWorkbenchCommand"/>
<!--<Class id = "StartCodeCompletionWizard"
class = "MonoDevelop.Commands.StartCodeCompletionWizard"/>-->
- <Class id = "StartParserServiceThread"
- class = "MonoDevelop.Commands.StartParserServiceThread"/>
<!-- #assembly preload -->
<!-- <Class id = "StartSharpAssemblyPreloadThread"
class = "MonoDevelop.Commands.StartSharpAssemblyPreloadThread"/>-->
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/AssemblyCodeCompletionDatabase.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/AssemblyCodeCompletionDatabase.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/AssemblyCodeCompletionDatabase.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -44,8 +44,8 @@
string baseDir;
string assemblyName;
- public AssemblyCodeCompletionDatabase (string baseDir, string assemblyName, DefaultParserService parserService)
- : base (parserService)
+ public AssemblyCodeCompletionDatabase (string baseDir, string assemblyName, ParserDatabase parserDatabase)
+ : base (parserDatabase)
{
string assemblyFile;
string[] refUris;
@@ -97,7 +97,7 @@
protected override void ParseFile (string fileName, IProgressMonitor parentMonitor)
{
IProgressMonitor monitor = parentMonitor;
- if (parentMonitor == null) monitor = parserService.GetParseProgressMonitor ();
+ if (parentMonitor == null) monitor = parserDatabase.GetParseProgressMonitor ();
try {
monitor.BeginTask ("Parsing assembly: " + Path.GetFileName (fileName), 1);
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/CodeCompletionDatabase.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/CodeCompletionDatabase.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/CodeCompletionDatabase.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -54,7 +54,7 @@
NamespaceEntry rootNamespace;
protected ArrayList references;
protected Hashtable files;
- protected DefaultParserService parserService;
+ protected ParserDatabase parserDatabase;
protected Hashtable headers;
BinaryReader datareader;
@@ -67,9 +67,9 @@
protected Object rwlock = new Object ();
- public CodeCompletionDatabase (DefaultParserService parserService)
+ public CodeCompletionDatabase (ParserDatabase parserDatabase)
{
- this.parserService = parserService;
+ this.parserDatabase = parserDatabase;
rootNamespace = new NamespaceEntry ();
files = new Hashtable ();
references = new ArrayList ();
@@ -219,7 +219,7 @@
}
else {
buffer.Position = 0;
- PersistentClass.WriteTo (c, bufWriter, parserService.DefaultNameEncoder);
+ PersistentClass.WriteTo (c, bufWriter, parserDatabase.DefaultNameEncoder);
data = buffer.GetBuffer ();
len = (int)buffer.Position;
}
@@ -303,7 +303,7 @@
}
datafile.Position = ce.Position;
datareader.ReadInt32 (); // Length of data
- return PersistentClass.Read (datareader, parserService.DefaultNameDecoder);
+ return PersistentClass.Read (datareader, parserDatabase.DefaultNameDecoder);
}
void CloseReader ()
@@ -396,7 +396,7 @@
FileInfo fi = new FileInfo (file.FileName);
file.LastParseTime = fi.LastWriteTime;
- parserService.QueueParseJob (new JobCallback (ParseCallback), file.FileName);
+ parserDatabase.QueueParseJob (new JobCallback (ParseCallback), file.FileName);
}
void ParseCallback (object ob, IProgressMonitor monitor)
@@ -658,11 +658,11 @@
{
MemoryStream ms = new MemoryStream ();
BinaryWriter bw = new BinaryWriter (ms);
- PersistentClass.WriteTo (cls, bw, parserService.DefaultNameEncoder);
+ PersistentClass.WriteTo (cls, bw, parserDatabase.DefaultNameEncoder);
bw.Flush ();
ms.Position = 0;
BinaryReader br = new BinaryReader (ms);
- return PersistentClass.Read (br, parserService.DefaultNameDecoder);
+ return PersistentClass.Read (br, parserDatabase.DefaultNameDecoder);
}
bool GetBestNamespaceEntry (string[] path, int length, bool createPath, bool caseSensitive, out NamespaceEntry lastEntry, out int numMatched)
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/DefaultParserService.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -25,14 +25,241 @@
using MonoDevelop.Services;
using MonoDevelop.Core.AddIns;
using MonoDevelop.Internal.Project;
-using MonoDevelop.Gui;
using MonoDevelop.Internal.Parser;
namespace MonoDevelop.Services
{
public class DefaultParserService : AbstractService, IParserService
{
+ IParser[] parsers;
+
+ public override void InitializeService()
+ {
+ parsers = (IParser[])(AddInTreeSingleton.AddInTree.GetTreeNode("/Workspace/Parser").BuildChildItems(this)).ToArray(typeof(IParser));
+ }
+
+ public IParserDatabase CreateParserDatabase ()
+ {
+ ParserDatabase c = new ParserDatabase (this);
+ c.Initialize ();
+ return c;
+ }
+
+ public IExpressionFinder GetExpressionFinder(string fileName)
+ {
+ IParser parser = GetParser (fileName);
+ if (parser != null) {
+ return parser.ExpressionFinder;
+ }
+ return null;
+ }
+
+ public virtual IParser GetParser (string fileName)
+ {
+ // HACK: I'm too lazy to do it 'right'
+ // HACK: Still a hack, but extensible
+ if (fileName != null) {
+ foreach(IParser p in parsers) {
+ if (p.CanParse(fileName)) {
+ return p;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void GenerateAssemblyDatabase (string baseDir, string name)
+ {
+ AssemblyCodeCompletionDatabase db = new AssemblyCodeCompletionDatabase (baseDir, name, (ParserDatabase) CreateParserDatabase());
+ db.ParseInExternalProcess = false;
+ db.ParseAll ();
+ db.Write ();
+ }
+ }
+
+ internal class ParserContext: IParserContext
+ {
+ DefaultParserService parserService;
+ CodeCompletionDatabase db;
+ ParserDatabase pdb;
+
+ internal ParserContext (DefaultParserService parserService, ParserDatabase pdb, CodeCompletionDatabase db)
+ {
+ this.parserService = parserService;
+ this.pdb = pdb;
+ this.db = db;
+ }
+
+ public IExpressionFinder GetExpressionFinder (string fileName)
+ {
+ return pdb.GetExpressionFinder (fileName);
+ }
+
+ public IParseInformation ParseFile (string fileName)
+ {
+ return pdb.ParseFile (fileName);
+ }
+
+ public IParseInformation ParseFile (string fileName, string fileContent)
+ {
+ return pdb.ParseFile (fileName, fileContent);
+ }
+
+ public IParseInformation GetParseInformation (string fileName)
+ {
+ return pdb.GetParseInformation (fileName);
+ }
+
+ public IClass GetClass (string typeName)
+ {
+ return pdb.GetClass (db, typeName);
+ }
+
+ public string[] GetClassList (string subNameSpace, bool includeReferences)
+ {
+ return pdb.GetClassList (db, subNameSpace, includeReferences);
+ }
+
+ public string[] GetNamespaceList (string subNameSpace)
+ {
+ return pdb.GetNamespaceList (db, subNameSpace);
+ }
+
+ public ArrayList GetNamespaceContents (string subNameSpace, bool includeReferences)
+ {
+ return pdb.GetNamespaceContents (db, subNameSpace, includeReferences);
+ }
+
+ public bool NamespaceExists (string name)
+ {
+ return pdb.NamespaceExists (db, name);
+ }
+
+ public string SearchNamespace (IUsing iusing, string partitialNamespaceName)
+ {
+ return pdb.SearchNamespace (db, iusing, partitialNamespaceName);
+ }
+
+ public IClass SearchType (IUsing iusing, string partitialTypeName)
+ {
+ return pdb.SearchType (db, iusing, partitialTypeName);
+ }
+
+
+ public IClass GetClass (string typeName, bool deepSearchReferences, bool caseSensitive)
+ {
+ return pdb.GetClass (db, typeName, deepSearchReferences, caseSensitive);
+ }
+
+ public string[] GetClassList (string subNameSpace, bool includeReferences, bool caseSensitive)
+ {
+ return pdb.GetClassList (db, subNameSpace, includeReferences, caseSensitive);
+ }
+
+ public string[] GetNamespaceList (string subNameSpace, bool includeReferences, bool caseSensitive)
+ {
+ return pdb.GetNamespaceList (db, subNameSpace, includeReferences, caseSensitive);
+ }
+
+ public ArrayList GetNamespaceContents (string subNameSpace, bool includeReferences, bool caseSensitive)
+ {
+ return pdb.GetNamespaceContents (db, subNameSpace, includeReferences, caseSensitive);
+ }
+
+ public bool NamespaceExists (string name, bool caseSensitive)
+ {
+ return pdb.NamespaceExists (db, name, caseSensitive);
+ }
+
+ public string SearchNamespace (IUsing iusing, string partitialNamespaceName, bool caseSensitive)
+ {
+ return pdb.SearchNamespace (db, iusing, partitialNamespaceName, caseSensitive);
+ }
+
+ public IClass SearchType (IUsing iusing, string partitialTypeName, bool caseSensitive)
+ {
+ return pdb.SearchType (db, iusing, partitialTypeName, caseSensitive);
+ }
+
+ public IClass SearchType (string name, IClass callingClass, ICompilationUnit unit)
+ {
+ return pdb.SearchType (db, name, callingClass, unit);
+ }
+
+ public IEnumerable GetClassInheritanceTree (IClass cls)
+ {
+ return pdb.GetClassInheritanceTree (db, cls);
+ }
+
+ public IClass[] GetFileContents (string fileName)
+ {
+ return pdb.GetFileContents (db, fileName);
+ }
+
+ public IClass[] GetProjectContents ()
+ {
+ return pdb.GetProjectContents (db);
+ }
+
+ public ResolveResult Resolve (string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent)
+ {
+ // added exception handling here to prevent silly parser exceptions from
+ // being thrown and corrupting the textarea control
+ try {
+ IParser parser = parserService.GetParser (fileName);
+ //Runtime.LoggingService.Info("Parse info : " + GetParseInformation(fileName).MostRecentCompilationUnit.Tag);
+ if (parser != null) {
+ return parser.Resolve (this, expression, caretLineNumber, caretColumn, fileName, fileContent);
+ }
+ return null;
+ } catch {
+ return null;
+ }
+ }
+
+ public string MonodocResolver (string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent)
+ {
+ try {
+ IParser parser = parserService.GetParser (fileName);
+ if (parser != null) {
+ return parser.MonodocResolver (this, expression, caretLineNumber, caretColumn, fileName, fileContent);
+ }
+ return null;
+ } catch {
+ return null;
+ }
+ }
+
+ public ArrayList IsAsResolve (string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent)
+ {
+ try {
+ IParser parser = parserService.GetParser (fileName);
+ if (parser != null) {
+ return parser.IsAsResolve (this, expression, caretLineNumber, caretColumn, fileName, fileContent);
+ }
+ return null;
+ } catch {
+ return null;
+ }
+ }
+
+ public ArrayList CtrlSpace (int caretLine, int caretColumn, string fileName)
+ {
+ IParser parser = parserService.GetParser (fileName);
+ if (parser != null) {
+ return parser.CtrlSpace (this, caretLine, caretColumn, fileName);
+ }
+ return null;
+ }
+ }
+
+ internal class ParserDatabase : IParserDatabase
+ {
+ DefaultParserService parserService;
CodeCompletionDatabase coreDatabase;
+ bool threadRunning;
+ bool trackingFileChanges;
+ IProgressMonitorFactory parseProgressMonitorFactory;
const int MAX_PARSING_CACHE_SIZE = 10;
const int MAX_SINGLEDB_CACHE_SIZE = 10;
@@ -60,21 +287,21 @@
class CompilationUnitTypeResolver: ITypeResolver
{
public IClass CallingClass;
- Project project;
+ CodeCompletionDatabase db;
ICompilationUnit unit;
- DefaultParserService parserService;
+ ParserDatabase parserDatabase;
bool allResolved;
- public CompilationUnitTypeResolver (Project project, ICompilationUnit unit, DefaultParserService parserService)
+ public CompilationUnitTypeResolver (CodeCompletionDatabase db, ICompilationUnit unit, ParserDatabase parserDatabase)
{
- this.project = project;
+ this.db = db;
this.unit = unit;
- this.parserService = parserService;
+ this.parserDatabase = parserDatabase;
}
public string Resolve (string typeName)
{
- IClass c = parserService.SearchType (project, typeName, CallingClass, unit);
+ IClass c = parserDatabase.SearchType (db, typeName, CallingClass, unit);
if (c != null)
return c.FullyQualifiedName;
else {
@@ -96,15 +323,14 @@
CombineEntryEventHandler combineEntryAddedHandler;
CombineEntryEventHandler combineEntryRemovedHandler;
- public static Queue parseQueue = new Queue();
+ Queue parseQueue = new Queue();
+ AutoResetEvent parseEvent = new AutoResetEvent (false);
string codeCompletionPath;
Hashtable databases = new Hashtable();
Hashtable singleDatabases = new Hashtable ();
- IParser[] parser;
-
readonly static string[] assemblyList = {
"Microsoft.VisualBasic",
"mscorlib",
@@ -143,32 +369,52 @@
"System.UInt16", "System.UInt32", "System.UInt64", "System.Void"
};
- public DefaultParserService()
+ public ParserDatabase (DefaultParserService parserService)
{
+ this.parserService = parserService;
combineEntryAddedHandler = new CombineEntryEventHandler (OnCombineEntryAdded);
combineEntryRemovedHandler = new CombineEntryEventHandler (OnCombineEntryRemoved);
nameTable = new StringNameTable (sharedNameTable);
}
- public string LoadAssemblyFromGac (string name) {
- if (name == "mscorlib")
- return typeof(object).Assembly.Location;
+ public IParserContext GetProjectParserContext (Project project)
+ {
+ return new ParserContext (parserService, this, GetProjectDatabase (project));
+ }
+
+ public IParserContext GetFileParserContext (string file)
+ {
+ return new ParserContext (parserService, this, GetSingleFileDatabase (file));
+ }
+
+ public IProgressMonitorFactory ParseProgressMonitorFactory {
+ get { return parseProgressMonitorFactory; }
+ set { parseProgressMonitorFactory = value; }
+ }
+
+
+ public bool TrackFileChanges {
+ get {
+ return trackingFileChanges;
+ }
+ set {
+ if (value == trackingFileChanges)
+ return;
- Assembly asm;
- try {
- asm = Assembly.Load (name);
+ lock (this) {
+ trackingFileChanges = value;
+
+ if (value)
+ StartParserThread ();
+ }
}
- catch {
- asm = Assembly.LoadWithPartialName (name);
- }
- if (asm == null) {
- Runtime.LoggingService.Info ("Could not find: " + name);
- return string.Empty;
- }
-
- return asm.Location;
}
+ public IExpressionFinder GetExpressionFinder(string fileName)
+ {
+ return parserService.GetExpressionFinder (fileName);
+ }
+
private bool ContinueWithProcess(IProgressMonitor progressMonitor)
{
while (Gtk.Application.EventsPending ())
@@ -208,14 +454,6 @@
}
}
- public void GenerateAssemblyDatabase (string baseDir, string name)
- {
- AssemblyCodeCompletionDatabase db = new AssemblyCodeCompletionDatabase (baseDir, name, this);
- db.ParseInExternalProcess = false;
- db.ParseAll ();
- db.Write ();
- }
-
void SetDefaultCompletionFileLocation()
{
PropertyService propertyService = Runtime.Properties;
@@ -231,10 +469,8 @@
codeCompletionPath = Runtime.FileUtilityService.GetDirectoryNameWithSeparator(path);
}
- public override void InitializeService()
+ public void Initialize ()
{
- parser = (IParser[])(AddInTreeSingleton.AddInTree.GetTreeNode("/Workspace/Parser").BuildChildItems(this)).ToArray(typeof(IParser));
-
SetDefaultCompletionFileLocation();
DeleteObsoleteDatabases ();
@@ -242,18 +478,14 @@
CoreDB = "Assembly:" + coreName;
coreDatabase = new AssemblyCodeCompletionDatabase (codeCompletionPath, coreName, this);
databases [CoreDB] = coreDatabase;
-
- IProjectService projectService = Runtime.ProjectService;
- projectService.CombineOpened += new CombineEventHandler(OnCombineOpened);
- projectService.CombineClosed += new CombineEventHandler(OnCombineClosed);
}
internal IProgressMonitor GetParseProgressMonitor ()
{
- if (Runtime.TaskService == null) {
- return new ConsoleProgressMonitor ();
- }
- return Runtime.TaskService.GetBackgroundProgressMonitor ("Code Completion Database Generation", "Icons.16x16.RunProgramIcon");
+ if (parseProgressMonitorFactory != null)
+ return parseProgressMonitorFactory.CreateProgressMonitor ();
+ else
+ return new NullProgressMonitor ();
}
internal CodeCompletionDatabase GetDatabase (string uri)
@@ -342,6 +574,22 @@
}
}
+ public void Load (CombineEntry entry)
+ {
+ if (entry is Project)
+ LoadProjectDatabase ((Project)entry);
+ else if (entry is Combine)
+ LoadCombineDatabases ((Combine)entry);
+ }
+
+ public void Unload (CombineEntry entry)
+ {
+ if (entry is Project)
+ UnloadProjectDatabase ((Project)entry);
+ else if (entry is Combine)
+ UnloadCombineDatabases ((Combine)entry);
+ }
+
void LoadProjectDatabase (Project project)
{
lock (databases)
@@ -409,47 +657,40 @@
}
}
- public void LoadCombineDatabases (Combine combine)
+ void LoadCombineDatabases (Combine combine)
{
CombineEntryCollection projects = combine.GetAllProjects();
foreach (Project entry in projects) {
LoadProjectDatabase (entry);
}
+ combine.EntryAdded += combineEntryAddedHandler;
+ combine.EntryRemoved += combineEntryRemovedHandler;
}
- public void UnloadCombineDatabases (Combine combine)
+ void UnloadCombineDatabases (Combine combine)
{
CombineEntryCollection projects = combine.GetAllProjects();
foreach (Project entry in projects) {
UnloadProjectDatabase (entry);
}
- }
-
- public void OnCombineOpened(object sender, CombineEventArgs e)
- {
- LoadCombineDatabases (e.Combine);
- e.Combine.EntryAdded += combineEntryAddedHandler;
- e.Combine.EntryRemoved += combineEntryRemovedHandler;
- }
-
- public void OnCombineClosed (object sender, CombineEventArgs e)
- {
- UnloadCombineDatabases (e.Combine);
CleanUnusedDatabases ();
- e.Combine.EntryAdded -= combineEntryAddedHandler;
- e.Combine.EntryRemoved -= combineEntryRemovedHandler;
+ combine.EntryAdded -= combineEntryAddedHandler;
+ combine.EntryRemoved -= combineEntryRemovedHandler;
}
void OnProjectRenamed (object sender, CombineEntryRenamedEventArgs args)
{
- ProjectCodeCompletionDatabase db = GetProjectDatabase ((Project) args.CombineEntry);
- if (db == null) return;
-
- db.Rename (args.NewName);
- databases.Remove ("Project:" + args.OldName);
- databases ["Project:" + args.NewName] = db;
- RefreshProjectDatabases ();
- CleanUnusedDatabases ();
+ lock (databases)
+ {
+ ProjectCodeCompletionDatabase db = GetProjectDatabase ((Project) args.CombineEntry);
+ if (db == null) return;
+
+ db.Rename (args.NewName);
+ databases.Remove ("Project:" + args.OldName);
+ databases ["Project:" + args.NewName] = db;
+ RefreshProjectDatabases ();
+ CleanUnusedDatabases ();
+ }
}
void OnCombineEntryAdded (object sender, CombineEntryEventArgs args)
@@ -484,11 +725,14 @@
void RefreshProjectDatabases ()
{
- foreach (CodeCompletionDatabase db in databases.Values)
+ lock (databases)
{
- ProjectCodeCompletionDatabase pdb = db as ProjectCodeCompletionDatabase;
- if (pdb != null)
- pdb.UpdateFromProject ();
+ foreach (CodeCompletionDatabase db in databases.Values)
+ {
+ ProjectCodeCompletionDatabase pdb = db as ProjectCodeCompletionDatabase;
+ if (pdb != null)
+ pdb.UpdateFromProject ();
+ }
}
}
@@ -500,6 +744,7 @@
lock (parseQueue)
{
parseQueue.Enqueue (job);
+ parseEvent.Set ();
}
}
@@ -514,30 +759,33 @@
}
}
- public void StartParserThread()
+ void StartParserThread()
{
- Thread t = new Thread(new ThreadStart(ParserUpdateThread));
- t.IsBackground = true;
- t.Start();
+ lock (this) {
+ if (!threadRunning) {
+ threadRunning = true;
+ Thread t = new Thread(new ThreadStart(ParserUpdateThread));
+ t.IsBackground = true;
+ t.Start();
+ }
+ }
}
void ParserUpdateThread()
{
- int loop = 0;
- while (true)
+ while (trackingFileChanges)
{
- Thread.Sleep(500);
-
- ParseCurrentFile ();
-
- ConsumeParsingQueue ();
-
- if (loop % 10 == 0)
+ if (!parseEvent.WaitOne (5000, true))
CheckModifiedFiles ();
-
- loop++;
+ else if (trackingFileChanges)
+ ConsumeParsingQueue ();
}
+ lock (this) {
+ threadRunning = false;
+ if (trackingFileChanges)
+ StartParserThread ();
+ }
}
void CheckModifiedFiles ()
@@ -628,58 +876,31 @@
}
}
-
- void ParseCurrentFile()
+ public void UpdateFile (Project project, string fileName, string fileContent)
{
try {
- IWorkbenchWindow win = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
- if (win == null || win.ActiveViewContent == null) return;
-
- IEditable editable = win.ActiveViewContent as IEditable;
- if (editable == null) return;
-
- string fileName = null;
-
- IViewContent viewContent = win.ViewContent;
- IParseableContent parseableContent = win.ActiveViewContent as IParseableContent;
-
- if (parseableContent != null) {
- fileName = parseableContent.ParseableContentName;
- } else {
- fileName = viewContent.IsUntitled ? viewContent.UntitledName : viewContent.ContentName;
- }
-
- if (fileName == null || fileName.Length == 0) return;
-
- if (GetParser (fileName) == null)
+ if (parserService.GetParser (fileName) == null)
return;
- string text = editable.Text;
- if (text == null) return;
-
IParseInformation parseInformation = null;
- bool updated = false;
+ int contentHash = fileContent.GetHashCode ();
- if (lastUpdateSize[fileName] == null || (int)lastUpdateSize[fileName] != text.GetHashCode()) {
- parseInformation = DoParseFile(fileName, text);
+ if (lastUpdateSize[fileName] == null || (int)lastUpdateSize[fileName] != contentHash) {
+ parseInformation = DoParseFile (fileName, fileContent);
if (parseInformation == null) return;
- if (viewContent.Project != null) {
- ProjectCodeCompletionDatabase db = GetProjectDatabase (viewContent.Project);
+ if (project != null) {
+ ProjectCodeCompletionDatabase db = GetProjectDatabase (project);
ClassUpdateInformation res = db.UpdateFromParseInfo (parseInformation, fileName);
- if (res != null) NotifyParseInfoChange (fileName, res, viewContent.Project);
+ if (res != null) NotifyParseInfoChange (fileName, res, project);
}
else {
SimpleCodeCompletionDatabase db = GetSingleFileDatabase (fileName);
db.UpdateFromParseInfo (parseInformation);
}
- lastUpdateSize[fileName] = text.GetHashCode();
- updated = true;
+ lastUpdateSize[fileName] = contentHash;
}
- if (updated && parseInformation != null && editable is IParseInformationListener) {
- ((IParseInformationListener)editable).ParseInformationUpdated(parseInformation);
- }
} catch (Exception e) {
try {
Runtime.LoggingService.Info(e.ToString());
@@ -687,47 +908,23 @@
}
}
- CodeCompletionDatabase GetActiveFileDatabase()
- {
- IWorkbenchWindow win = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
- if (win == null || win.ActiveViewContent == null) return null;
-
- IEditable editable = win.ActiveViewContent as IEditable;
- if (editable == null) return null;
-
- string fileName = null;
-
- IViewContent viewContent = win.ViewContent;
- IParseableContent parseableContent = win.ActiveViewContent as IParseableContent;
-
- if (parseableContent != null) {
- fileName = parseableContent.ParseableContentName;
- } else {
- fileName = viewContent.IsUntitled ? viewContent.UntitledName : viewContent.ContentName;
- }
-
- if (fileName == null || fileName.Length == 0) return null;
- return GetSingleFileDatabase (fileName);
- }
-
#region Default Parser Layer dependent functions
- public IClass GetClass (Project project, string typeName)
+ public IClass GetClass (CodeCompletionDatabase db, string typeName)
{
- return GetClass(project, typeName, false, true);
+ return GetClass (db, typeName, false, true);
}
- public IClass GetClass (Project project, string typeName, bool deepSearchReferences, bool caseSensitive)
+ public IClass GetClass (CodeCompletionDatabase db, string typeName, bool deepSearchReferences, bool caseSensitive)
{
if (deepSearchReferences)
- return DeepGetClass (project, typeName, caseSensitive);
+ return DeepGetClass (db, typeName, caseSensitive);
else
- return GetClass (project, typeName, caseSensitive);
+ return GetClass (db, typeName, caseSensitive);
}
- public IClass GetClass (Project project, string typeName, bool caseSensitive)
+ public IClass GetClass (CodeCompletionDatabase db, string typeName, bool caseSensitive)
{
- CodeCompletionDatabase db = project != null ? GetProjectDatabase (project) : GetActiveFileDatabase ();
if (db != null) {
IClass c = db.GetClass (typeName, caseSensitive);
if (c != null) return c;
@@ -744,10 +941,8 @@
return db.GetClass (typeName, caseSensitive);
}
- public IClass DeepGetClass (Project project, string typeName, bool caseSensitive)
+ public IClass DeepGetClass (CodeCompletionDatabase db, string typeName, bool caseSensitive)
{
- CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
-
ArrayList visited = new ArrayList ();
IClass c = DeepGetClassRec (visited, db, typeName, caseSensitive);
if (c != null) return c;
@@ -776,25 +971,23 @@
return null;
}
- public IClass[] GetProjectContents (Project project)
+ public IClass[] GetProjectContents (CodeCompletionDatabase db)
{
- CodeCompletionDatabase db = GetProjectDatabase (project);
if (db != null)
return db.GetClassList ();
else
return new IClass[0];
}
- public string[] GetClassList (Project project, string subNameSpace, bool includeReferences)
+ public string[] GetClassList (CodeCompletionDatabase db, string subNameSpace, bool includeReferences)
{
- return GetClassList (project, subNameSpace, includeReferences, true);
+ return GetClassList (db, subNameSpace, includeReferences, true);
}
- public string[] GetClassList (Project project, string subNameSpace, bool includeReferences, bool caseSensitive)
+ public string[] GetClassList (CodeCompletionDatabase db, string subNameSpace, bool includeReferences, bool caseSensitive)
{
ArrayList contents = new ArrayList ();
- CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
if (db != null) {
db.GetClassList (contents, subNameSpace, caseSensitive);
if (includeReferences) {
@@ -814,16 +1007,15 @@
return (string[]) contents.ToArray (typeof(string));
}
- public string[] GetNamespaceList (Project project, string subNameSpace)
+ public string[] GetNamespaceList (CodeCompletionDatabase db, string subNameSpace)
{
- return GetNamespaceList (project, subNameSpace, true, true);
+ return GetNamespaceList (db, subNameSpace, true, true);
}
- public string[] GetNamespaceList (Project project, string subNameSpace, bool includeReferences, bool caseSensitive)
+ public string[] GetNamespaceList (CodeCompletionDatabase db, string subNameSpace, bool includeReferences, bool caseSensitive)
{
ArrayList contents = new ArrayList ();
- CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
if (db != null) {
db.GetNamespaceList (contents, subNameSpace, caseSensitive);
if (includeReferences) {
@@ -843,16 +1035,15 @@
return (string[]) contents.ToArray (typeof(string));
}
- public ArrayList GetNamespaceContents (Project project, string namspace, bool includeReferences)
+ public ArrayList GetNamespaceContents (CodeCompletionDatabase db, string namspace, bool includeReferences)
{
- return GetNamespaceContents (project, namspace, includeReferences, true);
+ return GetNamespaceContents (db, namspace, includeReferences, true);
}
- public ArrayList GetNamespaceContents (Project project, string namspace, bool includeReferences, bool caseSensitive)
+ public ArrayList GetNamespaceContents (CodeCompletionDatabase db, string namspace, bool includeReferences, bool caseSensitive)
{
ArrayList contents = new ArrayList ();
- CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
if (db != null) {
db.GetNamespaceContents (contents, namspace, caseSensitive);
if (includeReferences) {
@@ -873,14 +1064,13 @@
return contents;
}
- public bool NamespaceExists(Project project, string name)
+ public bool NamespaceExists (CodeCompletionDatabase db, string name)
{
- return NamespaceExists(project, name, true);
+ return NamespaceExists (db, name, true);
}
- public bool NamespaceExists(Project project, string name, bool caseSensitive)
+ public bool NamespaceExists (CodeCompletionDatabase db, string name, bool caseSensitive)
{
- CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
if (db != null) {
if (db.NamespaceExists (name, caseSensitive)) return true;
foreach (ReferenceEntry re in db.References)
@@ -895,15 +1085,15 @@
return db.NamespaceExists (name, caseSensitive);
}
- public string SearchNamespace(Project project, IUsing usin, string partitialNamespaceName)
+ public string SearchNamespace (CodeCompletionDatabase db, IUsing usin, string partitialNamespaceName)
{
- return SearchNamespace(project, usin, partitialNamespaceName, true);
+ return SearchNamespace (db, usin, partitialNamespaceName, true);
}
- public string SearchNamespace(Project project, IUsing usin, string partitialNamespaceName, bool caseSensitive)
+ public string SearchNamespace (CodeCompletionDatabase db, IUsing usin, string partitialNamespaceName, bool caseSensitive)
{
// Runtime.LoggingService.Info("SearchNamespace : >{0}<", partitialNamespaceName);
- if (NamespaceExists(project, partitialNamespaceName, caseSensitive)) {
+ if (NamespaceExists (db, partitialNamespaceName, caseSensitive)) {
return partitialNamespaceName;
}
@@ -911,7 +1101,7 @@
string declaringNamespace = (string)usin.Aliases[""];
if (declaringNamespace != null) {
while (declaringNamespace.Length > 0) {
- if ((caseSensitive ? declaringNamespace.EndsWith(partitialNamespaceName) : declaringNamespace.ToLower().EndsWith(partitialNamespaceName.ToLower()) ) && NamespaceExists(project, declaringNamespace, caseSensitive)) {
+ if ((caseSensitive ? declaringNamespace.EndsWith(partitialNamespaceName) : declaringNamespace.ToLower().EndsWith(partitialNamespaceName.ToLower()) ) && NamespaceExists (db, declaringNamespace, caseSensitive)) {
return declaringNamespace;
}
int index = declaringNamespace.IndexOf('.');
@@ -931,7 +1121,7 @@
if (caseSensitive ? partitialNamespaceName.StartsWith(aliasString) : partitialNamespaceName.ToLower().StartsWith(aliasString.ToLower())) {
if (aliasString.Length >= 0) {
string nsName = nsName = String.Concat(entry.Value.ToString(), partitialNamespaceName.Remove(0, aliasString.Length));
- if (NamespaceExists (project, nsName, caseSensitive)) {
+ if (NamespaceExists (db, nsName, caseSensitive)) {
return nsName;
}
}
@@ -943,20 +1133,20 @@
/// <remarks>
/// use the usings and the name of the namespace to find a class
/// </remarks>
- public IClass SearchType (Project project, string name, IClass callingClass, ICompilationUnit unit)
+ public IClass SearchType (CodeCompletionDatabase db, string name, IClass callingClass, ICompilationUnit unit)
{
if (name == null || name == String.Empty)
return null;
IClass c;
- c = GetClass(project, name);
+ c = GetClass (db, name);
if (c != null)
return c;
if (unit != null) {
foreach (IUsing u in unit.Usings) {
if (u != null) {
- c = SearchType(project, u, name);
+ c = SearchType (db, u, name);
if (c != null) {
return c;
}
@@ -973,7 +1163,7 @@
do {
curnamespace += namespaces[i] + '.';
- c = GetClass(project, curnamespace + name);
+ c = GetClass (db, curnamespace + name);
if (c != null) {
return c;
}
@@ -984,15 +1174,15 @@
return null;
}
- public IClass SearchType(Project project, IUsing iusing, string partitialTypeName)
+ public IClass SearchType (CodeCompletionDatabase db, IUsing iusing, string partitialTypeName)
{
- return SearchType(project, iusing, partitialTypeName, true);
+ return SearchType (db, iusing, partitialTypeName, true);
}
- public IClass SearchType(Project project, IUsing iusing, string partitialTypeName, bool caseSensitive)
+ public IClass SearchType (CodeCompletionDatabase db, IUsing iusing, string partitialTypeName, bool caseSensitive)
{
// Runtime.LoggingService.Info("Search type : >{0}<", partitialTypeName);
- IClass c = GetClass(project, partitialTypeName, caseSensitive);
+ IClass c = GetClass (db, partitialTypeName, caseSensitive);
if (c != null) {
return c;
}
@@ -1000,7 +1190,7 @@
foreach (string str in iusing.Usings) {
string possibleType = String.Concat(str, ".", partitialTypeName);
// Runtime.LoggingService.Info("looking for " + possibleType);
- c = GetClass(project, possibleType, caseSensitive);
+ c = GetClass (db, possibleType, caseSensitive);
if (c != null) {
// Runtime.LoggingService.Info("Found!");
return c;
@@ -1013,7 +1203,7 @@
while (declaringNamespace.Length > 0) {
string className = String.Concat(declaringNamespace, ".", partitialTypeName);
// Runtime.LoggingService.Info("looking for " + className);
- c = GetClass(project, className, caseSensitive);
+ c = GetClass (db, className, caseSensitive);
if (c != null) {
// Runtime.LoggingService.Info("Found!");
return c;
@@ -1034,7 +1224,7 @@
if (aliasString.Length > 0) {
className = String.Concat(entry.Value.ToString(), partitialTypeName.Remove(0, aliasString.Length));
// Runtime.LoggingService.Info("looking for " + className);
- c = GetClass(project, className, caseSensitive);
+ c = GetClass (db, className, caseSensitive);
if (c != null) {
// Runtime.LoggingService.Info("Found!");
return c;
@@ -1048,7 +1238,7 @@
public bool ResolveTypes (Project project, ICompilationUnit unit, ClassCollection types, out ClassCollection result)
{
- CompilationUnitTypeResolver tr = new CompilationUnitTypeResolver (project, unit, this);
+ CompilationUnitTypeResolver tr = new CompilationUnitTypeResolver (GetProjectDatabase (project), unit, this);
bool allResolved = true;
result = new ClassCollection ();
@@ -1062,14 +1252,13 @@
return allResolved;
}
- public IEnumerable GetClassInheritanceTree (Project project, IClass cls)
+ public IEnumerable GetClassInheritanceTree (CodeCompletionDatabase db, IClass cls)
{
- return new ClassInheritanceEnumerator (this, project, cls);
+ return new ClassInheritanceEnumerator (this, db, cls);
}
- public IClass[] GetFileContents (Project project, string fileName)
+ public IClass[] GetFileContents (CodeCompletionDatabase db, string fileName)
{
- CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
return db.GetFileContents (fileName);
}
@@ -1087,7 +1276,7 @@
public IParseInformation DoParseFile (string fileName, string fileContent)
{
- IParser parser = GetParser(fileName);
+ IParser parser = parserService.GetParser (fileName);
if (parser == null) {
return null;
@@ -1098,11 +1287,12 @@
ICompilationUnitBase parserOutput = null;
if (fileContent == null) {
- if (Runtime.ProjectService.CurrentOpenCombine != null) {
- CombineEntryCollection projects = Runtime.ProjectService.CurrentOpenCombine.GetAllProjects ();
- foreach (Project entry in projects) {
- if (entry.IsFileInProject(fileName)) {
- fileContent = entry.GetParseableFileContent(fileName);
+ lock (databases) {
+ foreach (object ob in databases.Values) {
+ ProjectCodeCompletionDatabase db = ob as ProjectCodeCompletionDatabase;
+ if (db != null) {
+ if (db.Project.IsFileInProject (fileName))
+ fileContent = db.Project.GetParseableFileContent(fileName);
}
}
}
@@ -1188,74 +1378,8 @@
else return ParseFile(fileName);
}
- public IExpressionFinder GetExpressionFinder(string fileName)
- {
- IParser parser = GetParser(fileName);
- if (parser != null) {
- return parser.ExpressionFinder;
- }
- return null;
- }
-
- public virtual IParser GetParser(string fileName)
- {
- // HACK: I'm too lazy to do it 'right'
- // HACK: Still a hack, but extensible
- if (fileName != null) {
- foreach(IParser p in parser){
- if(p.CanParse(fileName)){
- return p;
- }
- }
- }
- return null;
- }
-
////////////////////////////////////
- public ArrayList CtrlSpace(IParserService parserService, Project project, int caretLine, int caretColumn, string fileName)
- {
- IParser parser = GetParser(fileName);
- if (parser != null) {
- return parser.CtrlSpace(parserService, project, caretLine, caretColumn, fileName);
- }
- return null;
- }
-
- public ArrayList IsAsResolve (Project project, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent)
- {
- try {
- IParser parser = GetParser (fileName);
- if (parser != null) {
- return parser.IsAsResolve (this, project, expression, caretLineNumber, caretColumn, fileName, fileContent);
- }
- return null;
- } catch {
- return null;
- }
- }
-
- public ResolveResult Resolve(Project project,
- string expression,
- int caretLineNumber,
- int caretColumn,
- string fileName,
- string fileContent)
- {
- // added exception handling here to prevent silly parser exceptions from
- // being thrown and corrupting the textarea control
- try {
- IParser parser = GetParser(fileName);
- //Runtime.LoggingService.Info("Parse info : " + GetParseInformation(fileName).MostRecentCompilationUnit.Tag);
- if (parser != null) {
- return parser.Resolve(this, project, expression, caretLineNumber, caretColumn, fileName, fileContent);
- }
- return null;
- } catch {
- return null;
- }
- }
-
internal INameEncoder DefaultNameEncoder {
get { return nameTable; }
}
@@ -1264,19 +1388,6 @@
get { return nameTable; }
}
- public string MonodocResolver (Project project, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent)
- {
- try {
- IParser parser = GetParser (fileName);
- if (parser != null) {
- return parser.MonodocResolver (this, project, expression, caretLineNumber, caretColumn, fileName, fileContent);
- }
- return null;
- } catch {
- return null;
- }
- }
-
public void NotifyParseInfoChange (string file, ClassUpdateInformation res, Project project)
{
ClassInformationEventArgs args = new ClassInformationEventArgs (file, res, project);
@@ -1329,16 +1440,16 @@
internal class ClassInheritanceEnumerator : IEnumerator, IEnumerable
{
- DefaultParserService parserService;
+ ParserDatabase parserDatabase;
IClass topLevelClass;
IClass currentClass = null;
Queue baseTypeQueue = new Queue();
- Project project;
+ CodeCompletionDatabase db;
- internal ClassInheritanceEnumerator(DefaultParserService parserService, Project project, IClass topLevelClass)
+ internal ClassInheritanceEnumerator (ParserDatabase parserDatabase, CodeCompletionDatabase db, IClass topLevelClass)
{
- this.parserService = parserService;
- this.project = project;
+ this.parserDatabase = parserDatabase;
+ this.db = db;
this.topLevelClass = topLevelClass;
baseTypeQueue.Enqueue(topLevelClass.FullyQualifiedName);
PutBaseClassesOnStack(topLevelClass);
@@ -1374,12 +1485,12 @@
}
string baseTypeName = baseTypeQueue.Dequeue().ToString();
- IClass baseType = parserService.DeepGetClass (project, baseTypeName, true);
+ IClass baseType = parserDatabase.DeepGetClass (db, baseTypeName, true);
if (baseType == null) {
ICompilationUnit unit = currentClass == null ? null : currentClass.CompilationUnit;
if (unit != null) {
foreach (IUsing u in unit.Usings) {
- baseType = parserService.SearchType(project, u, baseTypeName);
+ baseType = parserDatabase.SearchType (db, u, baseTypeName);
if (baseType != null) {
break;
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/IParserService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/IParserService.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/IParserService.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -36,39 +36,64 @@
get;
}
}
-
+
public interface IParserService
{
- IParseInformation ParseFile(string fileName);
- IParseInformation ParseFile(string fileName, string fileContent);
+ IParserDatabase CreateParserDatabase ();
- IParseInformation GetParseInformation(string fileName);
-
IParser GetParser(string fileName);
IExpressionFinder GetExpressionFinder(string fileName);
+ }
+
+ public interface IParserDatabase
+ {
+ void Load (CombineEntry entry);
+ void Unload (CombineEntry entry);
+ IParserContext GetProjectParserContext (Project project);
+ IParserContext GetFileParserContext (string file);
+
+ void UpdateFile (Project project, string fileName, string fileContent);
+
+ bool TrackFileChanges { get; set; }
+
+ IProgressMonitorFactory ParseProgressMonitorFactory { get; set; }
+
+ event ParseInformationEventHandler ParseInformationChanged;
+ event ClassInformationEventHandler ClassInformationChanged;
+ }
+
+ public interface IParserContext
+ {
+ IExpressionFinder GetExpressionFinder(string fileName);
+
+ IParseInformation ParseFile (string fileName);
+ IParseInformation ParseFile (string fileName, string fileContent);
+
+ IParseInformation GetParseInformation (string fileName);
+
// Default Parser Layer dependent functions
- IClass GetClass(Project project, string typeName);
- string[] GetClassList (Project project, string subNameSpace, bool includeReferences);
- string[] GetNamespaceList(Project project, string subNameSpace);
- ArrayList GetNamespaceContents(Project project, string subNameSpace, bool includeReferences);
- bool NamespaceExists(Project project, string name);
- string SearchNamespace(Project project, IUsing iusing, string partitialNamespaceName);
- IClass SearchType(Project project, IUsing iusing, string partitialTypeName);
+ IClass GetClass (string typeName);
+ string[] GetClassList (string subNameSpace, bool includeReferences);
+ string[] GetNamespaceList (string subNameSpace);
+ ArrayList GetNamespaceContents (string subNameSpace, bool includeReferences);
+ bool NamespaceExists (string name);
+ string SearchNamespace (IUsing iusing, string partitialNamespaceName);
+ IClass SearchType (IUsing iusing, string partitialTypeName);
- IClass GetClass(Project project, string typeName, bool deepSearchReferences, bool caseSensitive);
- string[] GetClassList (Project project, string subNameSpace, bool includeReferences, bool caseSensitive);
- string[] GetNamespaceList(Project project, string subNameSpace, bool includeReferences, bool caseSensitive);
- ArrayList GetNamespaceContents(Project project, string subNameSpace, bool includeReferences, bool caseSensitive);
- bool NamespaceExists(Project project, string name, bool caseSensitive);
- string SearchNamespace(Project project, IUsing iusing, string partitialNamespaceName, bool caseSensitive);
- IClass SearchType(Project project, IUsing iusing, string partitialTypeName, bool caseSensitive);
- IClass SearchType (Project project, string name, IClass callingClass, ICompilationUnit unit);
+ IClass GetClass (string typeName, bool deepSearchReferences, bool caseSensitive);
+ string[] GetClassList (string subNameSpace, bool includeReferences, bool caseSensitive);
+ string[] GetNamespaceList (string subNameSpace, bool includeReferences, bool caseSensitive);
+ ArrayList GetNamespaceContents (string subNameSpace, bool includeReferences, bool caseSensitive);
+ bool NamespaceExists (string name, bool caseSensitive);
+ string SearchNamespace (IUsing iusing, string partitialNamespaceName, bool caseSensitive);
+ IClass SearchType (IUsing iusing, string partitialTypeName, bool caseSensitive);
+ IClass SearchType (string name, IClass callingClass, ICompilationUnit unit);
- IEnumerable GetClassInheritanceTree (Project project, IClass cls);
+ IEnumerable GetClassInheritanceTree (IClass cls);
- IClass[] GetFileContents (Project project, string fileName);
- IClass[] GetProjectContents (Project project);
+ IClass[] GetFileContents (string fileName);
+ IClass[] GetProjectContents ();
////////////////////////////////////////////
@@ -76,18 +101,15 @@
/// Resolves an expression.
/// The caretLineNumber and caretColumn is 1 based.
/// </summary>
- ResolveResult Resolve(Project project,
- string expression,
- int caretLineNumber,
- int caretColumn,
- string fileName,
- string fileContent);
- string MonodocResolver (Project project, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
- ArrayList IsAsResolve (Project project, string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
- ArrayList CtrlSpace(IParserService parserService, Project project, int caretLine, int caretColumn, string fileName);
- string LoadAssemblyFromGac (string name);
-
- event ParseInformationEventHandler ParseInformationChanged;
- event ClassInformationEventHandler ClassInformationChanged;
+ ResolveResult Resolve (string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
+
+ string MonodocResolver (string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
+ ArrayList IsAsResolve (string expression, int caretLineNumber, int caretColumn, string fileName, string fileContent);
+ ArrayList CtrlSpace (int caretLine, int caretColumn, string fileName);
}
+
+ public interface IProgressMonitorFactory
+ {
+ IProgressMonitor CreateProgressMonitor ();
+ }
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/ProjectCodeCompletionDatabase.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/ProjectCodeCompletionDatabase.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/ProjectCodeCompletionDatabase.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -41,8 +41,8 @@
Project project;
bool initialFileCheck;
- public ProjectCodeCompletionDatabase (Project project, DefaultParserService parserService)
- : base (parserService)
+ public ProjectCodeCompletionDatabase (Project project, ParserDatabase parserDatabase)
+ : base (parserDatabase)
{
initialFileCheck = true;
@@ -59,6 +59,10 @@
project.FileRenamedInProject += new ProjectFileRenamedEventHandler (OnFileRenamed);
}
+ public Project Project {
+ get { return project; }
+ }
+
public override void Dispose ()
{
project.FileChangedInProject -= new ProjectFileEventHandler (OnFileChanged);
@@ -154,10 +158,10 @@
if (monitor != null) monitor.BeginTask ("Parsing file: " + Path.GetFileName (fileName), 1);
try {
- IParseInformation parserInfo = parserService.DoParseFile ((string)fileName, null);
+ IParseInformation parserInfo = parserDatabase.DoParseFile ((string)fileName, null);
if (parserInfo != null) {
ClassUpdateInformation res = UpdateFromParseInfo (parserInfo, fileName);
- if (res != null) parserService.NotifyParseInfoChange (fileName, res, project);
+ if (res != null) parserDatabase.NotifyParseInfoChange (fileName, res, project);
}
} finally {
if (monitor != null) monitor.EndTask ();
@@ -169,7 +173,7 @@
ICompilationUnit cu = (ICompilationUnit)parserInfo.BestCompilationUnit;
ClassCollection resolved;
- bool allResolved = parserService.ResolveTypes (project, cu, cu.Classes, out resolved);
+ bool allResolved = parserDatabase.ResolveTypes (project, cu, cu.Classes, out resolved);
ClassUpdateInformation res = UpdateClassInformation (resolved, fileName);
FileEntry file = files [fileName] as FileEntry;
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/SimpleCodeCompletionDatabase.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/SimpleCodeCompletionDatabase.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/ParserService/SimpleCodeCompletionDatabase.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -36,8 +36,8 @@
{
string file = "_currentFile";
- public SimpleCodeCompletionDatabase (string file, DefaultParserService parserService)
- : base (parserService)
+ public SimpleCodeCompletionDatabase (string file, ParserDatabase parserDatabase)
+ : base (parserDatabase)
{
AddFile (file);
this.file = file;
@@ -47,7 +47,7 @@
{
ICompilationUnit cu = (ICompilationUnit)parserInfo.BestCompilationUnit;
ClassCollection resolved;
- parserService.ResolveTypes (null, cu, cu.Classes, out resolved);
+ parserDatabase.ResolveTypes (null, cu, cu.Classes, out resolved);
return UpdateClassInformation (resolved, file);
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/IProjectService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/IProjectService.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/IProjectService.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -73,6 +73,10 @@
get;
}
+ IParserDatabase ParserDatabase {
+ get;
+ }
+
FileFormatManager FileFormats {
get;
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/Project/ProjectService.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -41,6 +41,7 @@
Combine openCombine = null;
DataContext dataContext = new DataContext ();
ProjectBindingCodon[] projectBindings;
+ IParserDatabase parserDatabase;
IAsyncOperation currentBuildOperation = NullAsyncOperation.Success;
IAsyncOperation currentRunOperation = NullAsyncOperation.Success;
@@ -140,6 +141,11 @@
get { return dataContext; }
}
+ public IParserDatabase ParserDatabase {
+ get { return parserDatabase; }
+ }
+
+
public FileFormatManager FileFormats {
get { return formatManager; }
}
@@ -218,6 +224,9 @@
CurrentSelectedProject = null;
CurrentOpenCombine = CurrentSelectedCombine = null;
WorkbenchSingleton.Workbench.CloseAllViews();
+
+ parserDatabase.Unload (closedCombine);
+
OnCombineClosed(new CombineEventArgs(closedCombine));
closedCombine.Dispose();
}
@@ -294,9 +303,10 @@
openCombine.ReferenceRemovedFromProject += new ProjectReferenceEventHandler (NotifyReferenceRemovedFromProject);
SearchForNewFiles ();
-
- OnCombineOpened(new CombineEventArgs(openCombine));
+ parserDatabase.Load (openCombine);
+ OnCombineOpened (new CombineEventArgs(openCombine));
+
Runtime.DispatchService.GuiDispatch (new StatefulMessageHandler (RestoreCombinePreferences), CurrentOpenCombine);
SaveCombine ();
@@ -861,6 +871,10 @@
Runtime.FileService.FileRenamed += new FileEventHandler(CheckFileRename);
projectBindings = (ProjectBindingCodon[])(AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/Workbench/ProjectBindings").BuildChildItems(null)).ToArray(typeof(ProjectBindingCodon));
+
+ parserDatabase = Runtime.ParserService.CreateParserDatabase ();
+ parserDatabase.TrackFileChanges = true;
+ parserDatabase.ParseProgressMonitorFactory = new ParseProgressMonitorFactory ();
}
void RestoreCombinePreferences (object data)
@@ -1278,4 +1292,12 @@
public event ProjectReferenceEventHandler ReferenceAddedToProject;
public event ProjectReferenceEventHandler ReferenceRemovedFromProject;
}
+
+ class ParseProgressMonitorFactory: IProgressMonitorFactory
+ {
+ public IProgressMonitor CreateProgressMonitor ()
+ {
+ return Runtime.TaskService.GetBackgroundProgressMonitor ("Code Completion Database Generation", "Icons.16x16.RunProgramIcon");
+ }
+ }
}
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/SystemAssemblyService.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/SystemAssemblyService.cs 2005-08-09 03:33:36 UTC (rev 2719)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Services/SystemAssemblyService.cs 2005-08-09 23:45:27 UTC (rev 2720)
@@ -2,10 +2,12 @@
using System.IO;
using System.Collections;
using System.Diagnostics;
+using System.Reflection;
using MonoDevelop.Core.Services;
-namespace MonoDevelop.Services {
+namespace MonoDevelop.Services
+{
public class SystemAssemblyService : AbstractService
{
Hashtable assemblyPathToPackage = new Hashtable ();
@@ -37,6 +39,17 @@
return (string)assemblyPathToPackage[path];
}
+ public string GetAssemblyLocation (string assemblyName)
+ {
+ if (assemblyName == "mscorlib")
+ return typeof(object).Assembly.Location;
+
+ AssemblyLocator locator = (AssemblyLocator) Runtime.ProcessService.CreateExternalProcessObject (typeof(AssemblyLocator), true);
+ using (locator) {
+ return locator.Locate (assemblyName);
+ }
+ }
+
new void Initialize ()
{
initialized = true;
@@ -191,4 +204,22 @@
return ret;
}
}
+
+ internal class AssemblyLocator: RemoteProcessObject
+ {
+ public string Locate (string assemblyName)
+ {
+ Assembly asm;
+ try {
+ asm = Assembly.Load (assemblyName);
+ }
+ catch {
+ asm = Assembly.LoadWithPartialName (assemblyName);
+ }
+ if (asm == null)
+ return null;
+
+ return asm.Location;
+ }
+ }
}
More information about the Monodevelop-patches-list
mailing list