16 changed files with 502 additions and 59 deletions
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
// 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 ICSharpCode.NRefactory.TypeSystem; |
||||
|
||||
namespace ICSharpCode.NRefactory.Documentation |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a documentation comment.
|
||||
/// </summary>
|
||||
[Serializable] |
||||
public class DocumentationComment |
||||
{ |
||||
string xmlText; |
||||
|
||||
/// <summary>
|
||||
/// Gets the XML code for this documentation comment.
|
||||
/// </summary>
|
||||
public string XmlText { |
||||
get { return xmlText; } |
||||
} |
||||
|
||||
public DocumentationComment(string xmlText) |
||||
{ |
||||
if (xmlText == null) |
||||
throw new ArgumentNullException("xmlText"); |
||||
this.xmlText = xmlText; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Resolves the given cref value to an entity.
|
||||
/// Returns null if the entity is not found, or if the cref attribute is syntactically invalid.
|
||||
/// </summary>
|
||||
public virtual IEntity ResolveCRef(string cref) |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
// 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.Linq; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
|
||||
namespace ICSharpCode.NRefactory.Documentation |
||||
{ |
||||
/// <summary>
|
||||
/// A type reference of the form 'Some.Namespace.TopLevelType.NestedType`n'.
|
||||
/// We do not know the boundary between namespace name and top level type, so we have to try
|
||||
/// all possibilities.
|
||||
/// The type parameter count only applies to the innermost type, all outer types must be non-generic.
|
||||
/// </summary>
|
||||
[Serializable] |
||||
class GetPotentiallyNestedClassTypeReference : ITypeReference |
||||
{ |
||||
readonly string typeName; |
||||
readonly int typeParameterCount; |
||||
|
||||
public GetPotentiallyNestedClassTypeReference(string typeName, int typeParameterCount) |
||||
{ |
||||
this.typeName = typeName; |
||||
this.typeParameterCount = typeParameterCount; |
||||
} |
||||
|
||||
public IType Resolve(ITypeResolveContext context) |
||||
{ |
||||
string[] parts = typeName.Split('.'); |
||||
var assemblies = new [] { context.CurrentAssembly, context.Compilation.MainAssembly }.Concat(context.Compilation.ReferencedAssemblies); |
||||
for (int i = parts.Length - 1; i >= 0; i++) { |
||||
string ns = string.Join(".", parts, 0, i); |
||||
string name = parts[i]; |
||||
int topLevelTPC = (i == parts.Length - 1 ? typeParameterCount : 0); |
||||
foreach (var asm in assemblies) { |
||||
if (asm == null) |
||||
continue; |
||||
ITypeDefinition typeDef = asm.GetTypeDefinition(ns, name, topLevelTPC); |
||||
for (int j = i + 1; j < parts.Length && typeDef != null; j++) { |
||||
int tpc = (j == parts.Length - 1 ? typeParameterCount : 0); |
||||
typeDef = typeDef.NestedTypes.FirstOrDefault(n => n.Name == parts[j] && n.TypeParameterCount == tpc); |
||||
} |
||||
if (typeDef != null) |
||||
return typeDef; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,72 @@
@@ -0,0 +1,72 @@
|
||||
// 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 ICSharpCode.NRefactory.TypeSystem; |
||||
|
||||
namespace ICSharpCode.NRefactory.Documentation |
||||
{ |
||||
[Serializable] |
||||
class IDStringMemberReference : IMemberReference |
||||
{ |
||||
readonly ITypeReference declaringTypeReference; |
||||
readonly char memberType; |
||||
readonly string memberName; |
||||
readonly string memberIDString; |
||||
|
||||
public IDStringMemberReference(ITypeReference declaringTypeReference, char memberType, string memberName, string memberIDString) |
||||
{ |
||||
this.declaringTypeReference = declaringTypeReference; |
||||
this.memberType = memberType; |
||||
this.memberName = memberName; |
||||
this.memberIDString = memberIDString; |
||||
} |
||||
|
||||
bool CanMatch(IUnresolvedMember member) |
||||
{ |
||||
if (member.Name != memberName) |
||||
return false; |
||||
switch (member.EntityType) { |
||||
case EntityType.Field: |
||||
return memberType == 'F'; |
||||
case EntityType.Property: |
||||
case EntityType.Indexer: |
||||
return memberType == 'P'; |
||||
case EntityType.Event: |
||||
return memberType == 'E'; |
||||
case EntityType.Method: |
||||
case EntityType.Operator: |
||||
case EntityType.Constructor: |
||||
case EntityType.Destructor: |
||||
return memberType == 'M'; |
||||
default: |
||||
throw new NotSupportedException(member.EntityType.ToString()); |
||||
} |
||||
} |
||||
|
||||
public IMember Resolve(ITypeResolveContext context) |
||||
{ |
||||
IType declaringType = declaringTypeReference.Resolve(context); |
||||
foreach (var member in declaringType.GetMembers(CanMatch, GetMemberOptions.IgnoreInheritedMembers)) { |
||||
if (IDStringProvider.GetIDString(member) == memberIDString) |
||||
return member; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue