Browse Source

Add protected virtual Clone() method to CSharpProjectContent.

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
bf12c0083e
  1. 19
      ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs

19
ICSharpCode.NRefactory.CSharp/CSharpProjectContent.cs

@ -87,7 +87,7 @@ namespace ICSharpCode.NRefactory.CSharp
return null; return null;
} }
public ICompilation CreateCompilation() public virtual ICompilation CreateCompilation()
{ {
var solutionSnapshot = new DefaultSolutionSnapshot(); var solutionSnapshot = new DefaultSolutionSnapshot();
ICompilation compilation = new SimpleCompilation(solutionSnapshot, this, assemblyReferences); ICompilation compilation = new SimpleCompilation(solutionSnapshot, this, assemblyReferences);
@ -95,28 +95,33 @@ namespace ICSharpCode.NRefactory.CSharp
return compilation; return compilation;
} }
public ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot) public virtual ICompilation CreateCompilation(ISolutionSnapshot solutionSnapshot)
{ {
return new SimpleCompilation(solutionSnapshot, this, assemblyReferences); return new SimpleCompilation(solutionSnapshot, this, assemblyReferences);
} }
protected virtual CSharpProjectContent Clone()
{
return new CSharpProjectContent(this);
}
public IProjectContent SetAssemblyName(string newAssemblyName) public IProjectContent SetAssemblyName(string newAssemblyName)
{ {
CSharpProjectContent pc = new CSharpProjectContent(this); CSharpProjectContent pc = Clone();
pc.assemblyName = newAssemblyName; pc.assemblyName = newAssemblyName;
return pc; return pc;
} }
public IProjectContent AddAssemblyReferences(IEnumerable<IAssemblyReference> references) public IProjectContent AddAssemblyReferences(IEnumerable<IAssemblyReference> references)
{ {
CSharpProjectContent pc = new CSharpProjectContent(this); CSharpProjectContent pc = Clone();
pc.assemblyReferences.AddRange(references); pc.assemblyReferences.AddRange(references);
return pc; return pc;
} }
public IProjectContent RemoveAssemblyReferences(IEnumerable<IAssemblyReference> references) public IProjectContent RemoveAssemblyReferences(IEnumerable<IAssemblyReference> references)
{ {
CSharpProjectContent pc = new CSharpProjectContent(this); CSharpProjectContent pc = Clone();
pc.assemblyReferences.RemoveAll(r => references.Contains(r)); pc.assemblyReferences.RemoveAll(r => references.Contains(r));
return pc; return pc;
} }
@ -129,7 +134,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (!Platform.FileNameComparer.Equals(oldFile.FileName, newFile.FileName)) if (!Platform.FileNameComparer.Equals(oldFile.FileName, newFile.FileName))
throw new ArgumentException("When both oldFile and newFile are specified, they must use the same file name."); throw new ArgumentException("When both oldFile and newFile are specified, they must use the same file name.");
} }
CSharpProjectContent pc = new CSharpProjectContent(this); CSharpProjectContent pc = Clone();
if (newFile == null) if (newFile == null)
pc.parsedFiles.Remove(oldFile.FileName); pc.parsedFiles.Remove(oldFile.FileName);
else else
@ -139,7 +144,7 @@ namespace ICSharpCode.NRefactory.CSharp
public IProjectContent UpdateProjectContent(IEnumerable<IParsedFile> oldFiles, IEnumerable<IParsedFile> newFiles) public IProjectContent UpdateProjectContent(IEnumerable<IParsedFile> oldFiles, IEnumerable<IParsedFile> newFiles)
{ {
CSharpProjectContent pc = new CSharpProjectContent(this); CSharpProjectContent pc = Clone();
if (oldFiles != null) { if (oldFiles != null) {
foreach (var oldFile in oldFiles) { foreach (var oldFile in oldFiles) {
pc.parsedFiles.Remove(oldFile.FileName); pc.parsedFiles.Remove(oldFile.FileName);

Loading…
Cancel
Save