[Monodevelop-patches-list] r1732 - in trunk/MonoDevelop/src/Main/Base: . Commands/ProjectBrowserCommands Internal/Project/Project Internal/Project/Project/Collections Services/File Services/ParserService
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Thu Jun 10 06:02:41 EDT 2004
Author: lluis
Date: 2004-06-10 06:02:40 -0400 (Thu, 10 Jun 2004)
New Revision: 1732
Modified:
trunk/MonoDevelop/src/Main/Base/ChangeLog
trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/FolderNodeCommands.cs
trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/AbstractProject.cs
trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/Collections/ProjectFileCollection.cs
trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/ProjectFile.cs
trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs
trunk/MonoDevelop/src/Main/Base/Services/ParserService/CodeCompletionDatabase.cs
trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs
Log:
* Commands/ProjectBrowserCommands/FolderNodeCommands.cs: Set the project of
newly added files.
* Services/ParserService/DefaultParserService.cs: Generate and cache code
completion databases for opened files that do not belong to any project.
* Services/ParserService/CodeCompletionDatabase.cs: Added Clear method.
Made Write() virtual.
Added new SimpleCodeCompletionDatabase, for storing information for a
single file.
* Internal/Project/Project/AbstractProject.cs: Ignore members with the
xml name set to null.
* Internal/Project/Project/ProjectFile.cs: Added project filed. Notify
the project when the file name changes.
* Internal/Project/Project/Collections/ProjectFileCollection.cs: assign
the project to the files in the collection.
Modified: trunk/MonoDevelop/src/Main/Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-06-10 04:48:59 UTC (rev 1731)
+++ trunk/MonoDevelop/src/Main/Base/ChangeLog 2004-06-10 10:02:40 UTC (rev 1732)
@@ -1,3 +1,20 @@
+2004-06-10 Lluis Sanchez Gual <lluis at ximian.com>
+
+ * Commands/ProjectBrowserCommands/FolderNodeCommands.cs: Set the project of
+ newly added files.
+ * Services/ParserService/DefaultParserService.cs: Generate and cache code
+ completion databases for opened files that do not belong to any project.
+ * Services/ParserService/CodeCompletionDatabase.cs: Added Clear method.
+ Made Write() virtual.
+ Added new SimpleCodeCompletionDatabase, for storing information for a
+ single file.
+ * Internal/Project/Project/AbstractProject.cs: Ignore members with the
+ xml name set to null.
+ * Internal/Project/Project/ProjectFile.cs: Added project filed. Notify
+ the project when the file name changes.
+ * Internal/Project/Project/Collections/ProjectFileCollection.cs: assign
+ the project to the files in the collection.
+
2004-06-06 John Luke <jluke at cfl.rr.com>
* Gui/Dialogs/CommonAboutDialog.cs: make the scrollbox not expand
Modified: trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/FolderNodeCommands.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/FolderNodeCommands.cs 2004-06-10 04:48:59 UTC (rev 1731)
+++ trunk/MonoDevelop/src/Main/Base/Commands/ProjectBrowserCommands/FolderNodeCommands.cs 2004-06-10 10:02:40 UTC (rev 1732)
@@ -143,6 +143,7 @@
parentNode.Nodes.Add(newNode);
parentNode.Project.ProjectFiles.Add(newFileInformation);
+ window.ViewContent.Project = parentNode.Project;
newNode.EnsureVisible();
browser.StealFocus ();
Modified: trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/AbstractProject.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/AbstractProject.cs 2004-06-10 04:48:59 UTC (rev 1731)
+++ trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/AbstractProject.cs 2004-06-10 10:02:40 UTC (rev 1732)
@@ -324,6 +324,7 @@
bool convertRel = convertToRelPath != null && convertToRelPath.Length > 0;
if (xmlAttributes != null && xmlAttributes.Length > 0) {
+ if (xmlAttributes[0].Name == null) continue;
XmlAttribute xmlAttribute = element.Attributes[xmlAttributes[0].Name];
if (xmlAttribute != null) {
if (convertRel && convertToRelPath[0].PredicatePropertyName != null && convertToRelPath[0].PredicatePropertyName.Length > 0) {
@@ -402,6 +403,7 @@
bool convertRel = convertToRelPath != null && convertToRelPath.Length > 0;
if (xmlAttributes != null && xmlAttributes.Length > 0) {
+ if (xmlAttributes[0].Name == null) continue;
XmlAttribute xmlAttribute = doc.CreateAttribute(xmlAttributes[0].Name);
object fieldValue = fieldInfo.GetValue(o);
Modified: trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/Collections/ProjectFileCollection.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/Collections/ProjectFileCollection.cs 2004-06-10 04:48:59 UTC (rev 1731)
+++ trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/Collections/ProjectFileCollection.cs 2004-06-10 10:02:40 UTC (rev 1732)
@@ -31,6 +31,8 @@
internal void SetProject (AbstractProject project)
{
this.project = project;
+ foreach (ProjectFile file in List)
+ file.SetProject (project);
}
/// <summary>
@@ -48,6 +50,7 @@
set {
project.NotifyFileRemovedFromProject ((ProjectFile)List[index]);
List[index] = value;
+ value.SetProject (project);
project.NotifyFileAddedToProject (value);
}
}
@@ -63,6 +66,7 @@
/// <seealso cref='.ProjectFileCollection.AddRange'/>
public int Add(ProjectFile value) {
int i = List.Add(value);
+ value.SetProject (project);
project.NotifyFileAddedToProject (value);
return i;
}
@@ -155,6 +159,7 @@
/// <seealso cref='.ProjectFileCollection.Add'/>
public void Insert(int index, ProjectFile value) {
List.Insert(index, value);
+ value.SetProject (project);
project.NotifyFileAddedToProject (value);
}
Modified: trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/ProjectFile.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/ProjectFile.cs 2004-06-10 04:48:59 UTC (rev 1731)
+++ trunk/MonoDevelop/src/Main/Base/Internal/Project/Project/ProjectFile.cs 2004-06-10 10:02:40 UTC (rev 1732)
@@ -54,6 +54,14 @@
[XmlAttribute("data")]
string data;
+
+ [XmlAttribute(null)]
+ AbstractProject project;
+
+ internal void SetProject (AbstractProject prj)
+ {
+ project = prj;
+ }
[LocalizedProperty("${res:MonoDevelop.Internal.Project.ProjectFile.Name}",
Description ="${res:MonoDevelop.Internal.Project.ProjectFile.Name.Description}")]
@@ -63,8 +71,10 @@
return filename;
}
set {
+ project.NotifyFileRemovedFromProject (this);
filename = value;
Debug.Assert(filename != null && filename.Length > 0, "name == null || name.Length == 0");
+ project.NotifyFileAddedToProject (this);
}
}
Modified: trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs 2004-06-10 04:48:59 UTC (rev 1731)
+++ trunk/MonoDevelop/src/Main/Base/Services/File/DefaultFileService.cs 2004-06-10 10:02:40 UTC (rev 1732)
@@ -85,6 +85,7 @@
{
if (fileName == null)
return;
+
string origName = fileName;
if (!fileName.StartsWith ("http://"))
fileName = System.IO.Path.GetFullPath (fileName);
Modified: trunk/MonoDevelop/src/Main/Base/Services/ParserService/CodeCompletionDatabase.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/ParserService/CodeCompletionDatabase.cs 2004-06-10 04:48:59 UTC (rev 1731)
+++ trunk/MonoDevelop/src/Main/Base/Services/ParserService/CodeCompletionDatabase.cs 2004-06-10 10:02:40 UTC (rev 1732)
@@ -144,7 +144,7 @@
return headers;
}
- public void Write ()
+ public virtual void Write ()
{
lock (rwlock)
{
@@ -284,6 +284,14 @@
}
}
+ public void Clear ()
+ {
+ rootNamespace = new NamespaceEntry ();
+ files = new Hashtable ();
+ references = new ArrayList ();
+ headers = new Hashtable ();
+ }
+
public IClass GetClass (string typeName, bool caseSensitive)
{
lock (rwlock)
@@ -681,7 +689,7 @@
ICompilationUnit cu = (ICompilationUnit)parserInfo.BestCompilationUnit;
ClassUpdateInformation res = UpdateFromParseInfo (parserInfo, fileName);
- parserService.NotifyParseInfoChange (fileName, res);
+ if (res != null) parserService.NotifyParseInfoChange (fileName, res);
}
public ClassUpdateInformation UpdateFromParseInfo (IParseInformation parserInfo, string fileName)
@@ -693,18 +701,17 @@
ClassUpdateInformation res = UpdateClassInformation (resolved, fileName);
FileEntry file = files [fileName] as FileEntry;
+ if (file == null) return res;
if (!allResolved) {
if (file.ParseErrorRetries > 0) {
file.ParseErrorRetries--;
}
- else {
+ else
file.ParseErrorRetries = 3;
- }
}
- else {
+ else
file.ParseErrorRetries = 0;
- }
return res;
}
@@ -870,6 +877,29 @@
}
}
+ internal class SimpleCodeCompletionDatabase: CodeCompletionDatabase
+ {
+ string file = "_currentFile";
+
+ public SimpleCodeCompletionDatabase (string file, DefaultParserService parserService)
+ : base (parserService)
+ {
+ AddFile (file);
+ this.file = file;
+ }
+
+ public ClassUpdateInformation UpdateFromParseInfo (IParseInformation parserInfo)
+ {
+ ICompilationUnit cu = (ICompilationUnit)parserInfo.BestCompilationUnit;
+ ClassCollection resolved;
+ parserService.ResolveTypes (null, cu, cu.Classes, out resolved);
+ return UpdateClassInformation (resolved, file);
+ }
+
+ public override void Read () {}
+ public override void Write () {}
+ }
+
public interface INameEncoder
{
Modified: trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs 2004-06-10 04:48:59 UTC (rev 1731)
+++ trunk/MonoDevelop/src/Main/Base/Services/ParserService/DefaultParserService.cs 2004-06-10 10:02:40 UTC (rev 1732)
@@ -34,7 +34,8 @@
{
CodeCompletionDatabase coreDatabase;
- const int MAX_CACHE_SIZE = 10;
+ const int MAX_PARSING_CACHE_SIZE = 10;
+ const int MAX_SINGLEDB_CACHE_SIZE = 10;
string CoreDB;
class ParsingCacheEntry
@@ -44,6 +45,12 @@
public DateTime AccessTime;
}
+ class SingleFileCacheEntry
+ {
+ public SimpleCodeCompletionDatabase Database;
+ public DateTime AccessTime;
+ }
+
class ParsingJob
{
public object Data;
@@ -86,8 +93,6 @@
Hashtable lastUpdateSize = new Hashtable();
Hashtable parsings = new Hashtable ();
- ParseInformation addedParseInformation = new ParseInformation();
- ParseInformation removedParseInformation = new ParseInformation();
CombineEntryEventHandler combineEntryAddedHandler;
CombineEntryEventHandler combineEntryRemovedHandler;
@@ -96,6 +101,7 @@
string codeCompletionPath;
Hashtable databases = new Hashtable();
+ Hashtable singleDatabases = new Hashtable ();
IParser[] parser;
@@ -139,8 +145,6 @@
public DefaultParserService()
{
- addedParseInformation.DirtyCompilationUnit = new DummyCompilationUnit();
- removedParseInformation.DirtyCompilationUnit = new DummyCompilationUnit();
combineEntryAddedHandler = new CombineEntryEventHandler (OnCombineEntryAdded);
combineEntryRemovedHandler = new CombineEntryEventHandler (OnCombineEntryRemoved);
nameTable = new StringNameTable (sharedNameTable);
@@ -311,6 +315,42 @@
}
}
+ internal SimpleCodeCompletionDatabase GetSingleFileDatabase (string file)
+ {
+ lock (singleDatabases)
+ {
+ SingleFileCacheEntry entry = singleDatabases [file] as SingleFileCacheEntry;
+ if (entry != null) {
+ entry.AccessTime = DateTime.Now;
+ return entry.Database;
+ }
+ else
+ {
+ if (singleDatabases.Count >= MAX_SINGLEDB_CACHE_SIZE)
+ {
+ DateTime tim = DateTime.MaxValue;
+ string toDelete = null;
+ foreach (DictionaryEntry pce in singleDatabases)
+ {
+ DateTime ptim = ((SingleFileCacheEntry)pce.Value).AccessTime;
+ if (ptim < tim) {
+ tim = ptim;
+ toDelete = pce.Key.ToString();
+ }
+ }
+ singleDatabases.Remove (toDelete);
+ }
+
+ SimpleCodeCompletionDatabase db = new SimpleCodeCompletionDatabase (file, this);
+ entry = new SingleFileCacheEntry ();
+ entry.Database = db;
+ entry.AccessTime = DateTime.Now;
+ singleDatabases [file] = entry;
+ return db;
+ }
+ }
+ }
+
void LoadProjectDatabase (IProject project)
{
lock (databases)
@@ -620,11 +660,16 @@
parseInformation = DoParseFile(fileName, text);
if (parseInformation == null) return;
- ProjectCodeCompletionDatabase db = GetProjectDatabase (viewContent.Project);
- if (db != null) {
+ if (viewContent.Project != null) {
+ ProjectCodeCompletionDatabase db = GetProjectDatabase (viewContent.Project);
ClassUpdateInformation res = db.UpdateFromParseInfo (parseInformation, fileName);
- NotifyParseInfoChange (fileName, res);
+ if (res != null) NotifyParseInfoChange (fileName, res);
}
+ else {
+ SimpleCodeCompletionDatabase db = GetSingleFileDatabase (fileName);
+ db.UpdateFromParseInfo (parseInformation);
+ }
+
lastUpdateSize[fileName] = text.GetHashCode();
updated = true;
}
@@ -639,6 +684,28 @@
}
}
+ 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
@@ -657,10 +724,9 @@
public IClass GetClass (IProject project, string typeName, bool caseSensitive)
{
- CodeCompletionDatabase db = GetProjectDatabase (project);
- IClass c;
+ CodeCompletionDatabase db = project != null ? GetProjectDatabase (project) : GetActiveFileDatabase ();
if (db != null) {
- c = db.GetClass (typeName, caseSensitive);
+ IClass c = db.GetClass (typeName, caseSensitive);
if (c != null) return c;
foreach (ReferenceEntry re in db.References)
{
@@ -670,17 +736,20 @@
if (c != null) return c;
}
}
+
db = GetDatabase (CoreDB);
return db.GetClass (typeName, caseSensitive);
}
public IClass DeepGetClass (IProject project, string typeName, bool caseSensitive)
{
+ CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
+
ArrayList visited = new ArrayList ();
- IClass c = DeepGetClassRec (visited, GetProjectDatabase (project), typeName, caseSensitive);
+ IClass c = DeepGetClassRec (visited, db, typeName, caseSensitive);
if (c != null) return c;
- CodeCompletionDatabase db = GetDatabase (CoreDB);
+ db = GetDatabase (CoreDB);
return db.GetClass (typeName, caseSensitive);
}
@@ -713,7 +782,7 @@
{
ArrayList contents = new ArrayList ();
- CodeCompletionDatabase db = GetProjectDatabase (project);
+ CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
if (db != null) {
db.GetNamespaceList (contents, subNameSpace, caseSensitive);
foreach (ReferenceEntry re in db.References)
@@ -739,7 +808,7 @@
{
ArrayList contents = new ArrayList ();
- CodeCompletionDatabase db = GetProjectDatabase (project);
+ CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
if (db != null) {
db.GetNamespaceContents (contents, namspace, caseSensitive);
if (includeReferences) {
@@ -767,7 +836,7 @@
public bool NamespaceExists(IProject project, string name, bool caseSensitive)
{
- CodeCompletionDatabase db = GetProjectDatabase (project);
+ CodeCompletionDatabase db = (project != null) ? GetProjectDatabase (project) : GetActiveFileDatabase ();
if (db != null) {
if (db.NamespaceExists (name, caseSensitive)) return true;
foreach (ReferenceEntry re in db.References)
@@ -1037,7 +1106,7 @@
{
lock (parsings)
{
- if (parsings.Count >= MAX_CACHE_SIZE)
+ if (parsings.Count >= MAX_PARSING_CACHE_SIZE)
{
DateTime tim = DateTime.MaxValue;
string toDelete = null;
More information about the Monodevelop-patches-list
mailing list