14 changed files with 181 additions and 347 deletions
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
|
||||
bin/ |
||||
obj/ |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a snapshot of the whole solution (multiple compilations).
|
||||
/// </summary>
|
||||
public interface ISolutionSnapshot |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the compilation for the specified project.
|
||||
/// </summary>
|
||||
ICompilation GetCompilation(IProjectContent project); |
||||
} |
||||
} |
||||
@ -1,329 +0,0 @@
@@ -1,329 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.NRefactory.Utils; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Base class for <see cref="IMember"/> implementations.
|
||||
/// </summary>
|
||||
[Serializable] |
||||
public abstract class AbstractMember : AbstractFreezable, IMember |
||||
{ |
||||
// possible optimizations to reduce the memory usage of AbstractMember:
|
||||
// - put 'bool isFrozen' into flags
|
||||
// - store regions in more compact form (e.g. assume both file names are identical; use ushort for columns)
|
||||
|
||||
ITypeDefinition declaringTypeDefinition; |
||||
ITypeReference returnType = SharedTypes.UnknownType; |
||||
IList<IAttribute> attributes; |
||||
IList<IExplicitInterfaceImplementation> interfaceImplementations; |
||||
DomRegion region; |
||||
DomRegion bodyRegion; |
||||
string name; |
||||
|
||||
// 1 byte per enum + 2 bytes for flags
|
||||
Accessibility accessibility; |
||||
EntityType entityType; |
||||
|
||||
[CLSCompliant(false)] |
||||
protected BitVector16 flags; |
||||
const ushort FlagSealed = 0x0001; |
||||
const ushort FlagAbstract = 0x0002; |
||||
const ushort FlagShadowing = 0x0004; |
||||
const ushort FlagSynthetic = 0x0008; |
||||
const ushort FlagVirtual = 0x0010; |
||||
const ushort FlagOverride = 0x0020; |
||||
const ushort FlagStatic = 0x0040; |
||||
const ushort FlagPartial = 0x0080; |
||||
|
||||
// Flags of form 0xY000 are reserved for use in derived classes (DefaultMethod etc.)
|
||||
|
||||
protected override void FreezeInternal() |
||||
{ |
||||
attributes = FreezeList(attributes); |
||||
interfaceImplementations = FreezeList(interfaceImplementations); |
||||
base.FreezeInternal(); |
||||
} |
||||
|
||||
protected AbstractMember(ITypeDefinition declaringTypeDefinition, string name, EntityType entityType) |
||||
{ |
||||
if (declaringTypeDefinition == null) |
||||
throw new ArgumentNullException("declaringTypeDefinition"); |
||||
if (name == null) |
||||
throw new ArgumentNullException("name"); |
||||
this.declaringTypeDefinition = declaringTypeDefinition; |
||||
this.entityType = entityType; |
||||
this.name = name; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Copy constructor
|
||||
/// </summary>
|
||||
protected AbstractMember(IMember member) |
||||
{ |
||||
if (member == null) |
||||
throw new ArgumentNullException("member"); |
||||
this.declaringTypeDefinition = member.DeclaringTypeDefinition; |
||||
this.returnType = member.ReturnType; |
||||
this.attributes = CopyList(member.Attributes); |
||||
this.interfaceImplementations = CopyList(member.InterfaceImplementations); |
||||
this.region = member.Region; |
||||
this.bodyRegion = member.BodyRegion; |
||||
this.name = member.Name; |
||||
this.accessibility = member.Accessibility; |
||||
this.entityType = member.EntityType; |
||||
this.IsSealed = member.IsSealed; |
||||
this.IsAbstract = member.IsAbstract; |
||||
this.IsShadowing = member.IsShadowing; |
||||
this.IsSynthetic = member.IsSynthetic; |
||||
this.IsVirtual = member.IsVirtual; |
||||
this.IsOverride = member.IsOverride; |
||||
this.IsStatic = member.IsStatic; |
||||
} |
||||
|
||||
public ITypeDefinition DeclaringTypeDefinition { |
||||
get { return declaringTypeDefinition; } |
||||
} |
||||
|
||||
public virtual IType DeclaringType { |
||||
get { return declaringTypeDefinition; } |
||||
} |
||||
|
||||
public virtual IMember MemberDefinition { |
||||
get { return this; } |
||||
} |
||||
|
||||
public ITypeReference ReturnType { |
||||
get { return returnType; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
if (value == null) |
||||
throw new ArgumentNullException(); |
||||
returnType = value; |
||||
} |
||||
} |
||||
|
||||
public IList<IExplicitInterfaceImplementation> InterfaceImplementations { |
||||
get { |
||||
if (interfaceImplementations == null) |
||||
interfaceImplementations = new List<IExplicitInterfaceImplementation>(); |
||||
return interfaceImplementations; |
||||
} |
||||
} |
||||
|
||||
public bool IsVirtual { |
||||
get { return flags[FlagVirtual]; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
flags[FlagVirtual] = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsOverride { |
||||
get { return flags[FlagOverride]; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
flags[FlagOverride] = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsPartial { |
||||
get { return flags[FlagPartial]; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
flags[FlagPartial] = value; |
||||
} |
||||
} |
||||
|
||||
|
||||
public bool IsOverridable { |
||||
get { |
||||
return (IsAbstract || IsVirtual || IsOverride) && !IsSealed; |
||||
} |
||||
} |
||||
|
||||
public EntityType EntityType { |
||||
get { return entityType; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
entityType = value; |
||||
} |
||||
} |
||||
|
||||
public DomRegion Region { |
||||
get { return region; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
region = value; |
||||
} |
||||
} |
||||
|
||||
public DomRegion BodyRegion { |
||||
get { return bodyRegion; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
bodyRegion = value; |
||||
} |
||||
} |
||||
|
||||
public IList<IAttribute> Attributes { |
||||
get { |
||||
if (attributes == null) |
||||
attributes = new List<IAttribute>(); |
||||
return attributes; |
||||
} |
||||
} |
||||
|
||||
public virtual string Documentation { |
||||
get { |
||||
// To save memory, we don't store the documentation provider within the member,
|
||||
// but simply use our declaring type definition as documentation provider.
|
||||
// If that fails, we try if the project content is a documentation provider:
|
||||
IDocumentationProvider provider = declaringTypeDefinition as IDocumentationProvider |
||||
?? declaringTypeDefinition.ProjectContent as IDocumentationProvider; |
||||
if (provider != null) |
||||
return provider.GetDocumentation(this); |
||||
else |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public Accessibility Accessibility { |
||||
get { return accessibility; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
accessibility = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsStatic { |
||||
get { return flags[FlagStatic]; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
flags[FlagStatic] = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsAbstract { |
||||
get { return flags[FlagAbstract]; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
flags[FlagAbstract] = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsSealed { |
||||
get { return flags[FlagSealed]; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
flags[FlagSealed] = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsShadowing { |
||||
get { return flags[FlagShadowing]; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
flags[FlagShadowing] = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsSynthetic { |
||||
get { return flags[FlagSynthetic]; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
flags[FlagSynthetic] = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsPrivate { |
||||
get { return Accessibility == Accessibility.Private; } |
||||
} |
||||
|
||||
public bool IsPublic { |
||||
get { return Accessibility == Accessibility.Public; } |
||||
} |
||||
|
||||
public bool IsProtected { |
||||
get { return Accessibility == Accessibility.Protected; } |
||||
} |
||||
|
||||
public bool IsInternal { |
||||
get { return Accessibility == Accessibility.Internal; } |
||||
} |
||||
|
||||
public bool IsProtectedOrInternal { |
||||
get { return Accessibility == Accessibility.ProtectedOrInternal; } |
||||
} |
||||
|
||||
public bool IsProtectedAndInternal { |
||||
get { return Accessibility == Accessibility.ProtectedAndInternal; } |
||||
} |
||||
|
||||
public IProjectContent ProjectContent { |
||||
get { return declaringTypeDefinition.ProjectContent; } |
||||
} |
||||
|
||||
public IParsedFile ParsedFile { |
||||
get { return declaringTypeDefinition.ParsedFile; } |
||||
} |
||||
|
||||
public string Name { |
||||
get { return name; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
if (value == null) |
||||
throw new ArgumentNullException(); |
||||
name = value; |
||||
} |
||||
} |
||||
|
||||
public virtual string FullName { |
||||
get { |
||||
return this.DeclaringType.FullName + "." + this.Name; |
||||
} |
||||
} |
||||
|
||||
public string Namespace { |
||||
get { return declaringTypeDefinition.Namespace; } |
||||
} |
||||
|
||||
public virtual string ReflectionName { |
||||
get { return this.DeclaringType.ReflectionName + "." + this.Name; } |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return "[" + EntityType + " " + ReflectionName + ":" + ReturnType + "]"; |
||||
} |
||||
|
||||
public virtual void ApplyInterningProvider(IInterningProvider provider) |
||||
{ |
||||
if (provider != null) { |
||||
returnType = provider.Intern(returnType); |
||||
attributes = provider.InternList(attributes); |
||||
interfaceImplementations = provider.InternList(interfaceImplementations); |
||||
name = provider.Intern(name); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Concurrent; |
||||
|
||||
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||
{ |
||||
/// <summary>
|
||||
/// Default implementation of ISolutionSnapshot.
|
||||
/// </summary>
|
||||
public sealed class DefaultSolutionSnapshot : ISolutionSnapshot |
||||
{ |
||||
ConcurrentDictionary<IProjectContent, ICompilation> dictionary = new ConcurrentDictionary<IProjectContent, ICompilation>(); |
||||
|
||||
public ICompilation GetCompilation(IProjectContent project) |
||||
{ |
||||
if (project == null) |
||||
throw new ArgumentNullException("project"); |
||||
return dictionary.GetOrAdd(project, p => p.CreateCompilation(this)); |
||||
} |
||||
|
||||
public void AddCompilation(IProjectContent project, ICompilation compilation) |
||||
{ |
||||
if (project == null) |
||||
throw new ArgumentNullException("project"); |
||||
if (compilation == null) |
||||
throw new ArgumentNullException("compilation"); |
||||
if (!dictionary.TryAdd(project, compilation)) |
||||
throw new InvalidOperationException(); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue