[Monodevelop-patches-list] r2737 - in trunk/MonoDevelop/Core/src/MonoDevelop.Base: . Internal/Project/Combine Internal/Project/Project Internal/Project/Project/Collections
Lluis Sanchez <lluis@ximian.com>
lluis at mono-cvs.ximian.com
Wed Aug 10 18:06:42 EDT 2005
Author: lluis
Date: 2005-08-10 18:06:42 -0400 (Wed, 10 Aug 2005)
New Revision: 2737
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/Combine.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/CombineEntry.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/CombineEntryCollection.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Collections/ProjectReferenceCollection.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Project.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/ProjectReference.cs
Log:
2005-08-10 Lluis Sanchez Gual <lluis at novell.com>
* Internal/Project/Project/ProjectReference.cs: Find referenced projects
looking at the root combine that contain this reference.
* Internal/Project/Project/Collections/ProjectReferenceCollection.cs:
Set the owner project of the references being added.
* Internal/Project/Combine/Combine.cs: Added method for finding projects
in the combine hierarchy.
* Internal/Project/Combine/CombineEntry.cs: Added property for getting
the root combine of a project.
* Internal/Project/Project/Project.cs: Make sure to always set the
owner project to the references collection.
Use RootCombine to find referenced projects, instead of the project
service. Perform a topological sort of the referenced projects to build.
* Internal/Project/Combine/CombineEntryCollection.cs: Added Contains
method.
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-08-10 21:17:55 UTC (rev 2736)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/ChangeLog 2005-08-10 22:06:42 UTC (rev 2737)
@@ -1,3 +1,20 @@
+2005-08-10 Lluis Sanchez Gual <lluis at novell.com>
+
+ * Internal/Project/Project/ProjectReference.cs: Find referenced projects
+ looking at the root combine that contain this reference.
+ * Internal/Project/Project/Collections/ProjectReferenceCollection.cs:
+ Set the owner project of the references being added.
+ * Internal/Project/Combine/Combine.cs: Added method for finding projects
+ in the combine hierarchy.
+ * Internal/Project/Combine/CombineEntry.cs: Added property for getting
+ the root combine of a project.
+ * Internal/Project/Project/Project.cs: Make sure to always set the
+ owner project to the references collection.
+ Use RootCombine to find referenced projects, instead of the project
+ service. Perform a topological sort of the referenced projects to build.
+ * Internal/Project/Combine/CombineEntryCollection.cs: Added Contains
+ method.
+
2005-08-10 Lluis Sanchez Gual <lluis at novell.com>
* Commands/EditCommands.cs:
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/Combine.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/Combine.cs 2005-08-10 21:17:55 UTC (rev 2736)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/Combine.cs 2005-08-10 22:06:42 UTC (rev 2737)
@@ -487,8 +487,18 @@
return null;
}
- CombineEntryCollection TopologicalSort (CombineEntryCollection allProjects)
+ public Project FindProject (string projectName)
{
+ CombineEntryCollection allProjects = GetAllProjects();
+ foreach (Project project in allProjects) {
+ if (project.Name == projectName)
+ return project;
+ }
+ return null;
+ }
+
+ internal static CombineEntryCollection TopologicalSort (CombineEntryCollection allProjects)
+ {
CombineEntryCollection sortedEntries = new CombineEntryCollection ();
bool[] inserted = new bool[allProjects.Count];
bool[] triedToInsert = new bool[allProjects.Count];
@@ -503,7 +513,7 @@
return sortedEntries;
}
- void Insert(int index, CombineEntryCollection allProjects, CombineEntryCollection sortedEntries, bool[] inserted, bool[] triedToInsert)
+ static void Insert(int index, CombineEntryCollection allProjects, CombineEntryCollection sortedEntries, bool[] inserted, bool[] triedToInsert)
{
if (triedToInsert[index]) {
throw new CyclicBuildOrderException();
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/CombineEntry.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/CombineEntry.cs 2005-08-10 21:17:55 UTC (rev 2736)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/CombineEntry.cs 2005-08-10 22:06:42 UTC (rev 2737)
@@ -122,6 +122,10 @@
Save (monitor);
}
+ public Combine RootCombine {
+ get { return parentCombine != null ? parentCombine.RootCombine : this as Combine; }
+ }
+
public virtual void Save (IProgressMonitor monitor)
{
Runtime.ProjectService.WriteFile (FileName, this, monitor);
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/CombineEntryCollection.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/CombineEntryCollection.cs 2005-08-10 21:17:55 UTC (rev 2736)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Combine/CombineEntryCollection.cs 2005-08-10 22:06:42 UTC (rev 2737)
@@ -79,6 +79,11 @@
return list.IndexOf (entry);
}
+ public bool Contains (CombineEntry entry)
+ {
+ return IndexOf (entry) != -1;
+ }
+
public int IndexOf (string name)
{
for (int n=0; n<list.Count; n++)
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Collections/ProjectReferenceCollection.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Collections/ProjectReferenceCollection.cs 2005-08-10 21:17:55 UTC (rev 2736)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Collections/ProjectReferenceCollection.cs 2005-08-10 22:06:42 UTC (rev 2737)
@@ -180,29 +180,43 @@
if (project != null) {
ArrayList list = (ArrayList) InnerList.Clone ();
InnerList.Clear ();
- foreach (ProjectReference pref in list)
+ foreach (ProjectReference pref in list) {
+ pref.SetOwnerProject (null);
project.NotifyReferenceRemovedFromProject (pref);
+ }
}
}
protected override void OnInsertComplete(int index, object value)
{
- if (project != null) project.NotifyReferenceAddedToProject ((ProjectReference)value);
+ if (project != null) {
+ ((ProjectReference) value).SetOwnerProject (project);
+ project.NotifyReferenceAddedToProject ((ProjectReference)value);
+ }
}
protected override void OnRemoveComplete(int index, object value)
{
- if (project != null) project.NotifyReferenceRemovedFromProject ((ProjectReference) value);
+ if (project != null) {
+ ((ProjectReference) value).SetOwnerProject (null);
+ project.NotifyReferenceRemovedFromProject ((ProjectReference) value);
+ }
}
protected override void OnSet (int index, object oldValue, object newValue)
{
- if (project != null) project.NotifyReferenceRemovedFromProject ((ProjectReference) oldValue);
+ if (project != null) {
+ ((ProjectReference) oldValue).SetOwnerProject (null);
+ project.NotifyReferenceRemovedFromProject ((ProjectReference) oldValue);
+ }
}
protected override void OnSetComplete (int index, object oldValue, object newValue)
{
- if (project != null) project.NotifyReferenceAddedToProject ((ProjectReference) newValue);
+ if (project != null) {
+ ((ProjectReference) newValue).SetOwnerProject (project);
+ project.NotifyReferenceAddedToProject ((ProjectReference) newValue);
+ }
}
public class ProjectReferenceEnumerator : object, IEnumerator {
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Project.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Project.cs 2005-08-10 21:17:55 UTC (rev 2736)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/Project.cs 2005-08-10 22:06:42 UTC (rev 2737)
@@ -51,8 +51,7 @@
ProjectFileCollection projectFiles;
- [ItemProperty ("References")]
- protected ProjectReferenceCollection projectReferences = new ProjectReferenceCollection();
+ protected ProjectReferenceCollection projectReferences;
[ItemProperty ("DeploymentInformation")]
protected DeployInformation deployInformation = new DeployInformation();
@@ -65,6 +64,7 @@
public Project ()
{
Name = "New Project";
+ projectReferences = new ProjectReferenceCollection ();
projectReferences.SetProject (this);
projectFileWatcher = new FileSystemWatcher();
@@ -94,6 +94,7 @@
}
[Browsable(false)]
+ [ItemProperty ("References")]
public ProjectReferenceCollection ProjectReferences {
get {
return projectReferences;
@@ -285,8 +286,8 @@
Runtime.LoggingService.InfoFormat("Can't copy reference file from {0} to {1} reason {2}", referenceFileName, destinationFileName, e);
}
}
- if (projectReference.ReferenceType == ReferenceType.Project) {
- Project p = Runtime.ProjectService.GetProject (projectReference.Reference);
+ if (projectReference.ReferenceType == ReferenceType.Project && RootCombine != null) {
+ Project p = RootCombine.FindProject (projectReference.Reference);
p.CopyReferencesToOutputPath (destPath, force);
}
}
@@ -346,9 +347,11 @@
{
if (buildReferences)
{
- ArrayList referenced = new ArrayList ();
+ CombineEntryCollection referenced = new CombineEntryCollection ();
GetReferencedProjects (referenced, this);
+ referenced = Combine.TopologicalSort (referenced);
+
CompilerResults cres = new CompilerResults (null);
int builds = 0;
@@ -399,17 +402,21 @@
}
}
- void GetReferencedProjects (ArrayList referenced, Project project)
+ void GetReferencedProjects (CombineEntryCollection referenced, Project project)
{
if (referenced.Contains (project)) return;
if (NeedsBuilding)
- referenced.Insert (0, project);
+ referenced.Add (project);
foreach (ProjectReference pref in project.ProjectReferences) {
if (pref.ReferenceType == ReferenceType.Project) {
- Project rp = Runtime.ProjectService.GetProject (pref.Reference);
- GetReferencedProjects (referenced, rp);
+ Combine c = project.RootCombine;
+ if (c != null) {
+ Project rp = c.FindProject (pref.Reference);
+ if (rp != null)
+ GetReferencedProjects (referenced, rp);
+ }
}
}
}
@@ -544,8 +551,8 @@
}
foreach (ProjectReference pref in ProjectReferences) {
- if (pref.ReferenceType == ReferenceType.Project) {
- Project rp = Runtime.ProjectService.GetProject (pref.Reference);
+ if (pref.ReferenceType == ReferenceType.Project && RootCombine != null) {
+ Project rp = RootCombine.FindProject (pref.Reference);
if (rp != null && rp.NeedsBuilding) {
isDirty = true;
return;
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-10 21:17:55 UTC (rev 2736)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Internal/Project/Project/ProjectReference.cs 2005-08-10 22:06:42 UTC (rev 2737)
@@ -34,6 +34,8 @@
[ItemProperty ("type")]
ReferenceType referenceType;
+ Project ownerProject;
+
string reference = String.Empty;
[ItemProperty ("localcopy")]
@@ -43,6 +45,11 @@
{
}
+ internal void SetOwnerProject (Project project)
+ {
+ ownerProject = project;
+ }
+
public ProjectReference(ReferenceType referenceType, string reference)
{
this.referenceType = referenceType;
@@ -109,8 +116,15 @@
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;
+ if (ownerProject != null) {
+ Combine c = ownerProject.RootCombine;
+ if (c != null) {
+ Project p = c.FindProject (reference);
+ if (p != null) return p.GetOutputFileName ();
+ }
+ }
+ Console.WriteLine ("Reference not found for project " + reference);
+ return null;
default:
throw new NotImplementedException("unknown reference type : " + ReferenceType);
More information about the Monodevelop-patches-list
mailing list