|
|
|
|
@ -79,6 +79,7 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -79,6 +79,7 @@ namespace ICSharpCode.SharpDevelop.Dom
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NamespaceStruct behaves like a reference type because it only consists of readonly references!
|
|
|
|
|
protected struct NamespaceStruct |
|
|
|
|
{ |
|
|
|
|
public readonly List<IClass> Classes; |
|
|
|
|
@ -89,6 +90,16 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -89,6 +90,16 @@ namespace ICSharpCode.SharpDevelop.Dom
|
|
|
|
|
this.Classes = new List<IClass>(); |
|
|
|
|
this.SubNamespaces = new List<string>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public NamespaceStruct MergeWith(NamespaceStruct other) |
|
|
|
|
{ |
|
|
|
|
NamespaceStruct newStruct = new NamespaceStruct(null); |
|
|
|
|
newStruct.Classes.AddRange(this.Classes); |
|
|
|
|
newStruct.Classes.AddRange(other.Classes); |
|
|
|
|
newStruct.SubNamespaces.AddRange(this.SubNamespaces); |
|
|
|
|
newStruct.SubNamespaces.AddRange(other.SubNamespaces); |
|
|
|
|
return newStruct; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
@ -130,7 +141,15 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -130,7 +141,15 @@ namespace ICSharpCode.SharpDevelop.Dom
|
|
|
|
|
Dictionary<string, NamespaceStruct> oldList = namespaces[0]; |
|
|
|
|
d = new Dictionary<string, NamespaceStruct>(oldList.Count, language.NameComparer); |
|
|
|
|
foreach (KeyValuePair<string, NamespaceStruct> pair in oldList) { |
|
|
|
|
d.Add(pair.Key, pair.Value); |
|
|
|
|
NamespaceStruct ns; |
|
|
|
|
if (d.TryGetValue(pair.Key, out ns)) { |
|
|
|
|
// we got a name conflict due to the new NameComparer.
|
|
|
|
|
// This happens if a C# assembly contains the namespace "a" and "A",
|
|
|
|
|
// and now we're trying to get a dictionary for use in VB.
|
|
|
|
|
d[pair.Key] = ns.MergeWith(pair.Value); |
|
|
|
|
} else { |
|
|
|
|
d.Add(pair.Key, pair.Value); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
d = new Dictionary<string, NamespaceStruct>(language.NameComparer); |
|
|
|
|
@ -351,6 +370,7 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -351,6 +370,7 @@ namespace ICSharpCode.SharpDevelop.Dom
|
|
|
|
|
|
|
|
|
|
void AddClassToNamespaceListInternal2(IClass addClass) |
|
|
|
|
{ |
|
|
|
|
bool isReplacingExistingClass = false; |
|
|
|
|
string fullyQualifiedName = addClass.FullyQualifiedName; |
|
|
|
|
IClass oldDictionaryClass; |
|
|
|
|
if (GetClasses(language).TryGetValue(fullyQualifiedName, out oldDictionaryClass)) { |
|
|
|
|
@ -363,6 +383,7 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -363,6 +383,7 @@ namespace ICSharpCode.SharpDevelop.Dom
|
|
|
|
|
gcc.Set(addClass); |
|
|
|
|
gcc.Set(oldDictionaryClass); |
|
|
|
|
addClass = gcc; |
|
|
|
|
isReplacingExistingClass = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -375,10 +396,12 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -375,10 +396,12 @@ namespace ICSharpCode.SharpDevelop.Dom
|
|
|
|
|
} |
|
|
|
|
CreateNamespace(nSpace); |
|
|
|
|
List<IClass> classList = GetNamespaces(this.language)[nSpace].Classes; |
|
|
|
|
for (int i = 0; i < classList.Count; i++) { |
|
|
|
|
if (classList[i].FullyQualifiedName == fullyQualifiedName) { |
|
|
|
|
classList[i] = addClass; |
|
|
|
|
return; |
|
|
|
|
if (isReplacingExistingClass) { |
|
|
|
|
for (int i = 0; i < classList.Count; i++) { |
|
|
|
|
if (classList[i].FullyQualifiedName == fullyQualifiedName) { |
|
|
|
|
classList[i] = addClass; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
classList.Add(addClass); |
|
|
|
|
@ -394,7 +417,11 @@ namespace ICSharpCode.SharpDevelop.Dom
@@ -394,7 +417,11 @@ namespace ICSharpCode.SharpDevelop.Dom
|
|
|
|
|
// use the same namespaceStruct for all dictionaries
|
|
|
|
|
foreach (Dictionary<string, NamespaceStruct> otherDict in namespaces) { |
|
|
|
|
if (otherDict == dict) continue; |
|
|
|
|
otherDict.Add(nSpace, namespaceStruct); |
|
|
|
|
NamespaceStruct existingNamespaceStruct; |
|
|
|
|
if (otherDict.TryGetValue(nSpace, out existingNamespaceStruct)) |
|
|
|
|
otherDict[nSpace] = existingNamespaceStruct.MergeWith(namespaceStruct); |
|
|
|
|
else |
|
|
|
|
otherDict.Add(nSpace, namespaceStruct); |
|
|
|
|
} |
|
|
|
|
if (nSpace.Length == 0) |
|
|
|
|
return; |
|
|
|
|
|