Browse Source
- the static class "SD" is providing services - service interfaces are defined in ICSharpCode.SharpDevelop.dll - services are implemented in SharpDevelop.exe or in AddIns - ICSharpCode.SharpDevelop.Sda is moved into SharpDevelop.exe Also added XmlEditor.Tests to SharpDevelop.Tests.slnnewNRvisualizers
240 changed files with 789 additions and 28722 deletions
@ -1,53 +0,0 @@
@@ -1,53 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
|
||||
namespace XmlEditor.Tests.Utils |
||||
{ |
||||
public class MockCaret : ITextEditorCaret |
||||
{ |
||||
int offset = -1; |
||||
|
||||
public MockCaret() |
||||
{ |
||||
Position = Location.Empty; |
||||
} |
||||
|
||||
public event EventHandler PositionChanged; |
||||
|
||||
protected virtual void OnPositionChanged(EventArgs e) |
||||
{ |
||||
if (PositionChanged != null) { |
||||
PositionChanged(this, e); |
||||
} |
||||
} |
||||
|
||||
public int Offset { |
||||
get { return offset; } |
||||
set { offset = value; } |
||||
} |
||||
|
||||
public int Line { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int Column { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public Location Position { get; set; } |
||||
} |
||||
} |
@ -1,53 +0,0 @@
@@ -1,53 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
|
||||
namespace XmlEditor.Tests.Utils |
||||
{ |
||||
public class MockDocumentLine : IDocumentLine |
||||
{ |
||||
public MockDocumentLine() |
||||
{ |
||||
} |
||||
|
||||
public int Offset { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int Length { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int EndOffset { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int TotalLength { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int DelimiterLength { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int LineNumber { get; set; } |
||||
|
||||
public string Text { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.XmlEditor; |
||||
|
||||
namespace XmlEditor.Tests.Utils |
||||
{ |
||||
public class MockParserService : IParserService |
||||
{ |
||||
IProjectContent projectContentPassedToGetExistingParseInfoMethod; |
||||
Dictionary<string, ParseInformation> parseInfoDictionary = new Dictionary<string, ParseInformation>(); |
||||
|
||||
public MockParserService() |
||||
{ |
||||
} |
||||
|
||||
public ParseInformation GetExistingParseInformation(IProjectContent content, string fileName) |
||||
{ |
||||
projectContentPassedToGetExistingParseInfoMethod = content; |
||||
|
||||
ParseInformation parseInfo; |
||||
if (parseInfoDictionary.TryGetValue(fileName, out parseInfo)) { |
||||
return parseInfo; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public void SetExistingParseInformation(string fileName, ParseInformation parseInfo) |
||||
{ |
||||
parseInfoDictionary.Add(fileName, parseInfo); |
||||
} |
||||
|
||||
public IProjectContent ProjectContentPassedToGetExistingParseInforMethod { |
||||
get { return projectContentPassedToGetExistingParseInfoMethod; } |
||||
} |
||||
} |
||||
} |
@ -1,74 +0,0 @@
@@ -1,74 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace XmlEditor.Tests.Utils |
||||
{ |
||||
public class MockTextBuffer : ITextBuffer |
||||
{ |
||||
string text = String.Empty; |
||||
|
||||
public MockTextBuffer(string text) |
||||
{ |
||||
this.text = text; |
||||
} |
||||
|
||||
public event EventHandler TextChanged; |
||||
|
||||
protected virtual void OnTextChanged(EventArgs e) |
||||
{ |
||||
if (TextChanged != null) { |
||||
TextChanged(this, e); |
||||
} |
||||
} |
||||
|
||||
public ITextBufferVersion Version { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public int TextLength { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public string Text { |
||||
get { return text; } |
||||
} |
||||
|
||||
public ITextBuffer CreateSnapshot() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ITextBuffer CreateSnapshot(int offset, int length) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public TextReader CreateReader() |
||||
{ |
||||
return new StringReader(text); |
||||
} |
||||
|
||||
public TextReader CreateReader(int offset, int length) |
||||
{ |
||||
return new StringReader(text); |
||||
} |
||||
|
||||
public char GetCharAt(int offset) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public string GetText(int offset, int length) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.NRefactory; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Utils.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MockCaretTests |
||||
{ |
||||
MockCaret caret; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
caret = new MockCaret(); |
||||
} |
||||
|
||||
[Test] |
||||
public void CanSetAndGetCaretOffset() |
||||
{ |
||||
caret.Offset = 3; |
||||
Assert.AreEqual(3, caret.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void InitialCaretOffsetIsMinusOne() |
||||
{ |
||||
Assert.AreEqual(-1, caret.Offset); |
||||
} |
||||
|
||||
[Test] |
||||
public void CanGetAndSetCaretPosition() |
||||
{ |
||||
Location location = new Location(3, 2); |
||||
caret.Position = location; |
||||
Assert.AreEqual(location, caret.Position); |
||||
} |
||||
|
||||
[Test] |
||||
public void DefaultCaretPostionIsEmpty() |
||||
{ |
||||
Assert.AreEqual(Location.Empty, caret.Position); |
||||
} |
||||
} |
||||
} |
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Utils.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MockDocumentLineTests |
||||
{ |
||||
MockDocumentLine documentLine; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
documentLine = new MockDocumentLine(); |
||||
} |
||||
|
||||
[Test] |
||||
public void CanSetAndGetLineNumberProperty() |
||||
{ |
||||
documentLine.LineNumber = 2; |
||||
Assert.AreEqual(2, documentLine.LineNumber); |
||||
} |
||||
} |
||||
} |
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.XmlEditor; |
||||
using NUnit.Framework; |
||||
|
||||
namespace XmlEditor.Tests.Utils.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MockParserServiceTests |
||||
{ |
||||
MockParserService parserService; |
||||
ParseInformation existingParseInfo; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
|
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
DefaultCompilationUnit unit = new DefaultCompilationUnit(projectContent); |
||||
existingParseInfo = new ParseInformation(unit); |
||||
|
||||
parserService = new MockParserService(); |
||||
parserService.SetExistingParseInformation(@"d:\projects\test.xml", existingParseInfo); |
||||
} |
||||
|
||||
[Test] |
||||
public void CanGetProjectContentPassedToGetExistingParseInfoMethod() |
||||
{ |
||||
DefaultProjectContent projectContent = new DefaultProjectContent(); |
||||
parserService.GetExistingParseInformation(projectContent, "file.xml"); |
||||
Assert.AreSame(projectContent, parserService.ProjectContentPassedToGetExistingParseInforMethod); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetExistingParseInfoReturnsParseInfoObjectForKnownFileName() |
||||
{ |
||||
Assert.AreSame(existingParseInfo, parserService.GetExistingParseInformation(null, @"d:\projects\test.xml")); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetExistingParseInfoReturnsNullForKnownFileName() |
||||
{ |
||||
Assert.IsNull(parserService.GetExistingParseInformation(null, @"d:\projects\unknown.xml")); |
||||
} |
||||
} |
||||
} |
@ -1 +1,2 @@
@@ -1 +1,2 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" /> |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" /> |
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui |
||||
{ |
||||
public delegate void ViewContentEventHandler(object sender, ViewContentEventArgs e); |
||||
|
||||
public class ViewContentEventArgs : EventArgs |
||||
{ |
||||
IViewContent content; |
||||
|
||||
public IViewContent Content { |
||||
get { |
||||
return content; |
||||
} |
||||
} |
||||
|
||||
public ViewContentEventArgs(IViewContent content) |
||||
{ |
||||
if (content == null) |
||||
throw new ArgumentNullException("content"); |
||||
this.content = content; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<configuration> |
||||
<startup> |
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> |
||||
</startup> |
||||
</configuration> |
Binary file not shown.
@ -1,60 +1,67 @@
@@ -1,60 +1,67 @@
|
||||
#warning
|
||||
//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
//
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.ComponentModel.Design;
|
||||
//
|
||||
//using ICSharpCode.SharpDevelop.Editor;
|
||||
//using ICSharpCode.SharpDevelop.Editor.AvalonEdit;
|
||||
//
|
||||
//namespace ICSharpCode.SharpDevelop.Tests.Utils
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Description of MockTextEditor.
|
||||
// /// </summary>
|
||||
// public class MockTextMarkerService : ITextMarkerService
|
||||
// {
|
||||
// public static IDocument CreateDocumentWithMockService()
|
||||
// {
|
||||
// ServiceContainer container = new ServiceContainer();
|
||||
// container.AddService(typeof(ITextMarkerService), new MockTextMarkerService());
|
||||
//
|
||||
// return new AvalonEditDocumentAdapter(new ICSharpCode.AvalonEdit.Document.TextDocument(), container);
|
||||
// }
|
||||
//
|
||||
// List<ITextMarker> markers;
|
||||
//
|
||||
// public MockTextMarkerService()
|
||||
// {
|
||||
// this.markers = new List<ITextMarker>();
|
||||
// }
|
||||
//
|
||||
// public System.Collections.Generic.IEnumerable<ITextMarker> TextMarkers {
|
||||
// get {
|
||||
// return this.markers;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public ITextMarker Create(int startOffset, int length)
|
||||
// {
|
||||
// ITextMarker m = new MockTextMarker(this.markers, startOffset, startOffset + length, length);
|
||||
// this.markers.Add(m);
|
||||
// return m;
|
||||
// }
|
||||
//
|
||||
// public void Remove(ITextMarker marker)
|
||||
// {
|
||||
// marker.Delete();
|
||||
// }
|
||||
//
|
||||
// public void RemoveAll(Predicate<ITextMarker> predicate)
|
||||
// {
|
||||
// foreach (ITextMarker m in markers.ToArray()) {
|
||||
// if (predicate(m))
|
||||
// m.Delete();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel.Design; |
||||
using System.Linq; |
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.NRefactory.Editor; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Editor.AvalonEdit; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Tests.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// Description of MockTextEditor.
|
||||
/// </summary>
|
||||
public class MockTextMarkerService : ITextMarkerService |
||||
{ |
||||
public static IDocument CreateDocumentWithMockService() |
||||
{ |
||||
var document = new TextDocument(); |
||||
var container = (IServiceContainer)document.ServiceProvider.GetService(typeof(IServiceContainer)); |
||||
container.AddService(typeof(ITextMarkerService), new MockTextMarkerService()); |
||||
|
||||
return document; |
||||
} |
||||
|
||||
List<ITextMarker> markers; |
||||
|
||||
public MockTextMarkerService() |
||||
{ |
||||
this.markers = new List<ITextMarker>(); |
||||
} |
||||
|
||||
public System.Collections.Generic.IEnumerable<ITextMarker> TextMarkers { |
||||
get { |
||||
return this.markers; |
||||
} |
||||
} |
||||
|
||||
public ITextMarker Create(int startOffset, int length) |
||||
{ |
||||
ITextMarker m = new MockTextMarker(this.markers, startOffset, startOffset + length, length); |
||||
this.markers.Add(m); |
||||
return m; |
||||
} |
||||
|
||||
public void Remove(ITextMarker marker) |
||||
{ |
||||
marker.Delete(); |
||||
} |
||||
|
||||
public void RemoveAll(Predicate<ITextMarker> predicate) |
||||
{ |
||||
foreach (ITextMarker m in markers.ToArray()) { |
||||
if (predicate(m)) |
||||
m.Delete(); |
||||
} |
||||
} |
||||
|
||||
public IEnumerable<ITextMarker> GetMarkersAtOffset(int offset) |
||||
{ |
||||
return markers.Where(m => m.StartOffset <= offset && offset <= m.EndOffset); |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.ComponentModel.Design; |
||||
|
||||
namespace ICSharpCode.Core |
||||
{ |
||||
/// <summary>
|
||||
/// Registers a service in a service container.
|
||||
/// </summary>
|
||||
/// <attribute name="id" use="required">
|
||||
/// The service interface type.
|
||||
/// </attribute>
|
||||
/// <attribute name="class" use="required">
|
||||
/// The implementing service class name.
|
||||
/// </attribute>
|
||||
/// <usage>Only in /SharpDevelop/Services</usage>
|
||||
/// <returns>
|
||||
/// <c>null</c>. The service is registered, but not returned.
|
||||
/// </returns>
|
||||
public class ServiceDoozer : IDoozer |
||||
{ |
||||
public bool HandleConditions { |
||||
get { return false; } |
||||
} |
||||
|
||||
public object BuildItem(BuildItemArgs args) |
||||
{ |
||||
var container = (IServiceContainer)args.Caller; |
||||
if (container == null) |
||||
throw new InvalidOperationException("Expected the owner to be a service container"); |
||||
Type interfaceType = args.AddIn.FindType(args.Codon.Id); |
||||
if (interfaceType != null) { |
||||
string className = args.Codon.Properties["class"]; |
||||
// Use ServiceCreatorCallback to lazily create the service
|
||||
container.AddService( |
||||
interfaceType, delegate { |
||||
return args.AddIn.CreateObject(className); |
||||
}); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Security.Permissions; |
||||
|
||||
[assembly: CLSCompliant(true)] |
||||
[assembly: StringFreezing()] |
||||
|
||||
[assembly: Dependency("System.Core", LoadHint.Always)] |
||||
|
||||
[assembly: AssemblyTitle("ICSharpCode.SharpDevelop.Dom")] |
||||
[assembly: AssemblyDescription("Code-completion library")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
@ -1,216 +0,0 @@
@@ -1,216 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.SharpDevelop.Dom</RootNamespace> |
||||
<AssemblyName>ICSharpCode.SharpDevelop.Dom</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</ProjectGuid> |
||||
<SignAssembly>True</SignAssembly> |
||||
<AssemblyOriginatorKeyFile>..\..\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile> |
||||
<DelaySign>False</DelaySign> |
||||
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode> |
||||
<OutputPath>..\..\..\..\bin\</OutputPath> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>132644864</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<RunCodeAnalysis>False</RunCodeAnalysis> |
||||
<CodeAnalysisRules>-Microsoft.Design#CA1002;-Microsoft.Design#CA1063;-Microsoft.Performance#CA1800;-Microsoft.Security#CA2104</CodeAnalysisRules> |
||||
<TargetFrameworkProfile> |
||||
</TargetFrameworkProfile> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<IntermediateOutputPath>obj\Release\</IntermediateOutputPath> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="log4net"> |
||||
<HintPath>..\..\..\Libraries\log4net\log4net.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="..\..\Core\Project\Src\Services\FileUtility\FileUtility.Minimal.cs"> |
||||
<Link>Src\ProjectContent\FileUtility.Minimal.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="..\..\GlobalAssemblyInfo.cs"> |
||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Src\BusyManager.cs" /> |
||||
<Compile Include="Src\CSharp\CSharpExpressionContext.cs" /> |
||||
<Compile Include="Src\CSharp\OverloadResolution.cs" /> |
||||
<Compile Include="Src\CSharp\TypeInference.cs" /> |
||||
<Compile Include="Src\DomCache.cs" /> |
||||
<Compile Include="Src\ExtensionMethods.cs" /> |
||||
<Compile Include="Src\Implementations\AbstractEntity.cs" /> |
||||
<Compile Include="Src\Implementations\AbstractMember.cs" /> |
||||
<Compile Include="Src\Implementations\AbstractReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\AnonymousMethodReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\ArrayReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\AttributeReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\BoundTypeParameter.cs" /> |
||||
<Compile Include="Src\Implementations\CombinedReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\CompoundClass.cs" /> |
||||
<Compile Include="Src\Implementations\ConstructedReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\DecoratingReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultAttribute.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultClass.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultComment.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultCompilationUnit.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultEvent.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultField.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultMethod.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultParameter.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultProperty.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultTypeParameter.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultUsing.cs" /> |
||||
<Compile Include="Src\Implementations\DefaultUsingScope.cs" /> |
||||
<Compile Include="Src\Implementations\DynamicReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\ElementReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\GenericReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\GetClassReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\MethodGroupReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\NullReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\PointerReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\ProxyReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\ReferenceReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\SearchClassReturnType.cs" /> |
||||
<Compile Include="Src\Implementations\SystemTypes.cs" /> |
||||
<Compile Include="Src\Implementations\UnknownReturnType.cs" /> |
||||
<Compile Include="Src\Interfaces\ExplicitInterfaceImplementation.cs" /> |
||||
<Compile Include="Src\Interfaces\ICompletionEntry.cs" /> |
||||
<Compile Include="Src\Interfaces\IDomProgressMonitor.cs" /> |
||||
<Compile Include="Src\Interfaces\IFreezable.cs" /> |
||||
<Compile Include="Src\Interfaces\IUsingScope.cs" /> |
||||
<Compile Include="Src\LazyList.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\CodeSnippetConverter.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\CSharpToVBNetConvertVisitor.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\InferredReturnType.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\LambdaParameterReturnType.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\LambdaReturnType.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\NRefactoryASTConvertVisitor.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\NRefactoryInformationProvider.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\NRefactoryResolver.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\ResolveVisitor.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\TypeVisitor.cs" /> |
||||
<Compile Include="Src\NRefactoryResolver\VBNetToCSharpConvertVisitor.cs" /> |
||||
<Compile Include="Src\ParameterListComparer.cs" /> |
||||
<Compile Include="Src\ProjectContent\DomAssemblyName.cs" /> |
||||
<Compile Include="Src\ReadOnlyDictionary.cs" /> |
||||
<Compile Include="Src\Refactoring\CodeGeneratorOptions.cs" /> |
||||
<Compile Include="Src\Refactoring\CSharpCodeGenerator.cs" /> |
||||
<Compile Include="Src\Refactoring\TextFinder.cs" /> |
||||
<Compile Include="Src\Refactoring\VBNetCodeGenerator.cs" /> |
||||
<Compile Include="Src\ReflectionLayer\DomPersistence.cs" /> |
||||
<Compile Include="Src\ReflectionLayer\ReflectionClass.cs" /> |
||||
<Compile Include="Src\ReflectionLayer\ReflectionEvent.cs" /> |
||||
<Compile Include="Src\ReflectionLayer\ReflectionField.cs" /> |
||||
<Compile Include="Src\ReflectionLayer\ReflectionMethod.cs" /> |
||||
<Compile Include="Src\ReflectionLayer\ReflectionParameter.cs" /> |
||||
<Compile Include="Src\ReflectionLayer\ReflectionProperty.cs" /> |
||||
<Compile Include="Src\ReflectionLayer\ReflectionReturnType.cs" /> |
||||
<Compile Include="Src\CecilReader.cs" /> |
||||
<Compile Include="Src\ExpressionContext.cs" /> |
||||
<Compile Include="Src\FilePosition.cs" /> |
||||
<Compile Include="Src\FoldingRegion.cs" /> |
||||
<Compile Include="Src\IComment.cs" /> |
||||
<Compile Include="Src\ReflectionLayer\ReflectionTypeNameSyntaxError.cs" /> |
||||
<Compile Include="Src\SignatureComparer.cs" /> |
||||
<Compile Include="Src\VBNet\IVBNetOptionProvider.cs" /> |
||||
<Compile Include="Src\VBNet\VBNetCompilationUnit.cs" /> |
||||
<Compile Include="Src\VBNet\VBNetExpressionFinder.cs" /> |
||||
<Compile Include="Src\XmlDoc.cs" /> |
||||
<Compile Include="Src\Tag.cs" /> |
||||
<Compile Include="Src\ResolveResult.cs" /> |
||||
<Compile Include="Src\MemberLookupHelper.cs" /> |
||||
<Compile Include="Src\LanguageProperties.cs" /> |
||||
<Compile Include="Src\IResolver.cs" /> |
||||
<Compile Include="Src\IExpressionFinder.cs" /> |
||||
<Compile Include="Src\Interfaces\ClassType.cs" /> |
||||
<Compile Include="Src\Interfaces\IAttribute.cs" /> |
||||
<Compile Include="Src\Interfaces\IClass.cs" /> |
||||
<Compile Include="Src\Interfaces\ICompilationUnit.cs" /> |
||||
<Compile Include="Src\Interfaces\IEntity.cs" /> |
||||
<Compile Include="Src\Interfaces\IEvent.cs" /> |
||||
<Compile Include="Src\Interfaces\IField.cs" /> |
||||
<Compile Include="Src\Interfaces\IMember.cs" /> |
||||
<Compile Include="Src\Interfaces\IMethod.cs" /> |
||||
<Compile Include="Src\Interfaces\IParameter.cs" /> |
||||
<Compile Include="Src\Interfaces\IProperty.cs" /> |
||||
<Compile Include="Src\Interfaces\IReturnType.cs" /> |
||||
<Compile Include="Src\Interfaces\IUsing.cs" /> |
||||
<Compile Include="Src\Interfaces\ModifierEnum.cs" /> |
||||
<Compile Include="Src\Interfaces\ParameterModifiers.cs" /> |
||||
<Compile Include="Src\Interfaces\Region.cs" /> |
||||
<Compile Include="Src\Interfaces\ITypeParameter.cs" /> |
||||
<Compile Include="Src\ProjectContent\DefaultProjectContent.cs" /> |
||||
<Compile Include="Src\ProjectContent\IProjectContent.cs" /> |
||||
<Compile Include="Src\ProjectContent\ReflectionProjectContent.cs" /> |
||||
<Compile Include="Src\LoggingService.cs" /> |
||||
<Compile Include="Src\ProjectContent\ProjectContentRegistry.cs" /> |
||||
<Compile Include="Src\FusionNative.cs" /> |
||||
<Compile Include="Src\DiffUtility.cs" /> |
||||
<Compile Include="Src\ProjectContent\ParseInformation.cs" /> |
||||
<Compile Include="Src\HostCallback.cs" /> |
||||
<Compile Include="Src\Refactoring\CodeGenerator.cs" /> |
||||
<Compile Include="Src\Refactoring\IRefactoringDocument.cs" /> |
||||
<Compile Include="Src\ClassFinder.cs" /> |
||||
<Compile Include="Src\Refactoring\NRefactoryCodeGenerator.cs" /> |
||||
<Compile Include="Src\Refactoring\RefactoringProvider.cs" /> |
||||
<Compile Include="Src\Refactoring\NRefactoryRefactoringProvider.cs" /> |
||||
<Compile Include="Src\GacInterop.cs" /> |
||||
<Compile Include="Src\CtrlSpaceResolveHelper.cs" /> |
||||
<Compile Include="Src\CSharp\CSharpAmbience.cs" /> |
||||
<Compile Include="Src\Ambience.cs" /> |
||||
<Compile Include="Src\CSharp\ExpressionFinder.cs" /> |
||||
<Compile Include="Src\VBNet\VBNetAmbience.cs" /> |
||||
<Compile Include="Src\EasyCodeDom.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Configuration" /> |
||||
<Folder Include="Src" /> |
||||
<ProjectReference Include="..\..\..\Libraries\Mono.Cecil\Mono.Cecil.csproj"> |
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project> |
||||
<Name>Mono.Cecil</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Libraries\NRefactory\Project\NRefactory.csproj"> |
||||
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project> |
||||
<Name>NRefactory</Name> |
||||
</ProjectReference> |
||||
<Folder Include="Src\Implementations" /> |
||||
<Folder Include="Src\NRefactoryResolver" /> |
||||
<Folder Include="Src\ReflectionLayer" /> |
||||
<Folder Include="Src\Interfaces" /> |
||||
<Folder Include="Src\ProjectContent" /> |
||||
<Folder Include="Src\Refactoring" /> |
||||
<Folder Include="Src\CSharp" /> |
||||
<Folder Include="Src\VBNet" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -1,242 +0,0 @@
@@ -1,242 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
[Flags] |
||||
public enum ConversionFlags |
||||
{ |
||||
/// <summary>
|
||||
/// Convert only the name.
|
||||
/// </summary>
|
||||
None = 0, |
||||
/// <summary>
|
||||
/// Show the parameter list
|
||||
/// </summary>
|
||||
ShowParameterList = 1, |
||||
/// <summary>
|
||||
/// Show names for parameters
|
||||
/// </summary>
|
||||
ShowParameterNames = 2, |
||||
/// <summary>
|
||||
/// Show the accessibility (private, public, etc.)
|
||||
/// </summary>
|
||||
ShowAccessibility = 4, |
||||
/// <summary>
|
||||
/// Show the definition key word (class, struct, Sub, Function, etc.)
|
||||
/// </summary>
|
||||
ShowDefinitionKeyWord = 8, |
||||
/// <summary>
|
||||
/// Show the fully qualified name for the member
|
||||
/// </summary>
|
||||
UseFullyQualifiedMemberNames = 0x10, |
||||
/// <summary>
|
||||
/// Show modifiers (virtual, override, etc.)
|
||||
/// </summary>
|
||||
ShowModifiers = 0x20, |
||||
/// <summary>
|
||||
/// Show the inheritance declaration
|
||||
/// </summary>
|
||||
ShowInheritanceList = 0x40, |
||||
|
||||
IncludeHtmlMarkup = 0x80, |
||||
/// <summary>
|
||||
/// Show the return type
|
||||
/// </summary>
|
||||
ShowReturnType = 0x100, |
||||
/// <summary>
|
||||
/// Use fully qualified names for return type and parameters.
|
||||
/// </summary>
|
||||
UseFullyQualifiedTypeNames = 0x200, |
||||
/// <summary>
|
||||
/// Include opening brace (or equivalent) for methods or classes;
|
||||
/// or semicolon (or equivalent) for field, events.
|
||||
/// For properties, a block indicating if there is a getter/setter is included.
|
||||
/// </summary>
|
||||
IncludeBody = 0x400, |
||||
/// <summary>
|
||||
/// Show the list of type parameters on method and class declarations.
|
||||
/// Type arguments for parameter/return types are always shown.
|
||||
/// </summary>
|
||||
ShowTypeParameterList = 0x800, |
||||
|
||||
StandardConversionFlags = ShowParameterNames | |
||||
ShowAccessibility | |
||||
ShowParameterList | |
||||
ShowReturnType | |
||||
ShowModifiers | |
||||
ShowTypeParameterList | |
||||
ShowDefinitionKeyWord, |
||||
|
||||
All = 0xfff, |
||||
} |
||||
|
||||
public interface IAmbience |
||||
{ |
||||
ConversionFlags ConversionFlags { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
string Convert(IClass c); |
||||
string ConvertEnd(IClass c); |
||||
|
||||
string Convert(IEntity e); |
||||
|
||||
string Convert(IField field); |
||||
string Convert(IProperty property); |
||||
string Convert(IEvent e); |
||||
|
||||
string Convert(IMethod m); |
||||
string ConvertEnd(IMethod m); |
||||
|
||||
string Convert(IParameter param); |
||||
string Convert(IReturnType returnType); |
||||
|
||||
string ConvertAccessibility(ModifierEnum accessibility); |
||||
|
||||
string WrapAttribute(string attribute); |
||||
string WrapComment(string comment); |
||||
|
||||
string GetIntrinsicTypeName(string dotNetTypeName); |
||||
} |
||||
|
||||
public abstract class AbstractAmbience : IAmbience |
||||
{ |
||||
#if DEBUG
|
||||
int ownerThread = System.Threading.Thread.CurrentThread.ManagedThreadId; |
||||
#endif
|
||||
|
||||
[System.Diagnostics.Conditional("DEBUG")] |
||||
protected void CheckThread() |
||||
{ |
||||
#if DEBUG
|
||||
if (ownerThread != System.Threading.Thread.CurrentThread.ManagedThreadId) |
||||
throw new InvalidOperationException("Ambience may only be used by the thread that created it"); |
||||
#endif
|
||||
} |
||||
|
||||
ConversionFlags conversionFlags = ConversionFlags.StandardConversionFlags; |
||||
|
||||
public ConversionFlags ConversionFlags { |
||||
get { |
||||
return conversionFlags; |
||||
} |
||||
set { |
||||
CheckThread(); |
||||
conversionFlags = value; |
||||
} |
||||
} |
||||
|
||||
public bool ShowReturnType { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType; |
||||
} |
||||
} |
||||
|
||||
public bool ShowAccessibility { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.ShowAccessibility) == ConversionFlags.ShowAccessibility; |
||||
} |
||||
} |
||||
|
||||
public bool ShowParameterNames { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.ShowParameterNames) == ConversionFlags.ShowParameterNames; |
||||
} |
||||
} |
||||
|
||||
public bool UseFullyQualifiedTypeNames { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.UseFullyQualifiedTypeNames) == ConversionFlags.UseFullyQualifiedTypeNames; |
||||
} |
||||
} |
||||
|
||||
public bool ShowDefinitionKeyWord { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.ShowDefinitionKeyWord) == ConversionFlags.ShowDefinitionKeyWord; |
||||
} |
||||
} |
||||
|
||||
public bool ShowParameterList { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.ShowParameterList) == ConversionFlags.ShowParameterList; |
||||
} |
||||
} |
||||
|
||||
public bool ShowModifiers { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.ShowModifiers) == ConversionFlags.ShowModifiers; |
||||
} |
||||
} |
||||
|
||||
public bool ShowInheritanceList { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.ShowInheritanceList) == ConversionFlags.ShowInheritanceList; |
||||
} |
||||
} |
||||
|
||||
public bool IncludeHtmlMarkup { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.IncludeHtmlMarkup) == ConversionFlags.IncludeHtmlMarkup; |
||||
} |
||||
} |
||||
|
||||
public bool UseFullyQualifiedMemberNames { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.UseFullyQualifiedMemberNames) == ConversionFlags.UseFullyQualifiedMemberNames; |
||||
} |
||||
} |
||||
|
||||
public bool IncludeBody { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.IncludeBody) == ConversionFlags.IncludeBody; |
||||
} |
||||
} |
||||
|
||||
public bool ShowTypeParameterList { |
||||
get { |
||||
return (conversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList; |
||||
} |
||||
} |
||||
|
||||
public abstract string Convert(IClass c); |
||||
public abstract string ConvertEnd(IClass c); |
||||
public abstract string Convert(IField c); |
||||
public abstract string Convert(IProperty property); |
||||
public abstract string Convert(IEvent e); |
||||
public abstract string Convert(IMethod m); |
||||
public abstract string ConvertEnd(IMethod m); |
||||
public abstract string Convert(IParameter param); |
||||
public abstract string Convert(IReturnType returnType); |
||||
|
||||
public virtual string Convert(IEntity entity) |
||||
{ |
||||
if (entity == null) |
||||
throw new ArgumentNullException("entity"); |
||||
IClass c = entity as IClass; |
||||
if (c != null) |
||||
return Convert(c); |
||||
IMethod m = entity as IMethod; |
||||
if (m != null) |
||||
return Convert(m); |
||||
IField f = entity as IField; |
||||
if (f != null) |
||||
return Convert(f); |
||||
IProperty p = entity as IProperty; |
||||
if (p != null) |
||||
return Convert(p); |
||||
IEvent e = entity as IEvent; |
||||
if (e != null) |
||||
return Convert(e); |
||||
return entity.ToString(); |
||||
} |
||||
|
||||
public abstract string WrapAttribute(string attribute); |
||||
public abstract string WrapComment(string comment); |
||||
public abstract string GetIntrinsicTypeName(string dotNetTypeName); |
||||
public abstract string ConvertAccessibility(ModifierEnum accessibility); |
||||
} |
||||
} |
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// This class is used to prevent stack overflows by representing a 'busy' flag
|
||||
/// that prevents reentrance when another call is running.
|
||||
/// However, using a simple 'bool busy' is not thread-safe, so we use a
|
||||
/// thread-static BusyManager.
|
||||
/// </summary>
|
||||
sealed class BusyManager |
||||
{ |
||||
public struct BusyLock : IDisposable |
||||
{ |
||||
public static readonly BusyLock Failed = new BusyLock(null); |
||||
|
||||
readonly BusyManager manager; |
||||
|
||||
public BusyLock(BusyManager manager) |
||||
{ |
||||
this.manager = manager; |
||||
} |
||||
|
||||
public bool Success { |
||||
get { return manager != null; } |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
if (manager != null) { |
||||
manager.activeObjects.RemoveAt(manager.activeObjects.Count - 1); |
||||
} |
||||
} |
||||
} |
||||
|
||||
readonly List<object> activeObjects = new List<object>(); |
||||
|
||||
public BusyLock Enter(object obj) |
||||
{ |
||||
for (int i = 0; i < activeObjects.Count; i++) { |
||||
if (activeObjects[i] == obj) |
||||
return BusyLock.Failed; |
||||
} |
||||
activeObjects.Add(obj); |
||||
return new BusyLock(this); |
||||
} |
||||
} |
||||
} |
@ -1,606 +0,0 @@
@@ -1,606 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom.CSharp |
||||
{ |
||||
public class CSharpAmbience : AbstractAmbience |
||||
{ |
||||
public static IDictionary<string, string> TypeConversionTable { |
||||
get { return ICSharpCode.NRefactory.Ast.TypeReference.PrimitiveTypesCSharpReverse; } |
||||
} |
||||
|
||||
bool ModifierIsSet(ModifierEnum modifier, ModifierEnum query) |
||||
{ |
||||
return (modifier & query) == query; |
||||
} |
||||
|
||||
public override string ConvertAccessibility(ModifierEnum accessibility) |
||||
{ |
||||
if (ShowAccessibility) { |
||||
if (ModifierIsSet(accessibility, ModifierEnum.Public)) { |
||||
return "public "; |
||||
} else if (ModifierIsSet(accessibility, ModifierEnum.Private)) { |
||||
return "private "; |
||||
} else if (ModifierIsSet(accessibility, ModifierEnum.ProtectedAndInternal)) { |
||||
return "protected internal "; |
||||
} else if (ModifierIsSet(accessibility, ModifierEnum.Internal)) { |
||||
return "internal "; |
||||
} else if (ModifierIsSet(accessibility, ModifierEnum.Protected)) { |
||||
return "protected "; |
||||
} |
||||
} |
||||
|
||||
return string.Empty; |
||||
} |
||||
|
||||
string GetModifier(IEntity decoration) |
||||
{ |
||||
string ret = ""; |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
ret += "<i>"; |
||||
} |
||||
|
||||
if (decoration.IsStatic) { |
||||
ret += "static "; |
||||
} else if (decoration.IsSealed) { |
||||
ret += "sealed "; |
||||
} else if (decoration.IsVirtual) { |
||||
ret += "virtual "; |
||||
} else if (decoration.IsOverride) { |
||||
ret += "override "; |
||||
} else if (decoration.IsNew) { |
||||
ret += "new "; |
||||
} |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
ret += "</i>"; |
||||
} |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
public override string Convert(IClass c) |
||||
{ |
||||
CheckThread(); |
||||
|
||||
StringBuilder builder = new StringBuilder(); |
||||
|
||||
builder.Append(ConvertAccessibility(c.Modifiers)); |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("<i>"); |
||||
} |
||||
|
||||
if (ShowModifiers) { |
||||
if (c.IsStatic) { |
||||
builder.Append("static "); |
||||
} else if (c.IsSealed) { |
||||
switch (c.ClassType) { |
||||
case ClassType.Delegate: |
||||
case ClassType.Struct: |
||||
case ClassType.Enum: |
||||
break; |
||||
|
||||
default: |
||||
builder.Append("sealed "); |
||||
break; |
||||
} |
||||
} else if (c.IsAbstract && c.ClassType != ClassType.Interface) { |
||||
builder.Append("abstract "); |
||||
} |
||||
#if DEBUG
|
||||
if (c.HasCompoundClass) |
||||
builder.Append("multiple_parts "); |
||||
if (c is CompoundClass) { |
||||
builder.Append("compound{"); |
||||
builder.Append(string.Join(",", (c as CompoundClass).Parts.Select(p => p.CompilationUnit.FileName).ToArray())); |
||||
builder.Append("} "); |
||||
} |
||||
#endif
|
||||
} |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("</i>"); |
||||
} |
||||
|
||||
if (ShowDefinitionKeyWord) { |
||||
switch (c.ClassType) { |
||||
case ClassType.Delegate: |
||||
builder.Append("delegate"); |
||||
break; |
||||
case ClassType.Class: |
||||
case ClassType.Module: |
||||
builder.Append("class"); |
||||
break; |
||||
case ClassType.Struct: |
||||
builder.Append("struct"); |
||||
break; |
||||
case ClassType.Interface: |
||||
builder.Append("interface"); |
||||
break; |
||||
case ClassType.Enum: |
||||
builder.Append("enum"); |
||||
break; |
||||
} |
||||
builder.Append(' '); |
||||
} |
||||
if (ShowReturnType && c.ClassType == ClassType.Delegate) { |
||||
foreach(IMethod m in c.Methods) { |
||||
if (m.Name != "Invoke") continue; |
||||
|
||||
builder.Append(Convert(m.ReturnType)); |
||||
builder.Append(' '); |
||||
} |
||||
} |
||||
|
||||
AppendClassNameWithTypeParameters(builder, c, UseFullyQualifiedMemberNames, true, null); |
||||
|
||||
if (ShowParameterList && c.ClassType == ClassType.Delegate) { |
||||
builder.Append(" ("); |
||||
if (IncludeHtmlMarkup) builder.Append("<br>"); |
||||
|
||||
foreach(IMethod m in c.Methods) { |
||||
if (m.Name != "Invoke") continue; |
||||
|
||||
for (int i = 0; i < m.Parameters.Count; ++i) { |
||||
if (IncludeHtmlMarkup) builder.Append(" "); |
||||
|
||||
builder.Append(Convert(m.Parameters[i])); |
||||
if (i + 1 < m.Parameters.Count) builder.Append(", "); |
||||
|
||||
if (IncludeHtmlMarkup) builder.Append("<br>"); |
||||
} |
||||
} |
||||
builder.Append(')'); |
||||
|
||||
} else if (ShowInheritanceList) { |
||||
if (c.BaseTypes.Count > 0) { |
||||
builder.Append(" : "); |
||||
for (int i = 0; i < c.BaseTypes.Count; ++i) { |
||||
builder.Append(c.BaseTypes[i]); |
||||
if (i + 1 < c.BaseTypes.Count) { |
||||
builder.Append(", "); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (IncludeBody) { |
||||
builder.Append("\n{"); |
||||
} |
||||
|
||||
return builder.ToString(); |
||||
} |
||||
|
||||
void AppendClassNameWithTypeParameters(StringBuilder builder, IClass c, bool fullyQualified, bool isConvertingClassName, IList<IReturnType> typeArguments) |
||||
{ |
||||
if (isConvertingClassName && IncludeHtmlMarkup) { |
||||
builder.Append("<b>"); |
||||
} |
||||
if (fullyQualified) { |
||||
if (c.DeclaringType != null) { |
||||
AppendClassNameWithTypeParameters(builder, c.DeclaringType, fullyQualified, false, typeArguments); |
||||
builder.Append('.'); |
||||
builder.Append(c.Name); |
||||
} else { |
||||
builder.Append(c.FullyQualifiedName); |
||||
} |
||||
} else { |
||||
builder.Append(c.Name); |
||||
} |
||||
if (isConvertingClassName && IncludeHtmlMarkup) { |
||||
builder.Append("</b>"); |
||||
} |
||||
// skip type parameters that belong to declaring types (in DOM, inner classes repeat type parameters from outer classes)
|
||||
int skippedTypeParameterCount = c.DeclaringType != null ? c.DeclaringType.TypeParameters.Count : 0; |
||||
// show type parameters for classes only if ShowTypeParameterList is set; but always show them in other cases.
|
||||
if ((ShowTypeParameterList || !isConvertingClassName) && c.TypeParameters.Count > skippedTypeParameterCount) { |
||||
builder.Append('<'); |
||||
for (int i = skippedTypeParameterCount; i < c.TypeParameters.Count; ++i) { |
||||
if (i > skippedTypeParameterCount) |
||||
builder.Append(", "); |
||||
if (typeArguments != null && i < typeArguments.Count) |
||||
AppendReturnType(builder, typeArguments[i], false); |
||||
else |
||||
builder.Append(ConvertTypeParameter(c.TypeParameters[i])); |
||||
} |
||||
builder.Append('>'); |
||||
} |
||||
} |
||||
|
||||
public override string ConvertEnd(IClass c) |
||||
{ |
||||
return "}"; |
||||
} |
||||
|
||||
public override string Convert(IField field) |
||||
{ |
||||
CheckThread(); |
||||
|
||||
StringBuilder builder = new StringBuilder(); |
||||
|
||||
builder.Append(ConvertAccessibility(field.Modifiers)); |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("<i>"); |
||||
} |
||||
|
||||
if (ShowModifiers) { |
||||
if (field.IsConst) { |
||||
builder.Append("const "); |
||||
} else if (field.IsStatic) { |
||||
builder.Append("static "); |
||||
} |
||||
|
||||
if (field.IsNew) { |
||||
builder.Append("new "); |
||||
} |
||||
if (field.IsReadonly) { |
||||
builder.Append("readonly "); |
||||
} |
||||
if ((field.Modifiers & ModifierEnum.Volatile) == ModifierEnum.Volatile) { |
||||
builder.Append("volatile "); |
||||
} |
||||
} |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("</i>"); |
||||
} |
||||
|
||||
if (field.ReturnType != null && ShowReturnType) { |
||||
builder.Append(Convert(field.ReturnType)); |
||||
builder.Append(' '); |
||||
} |
||||
|
||||
AppendTypeNameForFullyQualifiedMemberName(builder, field.DeclaringTypeReference); |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("<b>"); |
||||
} |
||||
|
||||
builder.Append(field.Name); |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("</b>"); |
||||
} |
||||
|
||||
if (IncludeBody) builder.Append(";"); |
||||
|
||||
return builder.ToString(); |
||||
} |
||||
|
||||
public override string Convert(IProperty property) |
||||
{ |
||||
CheckThread(); |
||||
|
||||
StringBuilder builder = new StringBuilder(); |
||||
|
||||
builder.Append(ConvertAccessibility(property.Modifiers)); |
||||
|
||||
if (ShowModifiers) { |
||||
builder.Append(GetModifier(property)); |
||||
} |
||||
|
||||
if (property.ReturnType != null && ShowReturnType) { |
||||
builder.Append(Convert(property.ReturnType)); |
||||
builder.Append(' '); |
||||
} |
||||
|
||||
AppendTypeNameForFullyQualifiedMemberName(builder, property.DeclaringTypeReference); |
||||
|
||||
if (property.IsIndexer) { |
||||
builder.Append("this"); |
||||
} else { |
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("<b>"); |
||||
} |
||||
builder.Append(property.Name); |
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("</b>"); |
||||
} |
||||
} |
||||
|
||||
if (property.Parameters.Count > 0 && ShowParameterList) { |
||||
builder.Append(property.IsIndexer ? '[' : '('); |
||||
if (IncludeHtmlMarkup) builder.Append("<br>"); |
||||
|
||||
for (int i = 0; i < property.Parameters.Count; ++i) { |
||||
if (IncludeHtmlMarkup) builder.Append(" "); |
||||
builder.Append(Convert(property.Parameters[i])); |
||||
if (i + 1 < property.Parameters.Count) { |
||||
builder.Append(", "); |
||||
} |
||||
if (IncludeHtmlMarkup) builder.Append("<br>"); |
||||
} |
||||
|
||||
builder.Append(property.IsIndexer ? ']' : ')'); |
||||
} |
||||
|
||||
if (IncludeBody) { |
||||
builder.Append(" { "); |
||||
|
||||
if (property.CanGet) { |
||||
builder.Append("get; "); |
||||
} |
||||
if (property.CanSet) { |
||||
builder.Append("set; "); |
||||
} |
||||
|
||||
builder.Append(" } "); |
||||
} |
||||
|
||||
return builder.ToString(); |
||||
} |
||||
|
||||
public override string Convert(IEvent e) |
||||
{ |
||||
CheckThread(); |
||||
|
||||
StringBuilder builder = new StringBuilder(); |
||||
|
||||
builder.Append(ConvertAccessibility(e.Modifiers)); |
||||
|
||||
if (ShowModifiers) { |
||||
builder.Append(GetModifier(e)); |
||||
} |
||||
|
||||
if (ShowDefinitionKeyWord) { |
||||
builder.Append("event "); |
||||
} |
||||
|
||||
if (e.ReturnType != null && ShowReturnType) { |
||||
builder.Append(Convert(e.ReturnType)); |
||||
builder.Append(' '); |
||||
} |
||||
|
||||
AppendTypeNameForFullyQualifiedMemberName(builder, e.DeclaringTypeReference); |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("<b>"); |
||||
} |
||||
|
||||
builder.Append(e.Name); |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("</b>"); |
||||
} |
||||
|
||||
if (IncludeBody) builder.Append(";"); |
||||
|
||||
return builder.ToString(); |
||||
} |
||||
|
||||
public override string Convert(IMethod m) |
||||
{ |
||||
CheckThread(); |
||||
|
||||
StringBuilder builder = new StringBuilder(); |
||||
builder.Append(ConvertAccessibility(m.Modifiers)); |
||||
|
||||
if (ShowModifiers) { |
||||
builder.Append(GetModifier(m)); |
||||
} |
||||
|
||||
if (!m.IsConstructor && m.ReturnType != null && ShowReturnType) { |
||||
builder.Append(Convert(m.ReturnType)); |
||||
builder.Append(' '); |
||||
} |
||||
|
||||
AppendTypeNameForFullyQualifiedMemberName(builder, m.DeclaringTypeReference); |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("<b>"); |
||||
} |
||||
|
||||
if (m.IsConstructor && m.DeclaringType != null) { |
||||
builder.Append(m.DeclaringType.Name); |
||||
} else { |
||||
builder.Append(m.Name); |
||||
} |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("</b>"); |
||||
} |
||||
|
||||
if (ShowTypeParameterList && m.TypeParameters.Count > 0) { |
||||
builder.Append('<'); |
||||
for (int i = 0; i < m.TypeParameters.Count; ++i) { |
||||
if (i > 0) builder.Append(", "); |
||||
builder.Append(ConvertTypeParameter(m.TypeParameters[i])); |
||||
} |
||||
builder.Append('>'); |
||||
} |
||||
|
||||
if (ShowParameterList) { |
||||
builder.Append("("); |
||||
if (IncludeHtmlMarkup) builder.Append("<br>"); |
||||
|
||||
if (m.IsExtensionMethod) builder.Append("this "); |
||||
|
||||
for (int i = 0; i < m.Parameters.Count; ++i) { |
||||
if (IncludeHtmlMarkup) builder.Append(" "); |
||||
builder.Append(Convert(m.Parameters[i])); |
||||
if (i + 1 < m.Parameters.Count) { |
||||
builder.Append(", "); |
||||
} |
||||
if (IncludeHtmlMarkup) builder.Append("<br>"); |
||||
} |
||||
|
||||
builder.Append(')'); |
||||
} |
||||
|
||||
if (IncludeBody) { |
||||
if (m.DeclaringType != null) { |
||||
if (m.DeclaringType.ClassType == ClassType.Interface) { |
||||
builder.Append(";"); |
||||
} else { |
||||
builder.Append(" {"); |
||||
} |
||||
} else { |
||||
builder.Append(" {"); |
||||
} |
||||
} |
||||
return builder.ToString(); |
||||
} |
||||
|
||||
void AppendTypeNameForFullyQualifiedMemberName(StringBuilder builder, IReturnType declaringType) |
||||
{ |
||||
if (UseFullyQualifiedMemberNames && declaringType != null) { |
||||
AppendReturnType(builder, declaringType, true); |
||||
builder.Append('.'); |
||||
} |
||||
} |
||||
|
||||
string ConvertTypeParameter(ITypeParameter tp) |
||||
{ |
||||
if (tp.BoundTo != null) |
||||
return Convert(tp.BoundTo); |
||||
else |
||||
return tp.Name; |
||||
} |
||||
|
||||
public override string ConvertEnd(IMethod m) |
||||
{ |
||||
return "}"; |
||||
} |
||||
|
||||
public override string Convert(IReturnType returnType) |
||||
{ |
||||
CheckThread(); |
||||
|
||||
if (returnType == null) { |
||||
return String.Empty; |
||||
} |
||||
|
||||
returnType = returnType.GetDirectReturnType(); |
||||
|
||||
StringBuilder builder = new StringBuilder(); |
||||
|
||||
AppendReturnType(builder, returnType, false); |
||||
|
||||
return builder.ToString(); |
||||
} |
||||
|
||||
void AppendReturnType(StringBuilder builder, IReturnType returnType, bool forceFullyQualifiedName) |
||||
{ |
||||
IReturnType arrayReturnType = returnType; |
||||
returnType = GetElementType(returnType); |
||||
|
||||
if (returnType == null) |
||||
return; |
||||
|
||||
string fullName = returnType.FullyQualifiedName; |
||||
string shortName; |
||||
bool isConstructedType = returnType.IsConstructedReturnType; |
||||
if (fullName != null && !isConstructedType && TypeConversionTable.TryGetValue(fullName, out shortName)) { |
||||
builder.Append(shortName); |
||||
} else { |
||||
IClass c = returnType.GetUnderlyingClass(); |
||||
|
||||
if (c != null) { |
||||
IList<IReturnType> ta = isConstructedType ? returnType.CastToConstructedReturnType().TypeArguments : null; |
||||
AppendClassNameWithTypeParameters(builder, c, forceFullyQualifiedName || UseFullyQualifiedTypeNames, false, ta); |
||||
} else { |
||||
if (UseFullyQualifiedTypeNames || forceFullyQualifiedName) { |
||||
builder.Append(fullName); |
||||
} else { |
||||
builder.Append(returnType.Name); |
||||
} |
||||
if (isConstructedType) { |
||||
builder.Append('<'); |
||||
IList<IReturnType> ta = returnType.CastToConstructedReturnType().TypeArguments; |
||||
for (int i = 0; i < ta.Count; ++i) { |
||||
if (i > 0) builder.Append(", "); |
||||
AppendReturnType(builder, ta[i], false); |
||||
} |
||||
builder.Append('>'); |
||||
} |
||||
} |
||||
} |
||||
|
||||
UnpackArrayType(builder, arrayReturnType); |
||||
} |
||||
|
||||
static IReturnType GetElementType(IReturnType potentialArrayType) |
||||
{ |
||||
if (potentialArrayType == null) |
||||
return null; |
||||
ArrayReturnType result; |
||||
while ((result = potentialArrayType.CastToArrayReturnType()) != null) { |
||||
potentialArrayType = result.ArrayElementType; |
||||
} |
||||
return potentialArrayType; |
||||
} |
||||
|
||||
static void UnpackArrayType(StringBuilder builder, IReturnType returnType) |
||||
{ |
||||
if (returnType.IsArrayReturnType) { |
||||
builder.Append('['); |
||||
int dimensions = returnType.CastToArrayReturnType().ArrayDimensions; |
||||
for (int i = 1; i < dimensions; ++i) { |
||||
builder.Append(','); |
||||
} |
||||
builder.Append(']'); |
||||
UnpackArrayType(builder, returnType.CastToArrayReturnType().ArrayElementType); |
||||
} |
||||
} |
||||
|
||||
public override string Convert(IParameter param) |
||||
{ |
||||
CheckThread(); |
||||
|
||||
StringBuilder builder = new StringBuilder(); |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("<i>"); |
||||
} |
||||
|
||||
if (param.IsRef) { |
||||
builder.Append("ref "); |
||||
} else if (param.IsOut) { |
||||
builder.Append("out "); |
||||
} else if (param.IsParams) { |
||||
builder.Append("params "); |
||||
} |
||||
|
||||
if (IncludeHtmlMarkup) { |
||||
builder.Append("</i>"); |
||||
} |
||||
|
||||
builder.Append(Convert(param.ReturnType)); |
||||
|
||||
if (ShowParameterNames) { |
||||
builder.Append(' '); |
||||
builder.Append(param.Name); |
||||
} |
||||
return builder.ToString(); |
||||
} |
||||
|
||||
public override string WrapAttribute(string attribute) |
||||
{ |
||||
return "[" + attribute + "]"; |
||||
} |
||||
|
||||
public override string WrapComment(string comment) |
||||
{ |
||||
return "// " + comment; |
||||
} |
||||
|
||||
public override string GetIntrinsicTypeName(string dotNetTypeName) |
||||
{ |
||||
string shortName; |
||||
if (TypeConversionTable.TryGetValue(dotNetTypeName, out shortName)) { |
||||
return shortName; |
||||
} |
||||
return dotNetTypeName; |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,55 +0,0 @@
@@ -1,55 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom.CSharp |
||||
{ |
||||
public static class CSharpExpressionContext |
||||
{ |
||||
/// <summary>The context is the body of a property declaration.</summary>
|
||||
/// <example>string Name { *expr* }</example>
|
||||
public readonly static ExpressionContext PropertyDeclaration = new ExpressionContext.DefaultExpressionContext("PropertyDeclaration"); |
||||
|
||||
/// <summary>The context is the body of a property declaration inside an interface.</summary>
|
||||
/// <example>string Name { *expr* }</example>
|
||||
public readonly static ExpressionContext InterfacePropertyDeclaration = new ExpressionContext.DefaultExpressionContext("InterfacePropertyDeclaration"); |
||||
|
||||
/// <summary>The context is the body of a event declaration.</summary>
|
||||
/// <example>event EventHandler NameChanged { *expr* }</example>
|
||||
public readonly static ExpressionContext EventDeclaration = new ExpressionContext.DefaultExpressionContext("EventDeclaration"); |
||||
|
||||
/// <summary>The context is after the type parameters of a type/method declaration.
|
||||
/// The only valid keyword is "where"</summary>
|
||||
/// <example>class <T> *expr*</example>
|
||||
public readonly static ExpressionContext ConstraintsStart = new ExpressionContext.DefaultExpressionContext("ConstraintsStart"); |
||||
|
||||
/// <summary>The context is after the 'where' of a constraints list.</summary>
|
||||
/// <example>class <T> where *expr*</example>
|
||||
public readonly static ExpressionContext Constraints = new ExpressionContext.NonStaticTypeExpressionContext("Constraints", false); |
||||
|
||||
/// <summary>The context is the body of an interface declaration.</summary>
|
||||
public readonly static ExpressionContext InterfaceDeclaration = new ExpressionContext.NonStaticTypeExpressionContext("InterfaceDeclaration", true); |
||||
|
||||
/// <summary>Context expects "base" or "this".</summary>
|
||||
/// <example>public ClassName() : *expr*</example>
|
||||
public readonly static ExpressionContext BaseConstructorCall = new ExpressionContext.DefaultExpressionContext("BaseConstructorCall"); |
||||
|
||||
/// <summary>The first parameter</summary>
|
||||
/// <example>void MethodName(*expr*)</example>
|
||||
public readonly static ExpressionContext FirstParameterType = new ExpressionContext.NonStaticTypeExpressionContext("FirstParameterType", false); |
||||
|
||||
/// <summary>Another parameter</summary>
|
||||
/// <example>void MethodName(..., *expr*)</example>
|
||||
public readonly static ExpressionContext ParameterType = new ExpressionContext.NonStaticTypeExpressionContext("ParameterType", false); |
||||
|
||||
/// <summary>Context expects a fully qualified type name.</summary>
|
||||
/// <example>using Alias = *expr*;</example>
|
||||
public readonly static ExpressionContext FullyQualifiedType = new ExpressionContext.DefaultExpressionContext("FullyQualifiedType"); |
||||
|
||||
/// <summary>Context expects is a property name in an object initializer.</summary>
|
||||
/// <example>new *type* [(args)] { *expr* = ... }</example>
|
||||
public readonly static ExpressionContext ObjectInitializer = new ExpressionContext.DefaultExpressionContext("ObjectInitializer"); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,340 +0,0 @@
@@ -1,340 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom.CSharp |
||||
{ |
||||
/// <summary>
|
||||
/// Implements C# 3.0 overload resolution.
|
||||
/// </summary>
|
||||
public sealed class OverloadResolution |
||||
{ |
||||
private OverloadResolution() {} |
||||
|
||||
public static IMethodOrProperty FindOverload(IEnumerable<IMethodOrProperty> list, |
||||
IReturnType[] arguments, |
||||
bool allowAdditionalArguments, |
||||
bool substituteInferredTypes, |
||||
out bool acceptableMatch) |
||||
{ |
||||
OverloadResolution or = new OverloadResolution(); |
||||
or.candidates = list.Select(m => new Candidate(m)).ToList(); |
||||
or.arguments = arguments; |
||||
or.allowAdditionalArguments = allowAdditionalArguments; |
||||
|
||||
if (or.candidates.Count == 0) |
||||
throw new ArgumentException("at least one candidate is required"); |
||||
|
||||
MemberLookupHelper.Log("OverloadResolution"); |
||||
MemberLookupHelper.Log(" arguments = ", arguments); |
||||
|
||||
or.ConstructExpandedForms(); |
||||
or.InferTypeArguments(); |
||||
or.CheckApplicability(); |
||||
|
||||
Candidate result = or.FindBestCandidate(); |
||||
MemberLookupHelper.Log("Overload resolution finished. Winning candidate = " + result); |
||||
acceptableMatch = result.Status == CandidateStatus.Success; |
||||
if (substituteInferredTypes) |
||||
return result.Method; |
||||
else |
||||
return result.OriginalMethod; |
||||
} |
||||
|
||||
enum CandidateStatus |
||||
{ |
||||
Success, |
||||
WrongParameterCount, |
||||
TypeInferenceFailed, |
||||
NotApplicable |
||||
} |
||||
|
||||
sealed class Candidate |
||||
{ |
||||
public bool IsExpanded; |
||||
public IMethodOrProperty Method; |
||||
public IMethodOrProperty OriginalMethod; |
||||
public CandidateStatus Status = CandidateStatus.Success; |
||||
public int ApplicableArgumentCount; |
||||
|
||||
public IList<IParameter> Parameters { |
||||
get { return Method.Parameters; } |
||||
} |
||||
|
||||
public int TypeParameterCount { |
||||
get { |
||||
IMethod m = Method as IMethod; |
||||
if (m != null) |
||||
return m.TypeParameters.Count; |
||||
else |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
public Candidate(IMethodOrProperty method) |
||||
{ |
||||
if (method == null) |
||||
throw new ArgumentNullException("method"); |
||||
this.Method = method; |
||||
this.OriginalMethod = method; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return "[Candidate: " + Method + ", Status=" + Status + "]"; |
||||
} |
||||
} |
||||
|
||||
List<Candidate> candidates; |
||||
IList<IReturnType> arguments; |
||||
bool allowAdditionalArguments; |
||||
|
||||
/// <summary>
|
||||
/// For methods having a params-array as last parameter, expand the params array to
|
||||
/// n parameters of the element type and add those as new candidates.
|
||||
/// Mark candidates with the wrong parameter count as Status.WrongParameterCount.
|
||||
/// </summary>
|
||||
void ConstructExpandedForms() |
||||
{ |
||||
LogStep("Step 1 (Construct expanded forms)"); |
||||
foreach (Candidate candidate in candidates.ToArray()) { |
||||
if (candidate.Status == CandidateStatus.Success) { |
||||
if (candidate.Parameters.Count > 0 && arguments.Count >= candidate.Parameters.Count - 1) { |
||||
IParameter lastParameter = candidate.Parameters[candidate.Parameters.Count - 1]; |
||||
if (lastParameter.IsParams && lastParameter.ReturnType != null && lastParameter.ReturnType.IsArrayReturnType) { |
||||
// try to construct an expanded form with the correct parameter count
|
||||
IReturnType elementType = lastParameter.ReturnType.CastToArrayReturnType().ArrayElementType; |
||||
IMethodOrProperty expanded = (IMethodOrProperty)candidate.Method.CreateSpecializedMember(); |
||||
expanded.Parameters.RemoveAt(candidate.Parameters.Count - 1); |
||||
int index = 0; |
||||
while (expanded.Parameters.Count < arguments.Count) { |
||||
expanded.Parameters.Add(new DefaultParameter(lastParameter.Name + (index++), elementType, lastParameter.Region)); |
||||
} |
||||
candidates.Add(new Candidate(expanded) { |
||||
IsExpanded = true, |
||||
OriginalMethod = candidate.Method |
||||
}); |
||||
} |
||||
} |
||||
|
||||
if (allowAdditionalArguments) { |
||||
if (candidate.Parameters.Count < arguments.Count) { |
||||
candidate.Status = CandidateStatus.WrongParameterCount; |
||||
} |
||||
} else { |
||||
if (candidate.Parameters.Count != arguments.Count) { |
||||
candidate.Status = CandidateStatus.WrongParameterCount; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Infer the type arguments for generic methods.
|
||||
/// </summary>
|
||||
void InferTypeArguments() |
||||
{ |
||||
LogStep("Step 2 (Infer type arguments)"); |
||||
foreach (Candidate candidate in candidates) { |
||||
IMethod method = candidate.Method as IMethod; |
||||
if (method != null && method.TypeParameters.Count > 0 |
||||
&& candidate.Status == CandidateStatus.Success) |
||||
{ |
||||
bool success; |
||||
IReturnType[] typeArguments = TypeInference.InferTypeArguments(method, arguments, out success); |
||||
if (!success) { |
||||
candidate.Status = CandidateStatus.TypeInferenceFailed; |
||||
} |
||||
candidate.Method = ApplyTypeArgumentsToMethod(method, typeArguments); |
||||
} |
||||
} |
||||
} |
||||
|
||||
static IMethod ApplyTypeArgumentsToMethod(IMethod genericMethod, IList<IReturnType> typeArguments) |
||||
{ |
||||
if (typeArguments != null && typeArguments.Count > 0) { |
||||
// apply inferred type arguments
|
||||
IMethod method = (IMethod)genericMethod.CreateSpecializedMember(); |
||||
method.ReturnType = ConstructedReturnType.TranslateType(method.ReturnType, typeArguments, true); |
||||
for (int i = 0; i < method.Parameters.Count; ++i) { |
||||
method.Parameters[i].ReturnType = ConstructedReturnType.TranslateType(method.Parameters[i].ReturnType, typeArguments, true); |
||||
} |
||||
for (int i = 0; i < Math.Min(typeArguments.Count, method.TypeParameters.Count); i++) { |
||||
var tp = new BoundTypeParameter(method.TypeParameters[i], method.DeclaringType, method); |
||||
tp.BoundTo = typeArguments[i]; |
||||
method.TypeParameters[i] = tp; |
||||
} |
||||
return method; |
||||
} else { |
||||
return genericMethod; |
||||
} |
||||
} |
||||
|
||||
void CheckApplicability() |
||||
{ |
||||
LogStep("Step 3 (CheckApplicability)"); |
||||
foreach (Candidate candidate in candidates) { |
||||
int c = Math.Min(arguments.Count, candidate.Parameters.Count); |
||||
for (int i = 0; i < c; i++) { |
||||
if (MemberLookupHelper.IsApplicable(arguments[i], candidate.Parameters[i], candidate.Method as IMethod)) |
||||
candidate.ApplicableArgumentCount++; |
||||
} |
||||
if (candidate.Status == CandidateStatus.Success && candidate.ApplicableArgumentCount < arguments.Count) { |
||||
candidate.Status = CandidateStatus.NotApplicable; |
||||
} |
||||
} |
||||
} |
||||
|
||||
Candidate FindBestCandidate() |
||||
{ |
||||
LogStep("Step 4 (FindBestCandidate)"); |
||||
|
||||
// Find a candidate that is better than all other candidates
|
||||
Candidate best = null; |
||||
foreach (Candidate candidate in candidates) { |
||||
if (candidate.Status == CandidateStatus.Success) { |
||||
if (best == null || GetBetterFunctionMember(best, candidate) == 2) { |
||||
best = candidate; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (best != null) |
||||
return best; |
||||
|
||||
// no successful candidate found:
|
||||
// find the candidate that is nearest to being applicable
|
||||
// first try only candidates with the correct parameter count
|
||||
foreach (Candidate candidate in candidates) { |
||||
if (candidate.Status != CandidateStatus.WrongParameterCount) { |
||||
if (best == null || candidate.ApplicableArgumentCount > best.ApplicableArgumentCount) |
||||
best = candidate; |
||||
} |
||||
} |
||||
if (best != null) |
||||
return best; |
||||
// if all candidates have the wrong parameter count, return the candidate
|
||||
// with the most applicable parameters.
|
||||
best = candidates[0]; |
||||
foreach (Candidate candidate in candidates) { |
||||
if (candidate.ApplicableArgumentCount > best.ApplicableArgumentCount) |
||||
best = candidate; |
||||
} |
||||
return best; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets which function member is better. (§ 14.4.2.2)
|
||||
/// </summary>
|
||||
/// <returns>0 if neither method is better. 1 if c1 is better. 2 if c2 is better.</returns>
|
||||
int GetBetterFunctionMember(Candidate c1, Candidate c2) |
||||
{ |
||||
int length = Math.Min(Math.Min(c1.Parameters.Count, c2.Parameters.Count), arguments.Count); |
||||
bool foundBetterParamIn1 = false; |
||||
bool foundBetterParamIn2 = false; |
||||
for (int i = 0; i < length; i++) { |
||||
if (arguments[i] == null) |
||||
continue; |
||||
int res = MemberLookupHelper.GetBetterConversion(arguments[i], c1.Parameters[i].ReturnType, c2.Parameters[i].ReturnType); |
||||
if (res == 1) foundBetterParamIn1 = true; |
||||
if (res == 2) foundBetterParamIn2 = true; |
||||
} |
||||
if (foundBetterParamIn1 && !foundBetterParamIn2) |
||||
return 1; |
||||
if (foundBetterParamIn2 && !foundBetterParamIn1) |
||||
return 2; |
||||
if (foundBetterParamIn1 && foundBetterParamIn2) |
||||
return 0; // ambigous
|
||||
// If none conversion is better than any other, it is possible that the
|
||||
// expanded parameter lists are the same:
|
||||
for (int i = 0; i < length; i++) { |
||||
if (!object.Equals(c1.Parameters[i].ReturnType, c2.Parameters[i].ReturnType)) { |
||||
// if expanded parameters are not the same, neither function member is better
|
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
// the expanded parameters are the same, apply the tie-breaking rules from the spec:
|
||||
|
||||
// if one method is generic and the other non-generic, the non-generic is better
|
||||
bool m1IsGeneric = c1.TypeParameterCount > 0; |
||||
bool m2IsGeneric = c2.TypeParameterCount > 0; |
||||
if (m1IsGeneric && !m2IsGeneric) return 2; |
||||
if (m2IsGeneric && !m1IsGeneric) return 1; |
||||
|
||||
// for params parameters: non-expanded calls are better
|
||||
if (c1.IsExpanded && !c2.IsExpanded) return 2; |
||||
if (c2.IsExpanded && !c1.IsExpanded) return 1; |
||||
|
||||
// if the number of parameters is different, the one with more parameters is better
|
||||
// this occurs when only when both methods are expanded
|
||||
if (c1.OriginalMethod.Parameters.Count > c2.OriginalMethod.Parameters.Count) return 1; |
||||
if (c2.OriginalMethod.Parameters.Count > c1.OriginalMethod.Parameters.Count) return 2; |
||||
|
||||
IReturnType[] m1ParamTypes = new IReturnType[c1.Parameters.Count]; |
||||
IReturnType[] m2ParamTypes = new IReturnType[c2.Parameters.Count]; |
||||
for (int i = 0; i < m1ParamTypes.Length; i++) { |
||||
m1ParamTypes[i] = c1.Parameters[i].ReturnType; |
||||
m2ParamTypes[i] = c2.Parameters[i].ReturnType; |
||||
} |
||||
return GetMoreSpecific(m1ParamTypes, m2ParamTypes); |
||||
} |
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets which return type list is more specific.
|
||||
/// § 14.4.2.2: types with generic arguments are less specific than types with fixed arguments
|
||||
/// </summary>
|
||||
/// <returns>0 if both are equally specific, 1 if <paramref name="r"/> is more specific,
|
||||
/// 2 if <paramref name="s"/> is more specific.</returns>
|
||||
static int GetMoreSpecific(IList<IReturnType> r, IList<IReturnType> s) |
||||
{ |
||||
bool foundMoreSpecificParamIn1 = false; |
||||
bool foundMoreSpecificParamIn2 = false; |
||||
int length = Math.Min(r.Count, s.Count); |
||||
for (int i = 0; i < length; i++) { |
||||
int res = GetMoreSpecific(r[i], s[i]); |
||||
if (res == 1) foundMoreSpecificParamIn1 = true; |
||||
if (res == 2) foundMoreSpecificParamIn2 = true; |
||||
} |
||||
if (foundMoreSpecificParamIn1 && !foundMoreSpecificParamIn2) |
||||
return 1; |
||||
if (foundMoreSpecificParamIn2 && !foundMoreSpecificParamIn1) |
||||
return 2; |
||||
return 0; |
||||
} |
||||
|
||||
static int GetMoreSpecific(IReturnType r, IReturnType s) |
||||
{ |
||||
if (r == null && s == null) return 0; |
||||
if (r == null) return 2; |
||||
if (s == null) return 1; |
||||
if (r.IsGenericReturnType && !(s.IsGenericReturnType)) |
||||
return 2; |
||||
if (s.IsGenericReturnType && !(r.IsGenericReturnType)) |
||||
return 1; |
||||
if (r.IsArrayReturnType && s.IsArrayReturnType) |
||||
return GetMoreSpecific(r.CastToArrayReturnType().ArrayElementType, s.CastToArrayReturnType().ArrayElementType); |
||||
if (r.IsConstructedReturnType && s.IsConstructedReturnType) |
||||
return GetMoreSpecific(r.CastToConstructedReturnType().TypeArguments, s.CastToConstructedReturnType().TypeArguments); |
||||
return 0; |
||||
} |
||||
|
||||
[System.Diagnostics.ConditionalAttribute("DEBUG")] |
||||
void LogStep(string title) |
||||
{ |
||||
MemberLookupHelper.Log(" candidates = ", candidates); |
||||
MemberLookupHelper.Log("Overload resolution (" + title + ")"); |
||||
} |
||||
|
||||
[System.Diagnostics.ConditionalAttribute("DEBUG")] |
||||
void Log(string text) |
||||
{ |
||||
MemberLookupHelper.Log(text); |
||||
} |
||||
} |
||||
} |
@ -1,564 +0,0 @@
@@ -1,564 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
|
||||
using ICSharpCode.SharpDevelop.Dom.ReflectionLayer; |
||||
using Mono.Cecil; |
||||
using Mono.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
public static class CecilReader |
||||
{ |
||||
sealed class DummyAssemblyResolver : IAssemblyResolver |
||||
{ |
||||
public AssemblyDefinition Resolve(AssemblyNameReference name) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public AssemblyDefinition Resolve(string fullName) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public AssemblyDefinition Resolve(string fullName, ReaderParameters parameters) |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public static ReflectionProjectContent LoadAssembly(string fileName, ProjectContentRegistry registry) |
||||
{ |
||||
if (fileName == null) |
||||
throw new ArgumentNullException("fileName"); |
||||
if (registry == null) |
||||
throw new ArgumentNullException("registry"); |
||||
LoggingService.Info("Cecil: Load from " + fileName); |
||||
AssemblyDefinition asm = AssemblyDefinition.ReadAssembly(fileName, new ReaderParameters { AssemblyResolver = new DummyAssemblyResolver() }); |
||||
List<DomAssemblyName> referencedAssemblies = new List<DomAssemblyName>(); |
||||
foreach (ModuleDefinition module in asm.Modules) { |
||||
foreach (AssemblyNameReference anr in module.AssemblyReferences) { |
||||
referencedAssemblies.Add(new DomAssemblyName(anr.FullName)); |
||||
} |
||||
} |
||||
return new CecilProjectContent(asm.Name.FullName, fileName, referencedAssemblies.ToArray(), asm, registry); |
||||
} |
||||
|
||||
static void AddAttributes(IProjectContent pc, IEntity member, IList<IAttribute> list, ICustomAttributeProvider attributeProvider) |
||||
{ |
||||
if (!attributeProvider.HasCustomAttributes) |
||||
return; |
||||
foreach (CustomAttribute att in attributeProvider.CustomAttributes) { |
||||
DefaultAttribute a = new DefaultAttribute(CreateType(pc, member, att.Constructor.DeclaringType)); |
||||
// Currently Cecil returns string instead of TypeReference for typeof() arguments to attributes
|
||||
try { |
||||
foreach (var argument in att.ConstructorArguments) { |
||||
a.PositionalArguments.Add(GetValue(pc, member, argument)); |
||||
} |
||||
foreach (CustomAttributeNamedArgument entry in att.Properties) { |
||||
// some obfuscated assemblies may contain duplicate named arguments; we'll have to ignore those
|
||||
if (!a.NamedArguments.ContainsKey(entry.Name)) |
||||
a.NamedArguments.Add(entry.Name, GetValue(pc, member, entry.Argument)); |
||||
} |
||||
} catch (InvalidOperationException) { |
||||
// Workaround for Cecil bug. (some types cannot be resolved)
|
||||
} |
||||
list.Add(a); |
||||
} |
||||
} |
||||
|
||||
static object GetValue(IProjectContent pc, IEntity member, CustomAttributeArgument argument) |
||||
{ |
||||
if (argument.Value is TypeReference) |
||||
return CreateType(pc, member, (TypeReference)argument.Value); |
||||
else |
||||
return argument.Value; |
||||
} |
||||
|
||||
static void AddConstraintsFromType(ITypeParameter tp, GenericParameter g) |
||||
{ |
||||
foreach (TypeReference constraint in g.Constraints) { |
||||
if (tp.Method != null) { |
||||
tp.Constraints.Add(CreateType(tp.Class.ProjectContent, tp.Method, constraint)); |
||||
} else { |
||||
tp.Constraints.Add(CreateType(tp.Class.ProjectContent, tp.Class, constraint)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Create a SharpDevelop return type from a Cecil type reference.
|
||||
/// </summary>
|
||||
internal static IReturnType CreateType(IProjectContent pc, IEntity member, TypeReference type, ICustomAttributeProvider attributeProvider = null) |
||||
{ |
||||
int typeIndex = 0; |
||||
return CreateType(pc, member, type, attributeProvider, ref typeIndex); |
||||
} |
||||
|
||||
static IReturnType CreateType(IProjectContent pc, IEntity member, TypeReference type, ICustomAttributeProvider attributeProvider, ref int typeIndex) |
||||
{ |
||||
while (type is OptionalModifierType || type is RequiredModifierType) { |
||||
type = ((TypeSpecification)type).ElementType; |
||||
} |
||||
if (type == null) { |
||||
LoggingService.Warn("CecilReader: Null type for: " + member); |
||||
return new VoidReturnType(pc); |
||||
} |
||||
if (type is ByReferenceType) { |
||||
// TODO: Use ByRefRefReturnType
|
||||
return CreateType(pc, member, (type as ByReferenceType).ElementType, attributeProvider, ref typeIndex); |
||||
} else if (type is PointerType) { |
||||
typeIndex++; |
||||
return new PointerReturnType(CreateType(pc, member, (type as PointerType).ElementType, attributeProvider, ref typeIndex)); |
||||
} else if (type is ArrayType) { |
||||
typeIndex++; |
||||
return new ArrayReturnType(pc, CreateType(pc, member, (type as ArrayType).ElementType, attributeProvider, ref typeIndex), (type as ArrayType).Rank); |
||||
} else if (type is GenericInstanceType) { |
||||
GenericInstanceType gType = (GenericInstanceType)type; |
||||
IReturnType baseType = CreateType(pc, member, gType.ElementType, attributeProvider, ref typeIndex); |
||||
IReturnType[] para = new IReturnType[gType.GenericArguments.Count]; |
||||
for (int i = 0; i < para.Length; ++i) { |
||||
typeIndex++; |
||||
para[i] = CreateType(pc, member, gType.GenericArguments[i], attributeProvider, ref typeIndex); |
||||
} |
||||
return new ConstructedReturnType(baseType, para); |
||||
} else if (type is GenericParameter) { |
||||
GenericParameter typeGP = type as GenericParameter; |
||||
if (typeGP.Owner is MethodDefinition) { |
||||
IMethod method = member as IMethod; |
||||
if (method != null) { |
||||
if (typeGP.Position < method.TypeParameters.Count) { |
||||
return new GenericReturnType(method.TypeParameters[typeGP.Position]); |
||||
} |
||||
} |
||||
return new GenericReturnType(new DefaultTypeParameter(method, typeGP.Name, typeGP.Position)); |
||||
} else { |
||||
IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null; |
||||
if (c != null && typeGP.Position < c.TypeParameters.Count) { |
||||
if (c.TypeParameters[typeGP.Position].Name == type.Name) { |
||||
return new GenericReturnType(c.TypeParameters[typeGP.Position]); |
||||
} |
||||
} |
||||
return new GenericReturnType(new DefaultTypeParameter(c, typeGP.Name, typeGP.Position)); |
||||
} |
||||
} else { |
||||
string name = type.FullName; |
||||
if (name == null) |
||||
throw new ApplicationException("type.FullName returned null. Type: " + type.ToString()); |
||||
|
||||
int typeParameterCount; |
||||
if (name.IndexOf('/') > 0) { |
||||
typeParameterCount = 0; |
||||
StringBuilder newName = new StringBuilder(); |
||||
foreach (string namepart in name.Split('/')) { |
||||
if (newName.Length > 0) |
||||
newName.Append('.'); |
||||
int partTypeParameterCount; |
||||
newName.Append(ReflectionClass.SplitTypeParameterCountFromReflectionName(namepart, out partTypeParameterCount)); |
||||
typeParameterCount += partTypeParameterCount; |
||||
} |
||||
name = newName.ToString(); |
||||
} else { |
||||
name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name, out typeParameterCount); |
||||
} |
||||
|
||||
if (typeParameterCount == 0 && name == "System.Object" && HasDynamicAttribute(attributeProvider, typeIndex)) |
||||
return new DynamicReturnType(pc); |
||||
|
||||
IClass c = pc.GetClass(name, typeParameterCount, LanguageProperties.CSharp, GetClassOptions.Default | GetClassOptions.ExactMatch); |
||||
if (c != null) { |
||||
return c.DefaultReturnType; |
||||
} else { |
||||
// example where name is not found: pointers like System.Char*
|
||||
// or when the class is in a assembly that is not referenced
|
||||
return new GetClassReturnType(pc, name, typeParameterCount); |
||||
} |
||||
} |
||||
} |
||||
|
||||
static bool HasDynamicAttribute(ICustomAttributeProvider attributeProvider, int typeIndex) |
||||
{ |
||||
if (attributeProvider == null || attributeProvider.HasCustomAttributes == false) |
||||
return false; |
||||
foreach (CustomAttribute a in attributeProvider.CustomAttributes) { |
||||
if (a.Constructor.DeclaringType.FullName == "System.Runtime.CompilerServices.DynamicAttribute") { |
||||
if (a.ConstructorArguments.Count == 1) { |
||||
CustomAttributeArgument[] values = a.ConstructorArguments[0].Value as CustomAttributeArgument[]; |
||||
if (values != null && typeIndex < values.Length && values[typeIndex].Value is bool) |
||||
return (bool)values[typeIndex].Value; |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
private sealed class CecilProjectContent : ReflectionProjectContent |
||||
{ |
||||
public CecilProjectContent(string fullName, string fileName, DomAssemblyName[] referencedAssemblies, |
||||
AssemblyDefinition assembly, ProjectContentRegistry registry) |
||||
: base(fullName, fileName, referencedAssemblies, registry) |
||||
{ |
||||
foreach (ModuleDefinition module in assembly.Modules) { |
||||
AddTypes(module.Types); |
||||
} |
||||
AddAttributes(this, null, this.AssemblyCompilationUnit.Attributes, assembly); |
||||
InitializeSpecialClasses(); |
||||
this.AssemblyCompilationUnit.Freeze(); |
||||
} |
||||
|
||||
void AddTypes(Collection<TypeDefinition> types) |
||||
{ |
||||
foreach (TypeDefinition td in types) { |
||||
if ((td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.Public) { |
||||
string name = td.FullName; |
||||
if (name.Length == 0 || name[0] == '<') |
||||
continue; |
||||
name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name); |
||||
AddClassToNamespaceListInternal(new CecilClass(this.AssemblyCompilationUnit, null, td, name)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private sealed class CecilClass : DefaultClass |
||||
{ |
||||
public static bool IsDelegate(TypeDefinition type) |
||||
{ |
||||
if (type.BaseType == null) |
||||
return false; |
||||
else |
||||
return type.BaseType.FullName == "System.Delegate" |
||||
|| type.BaseType.FullName == "System.MulticastDelegate"; |
||||
} |
||||
|
||||
protected override bool KeepInheritanceTree { |
||||
get { return true; } |
||||
} |
||||
|
||||
public CecilClass(ICompilationUnit compilationUnit, IClass declaringType, |
||||
TypeDefinition td, string fullName) |
||||
: base(compilationUnit, declaringType) |
||||
{ |
||||
this.FullyQualifiedName = fullName; |
||||
|
||||
AddAttributes(compilationUnit.ProjectContent, this, this.Attributes, td); |
||||
|
||||
// set classtype
|
||||
if (td.IsInterface) { |
||||
this.ClassType = ClassType.Interface; |
||||
} else if (td.IsEnum) { |
||||
this.ClassType = ClassType.Enum; |
||||
} else if (td.IsValueType) { |
||||
this.ClassType = ClassType.Struct; |
||||
} else if (IsDelegate(td)) { |
||||
this.ClassType = ClassType.Delegate; |
||||
} else { |
||||
this.ClassType = ClassType.Class; |
||||
} |
||||
if (td.GenericParameters.Count > 0) { |
||||
foreach (GenericParameter g in td.GenericParameters) { |
||||
this.TypeParameters.Add(new DefaultTypeParameter(this, g.Name, g.Position)); |
||||
} |
||||
int i = 0; |
||||
foreach (GenericParameter g in td.GenericParameters) { |
||||
AddConstraintsFromType(this.TypeParameters[i++], g); |
||||
} |
||||
} |
||||
|
||||
ModifierEnum modifiers = ModifierEnum.None; |
||||
|
||||
if (td.IsSealed) { |
||||
modifiers |= ModifierEnum.Sealed; |
||||
} |
||||
if (td.IsAbstract) { |
||||
modifiers |= ModifierEnum.Abstract; |
||||
} |
||||
if (td.IsSealed && td.IsAbstract) { |
||||
modifiers |= ModifierEnum.Static; |
||||
} |
||||
|
||||
if ((td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic) { |
||||
modifiers |= ModifierEnum.Public; |
||||
} else if ((td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamily) { |
||||
modifiers |= ModifierEnum.Protected; |
||||
} else if ((td.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamORAssem) { |
||||
modifiers |= ModifierEnum.Protected; |
||||
} else { |
||||
modifiers |= ModifierEnum.Public; |
||||
} |
||||
|
||||
this.Modifiers = modifiers; |
||||
|
||||
// set base classes
|
||||
if (td.BaseType != null) { |
||||
BaseTypes.Add(CreateType(this.ProjectContent, this, td.BaseType)); |
||||
} |
||||
|
||||
foreach (TypeReference iface in td.Interfaces) { |
||||
BaseTypes.Add(CreateType(this.ProjectContent, this, iface)); |
||||
} |
||||
|
||||
ReflectionClass.ApplySpecialsFromAttributes(this); |
||||
|
||||
InitMembers(td); |
||||
} |
||||
|
||||
void InitMembers(TypeDefinition type) |
||||
{ |
||||
string defaultMemberName = null; |
||||
foreach (CustomAttribute att in type.CustomAttributes) { |
||||
if (att.Constructor.DeclaringType.FullName == "System.Reflection.DefaultMemberAttribute" |
||||
&& att.ConstructorArguments.Count == 1) |
||||
{ |
||||
defaultMemberName = att.ConstructorArguments[0].Value as string; |
||||
} |
||||
} |
||||
|
||||
foreach (TypeDefinition nestedType in type.NestedTypes) { |
||||
TypeAttributes visibility = nestedType.Attributes & TypeAttributes.VisibilityMask; |
||||
if (visibility == TypeAttributes.NestedPublic || visibility == TypeAttributes.NestedFamily |
||||
|| visibility == TypeAttributes.NestedFamORAssem) |
||||
{ |
||||
string name = nestedType.Name; |
||||
int pos = name.LastIndexOf('/'); |
||||
if (pos > 0) |
||||
name = name.Substring(pos + 1); |
||||
if (name.Length == 0 || name[0] == '<') |
||||
continue; |
||||
name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name); |
||||
name = this.FullyQualifiedName + "." + name; |
||||
InnerClasses.Add(new CecilClass(this.CompilationUnit, this, nestedType, name)); |
||||
} |
||||
} |
||||
|
||||
foreach (FieldDefinition field in type.Fields) { |
||||
if (IsVisible(field.Attributes) && !field.IsSpecialName) { |
||||
DefaultField f = new DefaultField(this, field.Name); |
||||
f.Modifiers = TranslateModifiers(field); |
||||
f.ReturnType = CreateType(this.ProjectContent, this, field.FieldType, field); |
||||
AddAttributes(CompilationUnit.ProjectContent, f, f.Attributes, field); |
||||
Fields.Add(f); |
||||
} |
||||
} |
||||
|
||||
foreach (PropertyDefinition property in type.Properties) { |
||||
AddProperty(defaultMemberName, property); |
||||
} |
||||
|
||||
foreach (EventDefinition eventDef in type.Events) { |
||||
if (eventDef.AddMethod != null && IsVisible(eventDef.AddMethod.Attributes)) { |
||||
DefaultEvent e = new DefaultEvent(this, eventDef.Name); |
||||
if (this.ClassType == ClassType.Interface) { |
||||
e.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract; |
||||
} else { |
||||
e.Modifiers = TranslateModifiers(eventDef); |
||||
} |
||||
e.ReturnType = CreateType(this.ProjectContent, this, eventDef.EventType, eventDef); |
||||
AddAttributes(CompilationUnit.ProjectContent, e, e.Attributes, eventDef); |
||||
Events.Add(e); |
||||
} |
||||
} |
||||
|
||||
this.AddDefaultConstructorIfRequired = (this.ClassType == ClassType.Struct || this.ClassType == ClassType.Enum); |
||||
foreach (MethodDefinition method in type.Methods) { |
||||
if (method.IsConstructor || !method.IsSpecialName) { |
||||
AddMethod(method); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void AddProperty(string defaultMemberName, PropertyDefinition property) |
||||
{ |
||||
if ((property.GetMethod != null && IsVisible(property.GetMethod.Attributes)) |
||||
|| (property.SetMethod != null && IsVisible(property.SetMethod.Attributes))) |
||||
{ |
||||
DefaultProperty p = new DefaultProperty(this, property.Name); |
||||
if (this.ClassType == ClassType.Interface) { |
||||
p.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract; |
||||
} else { |
||||
p.Modifiers = TranslateModifiers(property); |
||||
} |
||||
p.ReturnType = CreateType(this.ProjectContent, this, property.PropertyType, property); |
||||
p.CanGet = property.GetMethod != null && IsVisible(property.GetMethod.Attributes); |
||||
p.CanSet = property.SetMethod != null && IsVisible(property.SetMethod.Attributes); |
||||
if (p.CanGet) |
||||
p.GetterModifiers = GetAccessorVisibility(p, property.GetMethod); |
||||
if (p.CanSet) |
||||
p.SetterModifiers = GetAccessorVisibility(p, property.SetMethod); |
||||
if (p.Name == defaultMemberName) { |
||||
p.IsIndexer = true; |
||||
} |
||||
AddParameters(p, property.Parameters); |
||||
AddAttributes(CompilationUnit.ProjectContent, p, p.Attributes, property); |
||||
Properties.Add(p); |
||||
} |
||||
} |
||||
|
||||
static ModifierEnum GetAccessorVisibility(IProperty p, MethodDefinition accessor) |
||||
{ |
||||
ModifierEnum visibility = ModifierEnum.VisibilityMask & TranslateModifiers(accessor); |
||||
if (visibility == (p.Modifiers & ModifierEnum.VisibilityMask)) |
||||
return ModifierEnum.None; |
||||
else |
||||
return visibility; |
||||
} |
||||
|
||||
void AddMethod(MethodDefinition method) |
||||
{ |
||||
if (IsVisible(method.Attributes)) { |
||||
DefaultMethod m = new DefaultMethod(this, method.IsConstructor ? "#ctor" : method.Name); |
||||
|
||||
if (method.GenericParameters.Count > 0) { |
||||
foreach (GenericParameter g in method.GenericParameters) { |
||||
m.TypeParameters.Add(new DefaultTypeParameter(m, g.Name, g.Position)); |
||||
} |
||||
int i = 0; |
||||
foreach (GenericParameter g in method.GenericParameters) { |
||||
AddConstraintsFromType(m.TypeParameters[i++], g); |
||||
} |
||||
} |
||||
|
||||
if (method.IsConstructor) |
||||
m.ReturnType = this.DefaultReturnType; |
||||
else |
||||
m.ReturnType = CreateType(this.ProjectContent, m, method.ReturnType, method.MethodReturnType); |
||||
AddAttributes(CompilationUnit.ProjectContent, m, m.Attributes, method); |
||||
if (this.ClassType == ClassType.Interface) { |
||||
m.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract; |
||||
} else { |
||||
m.Modifiers = TranslateModifiers(method); |
||||
} |
||||
AddParameters(m, method.Parameters); |
||||
AddExplicitInterfaceImplementations(method.Overrides, m); |
||||
ReflectionLayer.ReflectionMethod.ApplySpecialsFromAttributes(m); |
||||
Methods.Add(m); |
||||
} |
||||
} |
||||
|
||||
void AddExplicitInterfaceImplementations(Collection<MethodReference> overrides, IMember targetMember) |
||||
{ |
||||
foreach (MethodReference overrideRef in overrides) { |
||||
if (overrideRef.Name == targetMember.Name && targetMember.IsPublic) { |
||||
continue; // is like implicit interface implementation / normal override
|
||||
} |
||||
targetMember.InterfaceImplementations.Add(new ExplicitInterfaceImplementation( |
||||
CreateType(this.ProjectContent, targetMember, overrideRef.DeclaringType), |
||||
overrideRef.Name |
||||
)); |
||||
} |
||||
} |
||||
|
||||
void AddParameters(IMethodOrProperty target, Collection<ParameterDefinition> plist) |
||||
{ |
||||
foreach (ParameterDefinition par in plist) { |
||||
IReturnType pReturnType = CreateType(this.ProjectContent, target, par.ParameterType, par); |
||||
DefaultParameter p = new DefaultParameter(par.Name, pReturnType, DomRegion.Empty); |
||||
if (par.ParameterType is ByReferenceType) { |
||||
if ((par.Attributes & ParameterAttributes.Out) == ParameterAttributes.Out) { |
||||
p.Modifiers = ParameterModifiers.Out; |
||||
} else { |
||||
p.Modifiers = ParameterModifiers.Ref; |
||||
} |
||||
} else { |
||||
p.Modifiers = ParameterModifiers.In; |
||||
} |
||||
if ((par.Attributes & ParameterAttributes.Optional) == ParameterAttributes.Optional) { |
||||
p.Modifiers |= ParameterModifiers.Optional; |
||||
} |
||||
if (p.ReturnType.IsArrayReturnType) { |
||||
foreach (CustomAttribute att in par.CustomAttributes) { |
||||
if (att.Constructor.DeclaringType.FullName == typeof(ParamArrayAttribute).FullName) { |
||||
p.Modifiers |= ParameterModifiers.Params; |
||||
} |
||||
} |
||||
} |
||||
target.Parameters.Add(p); |
||||
} |
||||
} |
||||
|
||||
static bool IsVisible(MethodAttributes att) |
||||
{ |
||||
return ((att & MethodAttributes.Public) == MethodAttributes.Public) |
||||
|| ((att & MethodAttributes.Family) == MethodAttributes.Family) |
||||
|| ((att & MethodAttributes.FamORAssem) == MethodAttributes.FamORAssem); |
||||
} |
||||
|
||||
static bool IsVisible(FieldAttributes att) |
||||
{ |
||||
return ((att & FieldAttributes.Public) == FieldAttributes.Public) |
||||
|| ((att & FieldAttributes.Family) == FieldAttributes.Family) |
||||
|| ((att & FieldAttributes.FamORAssem) == FieldAttributes.FamORAssem); |
||||
} |
||||
|
||||
static ModifierEnum TranslateModifiers(MethodDefinition method) |
||||
{ |
||||
ModifierEnum m = ModifierEnum.None; |
||||
|
||||
if (method.IsStatic) { |
||||
m |= ModifierEnum.Static; |
||||
} else { |
||||
if (method.IsAbstract) { |
||||
m |= ModifierEnum.Abstract; |
||||
} else if (method.IsFinal) { |
||||
m |= ModifierEnum.Sealed; |
||||
} else if (method.Overrides.Count > 0) { |
||||
m |= ModifierEnum.Override; |
||||
} else if (method.IsVirtual) { |
||||
if (method.IsNewSlot) |
||||
m |= ModifierEnum.Virtual; |
||||
else |
||||
m |= ModifierEnum.Override; |
||||
} |
||||
} |
||||
|
||||
if ((method.Attributes & MethodAttributes.Public) == MethodAttributes.Public) |
||||
m |= ModifierEnum.Public; |
||||
else |
||||
m |= ModifierEnum.Protected; |
||||
|
||||
return m; |
||||
} |
||||
|
||||
static ModifierEnum TranslateModifiers(PropertyDefinition property) |
||||
{ |
||||
return TranslateModifiers(property.GetMethod ?? property.SetMethod); |
||||
} |
||||
|
||||
static ModifierEnum TranslateModifiers(EventDefinition @event) |
||||
{ |
||||
return TranslateModifiers(@event.AddMethod); |
||||
} |
||||
|
||||
static ModifierEnum TranslateModifiers(FieldDefinition field) |
||||
{ |
||||
ModifierEnum m = ModifierEnum.None; |
||||
|
||||
if (field.IsStatic) |
||||
m |= ModifierEnum.Static; |
||||
|
||||
if (field.IsLiteral) |
||||
m |= ModifierEnum.Const; |
||||
else if (field.IsInitOnly) |
||||
m |= ModifierEnum.Readonly; |
||||
|
||||
if ((field.Attributes & FieldAttributes.Public) == FieldAttributes.Public) |
||||
m |= ModifierEnum.Public; |
||||
else |
||||
m |= ModifierEnum.Protected; |
||||
|
||||
return m; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,130 +0,0 @@
@@ -1,130 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Class that stores a source code context and can resolve type names
|
||||
/// in that context.
|
||||
/// </summary>
|
||||
public sealed class ClassFinder |
||||
{ |
||||
int caretLine, caretColumn; |
||||
ICompilationUnit cu; |
||||
IClass callingClass; |
||||
IProjectContent projectContent; |
||||
|
||||
public IClass CallingClass { |
||||
get { |
||||
return callingClass; |
||||
} |
||||
} |
||||
|
||||
public IProjectContent ProjectContent { |
||||
get { |
||||
return projectContent; |
||||
} |
||||
} |
||||
|
||||
public LanguageProperties Language { |
||||
get { |
||||
return projectContent.Language; |
||||
} |
||||
} |
||||
|
||||
public int CaretLine { |
||||
get { return caretLine; } |
||||
} |
||||
|
||||
public int CaretColumn { |
||||
get { return caretColumn; } |
||||
} |
||||
|
||||
public ClassFinder(ParseInformation parseInfo, string fileContent, int offset) |
||||
{ |
||||
caretLine = 0; |
||||
caretColumn = 0; |
||||
for (int i = 0; i < offset; i++) { |
||||
if (fileContent[i] == '\n') { |
||||
caretLine++; |
||||
caretColumn = 0; |
||||
} else { |
||||
caretColumn++; |
||||
} |
||||
} |
||||
Init(parseInfo); |
||||
} |
||||
|
||||
public ClassFinder(ParseInformation parseInfo, int caretLineNumber, int caretColumn) |
||||
{ |
||||
this.caretLine = caretLineNumber; |
||||
this.caretColumn = caretColumn; |
||||
|
||||
Init(parseInfo); |
||||
} |
||||
|
||||
public ClassFinder(IMember classMember) |
||||
: this(classMember.DeclaringType, classMember.Region.BeginLine, classMember.Region.BeginColumn) |
||||
{ |
||||
} |
||||
|
||||
public ClassFinder(IClass callingClass, int caretLine, int caretColumn) |
||||
{ |
||||
if (callingClass == null) |
||||
throw new ArgumentNullException("callingClass"); |
||||
if (callingClass is CompoundClass) |
||||
throw new ArgumentException("Cannot use compound class for ClassFinder - must pass a specific class part."); |
||||
this.caretLine = caretLine; |
||||
this.caretColumn = caretColumn; |
||||
this.callingClass = callingClass; |
||||
this.cu = callingClass.CompilationUnit; |
||||
this.projectContent = cu.ProjectContent; |
||||
if (projectContent == null) |
||||
throw new ArgumentException("callingClass must have a project content!"); |
||||
} |
||||
|
||||
// currently callingMember is not required
|
||||
public ClassFinder(IClass callingClass, IMember callingMember, int caretLine, int caretColumn) |
||||
: this(callingClass, caretLine, caretColumn) |
||||
{ |
||||
} |
||||
|
||||
void Init(ParseInformation parseInfo) |
||||
{ |
||||
if (parseInfo != null) { |
||||
cu = parseInfo.CompilationUnit; |
||||
} |
||||
|
||||
if (cu != null) { |
||||
callingClass = cu.GetInnermostClass(caretLine, caretColumn); |
||||
projectContent = cu.ProjectContent; |
||||
} else { |
||||
projectContent = DefaultProjectContent.DummyProjectContent; |
||||
} |
||||
if (projectContent == null) |
||||
throw new ArgumentException("projectContent not found!"); |
||||
} |
||||
|
||||
public IClass GetClass(string fullName, int typeParameterCount) |
||||
{ |
||||
return projectContent.GetClass(fullName, typeParameterCount); |
||||
} |
||||
|
||||
public IReturnType SearchType(string name, int typeParameterCount) |
||||
{ |
||||
return Search(name, typeParameterCount).Result; |
||||
} |
||||
|
||||
public SearchTypeResult Search(string name, int typeParameterCount) |
||||
{ |
||||
return projectContent.SearchType(new SearchTypeRequest(name, typeParameterCount, callingClass, cu, caretLine, caretColumn)); |
||||
} |
||||
|
||||
public string SearchNamespace(string name) |
||||
{ |
||||
return Search(name, 0).NamespaceResult; |
||||
} |
||||
} |
||||
} |
@ -1,285 +0,0 @@
@@ -1,285 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Provides static methods that fill a list of completion results with entries
|
||||
/// reachable from a certain calling class/member or entries that introduced
|
||||
/// by a certain Using statement.
|
||||
/// </summary>
|
||||
public class CtrlSpaceResolveHelper |
||||
{ |
||||
static void AddTypeParametersForCtrlSpace(List<ICompletionEntry> result, IEnumerable<ITypeParameter> typeParameters) |
||||
{ |
||||
foreach (ITypeParameter p in typeParameters) { |
||||
DefaultClass c = DefaultTypeParameter.GetDummyClassForTypeParameter(p); |
||||
if (p.Method != null) { |
||||
c.Documentation = "Type parameter of " + p.Method.Name; |
||||
} else { |
||||
c.Documentation = "Type parameter of " + p.Class.Name; |
||||
} |
||||
result.Add(c); |
||||
} |
||||
} |
||||
|
||||
public static void AddContentsFromCalling(List<ICompletionEntry> result, IClass callingClass, IMember callingMember) |
||||
{ |
||||
IMethodOrProperty methodOrProperty = callingMember as IMethodOrProperty; |
||||
if (methodOrProperty != null) { |
||||
foreach (IParameter p in methodOrProperty.Parameters) { |
||||
result.Add(new DefaultField.ParameterField(p.ReturnType, p.Name, methodOrProperty.Region, callingClass)); |
||||
} |
||||
if (callingMember is IMethod) { |
||||
AddTypeParametersForCtrlSpace(result, ((IMethod)callingMember).TypeParameters); |
||||
} |
||||
} |
||||
|
||||
bool inStatic = false; |
||||
if (callingMember != null) |
||||
inStatic = callingMember.IsStatic; |
||||
|
||||
if (callingClass != null) { |
||||
AddTypeParametersForCtrlSpace(result, callingClass.TypeParameters); |
||||
|
||||
|
||||
List<ICompletionEntry> members = new List<ICompletionEntry>(); |
||||
IReturnType t = callingClass.DefaultReturnType; |
||||
var language = callingClass.ProjectContent.Language; |
||||
foreach (IMember m in MemberLookupHelper.GetAccessibleMembers(t, callingClass, language, true)) { |
||||
if ((!inStatic || m.IsStatic) && language.ShowMember(m, m.IsStatic)) |
||||
result.Add(m); |
||||
} |
||||
members.Clear(); |
||||
IClass c = callingClass.DeclaringType; |
||||
while (c != null) { |
||||
t = c.DefaultReturnType; |
||||
foreach (IMember m in MemberLookupHelper.GetAccessibleMembers(t, c, language, true)) { |
||||
if (language.ShowMember(m, true)) |
||||
result.Add(m); |
||||
} |
||||
c = c.DeclaringType; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds contents of all assemblies referenced by <paramref name="cu" />'s project.
|
||||
/// Also adds contents of <paramref name="callingClass" />.
|
||||
/// </summary>
|
||||
public static void AddReferencedProjectsContents(List<ICompletionEntry> result, ICompilationUnit cu, IClass callingClass) |
||||
{ |
||||
IProjectContent projectContent = cu.ProjectContent; |
||||
projectContent.AddNamespaceContents(result, "", projectContent.Language, true); |
||||
var allContents = projectContent.GetAllContents(); |
||||
result.Capacity = result.Count + allContents.Count; |
||||
foreach (var entry in allContents.Where(e => !(e is NamespaceEntry))) { |
||||
result.Add(entry); |
||||
} |
||||
AddUsing(result, projectContent.DefaultImports, projectContent); |
||||
AddContentsFromCallingClass(result, projectContent, callingClass); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds contents of all namespaces that this <paramref name="callingClass" /> imports to the <paramref name="result" /> list.
|
||||
/// Also adds contents of <paramref name="callingClass" />.
|
||||
/// </summary>
|
||||
public static void AddImportedNamespaceContents(List<ICompletionEntry> result, ICompilationUnit cu, IClass callingClass) |
||||
{ |
||||
IProjectContent projectContent = cu.ProjectContent; |
||||
projectContent.AddNamespaceContents(result, "", projectContent.Language, true); |
||||
IUsingScope scope = (callingClass != null) ? callingClass.UsingScope : cu.UsingScope; |
||||
while (scope != null) { |
||||
foreach (IUsing u in scope.Usings) |
||||
AddUsing(result, u, projectContent); |
||||
scope = scope.Parent; |
||||
} |
||||
AddUsing(result, projectContent.DefaultImports, projectContent); |
||||
AddContentsFromCallingClass(result, projectContent, callingClass); |
||||
} |
||||
|
||||
static void AddContentsFromCallingClass(List<ICompletionEntry> result, IProjectContent projectContent, IClass callingClass) |
||||
{ |
||||
if (callingClass == null) { |
||||
return; |
||||
} |
||||
// use HashSet so that Contains lookups are possible in O(1).
|
||||
HashSet<ICompletionEntry> existingResults = new HashSet<ICompletionEntry>(result); |
||||
string[] namespaceParts = callingClass.Namespace.Split('.'); |
||||
for (int i = 1; i <= namespaceParts.Length; i++) { |
||||
foreach (ICompletionEntry member in projectContent.GetNamespaceContents(string.Join(".", namespaceParts, 0, i))) { |
||||
if (!existingResults.Contains(member)) |
||||
result.Add(member); |
||||
} |
||||
} |
||||
IClass currentClass = callingClass; |
||||
do { |
||||
foreach (IClass innerClass in currentClass.GetCompoundClass().GetAccessibleTypes(currentClass)) { |
||||
if (!existingResults.Contains(innerClass)) |
||||
result.Add(innerClass); |
||||
} |
||||
currentClass = currentClass.DeclaringType; |
||||
} while (currentClass != null); |
||||
} |
||||
|
||||
public static void AddUsing(List<ICompletionEntry> result, IUsing u, IProjectContent projectContent) |
||||
{ |
||||
if (u == null) { |
||||
return; |
||||
} |
||||
bool importNamespaces = projectContent.Language.ImportNamespaces; |
||||
bool importClasses = projectContent.Language.CanImportClasses; |
||||
foreach (string name in u.Usings) { |
||||
if (importClasses) { |
||||
IClass c = projectContent.GetClass(name, 0); |
||||
if (c != null) { |
||||
ArrayList members = new ArrayList(); |
||||
IReturnType t = c.DefaultReturnType; |
||||
members.AddRange(t.GetMethods()); |
||||
members.AddRange(t.GetFields()); |
||||
members.AddRange(t.GetEvents()); |
||||
members.AddRange(t.GetProperties()); |
||||
foreach (IMember m in members) { |
||||
if (m.IsStatic && m.IsPublic) { |
||||
result.Add(m); |
||||
} |
||||
} |
||||
continue; |
||||
} |
||||
} |
||||
if (importNamespaces) { |
||||
string newName = null; |
||||
if (projectContent.DefaultImports != null) { |
||||
newName = projectContent.DefaultImports.SearchNamespace(name); |
||||
} |
||||
projectContent.AddNamespaceContents(result, newName ?? name, projectContent.Language, true); |
||||
} else { |
||||
foreach (ICompletionEntry o in projectContent.GetNamespaceContents(name)) { |
||||
if (!(o is NamespaceEntry)) |
||||
result.Add(o); |
||||
} |
||||
} |
||||
} |
||||
if (u.HasAliases) { |
||||
foreach (string alias in u.Aliases.Keys) { |
||||
result.Add(new AliasEntry(alias)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class AliasEntry : ICompletionEntry |
||||
{ |
||||
public string Name { get; private set; } |
||||
|
||||
public AliasEntry(string name) |
||||
{ |
||||
if (name == null) |
||||
throw new ArgumentNullException("name"); |
||||
this.Name = name; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return Name.GetHashCode(); |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
AliasEntry e = obj as AliasEntry; |
||||
return e != null && e.Name == this.Name; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return Name; |
||||
} |
||||
} |
||||
|
||||
public static ResolveResult GetResultFromDeclarationLine(IClass callingClass, IMethodOrProperty callingMember, int caretLine, int caretColumn, ExpressionResult expressionResult) |
||||
{ |
||||
string expression = expressionResult.Expression; |
||||
if (expression == null) return null; |
||||
if (callingClass == null) return null; |
||||
int pos = expression.IndexOf('('); |
||||
if (pos >= 0) { |
||||
expression = expression.Substring(0, pos); |
||||
} |
||||
expression = expression.Trim(); |
||||
// if (!callingClass.BodyRegion.IsInside(caretLine, caretColumn)
|
||||
// && callingClass.ProjectContent.Language.NameComparer.Equals(expression, callingClass.Name))
|
||||
// {
|
||||
// return new TypeResolveResult(callingClass, callingMember, callingClass);
|
||||
// }
|
||||
if (expressionResult.Context != ExpressionContext.Type) { |
||||
if (callingMember != null |
||||
&& !callingMember.BodyRegion.IsInside(caretLine, caretColumn) |
||||
&& (callingClass.ProjectContent.Language.NameComparer.Equals(expression, callingMember.Name) || |
||||
// For constructor definition, the expression is the constructor name (e.g. "MyClass") but the name of the member is "#ctor"
|
||||
(callingMember.Name == "#ctor" && callingClass.ProjectContent.Language.NameComparer.Equals(expression, callingClass.Name)) |
||||
) |
||||
) |
||||
{ |
||||
return new MemberResolveResult(callingClass, callingMember, callingMember); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static IList<IMethodOrProperty> FindAllExtensions(LanguageProperties language, IClass callingClass, bool searchInAllNamespaces = false) |
||||
{ |
||||
if (language == null) |
||||
throw new ArgumentNullException("language"); |
||||
if (callingClass == null) |
||||
throw new ArgumentNullException("callingClass"); |
||||
|
||||
HashSet<IMethodOrProperty> res = new HashSet<IMethodOrProperty>(); |
||||
|
||||
bool supportsExtensionMethods = language.SupportsExtensionMethods; |
||||
bool supportsExtensionProperties = language.SupportsExtensionProperties; |
||||
if (supportsExtensionMethods || supportsExtensionProperties) { |
||||
List<ICompletionEntry> list = new List<ICompletionEntry>(); |
||||
IMethod dummyMethod = new DefaultMethod("dummy", callingClass.ProjectContent.SystemTypes.Void, |
||||
ModifierEnum.Static, DomRegion.Empty, DomRegion.Empty, callingClass); |
||||
CtrlSpaceResolveHelper.AddContentsFromCalling(list, callingClass, dummyMethod); |
||||
if (searchInAllNamespaces) { |
||||
// search extension methods in all referenced projects, no matter the using section
|
||||
CtrlSpaceResolveHelper.AddReferencedProjectsContents(list, callingClass.CompilationUnit, callingClass); |
||||
} else { |
||||
CtrlSpaceResolveHelper.AddImportedNamespaceContents(list, callingClass.CompilationUnit, callingClass); |
||||
} |
||||
|
||||
bool searchExtensionsInClasses = language.SearchExtensionsInClasses; |
||||
foreach (object o in list) { |
||||
IMethodOrProperty mp = o as IMethodOrProperty; |
||||
if (mp != null && mp.IsExtensionMethod && |
||||
(supportsExtensionMethods && o is IMethod || supportsExtensionProperties && o is IProperty)) |
||||
{ |
||||
res.Add(mp); |
||||
} else if (searchExtensionsInClasses && o is IClass) { |
||||
IClass c = o as IClass; |
||||
if (c.HasExtensionMethods) { |
||||
if (supportsExtensionProperties) { |
||||
foreach (IProperty p in c.Properties) { |
||||
if (p.IsExtensionMethod) |
||||
res.Add(p); |
||||
} |
||||
} |
||||
if (supportsExtensionMethods) { |
||||
foreach (IMethod m in c.Methods) { |
||||
if (m.IsExtensionMethod) |
||||
res.Add(m); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return res.ToList(); |
||||
} // FindAllExtensions
|
||||
} // CtrlSpaceResolveHelper class
|
||||
} |
@ -1,129 +0,0 @@
@@ -1,129 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
public static class DiffUtility |
||||
{ |
||||
public static int GetAddedItems(IList original, IList changed, IList result) |
||||
{ |
||||
return GetAddedItems(original, changed, result, Comparer.Default); |
||||
} |
||||
|
||||
public static int GetAddedItems(IList original, IList changed, IList result, IComparer comparer) |
||||
{ |
||||
int count = 0; |
||||
if(changed != null && result != null) { |
||||
if(original == null) { |
||||
foreach(object item in changed) { |
||||
result.Add(item); |
||||
} |
||||
count = changed.Count; |
||||
} |
||||
else { |
||||
foreach(object item in changed) { |
||||
if(!Contains(original, item, comparer)) { |
||||
result.Add(item); |
||||
count++; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return count; |
||||
} |
||||
|
||||
public static int GetRemovedItems(IList original, IList changed, IList result) |
||||
{ |
||||
return GetRemovedItems(original, changed, result, Comparer.Default); |
||||
} |
||||
|
||||
public static int GetRemovedItems(IList original, IList changed, IList result, IComparer comparer) |
||||
{ |
||||
return GetAddedItems(changed, original, result, comparer); |
||||
} |
||||
|
||||
static bool Contains(IList list, object value, IComparer comparer) |
||||
{ |
||||
foreach(object item in list) { |
||||
if(0 == comparer.Compare(item, value)) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
static public int Compare(IList a, IList b) |
||||
{ |
||||
return Compare(a, b, Comparer.Default); |
||||
} |
||||
|
||||
static public int Compare<T>(IList<T> a, IList<T> b) |
||||
{ |
||||
return Compare(a, b, Comparer.Default); |
||||
} |
||||
|
||||
static public int Compare<T>(IList<T> a, IList<T> b, IComparer comparer) |
||||
{ |
||||
if (a == null || b == null) { |
||||
return 1; |
||||
} |
||||
if (a.Count != b.Count) { |
||||
return Math.Sign(a.Count - b.Count); |
||||
} |
||||
int limit = (a.Count < b.Count) ? a.Count : b.Count; |
||||
for(int i=0; i < limit; i++) { |
||||
if (a[i] is IComparable && b[i] is IComparable) { |
||||
int cmp = comparer.Compare(a[i], b[i]); |
||||
if (cmp != 0) { |
||||
return cmp; |
||||
} |
||||
} |
||||
} |
||||
return a.Count - b.Count; |
||||
} |
||||
|
||||
static public int Compare(IList a, IList b, IComparer comparer) |
||||
{ |
||||
if (a == null || b == null) { |
||||
return 1; |
||||
} |
||||
if (a.Count != b.Count) { |
||||
return Math.Sign(a.Count - b.Count); |
||||
} |
||||
int limit = (a.Count < b.Count) ? a.Count : b.Count; |
||||
for(int i=0; i < limit; i++) { |
||||
if (a[i] is IComparable && b[i] is IComparable) { |
||||
int cmp = comparer.Compare(a[i], b[i]); |
||||
if (cmp != 0) { |
||||
return cmp; |
||||
} |
||||
} |
||||
} |
||||
return a.Count - b.Count; |
||||
} |
||||
|
||||
static public int Compare(SortedList a, SortedList b) |
||||
{ |
||||
return Compare(a, b, Comparer.Default); |
||||
} |
||||
|
||||
static public int Compare(SortedList a, SortedList b, IComparer comparer) |
||||
{ |
||||
if (a == null || b == null) { |
||||
return 1; |
||||
} |
||||
int cmp; |
||||
int limit = (a.Count < b.Count) ? a.Count : b.Count; |
||||
for(int i=0; i < limit; i++) { |
||||
if(0 != (cmp = comparer.Compare(a.GetByIndex(i), b.GetByIndex(i)))) { |
||||
return cmp; |
||||
} |
||||
} |
||||
return a.Count - b.Count; |
||||
} |
||||
} |
||||
} |
@ -1,41 +0,0 @@
@@ -1,41 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
static class DomCache |
||||
{ |
||||
/// <summary>
|
||||
/// Clear the static searchclass cache. You should call this method
|
||||
/// whenever the DOM changes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// automatically called by DefaultProjectContent.UpdateCompilationUnit
|
||||
/// and DefaultProjectContent.OnReferencedContentsChanged.
|
||||
/// </remarks>
|
||||
public static void Clear() |
||||
{ |
||||
List<Action> oldActions; |
||||
lock (lockObject) { |
||||
oldActions = actions; |
||||
actions = new List<Action>(); |
||||
} |
||||
foreach (Action a in oldActions) { |
||||
a(); |
||||
} |
||||
} |
||||
|
||||
static readonly object lockObject = new Object(); |
||||
static List<Action> actions = new List<Action>(); |
||||
|
||||
public static void RegisterForClear(Action action) |
||||
{ |
||||
lock (lockObject) { |
||||
actions.Add(action); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,382 +0,0 @@
@@ -1,382 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.CodeDom; |
||||
|
||||
namespace ICSharpCode.EasyCodeDom |
||||
{ |
||||
public static class Easy |
||||
{ |
||||
public static CodeTypeReference TypeRef(Type type) |
||||
{ |
||||
return new CodeTypeReference(type, CodeTypeReferenceOptions.GlobalReference); |
||||
} |
||||
public static CodeTypeReference TypeRef(CodeTypeDeclaration type) |
||||
{ |
||||
return new CodeTypeReference(type.Name); |
||||
} |
||||
public static CodeTypeReference TypeRef(string typeName, params string[] typeArguments) |
||||
{ |
||||
CodeTypeReference tr = new CodeTypeReference(typeName); |
||||
foreach (string ta in typeArguments) { |
||||
tr.TypeArguments.Add(ta); |
||||
} |
||||
return tr; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the CodeExpression for any primitive value that can be expressed as literal.
|
||||
/// Also works for enumeration values.
|
||||
/// </summary>
|
||||
public static CodeExpression Prim(object literalValue) |
||||
{ |
||||
if (literalValue is Enum) { |
||||
return Type(literalValue.GetType()).Field(literalValue.ToString()); |
||||
} else { |
||||
return new CodePrimitiveExpression(literalValue); |
||||
} |
||||
} |
||||
|
||||
public static CodeTypeReferenceExpression Type(Type type) |
||||
{ |
||||
return Type(TypeRef(type)); |
||||
} |
||||
public static CodeTypeReferenceExpression Type(CodeTypeReference type) |
||||
{ |
||||
return new CodeTypeReferenceExpression(type); |
||||
} |
||||
public static CodeTypeReferenceExpression Type(string type) |
||||
{ |
||||
return Type(new CodeTypeReference(type)); |
||||
} |
||||
|
||||
public static CodeTypeOfExpression TypeOf(Type type) |
||||
{ |
||||
return TypeOf(TypeRef(type)); |
||||
} |
||||
public static CodeTypeOfExpression TypeOf(CodeTypeReference type) |
||||
{ |
||||
return new CodeTypeOfExpression(type); |
||||
} |
||||
|
||||
public static CodeObjectCreateExpression New(Type type, params CodeExpression[] arguments) |
||||
{ |
||||
return New(TypeRef(type), arguments); |
||||
} |
||||
public static CodeObjectCreateExpression New(CodeTypeReference type, params CodeExpression[] arguments) |
||||
{ |
||||
return new CodeObjectCreateExpression(type, arguments); |
||||
} |
||||
|
||||
public static CodeVariableReferenceExpression Var(string name) |
||||
{ |
||||
return new CodeVariableReferenceExpression(name); |
||||
} |
||||
|
||||
public static CodeBinaryOperatorExpression Binary(CodeExpression left, |
||||
CodeBinaryOperatorType op, |
||||
CodeExpression right) |
||||
{ |
||||
return new CodeBinaryOperatorExpression(left, op, right); |
||||
} |
||||
|
||||
public static CodeThisReferenceExpression This { |
||||
get { |
||||
return new CodeThisReferenceExpression(); |
||||
} |
||||
} |
||||
|
||||
public static CodeBaseReferenceExpression Base { |
||||
get { |
||||
return new CodeBaseReferenceExpression(); |
||||
} |
||||
} |
||||
|
||||
public static CodePropertySetValueReferenceExpression Value { |
||||
get { |
||||
return new CodePropertySetValueReferenceExpression(); |
||||
} |
||||
} |
||||
|
||||
public static CodePrimitiveExpression Null { |
||||
get { |
||||
return new CodePrimitiveExpression(null); |
||||
} |
||||
} |
||||
|
||||
public static void AddSummary(CodeTypeMember member, string summary) |
||||
{ |
||||
member.Comments.Add(new CodeCommentStatement("<summary>", true)); |
||||
member.Comments.Add(new CodeCommentStatement(summary, true)); |
||||
member.Comments.Add(new CodeCommentStatement("</summary>", true)); |
||||
} |
||||
|
||||
internal static CodeAttributeDeclaration AddAttribute(CodeAttributeDeclarationCollection col, |
||||
CodeTypeReference type, |
||||
CodeExpression[] arguments) |
||||
{ |
||||
CodeAttributeArgument[] attributeArguments = new CodeAttributeArgument[arguments.Length]; |
||||
for (int i = 0; i < arguments.Length; i++) { |
||||
attributeArguments[i] = new CodeAttributeArgument(arguments[i]); |
||||
} |
||||
CodeAttributeDeclaration cad = new CodeAttributeDeclaration(type, attributeArguments); |
||||
col.Add(cad); |
||||
return cad; |
||||
} |
||||
} |
||||
|
||||
public static class ExtensionMethods |
||||
{ |
||||
public static CodeMethodInvokeExpression InvokeMethod(this CodeExpression expr, string name, params CodeExpression[] arguments) |
||||
{ |
||||
return new CodeMethodInvokeExpression(expr, name, arguments); |
||||
} |
||||
|
||||
public static CodeCastExpression CastTo(this CodeExpression expr, Type type) |
||||
{ |
||||
return expr.CastTo(Easy.TypeRef(type)); |
||||
} |
||||
public static CodeCastExpression CastTo(this CodeExpression expr, CodeTypeReference type) |
||||
{ |
||||
return new CodeCastExpression(type, expr); |
||||
} |
||||
|
||||
public static CodeIndexerExpression Index(this CodeExpression expr, params CodeExpression[] indices) |
||||
{ |
||||
return new CodeIndexerExpression(expr, indices); |
||||
} |
||||
|
||||
public static CodeFieldReferenceExpression Field(this CodeExpression expr, string name) |
||||
{ |
||||
return new CodeFieldReferenceExpression(expr, name); |
||||
} |
||||
|
||||
public static CodePropertyReferenceExpression Property(this CodeExpression expr, string name) |
||||
{ |
||||
return new CodePropertyReferenceExpression(expr, name); |
||||
} |
||||
|
||||
public static CodeNamespace AddNamespace(this CodeCompileUnit ccu, string name) |
||||
{ |
||||
CodeNamespace n = new CodeNamespace(name); |
||||
ccu.Namespaces.Add(n); |
||||
return n; |
||||
} |
||||
|
||||
public static CodeTypeDeclaration AddType(this CodeNamespace ns, string name) |
||||
{ |
||||
CodeTypeDeclaration n = new CodeTypeDeclaration(name); |
||||
ns.Types.Add(n); |
||||
return n; |
||||
} |
||||
|
||||
public static CodeNamespaceImport AddImport(this CodeNamespace ns, string nameSpace) |
||||
{ |
||||
CodeNamespaceImport cni = new CodeNamespaceImport(nameSpace); |
||||
ns.Imports.Add(cni); |
||||
return cni; |
||||
} |
||||
|
||||
public static CodeMemberField AddField(this CodeTypeDeclaration typeDecl, Type type, string name) |
||||
{ |
||||
return typeDecl.AddField(Easy.TypeRef(type), name); |
||||
} |
||||
public static CodeMemberField AddField(this CodeTypeDeclaration typeDecl, CodeTypeReference type, string name) |
||||
{ |
||||
CodeMemberField f = new CodeMemberField(type, name); |
||||
typeDecl.Members.Add(f); |
||||
return f; |
||||
} |
||||
|
||||
public static EasyProperty AddProperty(this CodeTypeDeclaration typeDecl, Type type, string name) |
||||
{ |
||||
return AddProperty(typeDecl, Easy.TypeRef(type), name); |
||||
} |
||||
public static EasyProperty AddProperty(this CodeTypeDeclaration typeDecl, CodeTypeReference type, string name) |
||||
{ |
||||
EasyProperty p = new EasyProperty(type, name); |
||||
typeDecl.Members.Add(p); |
||||
if (typeDecl.IsInterface == false) { |
||||
p.Attributes = MemberAttributes.Public | MemberAttributes.Final; |
||||
} |
||||
return p; |
||||
} |
||||
|
||||
public static EasyProperty AddProperty(this CodeTypeDeclaration typeDecl, CodeMemberField field, string name) |
||||
{ |
||||
EasyProperty p = AddProperty(typeDecl, field.Type, name); |
||||
p.Getter.Return(new CodeVariableReferenceExpression(field.Name)); |
||||
p.Attributes |= field.Attributes & MemberAttributes.Static; // copy static flag
|
||||
return p; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds a method with return type <c>void</c> and attributes=Public|Final to this type.
|
||||
/// </summary>
|
||||
public static EasyMethod AddMethod(this CodeTypeDeclaration typeDecl, string name) |
||||
{ |
||||
return AddMethod(typeDecl, Easy.TypeRef(typeof(void)), name); |
||||
} |
||||
/// <summary>
|
||||
/// Adds a method with return type <paramref name="type"/> and attributes=Public|Final to this type.
|
||||
/// </summary>
|
||||
public static EasyMethod AddMethod(this CodeTypeDeclaration typeDecl, Type type, string name) |
||||
{ |
||||
return AddMethod(typeDecl, Easy.TypeRef(type), name); |
||||
} |
||||
/// <summary>
|
||||
/// Adds a method with return type <paramref name="type"/> and attributes=Public|Final to this type.
|
||||
/// </summary>
|
||||
public static EasyMethod AddMethod(this CodeTypeDeclaration typeDecl, CodeTypeReference type, string name) |
||||
{ |
||||
EasyMethod p = new EasyMethod(type, name); |
||||
typeDecl.Members.Add(p); |
||||
if (typeDecl.IsInterface == false) { |
||||
p.Attributes = MemberAttributes.Public | MemberAttributes.Final; |
||||
} |
||||
return p; |
||||
} |
||||
|
||||
public static CodeAttributeDeclaration AddAttribute(this CodeTypeMember typeMember, Type type, params CodeExpression[] arguments) |
||||
{ |
||||
return Easy.AddAttribute(typeMember.CustomAttributes, Easy.TypeRef(type), arguments); |
||||
} |
||||
public static CodeAttributeDeclaration AddAttribute(this CodeTypeMember typeMember, CodeTypeReference type, params CodeExpression[] arguments) |
||||
{ |
||||
return Easy.AddAttribute(typeMember.CustomAttributes, type, arguments); |
||||
} |
||||
} |
||||
|
||||
public class EasyProperty : CodeMemberProperty |
||||
{ |
||||
EasyBlock getter, setter; |
||||
|
||||
public EasyProperty() |
||||
{ |
||||
getter = new EasyBlock(this.GetStatements); |
||||
setter = new EasyBlock(this.SetStatements); |
||||
} |
||||
|
||||
public EasyProperty(CodeTypeReference type, string name) : this() |
||||
{ |
||||
this.Type = type; |
||||
this.Name = name; |
||||
} |
||||
|
||||
public EasyBlock Getter { |
||||
get { return getter; } |
||||
} |
||||
|
||||
public EasyBlock Setter { |
||||
get { return setter; } |
||||
} |
||||
} |
||||
|
||||
public class EasyMethod : CodeMemberMethod |
||||
{ |
||||
EasyBlock body; |
||||
|
||||
public EasyMethod() |
||||
{ |
||||
body = new EasyBlock(this.Statements); |
||||
} |
||||
|
||||
public EasyMethod(CodeTypeReference type, string name) : this() |
||||
{ |
||||
this.ReturnType = type; |
||||
this.Name = name; |
||||
} |
||||
|
||||
public CodeParameterDeclarationExpression AddParameter(Type type, string name) |
||||
{ |
||||
return AddParameter(Easy.TypeRef(type), name); |
||||
} |
||||
public CodeParameterDeclarationExpression AddParameter(CodeTypeReference type, string name) |
||||
{ |
||||
CodeParameterDeclarationExpression cpde; |
||||
cpde = new CodeParameterDeclarationExpression(type, name); |
||||
this.Parameters.Add(cpde); |
||||
return cpde; |
||||
} |
||||
|
||||
public EasyBlock Body { |
||||
get { return body; } |
||||
} |
||||
} |
||||
|
||||
public sealed class EasyBlock |
||||
{ |
||||
readonly CodeStatementCollection csc; |
||||
|
||||
public EasyBlock(CodeStatementCollection csc) |
||||
{ |
||||
this.csc = csc; |
||||
} |
||||
|
||||
public CodeMethodReturnStatement Return(CodeExpression expr) |
||||
{ |
||||
CodeMethodReturnStatement st = new CodeMethodReturnStatement(expr); |
||||
csc.Add(st); |
||||
return st; |
||||
} |
||||
|
||||
public CodeThrowExceptionStatement Throw(CodeExpression expr) |
||||
{ |
||||
CodeThrowExceptionStatement st = new CodeThrowExceptionStatement(expr); |
||||
csc.Add(st); |
||||
return st; |
||||
} |
||||
|
||||
public CodeAssignStatement Assign(CodeExpression lhs, CodeExpression rhs) |
||||
{ |
||||
CodeAssignStatement st = new CodeAssignStatement(lhs, rhs); |
||||
csc.Add(st); |
||||
return st; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Execute one expression as statement.
|
||||
/// </summary>
|
||||
public CodeExpressionStatement Add(CodeExpression expr) |
||||
{ |
||||
CodeExpressionStatement st = new CodeExpressionStatement(expr); |
||||
csc.Add(st); |
||||
return st; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds the statement.
|
||||
/// </summary>
|
||||
public CodeStatement Add(CodeStatement st) |
||||
{ |
||||
csc.Add(st); |
||||
return st; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Invoke a method on target as statement.
|
||||
/// </summary>
|
||||
public CodeExpressionStatement InvokeMethod(CodeExpression target, string name, params CodeExpression[] arguments) |
||||
{ |
||||
return Add(new CodeMethodInvokeExpression(target, name, arguments)); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Declares a local variable.
|
||||
/// </summary>
|
||||
public CodeVariableDeclarationStatement DeclareVariable(Type type, string name) |
||||
{ |
||||
return DeclareVariable(Easy.TypeRef(type), name); |
||||
} |
||||
/// <summary>
|
||||
/// Declares a local variable.
|
||||
/// </summary>
|
||||
public CodeVariableDeclarationStatement DeclareVariable(CodeTypeReference type, string name) |
||||
{ |
||||
CodeVariableDeclarationStatement st = new CodeVariableDeclarationStatement(type, name); |
||||
csc.Add(st); |
||||
return st; |
||||
} |
||||
} |
||||
} |
@ -1,486 +0,0 @@
@@ -1,486 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Class describing a context in which an expression can be.
|
||||
/// Serves as filter for code completion results, but the contexts exposed as static fields
|
||||
/// can also be used as a kind of enumeration for special behaviour in the resolver.
|
||||
/// </summary>
|
||||
public abstract class ExpressionContext |
||||
{ |
||||
#region Instance members
|
||||
public abstract bool ShowEntry(ICompletionEntry o); |
||||
|
||||
protected bool readOnly = true; |
||||
object suggestedItem; |
||||
|
||||
/// <summary>
|
||||
/// Gets if the expression is in the context of an object creation.
|
||||
/// </summary>
|
||||
public virtual bool IsObjectCreation { |
||||
get { |
||||
return false; |
||||
} |
||||
set { |
||||
if (value) |
||||
throw new NotSupportedException(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the default item that should be included in a code completion popup
|
||||
/// in this context and selected as default value.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// "List<TypeName> var = new *expr*();" has as suggested item the pseudo-class
|
||||
/// "List<TypeName>".
|
||||
/// </example>
|
||||
public object SuggestedItem { |
||||
get { |
||||
return suggestedItem; |
||||
} |
||||
set { |
||||
if (readOnly) |
||||
throw new NotSupportedException(); |
||||
suggestedItem = value; |
||||
} |
||||
} |
||||
|
||||
public virtual bool IsTypeContext { |
||||
get { return false; } |
||||
} |
||||
#endregion
|
||||
|
||||
#region VB specific contexts (public static fields) * MOVE TO ANOTHER CLASS *
|
||||
/// <summary>The context expects a new parameter declaration</summary>
|
||||
/// <example>Function Test(*expr*, *expr*, ...)</example>
|
||||
public static readonly ExpressionContext Parameter = new DefaultExpressionContext("Parameter"); |
||||
#endregion
|
||||
|
||||
#region Default contexts (public static fields)
|
||||
/// <summary>Default/unknown context</summary>
|
||||
public readonly static ExpressionContext Default = new DefaultExpressionContext("Default"); |
||||
|
||||
/// <summary>The context expects the base type of an enum.</summary>
|
||||
/// <example>enum Name : *expr* {}</example>
|
||||
public readonly static ExpressionContext EnumBaseType = new EnumBaseTypeExpressionContext(); |
||||
|
||||
/// <summary>Context expects a non-sealed type or interface</summary>
|
||||
/// <example>class C : *expr* {}</example>
|
||||
public readonly static ExpressionContext InheritableType = new InheritableTypeExpressionContext(); |
||||
|
||||
/// <summary>Context expects a namespace name</summary>
|
||||
/// <example>using *expr*;</example>
|
||||
public readonly static ExpressionContext Namespace = new ImportableExpressionContext(false); |
||||
|
||||
/// <summary>Context expects an importable type (namespace or class with public static members)</summary>
|
||||
/// <example>Imports *expr*;</example>
|
||||
public readonly static ExpressionContext Importable = new ImportableExpressionContext(true); |
||||
|
||||
/// <summary>Context expects a type name</summary>
|
||||
/// <example>typeof(*expr*)</example>
|
||||
public readonly static ExpressionContext Type = new TypeExpressionContext(null, false, true); |
||||
|
||||
/// <summary>Context expects the name of a non-static, non-void type</summary>
|
||||
/// <example>is *expr*, *expr* variableName</example>
|
||||
public readonly static ExpressionContext NonStaticNonVoidType = new NonStaticTypeExpressionContext("NonStaticType", false); |
||||
|
||||
/// <summary>Context expects a non-abstract type that has accessible constructors</summary>
|
||||
/// <example>new *expr*();</example>
|
||||
/// <remarks>When using this context, a resolver should treat the expression as object creation,
|
||||
/// even when the keyword "new" is not part of the expression.</remarks>
|
||||
public readonly static ExpressionContext ObjectCreation = new TypeExpressionContext(null, true, true); |
||||
|
||||
/// <summary>Context expects a type deriving from System.Attribute.</summary>
|
||||
/// <example>[*expr*()]</example>
|
||||
/// <remarks>When using this context, a resolver should try resolving typenames with an
|
||||
/// appended "Attribute" suffix and treat "invocations" of the attribute type as
|
||||
/// object creation.</remarks>
|
||||
public readonly static ExpressionContext Attribute = new AttributeExpressionContext(); |
||||
|
||||
/// <summary>Context expects a type name which has special base type</summary>
|
||||
/// <param name="baseClass">The class the expression must derive from.</param>
|
||||
/// <param name="isObjectCreation">Specifies whether classes must be constructable.</param>
|
||||
/// <example>catch(*expr* ...), using(*expr* ...), throw new *expr*();</example>
|
||||
public static ExpressionContext TypeDerivingFrom(IReturnType baseType, bool isObjectCreation) |
||||
{ |
||||
return new TypeExpressionContext(baseType, isObjectCreation, false); |
||||
} |
||||
|
||||
/// <summary>Context expects an interface</summary>
|
||||
/// <example>interface C : *expr* {}</example>
|
||||
/// <example>Implements *expr*</example>
|
||||
public readonly static ExpressionContext Interface = new ClassTypeExpressionContext(ClassType.Interface); |
||||
|
||||
/// <summary>Context expects a delegate</summary>
|
||||
/// <example>public event *expr*</example>
|
||||
public readonly static ExpressionContext DelegateType = new ClassTypeExpressionContext(ClassType.Delegate); |
||||
|
||||
/// <summary>The context expects a new identifier</summary>
|
||||
/// <example>class *expr* {}; string *expr*;</example>
|
||||
public readonly static ExpressionContext IdentifierExpected = new DefaultExpressionContext("IdentifierExpected"); |
||||
|
||||
/// <summary>The context is outside of any type declaration, expecting a global-level keyword.</summary>
|
||||
public readonly static ExpressionContext Global = new DefaultExpressionContext("Global"); |
||||
|
||||
/// <summary>The context is the body of a type declaration.</summary>
|
||||
public readonly static ExpressionContext TypeDeclaration = new ExpressionContext.NonStaticTypeExpressionContext("TypeDeclaration", true); |
||||
|
||||
/// <summary>The context is the body of a method.</summary>
|
||||
/// <example>void Main () { *expr* }</example>
|
||||
public readonly static ExpressionContext MethodBody = new ExpressionContext.DefaultExpressionContext("MethodBody"); |
||||
#endregion
|
||||
|
||||
#region DefaultExpressionContext
|
||||
internal sealed class DefaultExpressionContext : ExpressionContext |
||||
{ |
||||
string name; |
||||
|
||||
public DefaultExpressionContext(string name) |
||||
{ |
||||
this.name = name; |
||||
} |
||||
|
||||
public override bool ShowEntry(ICompletionEntry o) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return "[" + GetType().Name + ": " + name + "]"; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region NamespaceExpressionContext
|
||||
sealed class ImportableExpressionContext : ExpressionContext |
||||
{ |
||||
bool allowImportClasses; |
||||
|
||||
public ImportableExpressionContext(bool allowImportClasses) |
||||
{ |
||||
this.allowImportClasses = allowImportClasses; |
||||
} |
||||
|
||||
public override bool ShowEntry(ICompletionEntry o) |
||||
{ |
||||
if (!(o is IEntity)) |
||||
return true; |
||||
IClass c = o as IClass; |
||||
if (allowImportClasses && c != null) { |
||||
return c.HasPublicOrInternalStaticMembers; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return "[" + GetType().Name + " AllowImportClasses=" + allowImportClasses.ToString() + "]"; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region TypeExpressionContext
|
||||
sealed class TypeExpressionContext : ExpressionContext |
||||
{ |
||||
IClass baseClass; |
||||
bool isObjectCreation; |
||||
|
||||
public TypeExpressionContext(IReturnType baseType, bool isObjectCreation, bool readOnly) |
||||
{ |
||||
if (baseType != null) |
||||
baseClass = baseType.GetUnderlyingClass(); |
||||
this.isObjectCreation = isObjectCreation; |
||||
this.readOnly = readOnly; |
||||
} |
||||
|
||||
public override bool ShowEntry(ICompletionEntry o) |
||||
{ |
||||
if (!(o is IEntity)) |
||||
return true; |
||||
IClass c = o as IClass; |
||||
if (c == null) |
||||
return false; |
||||
if (isObjectCreation) { |
||||
if (c.IsAbstract || c.IsStatic) return false; |
||||
if (c.ClassType == ClassType.Enum || c.ClassType == ClassType.Interface) |
||||
return false; |
||||
} |
||||
if (baseClass == null) |
||||
return true; |
||||
return c.IsTypeInInheritanceTree(baseClass); |
||||
} |
||||
|
||||
public override bool IsObjectCreation { |
||||
get { |
||||
return isObjectCreation; |
||||
} |
||||
set { |
||||
if (readOnly && value != isObjectCreation) |
||||
throw new NotSupportedException(); |
||||
isObjectCreation = value; |
||||
} |
||||
} |
||||
|
||||
public override bool IsTypeContext { |
||||
get { return true; } |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
if (baseClass != null) |
||||
return "[" + GetType().Name + ": " + baseClass.FullyQualifiedName |
||||
+ " IsObjectCreation=" + IsObjectCreation + "]"; |
||||
else |
||||
return "[" + GetType().Name + " IsObjectCreation=" + IsObjectCreation + "]"; |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
TypeExpressionContext o = obj as TypeExpressionContext; |
||||
return o != null && object.Equals(baseClass, o.baseClass) && IsObjectCreation == o.IsObjectCreation; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return ((baseClass != null) ? baseClass.GetHashCode() : 0) |
||||
^ isObjectCreation.GetHashCode(); |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region CombinedExpressionContext
|
||||
public static ExpressionContext operator | (ExpressionContext a, ExpressionContext b) |
||||
{ |
||||
return new CombinedExpressionContext(0, a, b); |
||||
} |
||||
|
||||
public static ExpressionContext operator & (ExpressionContext a, ExpressionContext b) |
||||
{ |
||||
return new CombinedExpressionContext(1, a, b); |
||||
} |
||||
|
||||
public static ExpressionContext operator ^ (ExpressionContext a, ExpressionContext b) |
||||
{ |
||||
return new CombinedExpressionContext(2, a, b); |
||||
} |
||||
|
||||
sealed class CombinedExpressionContext : ExpressionContext |
||||
{ |
||||
byte opType; // 0 = or ; 1 = and ; 2 = xor
|
||||
ExpressionContext a; |
||||
ExpressionContext b; |
||||
|
||||
public CombinedExpressionContext(byte opType, ExpressionContext a, ExpressionContext b) |
||||
{ |
||||
if (a == null) |
||||
throw new ArgumentNullException("a"); |
||||
if (b == null) |
||||
throw new ArgumentNullException("a"); |
||||
this.opType = opType; |
||||
this.a = a; |
||||
this.b = b; |
||||
} |
||||
|
||||
public override bool ShowEntry(ICompletionEntry o) |
||||
{ |
||||
if (opType == 0) |
||||
return a.ShowEntry(o) || b.ShowEntry(o); |
||||
else if (opType == 1) |
||||
return a.ShowEntry(o) && b.ShowEntry(o); |
||||
else |
||||
return a.ShowEntry(o) ^ b.ShowEntry(o); |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
string op; |
||||
if (opType == 0) |
||||
op = " OR "; |
||||
else if (opType == 1) |
||||
op = " AND "; |
||||
else |
||||
op = " XOR "; |
||||
return "[" + GetType().Name + ": " + a + op + b + "]"; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
int hashCode = 0; |
||||
unchecked { |
||||
hashCode += opType.GetHashCode(); |
||||
if (a != null) hashCode += a.GetHashCode() * 3; |
||||
if (b != null) hashCode += b.GetHashCode() * 181247123; |
||||
} |
||||
return hashCode; |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
CombinedExpressionContext cec = obj as CombinedExpressionContext; |
||||
return cec != null && this.opType == cec.opType && object.Equals(this.a, cec.a) && object.Equals(this.b, cec.b); |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region EnumBaseTypeExpressionContext
|
||||
sealed class EnumBaseTypeExpressionContext : ExpressionContext |
||||
{ |
||||
public override bool ShowEntry(ICompletionEntry o) |
||||
{ |
||||
IClass c = o as IClass; |
||||
if (c != null) { |
||||
// use this hack to show dummy classes like "short"
|
||||
// (go from the dummy class to the real class)
|
||||
if (c.Methods.Count > 0) { |
||||
c = c.Methods[0].DeclaringType; |
||||
} |
||||
switch (c.FullyQualifiedName) { |
||||
case "System.Byte": |
||||
case "System.SByte": |
||||
case "System.Int16": |
||||
case "System.UInt16": |
||||
case "System.Int32": |
||||
case "System.UInt32": |
||||
case "System.Int64": |
||||
case "System.UInt64": |
||||
return true; |
||||
default: |
||||
return false; |
||||
} |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return "[" + GetType().Name + "]"; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region AttributeExpressionContext
|
||||
sealed class AttributeExpressionContext : ExpressionContext |
||||
{ |
||||
public override bool ShowEntry(ICompletionEntry o) |
||||
{ |
||||
if (!(o is IEntity)) |
||||
return true; |
||||
IClass c = o as IClass; |
||||
if (c != null && !c.IsAbstract) { |
||||
return c.IsTypeInInheritanceTree(c.ProjectContent.SystemTypes.Attribute.GetUnderlyingClass()); |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override bool IsTypeContext { |
||||
get { return true; } |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return "[" + GetType().Name + "]"; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region InheritableTypeExpressionContext
|
||||
sealed class InheritableTypeExpressionContext : ExpressionContext |
||||
{ |
||||
public override bool ShowEntry(ICompletionEntry o) |
||||
{ |
||||
if (!(o is IEntity)) return true; |
||||
IClass c = o as IClass; |
||||
if (c != null) { |
||||
foreach (IClass innerClass in c.InnerClasses) { |
||||
if (ShowEntry(innerClass)) return true; |
||||
} |
||||
if (c.ClassType == ClassType.Interface) return true; |
||||
if (c.ClassType == ClassType.Class) { |
||||
if (!c.IsSealed && !c.IsStatic) return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return "[" + GetType().Name + "]"; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region ClassTypeExpressionContext
|
||||
sealed class ClassTypeExpressionContext : ExpressionContext |
||||
{ |
||||
readonly ClassType expectedType; |
||||
|
||||
public ClassTypeExpressionContext(ClassType expectedType) |
||||
{ |
||||
this.expectedType = expectedType; |
||||
} |
||||
|
||||
public override bool ShowEntry(ICompletionEntry o) |
||||
{ |
||||
if (!(o is IEntity)) return true; |
||||
IClass c = o as IClass; |
||||
if (c != null) { |
||||
foreach (IClass innerClass in c.InnerClasses) { |
||||
if (ShowEntry(innerClass)) return true; |
||||
} |
||||
if (c.ClassType == expectedType) return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return "[" + GetType().Name + " expectedType=" + expectedType.ToString() + "]"; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region NonStaticTypeExpressionContext
|
||||
internal sealed class NonStaticTypeExpressionContext : ExpressionContext |
||||
{ |
||||
string name; |
||||
bool allowVoid; |
||||
|
||||
public NonStaticTypeExpressionContext(string name, bool allowVoid) |
||||
{ |
||||
this.name = name; |
||||
this.allowVoid = allowVoid; |
||||
} |
||||
|
||||
public override bool ShowEntry(ICompletionEntry o) |
||||
{ |
||||
if (!(o is IEntity)) return true; |
||||
IClass c = o as IClass; |
||||
if (c != null) { |
||||
if (!allowVoid) { |
||||
if (c.FullyQualifiedName == "System.Void" || c.FullyQualifiedName == "void") return false; |
||||
} |
||||
|
||||
foreach (IClass innerClass in c.InnerClasses) { |
||||
if (ShowEntry(innerClass)) return true; |
||||
} |
||||
if (!c.IsStatic && c.ClassType != ClassType.Module) return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return "[" + GetType().Name + " " + name + "]"; |
||||
} |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
@ -1,104 +0,0 @@
@@ -1,104 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
static class ExtensionMethods |
||||
{ |
||||
public static void AddRange(this ArrayList arrayList, IEnumerable elements) |
||||
{ |
||||
foreach (object o in elements) |
||||
arrayList.Add(o); |
||||
} |
||||
|
||||
public static void AddRange<T>(this ICollection<T> list, IEnumerable<T> elements) |
||||
{ |
||||
foreach (T o in elements) |
||||
list.Add(o); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Converts a recursive data structure into a flat list.
|
||||
/// </summary>
|
||||
/// <param name="input">The root elements of the recursive data structure.</param>
|
||||
/// <param name="recursive">The function that gets the children of an element.</param>
|
||||
/// <returns>Iterator that enumerates the tree structure in preorder.</returns>
|
||||
public static IEnumerable<T> Flatten<T>(this IEnumerable<T> input, Func<T, IEnumerable<T>> recursion) |
||||
{ |
||||
Stack<IEnumerator<T>> stack = new Stack<IEnumerator<T>>(); |
||||
try { |
||||
stack.Push(input.GetEnumerator()); |
||||
while (stack.Count > 0) { |
||||
while (stack.Peek().MoveNext()) { |
||||
T element = stack.Peek().Current; |
||||
yield return element; |
||||
IEnumerable<T> children = recursion(element); |
||||
if (children != null) { |
||||
stack.Push(children.GetEnumerator()); |
||||
} |
||||
} |
||||
stack.Pop().Dispose(); |
||||
} |
||||
} finally { |
||||
while (stack.Count > 0) { |
||||
stack.Pop().Dispose(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static IEnumerable<IUsing> GetAllUsings(this ICompilationUnit cu) |
||||
{ |
||||
return (new[]{cu.UsingScope}).Flatten(s=>s.ChildScopes).SelectMany(s=>s.Usings); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Publicly visible helper methods.
|
||||
/// </summary>
|
||||
public static class ExtensionMethodsPublic |
||||
{ |
||||
// the difference between IClass and IReturnType is that IClass only contains the members
|
||||
// that are declared in this very class,
|
||||
// and IReturnType contains also members from base classes (including System.Object) and default (undeclared) constructors
|
||||
|
||||
static SignatureComparer memberSignatureComparer = new SignatureComparer(); |
||||
|
||||
public static bool HasMember(this IClass containingClass, IMember member) |
||||
{ |
||||
return containingClass.AllMembers.Any(m => memberSignatureComparer.Equals(member, m)); |
||||
} |
||||
|
||||
public static bool HasMember(this IReturnType containingClass, IMember member) |
||||
{ |
||||
return containingClass.GetMembers().Any(m => memberSignatureComparer.Equals(member, m)); |
||||
} |
||||
|
||||
public static bool ImplementsInterface(this IClass targetClass, IClass requiredInterface) |
||||
{ |
||||
var targetClassType = targetClass.GetCompoundClass().DefaultReturnType; |
||||
var requiredInterfaceType = requiredInterface.GetCompoundClass().DefaultReturnType; |
||||
// class.DefaultReturnType.GetMethods() returns also methods from base classes, default ctor, ToString() etc. etc.
|
||||
return !requiredInterfaceType.GetMembers().Any(missingMember => !targetClassType.HasMember(missingMember)); |
||||
} |
||||
|
||||
public static bool ImplementsAbstractClass(this IClass targetClass, IClass abstractClass) |
||||
{ |
||||
var requiredAbstractMembers = MemberLookupHelper.GetAccessibleMembers(abstractClass.DefaultReturnType, targetClass, LanguageProperties.CSharp, true).Where(m => m.IsAbstract); |
||||
return !requiredAbstractMembers.Any(missingMember => !targetClass.HasMember(missingMember)); |
||||
} |
||||
|
||||
public static IEnumerable<IMember> GetMembers(this IReturnType typeReference) |
||||
{ |
||||
var properties = typeReference.GetProperties().Cast<IMember>(); |
||||
var methods = typeReference.GetMethods().Cast<IMember>(); |
||||
var fields = typeReference.GetFields().Cast<IMember>(); |
||||
var events = typeReference.GetEvents().Cast<IMember>(); |
||||
return properties.Concat(methods).Concat(fields).Concat(events); |
||||
} |
||||
} |
||||
} |
@ -1,114 +0,0 @@
@@ -1,114 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.NRefactory; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
public struct FilePosition : IEquatable<FilePosition> |
||||
{ |
||||
string filename; |
||||
Location position; |
||||
ICompilationUnit compilationUnit; |
||||
|
||||
public static readonly FilePosition Empty = new FilePosition(null, Location.Empty); |
||||
|
||||
public FilePosition(ICompilationUnit compilationUnit, int line, int column) |
||||
{ |
||||
this.position = new Location(column, line); |
||||
this.compilationUnit = compilationUnit; |
||||
if (compilationUnit != null) { |
||||
this.filename = compilationUnit.FileName; |
||||
} else { |
||||
this.filename = null; |
||||
} |
||||
} |
||||
|
||||
public FilePosition(string filename) |
||||
: this(filename, Location.Empty) |
||||
{ |
||||
} |
||||
|
||||
public FilePosition(string filename, int line, int column) |
||||
: this(filename, new Location(column, line)) |
||||
{ |
||||
} |
||||
|
||||
public FilePosition(string filename, Location position) |
||||
{ |
||||
this.compilationUnit = null; |
||||
this.filename = filename; |
||||
this.position = position; |
||||
} |
||||
|
||||
public string FileName { |
||||
get { |
||||
return filename; |
||||
} |
||||
} |
||||
|
||||
public ICompilationUnit CompilationUnit { |
||||
get { |
||||
return compilationUnit; |
||||
} |
||||
} |
||||
|
||||
public Location Position { |
||||
get { |
||||
return position; |
||||
} |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return String.Format("{0} : (line {1}, col {2})", |
||||
filename, |
||||
Line, |
||||
Column); |
||||
} |
||||
|
||||
public int Line { |
||||
get { |
||||
return position.Y; |
||||
} |
||||
} |
||||
|
||||
public int Column { |
||||
get { |
||||
return position.X; |
||||
} |
||||
} |
||||
|
||||
public bool IsEmpty { |
||||
get { |
||||
return filename == null; |
||||
} |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
return obj is FilePosition && Equals((FilePosition)obj); |
||||
} |
||||
|
||||
public bool Equals(FilePosition other) |
||||
{ |
||||
return this.FileName == other.FileName && this.Position == other.Position; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return filename.GetHashCode() ^ position.GetHashCode(); |
||||
} |
||||
|
||||
public static bool operator ==(FilePosition lhs, FilePosition rhs) |
||||
{ |
||||
return lhs.Equals(rhs); |
||||
} |
||||
|
||||
public static bool operator !=(FilePosition lhs, FilePosition rhs) |
||||
{ |
||||
return !lhs.Equals(rhs); |
||||
} |
||||
} |
||||
} |
@ -1,31 +0,0 @@
@@ -1,31 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
public sealed class FoldingRegion : Immutable |
||||
{ |
||||
string name; |
||||
DomRegion region; |
||||
|
||||
public string Name { |
||||
get { |
||||
return name; |
||||
} |
||||
} |
||||
|
||||
public DomRegion Region { |
||||
get { |
||||
return region; |
||||
} |
||||
} |
||||
|
||||
public FoldingRegion(string name, DomRegion region) |
||||
{ |
||||
this.name = name; |
||||
this.region = region; |
||||
} |
||||
} |
||||
} |
@ -1,275 +0,0 @@
@@ -1,275 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Runtime.InteropServices; |
||||
using System.Runtime.InteropServices.ComTypes; |
||||
using System.Text; |
||||
|
||||
namespace MSjogren.GacTool.FusionNative |
||||
{ |
||||
[ComImport(), Guid("E707DCDE-D1CD-11D2-BAB9-00C04F8ECEAE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] |
||||
internal interface IAssemblyCache |
||||
{ |
||||
[PreserveSig()] |
||||
int UninstallAssembly(uint dwFlags, |
||||
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName, |
||||
IntPtr pvReserved, |
||||
out uint pulDisposition); |
||||
|
||||
[PreserveSig()] |
||||
int QueryAssemblyInfo(uint dwFlags, |
||||
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName, |
||||
IntPtr pAsmInfo); |
||||
|
||||
[PreserveSig()] |
||||
int CreateAssemblyCacheItem(uint dwFlags, |
||||
IntPtr pvReserved, |
||||
out IAssemblyCacheItem ppAsmItem, |
||||
[MarshalAs(UnmanagedType.LPWStr)] string pszAssemblyName); |
||||
|
||||
[PreserveSig()] |
||||
int CreateAssemblyScavenger(out object ppAsmScavenger); |
||||
|
||||
[PreserveSig()] |
||||
int InstallAssembly(uint dwFlags, |
||||
[MarshalAs(UnmanagedType.LPWStr)] string pszManifestFilePath, |
||||
IntPtr pvReserved); |
||||
} |
||||
|
||||
[ComImport(), Guid("9E3AAEB4-D1CD-11D2-BAB9-00C04F8ECEAE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] |
||||
internal interface IAssemblyCacheItem |
||||
{ |
||||
void CreateStream([MarshalAs(UnmanagedType.LPWStr)] string pszName, |
||||
uint dwFormat, |
||||
uint dwFlags, |
||||
uint dwMaxSize, |
||||
out IStream ppStream); |
||||
|
||||
void IsNameEqual(IAssemblyName pName); |
||||
|
||||
void Commit(uint dwFlags); |
||||
|
||||
void MarkAssemblyVisible(uint dwFlags); |
||||
} |
||||
|
||||
[ComImport(), Guid("CD193BC0-B4BC-11D2-9833-00C04FC31D2E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] |
||||
internal interface IAssemblyName |
||||
{ |
||||
//
|
||||
// Assembly name properties
|
||||
// 0 = PublicKey, byte[]* ; ???
|
||||
// 1 = PublicKeyToken, byte[8]*
|
||||
// 3 = Assembly Name, LPWSTR
|
||||
// 4 = Major Version, ushort*
|
||||
// 5 = Minor Version, ushort*
|
||||
// 6 = Build Number, ushort*
|
||||
// 7 = Revison Number, ushort*
|
||||
// 8 = Culture, LPWSTR
|
||||
// 9 = Processor Type, ??? ; ???
|
||||
// 10 = OS Type, ??? ; ???
|
||||
// 13 = Codebase, LPWSTR
|
||||
// 14 = Modified Date, FILETIME* ; Only for Downloaded assemblies ?
|
||||
// 17 = Custom, LPWSTR ; ZAP string, only for NGEN assemblies
|
||||
// 19 = MVID, byte[16]* ; MVID value from __AssemblyInfo__.ini - what's this?
|
||||
//
|
||||
[PreserveSig()] |
||||
int Set(uint PropertyId, |
||||
IntPtr pvProperty, |
||||
uint cbProperty); |
||||
|
||||
[PreserveSig()] |
||||
int Get(uint PropertyId, |
||||
IntPtr pvProperty, |
||||
ref uint pcbProperty); |
||||
|
||||
[PreserveSig()] |
||||
int Finalize(); |
||||
|
||||
[PreserveSig()] |
||||
int GetDisplayName([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder szDisplayName, |
||||
ref uint pccDisplayName, |
||||
uint dwDisplayFlags); |
||||
|
||||
[PreserveSig()] |
||||
int BindToObject(object refIID, |
||||
object pAsmBindSink, |
||||
IApplicationContext pApplicationContext, |
||||
[MarshalAs(UnmanagedType.LPWStr)] string szCodeBase, |
||||
long llFlags, |
||||
int pvReserved, |
||||
uint cbReserved, |
||||
out int ppv); |
||||
|
||||
[PreserveSig()] |
||||
int GetName(ref uint lpcwBuffer, |
||||
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwzName); |
||||
|
||||
[PreserveSig()] |
||||
int GetVersion(out uint pdwVersionHi, |
||||
out uint pdwVersionLow); |
||||
|
||||
[PreserveSig()] |
||||
int IsEqual(IAssemblyName pName, |
||||
uint dwCmpFlags); |
||||
|
||||
[PreserveSig()] |
||||
int Clone(out IAssemblyName pName); |
||||
} |
||||
|
||||
[ComImport(), Guid("7C23FF90-33AF-11D3-95DA-00A024A85B51"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] |
||||
internal interface IApplicationContext |
||||
{ |
||||
void SetContextNameObject(IAssemblyName pName); |
||||
|
||||
void GetContextNameObject(out IAssemblyName ppName); |
||||
|
||||
void Set([MarshalAs(UnmanagedType.LPWStr)] string szName, |
||||
int pvValue, |
||||
uint cbValue, |
||||
uint dwFlags); |
||||
|
||||
void Get([MarshalAs(UnmanagedType.LPWStr)] string szName, |
||||
out int pvValue, |
||||
ref uint pcbValue, |
||||
uint dwFlags); |
||||
|
||||
void GetDynamicDirectory(out int wzDynamicDir, |
||||
ref uint pdwSize); |
||||
} |
||||
|
||||
[ComImport(), Guid("21B8916C-F28E-11D2-A473-00C04F8EF448"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] |
||||
internal interface IAssemblyEnum |
||||
{ |
||||
[PreserveSig()] |
||||
int GetNextAssembly(out IApplicationContext ppAppCtx, |
||||
out IAssemblyName ppName, |
||||
uint dwFlags); |
||||
|
||||
[PreserveSig()] |
||||
int Reset(); |
||||
|
||||
[PreserveSig()] |
||||
int Clone(out IAssemblyEnum ppEnum); |
||||
} |
||||
|
||||
|
||||
[ComImport(), Guid("1D23DF4D-A1E2-4B8B-93D6-6EA3DC285A54"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] |
||||
internal interface IHistoryReader |
||||
{ |
||||
[PreserveSig()] |
||||
int GetFilePath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzFilePath, |
||||
ref uint pdwSize); |
||||
|
||||
[PreserveSig()] |
||||
int GetApplicationName([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzAppName, |
||||
ref uint pdwSize); |
||||
|
||||
[PreserveSig()] |
||||
int GetEXEModulePath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzExePath, |
||||
ref uint pdwSize); |
||||
|
||||
void GetNumActivations(out uint pdwNumActivations); |
||||
|
||||
void GetActivationDate(uint dwIdx, // One-based!
|
||||
out long /* FILETIME */ pftDate); |
||||
|
||||
[PreserveSig()] |
||||
int GetRunTimeVersion(ref long /* FILETIME */ pftActivationDate, |
||||
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzRunTimeVersion, |
||||
ref uint pdwSize); |
||||
|
||||
void GetNumAssemblies(ref long /* FILETIME */ pftActivationDate, |
||||
out uint pdwNumAsms); |
||||
|
||||
void GetHistoryAssembly(ref long /* FILETIME */ pftActivationDate, |
||||
uint dwIdx, // One-based!
|
||||
[MarshalAs(UnmanagedType.IUnknown)] out object ppHistAsm); |
||||
|
||||
} |
||||
|
||||
internal static class Fusion |
||||
{ |
||||
[DllImport("fusion.dll", CharSet=CharSet.Auto)] |
||||
internal static extern int CreateAssemblyCache(out IAssemblyCache ppAsmCache, |
||||
uint dwReserved); |
||||
|
||||
|
||||
//
|
||||
// dwFlags: 1 = Enumerate native image (NGEN) assemblies
|
||||
// 2 = Enumerate GAC assemblies
|
||||
// 4 = Enumerate Downloaded assemblies ???
|
||||
//
|
||||
[DllImport("fusion.dll", CharSet=CharSet.Auto)] |
||||
internal static extern int CreateAssemblyEnum(out IAssemblyEnum ppEnum, |
||||
IApplicationContext pAppCtx, |
||||
IAssemblyName pName, |
||||
uint dwFlags, |
||||
int pvReserved); |
||||
|
||||
[DllImport("fusion.dll", CharSet=CharSet.Auto)] |
||||
internal static extern int CreateAssemblyNameObject(out IAssemblyName ppName, |
||||
string szAssemblyName, |
||||
uint dwFlags, |
||||
int pvReserved); |
||||
|
||||
[DllImport("fusion.dll", CharSet=CharSet.Auto)] |
||||
internal static extern int CreateHistoryReader(string wzFilePath, |
||||
out IHistoryReader ppHistReader); |
||||
|
||||
// Retrieves the path of the ApplicationHistory folder, typically
|
||||
// Documents and Settings\<user>\Local Settings\Application Data\ApplicationHistory
|
||||
// containing .ini files that can be read with IHistoryReader.
|
||||
// pwdSize appears to be the offset of the last backslash in the returned
|
||||
// string after the call.
|
||||
// Returns S_OK on success, error HRESULT on failure.
|
||||
//
|
||||
[DllImport("fusion.dll", CharSet=CharSet.Unicode)] |
||||
internal static extern int GetHistoryFileDirectory([MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDir, |
||||
ref uint pdwSize); |
||||
|
||||
[DllImport("fusion.dll")] |
||||
internal static extern int NukeDownloadedCache(); |
||||
|
||||
// ?????
|
||||
[DllImport("fusion.dll")] |
||||
internal static extern int CreateApplicationContext(out IApplicationContext ppAppContext, |
||||
uint dw); |
||||
|
||||
[DllImport("fusion.dll")] |
||||
internal static extern int GetCachePath(uint flags, |
||||
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder wzDir, |
||||
ref uint pdwSize); |
||||
|
||||
public static string GetGacPath(bool isCLRv4 = false) |
||||
{ |
||||
const uint ASM_CACHE_ROOT = 0x08; // CLR V2.0
|
||||
const uint ASM_CACHE_ROOT_EX = 0x80; // CLR V4.0
|
||||
uint flags = isCLRv4 ? ASM_CACHE_ROOT_EX : ASM_CACHE_ROOT; |
||||
|
||||
const int size = 260; // MAX_PATH
|
||||
StringBuilder b = new StringBuilder(size); |
||||
uint tmp = size; |
||||
GetCachePath(flags, b, ref tmp); |
||||
return b.ToString(); |
||||
} |
||||
|
||||
// _InstallCustomAssembly@16
|
||||
// _InstallCustomModule@8
|
||||
// _LookupHistoryAssembly@28
|
||||
// _PreBindAssembly@20
|
||||
// _CreateInstallReferenceEnum@16
|
||||
|
||||
|
||||
//
|
||||
// Brings up the .NET Applicaion Restore wizard
|
||||
// Returns S_OK, 0x80131075 (App not run) or 0x80131087 (Fix failed)
|
||||
//
|
||||
[DllImport("shfusion.dll", CharSet=CharSet.Unicode)] |
||||
internal static extern uint PolicyManager(IntPtr hWndParent, |
||||
string pwzFullyQualifiedAppPath, |
||||
string pwzAppName, |
||||
int dwFlags); |
||||
|
||||
} |
||||
} |
@ -1,198 +0,0 @@
@@ -1,198 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Reflection; |
||||
using System.Text; |
||||
using MSjogren.GacTool.FusionNative; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Class with static members to access the content of the global assembly
|
||||
/// cache.
|
||||
/// </summary>
|
||||
public static class GacInterop |
||||
{ |
||||
static readonly string cachedGacPathV2 = Fusion.GetGacPath(false); |
||||
static readonly string cachedGacPathV4 = Fusion.GetGacPath(true); |
||||
|
||||
public static string GacRootPathV2 { |
||||
get { return cachedGacPathV2; } |
||||
} |
||||
|
||||
public static string GacRootPathV4 { |
||||
get { return cachedGacPathV4; } |
||||
} |
||||
|
||||
public static bool IsWithinGac(string assemblyLocation) |
||||
{ |
||||
return Core.FileUtility.IsBaseDirectory(GacRootPathV2, assemblyLocation) |
||||
|| Core.FileUtility.IsBaseDirectory(GacRootPathV4, assemblyLocation); |
||||
} |
||||
|
||||
public static List<DomAssemblyName> GetAssemblyList() |
||||
{ |
||||
IApplicationContext applicationContext = null; |
||||
IAssemblyEnum assemblyEnum = null; |
||||
IAssemblyName assemblyName = null; |
||||
|
||||
List<DomAssemblyName> l = new List<DomAssemblyName>(); |
||||
Fusion.CreateAssemblyEnum(out assemblyEnum, null, null, 2, 0); |
||||
while (assemblyEnum.GetNextAssembly(out applicationContext, out assemblyName, 0) == 0) { |
||||
uint nChars = 0; |
||||
assemblyName.GetDisplayName(null, ref nChars, 0); |
||||
|
||||
StringBuilder sb = new StringBuilder((int)nChars); |
||||
assemblyName.GetDisplayName(sb, ref nChars, 0); |
||||
|
||||
l.Add(new DomAssemblyName(sb.ToString())); |
||||
} |
||||
return l; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the full display name of the GAC assembly of the specified short name
|
||||
/// </summary>
|
||||
public static DomAssemblyName FindBestMatchingAssemblyName(string name) |
||||
{ |
||||
return FindBestMatchingAssemblyName(new DomAssemblyName(name)); |
||||
} |
||||
|
||||
public static DomAssemblyName FindBestMatchingAssemblyName(DomAssemblyName name) |
||||
{ |
||||
string[] info; |
||||
Version requiredVersion = name.Version; |
||||
string publicKey = name.PublicKeyToken; |
||||
|
||||
IApplicationContext applicationContext = null; |
||||
IAssemblyEnum assemblyEnum = null; |
||||
IAssemblyName assemblyName; |
||||
Fusion.CreateAssemblyNameObject(out assemblyName, name.ShortName, 0, 0); |
||||
Fusion.CreateAssemblyEnum(out assemblyEnum, null, assemblyName, 2, 0); |
||||
List<string> names = new List<string>(); |
||||
|
||||
while (assemblyEnum.GetNextAssembly(out applicationContext, out assemblyName, 0) == 0) { |
||||
uint nChars = 0; |
||||
assemblyName.GetDisplayName(null, ref nChars, 0); |
||||
|
||||
StringBuilder sb = new StringBuilder((int)nChars); |
||||
assemblyName.GetDisplayName(sb, ref nChars, 0); |
||||
|
||||
string fullName = sb.ToString(); |
||||
if (publicKey != null) { |
||||
info = fullName.Split(','); |
||||
if (publicKey != info[3].Substring(info[3].LastIndexOf('=') + 1)) { |
||||
// Assembly has wrong public key
|
||||
continue; |
||||
} |
||||
} |
||||
names.Add(fullName); |
||||
} |
||||
if (names.Count == 0) |
||||
return null; |
||||
string best = null; |
||||
Version bestVersion = null; |
||||
Version currentVersion; |
||||
if (requiredVersion != null) { |
||||
// use assembly with lowest version higher or equal to required version
|
||||
for (int i = 0; i < names.Count; i++) { |
||||
info = names[i].Split(','); |
||||
currentVersion = new Version(info[1].Substring(info[1].LastIndexOf('=') + 1)); |
||||
if (currentVersion.CompareTo(requiredVersion) < 0) |
||||
continue; // version not good enough
|
||||
if (best == null || currentVersion.CompareTo(bestVersion) < 0) { |
||||
bestVersion = currentVersion; |
||||
best = names[i]; |
||||
} |
||||
} |
||||
if (best != null) |
||||
return new DomAssemblyName(best); |
||||
} |
||||
// use assembly with highest version
|
||||
best = names[0]; |
||||
info = names[0].Split(','); |
||||
bestVersion = new Version(info[1].Substring(info[1].LastIndexOf('=') + 1)); |
||||
for (int i = 1; i < names.Count; i++) { |
||||
info = names[i].Split(','); |
||||
currentVersion = new Version(info[1].Substring(info[1].LastIndexOf('=') + 1)); |
||||
if (currentVersion.CompareTo(bestVersion) > 0) { |
||||
bestVersion = currentVersion; |
||||
best = names[i]; |
||||
} |
||||
} |
||||
return new DomAssemblyName(best); |
||||
} |
||||
|
||||
#region FindAssemblyInGac
|
||||
// This region is based on code from Mono.Cecil:
|
||||
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2010 Jb Evain
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
static readonly string[] gac_paths = { GacInterop.GacRootPathV2, GacInterop.GacRootPathV4 }; |
||||
static readonly string[] gacs = { "GAC_MSIL", "GAC_32", "GAC" }; |
||||
static readonly string[] prefixes = { string.Empty, "v4.0_" }; |
||||
|
||||
/// <summary>
|
||||
/// Gets the file name for an assembly stored in the GAC.
|
||||
/// </summary>
|
||||
public static string FindAssemblyInNetGac (DomAssemblyName reference) |
||||
{ |
||||
// without public key, it can't be in the GAC
|
||||
if (reference.PublicKeyToken == null) |
||||
return null; |
||||
|
||||
for (int i = 0; i < 2; i++) { |
||||
for (int j = 0; j < gacs.Length; j++) { |
||||
var gac = Path.Combine (gac_paths [i], gacs [j]); |
||||
var file = GetAssemblyFile (reference, prefixes [i], gac); |
||||
if (File.Exists (file)) |
||||
return file; |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
static string GetAssemblyFile (DomAssemblyName reference, string prefix, string gac) |
||||
{ |
||||
var gac_folder = new StringBuilder () |
||||
.Append (prefix) |
||||
.Append (reference.Version) |
||||
.Append ("__"); |
||||
|
||||
gac_folder.Append (reference.PublicKeyToken); |
||||
|
||||
return Path.Combine ( |
||||
Path.Combine ( |
||||
Path.Combine (gac, reference.ShortName), gac_folder.ToString ()), |
||||
reference.ShortName + ".dll"); |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
@ -1,62 +0,0 @@
@@ -1,62 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom.Refactoring; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// A class containing static actions that should be overridden by the
|
||||
/// application using ICSharpCode.SharpDevelop.Dom.
|
||||
/// </summary>
|
||||
public static class HostCallback |
||||
{ |
||||
/// <summary>
|
||||
/// Show an error message. (string message, Exception ex)
|
||||
/// </summary>
|
||||
public static Action<string, Exception> ShowError = delegate(string message, Exception ex) { |
||||
LoggingService.Error(message, ex); |
||||
throw new Exception(message, ex); |
||||
}; |
||||
|
||||
public static Action<string> ShowMessage = delegate(string message) { |
||||
LoggingService.Info(message); |
||||
}; |
||||
|
||||
/// <summary>
|
||||
/// Get the current project content.
|
||||
/// </summary>
|
||||
public static Func<IProjectContent> GetCurrentProjectContent = delegate { |
||||
throw new NotImplementedException("GetCurrentProjectContent was not implemented by the host."); |
||||
}; |
||||
|
||||
/// <summary>
|
||||
/// Rename the member (first argument) to the new name (second argument).
|
||||
/// Returns true on success, false on failure.
|
||||
/// </summary>
|
||||
public static Func<IMember, string, bool> RenameMember = delegate { |
||||
return false; |
||||
}; |
||||
|
||||
/// <summary>
|
||||
/// Show error loading code-completion information.
|
||||
/// The arguments are: string fileName, string include, string message
|
||||
/// </summary>
|
||||
public static Action<string, string, string> ShowAssemblyLoadError = delegate {}; |
||||
|
||||
internal static void ShowAssemblyLoadErrorInternal(string fileName, string include, string message) |
||||
{ |
||||
LoggingService.Warn("Error loading code-completion information for " |
||||
+ include + " from " + fileName |
||||
+ ":\r\n" + message + "\r\n"); |
||||
ShowAssemblyLoadError(fileName, include, message); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initialize the code generator options of the passed CodeGenerator.
|
||||
/// Invoked exactly once for each created instance of a class derived from CodeGenerator.
|
||||
/// </summary>
|
||||
public static Action<CodeGenerator> InitializeCodeGeneratorOptions = delegate {}; |
||||
} |
||||
} |
@ -1,24 +0,0 @@
@@ -1,24 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
public interface IComment |
||||
{ |
||||
bool IsBlockComment { |
||||
get; |
||||
} |
||||
|
||||
string CommentTag { |
||||
get; |
||||
} |
||||
|
||||
string CommentText { |
||||
get; |
||||
} |
||||
|
||||
DomRegion Region { |
||||
get; |
||||
} |
||||
} |
||||
} |
@ -1,66 +0,0 @@
@@ -1,66 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
public interface IExpressionFinder |
||||
{ |
||||
/// <summary>
|
||||
/// Finds an expression before the current offset.
|
||||
/// </summary>
|
||||
ExpressionResult FindExpression(string text, int offset); |
||||
|
||||
/// <summary>
|
||||
/// Finds an expression around the current offset.
|
||||
/// </summary>
|
||||
ExpressionResult FindFullExpression(string text, int offset); |
||||
|
||||
/// <summary>
|
||||
/// Removed the last part of the expression.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// "arr[i]" => "arr"
|
||||
/// "obj.Field" => "obj"
|
||||
/// "obj.Method(args,...)" => "obj.Method"
|
||||
/// </example>
|
||||
string RemoveLastPart(string expression); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Structure containing the result of a call to an expression finder.
|
||||
/// </summary>
|
||||
public struct ExpressionResult |
||||
{ |
||||
public static readonly ExpressionResult Empty = new ExpressionResult(null); |
||||
|
||||
/// <summary>The expression that has been found at the specified offset.</summary>
|
||||
public string Expression; |
||||
/// <summary>The exact source code location of the expression.</summary>
|
||||
public DomRegion Region; |
||||
/// <summary>Specifies the context in which the expression was found.</summary>
|
||||
public ExpressionContext Context; |
||||
/// <summary>An object carrying additional language-dependend data.</summary>
|
||||
public object Tag; |
||||
|
||||
public ExpressionResult(string expression) : this(expression, DomRegion.Empty, ExpressionContext.Default, null) {} |
||||
public ExpressionResult(string expression, ExpressionContext context) : this(expression, DomRegion.Empty, context, null) {} |
||||
|
||||
public ExpressionResult(string expression, DomRegion region, ExpressionContext context, object tag) |
||||
{ |
||||
this.Expression = expression; |
||||
this.Region = region; |
||||
this.Context = context; |
||||
this.Tag = tag; |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
if (Context == ExpressionContext.Default) |
||||
return "<" + Expression + ">"; |
||||
else |
||||
return "<" + Expression + "> (" + Context.ToString() + ")"; |
||||
} |
||||
} |
||||
} |
@ -1,22 +0,0 @@
@@ -1,22 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Description of IResolver.
|
||||
/// </summary>
|
||||
public interface IResolver |
||||
{ |
||||
/// <summary>
|
||||
/// Resolves an expression.
|
||||
/// The caretLineNumber and caretColumn is 1 based.
|
||||
/// </summary>
|
||||
ResolveResult Resolve(ExpressionResult expressionResult, |
||||
ParseInformation parseInfo, |
||||
string fileContent); |
||||
} |
||||
} |
@ -1,358 +0,0 @@
@@ -1,358 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
public abstract class AbstractEntity : AbstractFreezable, IEntity |
||||
{ |
||||
ModifierEnum modifiers = ModifierEnum.None; |
||||
IList<IAttribute> attributes; |
||||
DomRegion bodyRegion; |
||||
|
||||
IClass declaringType; |
||||
|
||||
string fullyQualifiedName; |
||||
string name; |
||||
string nspace; |
||||
|
||||
public AbstractEntity(IClass declaringType) |
||||
{ |
||||
this.declaringType = declaringType; |
||||
} |
||||
|
||||
public AbstractEntity(IClass declaringType, string name) |
||||
{ |
||||
this.declaringType = declaringType; |
||||
this.name = name; |
||||
if (declaringType != null) |
||||
nspace = declaringType.FullyQualifiedName; |
||||
|
||||
// lazy-computing the fully qualified name for class members saves ~7 MB RAM (when loading the SharpDevelop solution).
|
||||
//fullyQualifiedName = nspace + '.' + name;
|
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return String.Format("[{0}: {1}]", GetType().Name, FullyQualifiedName); |
||||
} |
||||
|
||||
#region Naming
|
||||
static readonly char[] nameDelimiters = { '.', '+' }; |
||||
|
||||
|
||||
public string FullyQualifiedName { |
||||
get { |
||||
if (fullyQualifiedName == null) { |
||||
if (name != null && nspace != null) { |
||||
fullyQualifiedName = nspace + '.' + name; |
||||
} else { |
||||
return String.Empty; |
||||
} |
||||
} |
||||
return fullyQualifiedName; |
||||
} |
||||
set { |
||||
CheckBeforeMutation(); |
||||
if (fullyQualifiedName == value) |
||||
return; |
||||
fullyQualifiedName = value; |
||||
name = null; |
||||
nspace = null; |
||||
OnFullyQualifiedNameChanged(EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnFullyQualifiedNameChanged(EventArgs e) |
||||
{ |
||||
} |
||||
|
||||
public virtual string DotNetName { |
||||
get { |
||||
if (this.DeclaringType != null) { |
||||
return this.DeclaringType.DotNetName + "." + this.Name; |
||||
} else { |
||||
return FullyQualifiedName; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public string Name { |
||||
get { |
||||
if (name == null && FullyQualifiedName != null) { |
||||
int lastIndex = FullyQualifiedName.LastIndexOfAny(nameDelimiters); |
||||
|
||||
if (lastIndex < 0) { |
||||
name = FullyQualifiedName; |
||||
} else { |
||||
name = FullyQualifiedName.Substring(lastIndex + 1); |
||||
} |
||||
} |
||||
return name; |
||||
} |
||||
} |
||||
|
||||
public string Namespace { |
||||
get { |
||||
if (nspace == null && FullyQualifiedName != null) { |
||||
int lastIndex = FullyQualifiedName.LastIndexOf('.'); |
||||
|
||||
if (lastIndex < 0) { |
||||
nspace = String.Empty; |
||||
} else { |
||||
nspace = FullyQualifiedName.Substring(0, lastIndex); |
||||
} |
||||
} |
||||
return nspace; |
||||
} |
||||
} |
||||
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void FreezeInternal() |
||||
{ |
||||
attributes = FreezeList(attributes); |
||||
base.FreezeInternal(); |
||||
} |
||||
|
||||
public IClass DeclaringType { |
||||
get { |
||||
return declaringType; |
||||
} |
||||
} |
||||
|
||||
public virtual DomRegion BodyRegion { |
||||
get { |
||||
return bodyRegion; |
||||
} |
||||
set { |
||||
CheckBeforeMutation(); |
||||
bodyRegion = value; |
||||
} |
||||
} |
||||
|
||||
public object UserData { get; set; } |
||||
|
||||
public IList<IAttribute> Attributes { |
||||
get { |
||||
if (attributes == null) { |
||||
attributes = new List<IAttribute>(); |
||||
} |
||||
return attributes; |
||||
} |
||||
set { |
||||
CheckBeforeMutation(); |
||||
attributes = value; |
||||
} |
||||
} |
||||
|
||||
string documentation; |
||||
|
||||
public virtual string Documentation { |
||||
get { |
||||
if (documentation == null) { |
||||
string documentationTag = this.DocumentationTag; |
||||
if (documentationTag != null) { |
||||
IProjectContent pc = null; |
||||
if (this is IClass) { |
||||
pc = ((IClass)this).ProjectContent; |
||||
} else if (declaringType != null) { |
||||
pc = declaringType.ProjectContent; |
||||
} |
||||
if (pc != null) { |
||||
return pc.GetXmlDocumentation(documentationTag); |
||||
} |
||||
} |
||||
} |
||||
return documentation; |
||||
} |
||||
set { |
||||
CheckBeforeMutation(); |
||||
documentation = value; |
||||
} |
||||
} |
||||
|
||||
protected void CopyDocumentationFrom(IEntity entity) |
||||
{ |
||||
AbstractEntity ae = entity as AbstractEntity; |
||||
if (ae != null) { |
||||
this.Documentation = ae.documentation; // do not cause pc.GetXmlDocumentation call for documentation copy
|
||||
} else { |
||||
this.Documentation = entity.Documentation; |
||||
} |
||||
} |
||||
|
||||
public abstract string DocumentationTag { |
||||
get; |
||||
} |
||||
|
||||
#region Modifiers
|
||||
public ModifierEnum Modifiers { |
||||
get { |
||||
return modifiers; |
||||
} |
||||
set { |
||||
CheckBeforeMutation(); |
||||
modifiers = value; |
||||
} |
||||
} |
||||
|
||||
public bool IsAbstract { |
||||
get { |
||||
return (modifiers & ModifierEnum.Abstract) == ModifierEnum.Abstract; |
||||
} |
||||
} |
||||
|
||||
public bool IsSealed { |
||||
get { |
||||
return (modifiers & ModifierEnum.Sealed) == ModifierEnum.Sealed; |
||||
} |
||||
} |
||||
|
||||
public bool IsStatic { |
||||
get { |
||||
return ((modifiers & ModifierEnum.Static) == ModifierEnum.Static) || IsConst; |
||||
} |
||||
} |
||||
|
||||
public bool IsConst { |
||||
get { |
||||
return (modifiers & ModifierEnum.Const) == ModifierEnum.Const; |
||||
} |
||||
} |
||||
|
||||
public bool IsVirtual { |
||||
get { |
||||
return (modifiers & ModifierEnum.Virtual) == ModifierEnum.Virtual; |
||||
} |
||||
} |
||||
|
||||
public bool IsPublic { |
||||
get { |
||||
return (modifiers & ModifierEnum.Public) == ModifierEnum.Public; |
||||
} |
||||
} |
||||
|
||||
public bool IsProtected { |
||||
get { |
||||
return (modifiers & ModifierEnum.Protected) == ModifierEnum.Protected; |
||||
} |
||||
} |
||||
|
||||
public bool IsPrivate { |
||||
get { |
||||
return (modifiers & ModifierEnum.Private) == ModifierEnum.Private; |
||||
} |
||||
} |
||||
|
||||
public bool IsInternal { |
||||
get { |
||||
return (modifiers & ModifierEnum.Internal) == ModifierEnum.Internal; |
||||
} |
||||
} |
||||
|
||||
[Obsolete("This property does not do what one would expect - it merely checks if protected+internal are set, it is not the equivalent of AssemblyAndFamily in Reflection!")] |
||||
public bool IsProtectedAndInternal { |
||||
get { |
||||
return (modifiers & (ModifierEnum.Internal | ModifierEnum.Protected)) == (ModifierEnum.Internal | ModifierEnum.Protected); |
||||
} |
||||
} |
||||
|
||||
[Obsolete("This property does not do what one would expect - it merely checks if one of protected+internal is set, it is not the equivalent of AssemblyOrFamily in Reflection!")] |
||||
public bool IsProtectedOrInternal { |
||||
get { |
||||
return IsProtected || IsInternal; |
||||
} |
||||
} |
||||
|
||||
public bool IsReadonly { |
||||
get { |
||||
return (modifiers & ModifierEnum.Readonly) == ModifierEnum.Readonly; |
||||
} |
||||
} |
||||
|
||||
public bool IsOverride { |
||||
get { |
||||
return (modifiers & ModifierEnum.Override) == ModifierEnum.Override; |
||||
} |
||||
} |
||||
public bool IsOverridable { |
||||
get { |
||||
return (IsOverride || IsVirtual || IsAbstract || |
||||
// Interface members have IsVirtual == IsAbstract == false. These properties are based on modifiers only.
|
||||
(this.DeclaringType != null && this.DeclaringType.ClassType == ClassType.Interface)) |
||||
&& !IsSealed; |
||||
} |
||||
} |
||||
public bool IsNew { |
||||
get { |
||||
return (modifiers & ModifierEnum.New) == ModifierEnum.New; |
||||
} |
||||
} |
||||
public bool IsSynthetic { |
||||
get { |
||||
return (modifiers & ModifierEnum.Synthetic) == ModifierEnum.Synthetic; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
public bool IsAccessible(IClass callingClass, bool isAccessThoughReferenceOfCurrentClass) |
||||
{ |
||||
if (IsPublic) { |
||||
return true; |
||||
} else if (IsInternal) { |
||||
// members can be both internal and protected: in that case, we want to return true if it is visible
|
||||
// through any of the modifiers
|
||||
if (callingClass != null && this.DeclaringType.ProjectContent.InternalsVisibleTo(callingClass.ProjectContent)) |
||||
return true; |
||||
} |
||||
// protected or private:
|
||||
// search in callingClass and, if callingClass is a nested class, in its outer classes
|
||||
while (callingClass != null) { |
||||
if (IsProtected) { |
||||
if (!isAccessThoughReferenceOfCurrentClass && !IsStatic) |
||||
return false; |
||||
return callingClass.IsTypeInInheritanceTree(this.DeclaringType); |
||||
} else { |
||||
// private
|
||||
if (DeclaringType.FullyQualifiedName == callingClass.FullyQualifiedName |
||||
&& DeclaringType.TypeParameters.Count == callingClass.TypeParameters.Count) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
callingClass = callingClass.DeclaringType; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public abstract ICompilationUnit CompilationUnit { |
||||
get; |
||||
} |
||||
|
||||
public IProjectContent ProjectContent { |
||||
[System.Diagnostics.DebuggerStepThrough] |
||||
get { |
||||
return this.CompilationUnit.ProjectContent; |
||||
} |
||||
} |
||||
|
||||
public virtual int CompareTo(IEntity value) |
||||
{ |
||||
return this.Modifiers - value.Modifiers; |
||||
} |
||||
|
||||
int IComparable.CompareTo(object value) |
||||
{ |
||||
return CompareTo((IEntity)value); |
||||
} |
||||
|
||||
public abstract EntityType EntityType { |
||||
get; |
||||
} |
||||
} |
||||
} |
@ -1,108 +0,0 @@
@@ -1,108 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
public abstract class AbstractMember : AbstractEntity, IMember |
||||
{ |
||||
IReturnType returnType; |
||||
DomRegion region; |
||||
IList<ExplicitInterfaceImplementation> interfaceImplementations; |
||||
IReturnType declaringTypeReference; |
||||
|
||||
protected override void FreezeInternal() |
||||
{ |
||||
interfaceImplementations = FreezeList(interfaceImplementations); |
||||
base.FreezeInternal(); |
||||
} |
||||
|
||||
public sealed override ICompilationUnit CompilationUnit { |
||||
[System.Diagnostics.DebuggerStepThrough] |
||||
get { |
||||
return this.DeclaringType.CompilationUnit; |
||||
} |
||||
} |
||||
|
||||
public virtual DomRegion Region { |
||||
get { |
||||
return region; |
||||
} |
||||
set { |
||||
CheckBeforeMutation(); |
||||
region = value; |
||||
} |
||||
} |
||||
|
||||
public virtual IReturnType ReturnType { |
||||
get { |
||||
return returnType; |
||||
} |
||||
set { |
||||
CheckBeforeMutation(); |
||||
returnType = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the declaring type reference (declaring type incl. type arguments)
|
||||
/// </summary>
|
||||
public virtual IReturnType DeclaringTypeReference { |
||||
get { |
||||
return declaringTypeReference ?? this.DeclaringType.DefaultReturnType; |
||||
} |
||||
set { |
||||
CheckBeforeMutation(); |
||||
declaringTypeReference = value; |
||||
} |
||||
} |
||||
|
||||
public IList<ExplicitInterfaceImplementation> InterfaceImplementations { |
||||
get { |
||||
return interfaceImplementations ?? (interfaceImplementations = new List<ExplicitInterfaceImplementation>()); |
||||
} |
||||
} |
||||
|
||||
public AbstractMember(IClass declaringType, string name) : base(declaringType, name) |
||||
{ |
||||
// members must have a parent class
|
||||
if (declaringType == null) |
||||
throw new ArgumentNullException("declaringType"); |
||||
} |
||||
|
||||
public abstract IMember Clone(); |
||||
|
||||
object ICloneable.Clone() |
||||
{ |
||||
return this.Clone(); |
||||
} |
||||
|
||||
public override string Documentation { |
||||
get { |
||||
if (genericMember != null) |
||||
return genericMember.Documentation; |
||||
return base.Documentation; |
||||
} |
||||
set { |
||||
base.Documentation = value; |
||||
} |
||||
} |
||||
|
||||
IMember genericMember; |
||||
|
||||
public virtual IMember GenericMember { |
||||
get { return genericMember; } |
||||
} |
||||
|
||||
public virtual IMember CreateSpecializedMember() |
||||
{ |
||||
AbstractMember copy = Clone() as AbstractMember; |
||||
if (copy == null) |
||||
throw new Exception("Clone() must return an AbstractMember instance, or CreateSpecializedMember must also be overridden."); |
||||
copy.genericMember = this; |
||||
return copy; |
||||
} |
||||
} |
||||
} |
@ -1,136 +0,0 @@
@@ -1,136 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Abstract return type for return types that are not a <see cref="ProxyReturnType"/>.
|
||||
/// </summary>
|
||||
public abstract class AbstractReturnType : IReturnType |
||||
{ |
||||
public abstract IClass GetUnderlyingClass(); |
||||
public abstract List<IMethod> GetMethods(); |
||||
public abstract List<IProperty> GetProperties(); |
||||
public abstract List<IField> GetFields(); |
||||
public abstract List<IEvent> GetEvents(); |
||||
|
||||
public virtual int TypeArgumentCount { |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
public virtual bool Equals(IReturnType other) |
||||
{ |
||||
if (other == null) |
||||
return false; |
||||
return other.IsDefaultReturnType && DefaultReturnType.Equals(this, other); |
||||
} |
||||
|
||||
public sealed override bool Equals(object o) |
||||
{ |
||||
return Equals(o as IReturnType); |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return DefaultReturnType.GetHashCode(this); |
||||
} |
||||
|
||||
string fullyQualifiedName = null; |
||||
|
||||
public virtual string FullyQualifiedName { |
||||
get { |
||||
if (fullyQualifiedName == null) { |
||||
return String.Empty; |
||||
} |
||||
return fullyQualifiedName; |
||||
} |
||||
set { |
||||
fullyQualifiedName = value; |
||||
} |
||||
} |
||||
|
||||
public virtual string Name { |
||||
get { |
||||
if (FullyQualifiedName == null) { |
||||
return null; |
||||
} |
||||
int index = FullyQualifiedName.LastIndexOf('.'); |
||||
return index < 0 ? FullyQualifiedName : FullyQualifiedName.Substring(index + 1); |
||||
} |
||||
} |
||||
|
||||
public virtual string Namespace { |
||||
get { |
||||
if (FullyQualifiedName == null) { |
||||
return null; |
||||
} |
||||
int index = FullyQualifiedName.LastIndexOf('.'); |
||||
return index < 0 ? String.Empty : FullyQualifiedName.Substring(0, index); |
||||
} |
||||
} |
||||
|
||||
public virtual string DotNetName { |
||||
get { |
||||
return FullyQualifiedName; |
||||
} |
||||
} |
||||
|
||||
public virtual bool IsDefaultReturnType { |
||||
get { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public virtual bool IsArrayReturnType { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
public virtual ArrayReturnType CastToArrayReturnType() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public virtual bool IsGenericReturnType { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
public virtual GenericReturnType CastToGenericReturnType() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public virtual bool IsConstructedReturnType { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
public virtual ConstructedReturnType CastToConstructedReturnType() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public bool IsDecoratingReturnType<T>() where T : DecoratingReturnType |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public T CastToDecoratingReturnType<T>() where T : DecoratingReturnType |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public virtual bool? IsReferenceType { get { return null; } } |
||||
|
||||
public virtual IReturnType GetDirectReturnType() |
||||
{ |
||||
return this; |
||||
} |
||||
} |
||||
} |
@ -1,190 +0,0 @@
@@ -1,190 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// The return type of anonymous method expressions or lambda expressions.
|
||||
/// </summary>
|
||||
public class AnonymousMethodReturnType : DecoratingReturnType |
||||
{ |
||||
IReturnType returnType; |
||||
IList<IParameter> parameters; |
||||
ICompilationUnit cu; |
||||
|
||||
public AnonymousMethodReturnType(ICompilationUnit cu) |
||||
{ |
||||
this.cu = cu; |
||||
} |
||||
|
||||
public override bool Equals(IReturnType other) |
||||
{ |
||||
if (other == null) return false; |
||||
AnonymousMethodReturnType o = other.CastToDecoratingReturnType<AnonymousMethodReturnType>(); |
||||
if (o == null) return false; |
||||
return this.FullyQualifiedName == o.FullyQualifiedName; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return this.FullyQualifiedName.GetHashCode(); |
||||
} |
||||
|
||||
public override T CastToDecoratingReturnType<T>() |
||||
{ |
||||
if (typeof(T) == typeof(AnonymousMethodReturnType)) { |
||||
return (T)(object)this; |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public IReturnType ToDefaultDelegate() |
||||
{ |
||||
IReturnType type = new GetClassReturnType(cu.ProjectContent, "System.Func", 0); |
||||
List<IReturnType> parameters = new List<IReturnType>(); |
||||
|
||||
if (this.HasParameterList) |
||||
parameters = MethodParameters.Select(p => p.ReturnType ?? new GetClassReturnType(cu.ProjectContent, "System.Object", 0)).ToList(); |
||||
|
||||
if (this.MethodReturnType != null && this.MethodReturnType.FullyQualifiedName == "System.Void") |
||||
type = new GetClassReturnType(cu.ProjectContent, "System.Action", 0); |
||||
else { |
||||
var rt = this.MethodReturnType; |
||||
if (rt == null) |
||||
rt = new GetClassReturnType(cu.ProjectContent, "System.Object", 0); |
||||
parameters.Add(rt); |
||||
} |
||||
|
||||
return new ConstructedReturnType(type, parameters); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Return type of the anonymous method. Can be null if inferred from context.
|
||||
/// </summary>
|
||||
public IReturnType MethodReturnType { |
||||
get { return returnType; } |
||||
set { returnType = value; } |
||||
} |
||||
|
||||
public virtual IReturnType ResolveReturnType() |
||||
{ |
||||
return returnType; |
||||
} |
||||
|
||||
public virtual IReturnType ResolveReturnType(IReturnType[] parameterTypes) |
||||
{ |
||||
return returnType; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of method parameters. Can be null if the anonymous method has no parameter list.
|
||||
/// </summary>
|
||||
public IList<IParameter> MethodParameters { |
||||
get { return parameters; } |
||||
set { parameters = value; } |
||||
} |
||||
|
||||
public virtual bool CanBeConvertedToExpressionTree { |
||||
get { return false; } |
||||
} |
||||
|
||||
public bool HasParameterList { |
||||
get { return parameters != null; } |
||||
} |
||||
|
||||
public bool HasImplicitlyTypedParameters { |
||||
get { |
||||
if (parameters == null) |
||||
return false; |
||||
else |
||||
return parameters.Any(p => p.ReturnType == null); |
||||
} |
||||
} |
||||
|
||||
DefaultClass cachedClass; |
||||
|
||||
public override IClass GetUnderlyingClass() |
||||
{ |
||||
if (cachedClass != null) return cachedClass; |
||||
DefaultClass c = new DefaultClass(cu, ClassType.Delegate, ModifierEnum.None, DomRegion.Empty, null); |
||||
c.BaseTypes.Add(cu.ProjectContent.SystemTypes.Delegate); |
||||
AddDefaultDelegateMethod(c, returnType ?? cu.ProjectContent.SystemTypes.Object, parameters ?? new IParameter[0]); |
||||
cachedClass = c; |
||||
return c; |
||||
} |
||||
|
||||
internal static void AddDefaultDelegateMethod(DefaultClass c, IReturnType returnType, IList<IParameter> parameters) |
||||
{ |
||||
ModifierEnum modifiers = ModifierEnum.Public | ModifierEnum.Synthetic; |
||||
DefaultMethod invokeMethod = new DefaultMethod("Invoke", returnType, modifiers, c.Region, DomRegion.Empty, c); |
||||
foreach (IParameter par in parameters) { |
||||
invokeMethod.Parameters.Add(par); |
||||
} |
||||
c.Methods.Add(invokeMethod); |
||||
invokeMethod = new DefaultMethod("BeginInvoke", c.ProjectContent.SystemTypes.IAsyncResult, modifiers, c.Region, DomRegion.Empty, c); |
||||
foreach (IParameter par in parameters) { |
||||
invokeMethod.Parameters.Add(par); |
||||
} |
||||
invokeMethod.Parameters.Add(new DefaultParameter("callback", c.ProjectContent.SystemTypes.AsyncCallback, DomRegion.Empty)); |
||||
invokeMethod.Parameters.Add(new DefaultParameter("object", c.ProjectContent.SystemTypes.Object, DomRegion.Empty)); |
||||
c.Methods.Add(invokeMethod); |
||||
invokeMethod = new DefaultMethod("EndInvoke", returnType, modifiers, c.Region, DomRegion.Empty, c); |
||||
invokeMethod.Parameters.Add(new DefaultParameter("result", c.ProjectContent.SystemTypes.IAsyncResult, DomRegion.Empty)); |
||||
c.Methods.Add(invokeMethod); |
||||
} |
||||
|
||||
public override IReturnType BaseType { |
||||
get { |
||||
return GetUnderlyingClass().DefaultReturnType; |
||||
} |
||||
} |
||||
|
||||
public override string Name { |
||||
get { |
||||
return "delegate"; |
||||
} |
||||
} |
||||
|
||||
public override string FullyQualifiedName { |
||||
get { |
||||
StringBuilder b = new StringBuilder("delegate"); |
||||
if (HasParameterList) { |
||||
bool first = true; |
||||
b.Append("("); |
||||
foreach (IParameter p in parameters) { |
||||
if (first) first = false; else b.Append(", "); |
||||
b.Append(p.Name); |
||||
if (p.ReturnType != null) { |
||||
b.Append(":"); |
||||
b.Append(p.ReturnType.Name); |
||||
} |
||||
} |
||||
b.Append(")"); |
||||
} |
||||
if (returnType != null) { |
||||
b.Append(":"); |
||||
b.Append(returnType.Name); |
||||
} |
||||
return b.ToString(); |
||||
} |
||||
} |
||||
|
||||
public override string Namespace { |
||||
get { |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
public override string DotNetName { |
||||
get { |
||||
return Name; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,157 +0,0 @@
@@ -1,157 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// The ArrayReturnType wraps around another type, converting it into an array
|
||||
/// with the specified number of dimensions.
|
||||
/// The element type is only used as return type for the indexer; all methods and fields
|
||||
/// are retrieved from System.Array.
|
||||
/// </summary>
|
||||
public sealed class ArrayReturnType : DecoratingReturnType |
||||
{ |
||||
IReturnType elementType; |
||||
int dimensions; |
||||
IProjectContent pc; |
||||
|
||||
internal IProjectContent ProjectContent { |
||||
get { |
||||
return pc; |
||||
} |
||||
} |
||||
|
||||
public ArrayReturnType(IProjectContent pc, IReturnType elementType, int dimensions) |
||||
{ |
||||
if (pc == null) |
||||
throw new ArgumentNullException("pc"); |
||||
if (dimensions <= 0) |
||||
throw new ArgumentOutOfRangeException("dimensions", dimensions, "dimensions must be positive"); |
||||
if (elementType == null) |
||||
throw new ArgumentNullException("elementType"); |
||||
this.pc = pc; |
||||
this.elementType = elementType; |
||||
this.dimensions = dimensions; |
||||
} |
||||
|
||||
public override IReturnType GetDirectReturnType() |
||||
{ |
||||
IReturnType newElementType = elementType.GetDirectReturnType(); |
||||
if (newElementType == elementType) |
||||
return this; |
||||
else |
||||
return new ArrayReturnType(pc, newElementType, dimensions); |
||||
} |
||||
|
||||
public override bool Equals(IReturnType rt) |
||||
{ |
||||
if (rt == null || !rt.IsArrayReturnType) return false; |
||||
ArrayReturnType art = rt.CastToArrayReturnType(); |
||||
if (art.ArrayDimensions != dimensions) return false; |
||||
return elementType.Equals(art.ArrayElementType); |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
unchecked { |
||||
return 2 * elementType.GetHashCode() + 27 * dimensions; |
||||
} |
||||
} |
||||
|
||||
public override T CastToDecoratingReturnType<T>() |
||||
{ |
||||
if (typeof(T) == typeof(ArrayReturnType)) { |
||||
return (T)(object)this; |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public IReturnType ArrayElementType { |
||||
get { |
||||
return elementType; |
||||
} |
||||
} |
||||
|
||||
public int ArrayDimensions { |
||||
get { |
||||
return dimensions; |
||||
} |
||||
} |
||||
|
||||
public override string FullyQualifiedName { |
||||
get { |
||||
return elementType.FullyQualifiedName; |
||||
} |
||||
} |
||||
|
||||
public override string Name { |
||||
get { |
||||
return elementType.Name; |
||||
} |
||||
} |
||||
|
||||
public override string DotNetName { |
||||
get { |
||||
return AppendArrayString(elementType.DotNetName); |
||||
} |
||||
} |
||||
|
||||
public override IReturnType BaseType { |
||||
get { |
||||
return pc.SystemTypes.Array; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Indexer used exclusively for array return types
|
||||
/// </summary>
|
||||
public class ArrayIndexer : DefaultProperty |
||||
{ |
||||
public ArrayIndexer(IReturnType elementType, IClass systemArray) |
||||
: base("Indexer", elementType, ModifierEnum.Public, DomRegion.Empty, DomRegion.Empty, systemArray) |
||||
{ |
||||
IsIndexer = true; |
||||
} |
||||
} |
||||
|
||||
public override List<IProperty> GetProperties() |
||||
{ |
||||
List<IProperty> l = base.GetProperties(); |
||||
IClass systemArray = this.BaseType.GetUnderlyingClass(); |
||||
if (systemArray != null) { |
||||
ArrayIndexer property = new ArrayIndexer(elementType, systemArray); |
||||
IReturnType int32 = pc.SystemTypes.Int32; |
||||
for (int i = 0; i < dimensions; ++i) { |
||||
property.Parameters.Add(new DefaultParameter("index", int32, DomRegion.Empty)); |
||||
} |
||||
property.Freeze(); |
||||
l.Add(property); |
||||
} |
||||
return l; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Appends the array characters ([,,,]) to the string <paramref name="a"/>.
|
||||
/// </summary>
|
||||
string AppendArrayString(string a) |
||||
{ |
||||
StringBuilder b = new StringBuilder(a, a.Length + 1 + dimensions); |
||||
b.Append('['); |
||||
for (int i = 1; i < dimensions; ++i) { |
||||
b.Append(','); |
||||
} |
||||
b.Append(']'); |
||||
return b.ToString(); |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return String.Format("[ArrayReturnType: {0}{1}]", elementType, AppendArrayString("")); |
||||
} |
||||
} |
||||
} |
@ -1,47 +0,0 @@
@@ -1,47 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Like SearchClassReturnType, but tries both the specified name and name+"Attribute".
|
||||
/// </summary>
|
||||
public class AttributeReturnType : ProxyReturnType |
||||
{ |
||||
string name; |
||||
SearchClassReturnType scrt1, scrt2; |
||||
|
||||
public AttributeReturnType(ClassFinder context, string name) |
||||
{ |
||||
if (context == null) |
||||
throw new ArgumentNullException("context"); |
||||
if (name == null) |
||||
throw new ArgumentNullException("name"); |
||||
this.name = name; |
||||
scrt1 = new SearchClassReturnType(context.ProjectContent, context.CallingClass, |
||||
context.CaretLine, context.CaretColumn, name, 0); |
||||
scrt2 = new SearchClassReturnType(context.ProjectContent, context.CallingClass, |
||||
context.CaretLine, context.CaretColumn, name + "Attribute", 0); |
||||
} |
||||
|
||||
public override IReturnType BaseType { |
||||
get { |
||||
IClass class1 = scrt1.GetUnderlyingClass(); |
||||
IClass class2 = scrt2.GetUnderlyingClass(); |
||||
if (class1 != null && class2 != null) { |
||||
if (class1.ClassInheritanceTree.Any(c => c.FullyQualifiedName == "System.Attribute")) |
||||
return scrt1; |
||||
else |
||||
return scrt2; |
||||
} else if (class2 != null) { |
||||
return scrt2; |
||||
} else { |
||||
return scrt1; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,91 +0,0 @@
@@ -1,91 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// A type parameter that was bound to a concrete type.
|
||||
/// </summary>
|
||||
public sealed class BoundTypeParameter : AbstractFreezable, ITypeParameter |
||||
{ |
||||
readonly ITypeParameter baseTypeParameter; |
||||
readonly IMethod owningMethod; |
||||
readonly IClass owningClass; |
||||
IReturnType boundTo; |
||||
|
||||
public BoundTypeParameter(ITypeParameter baseTypeParameter, IClass owningClass) |
||||
: this(baseTypeParameter, owningClass, null) |
||||
{ |
||||
} |
||||
|
||||
public BoundTypeParameter(ITypeParameter baseTypeParameter, IClass owningClass, IMethod owningMethod) |
||||
{ |
||||
if (owningClass == null) |
||||
throw new ArgumentNullException("owningClass"); |
||||
if (baseTypeParameter == null) |
||||
throw new ArgumentNullException("baseTypeParameter"); |
||||
this.baseTypeParameter = baseTypeParameter; |
||||
this.owningMethod = owningMethod; |
||||
this.owningClass = owningClass; |
||||
} |
||||
|
||||
protected override void FreezeInternal() |
||||
{ |
||||
base.FreezeInternal(); |
||||
baseTypeParameter.Freeze(); |
||||
owningMethod.Freeze(); |
||||
owningClass.Freeze(); |
||||
} |
||||
|
||||
public string Name { |
||||
get { return baseTypeParameter.Name; } |
||||
} |
||||
|
||||
public int Index { |
||||
get { return baseTypeParameter.Index; } |
||||
} |
||||
|
||||
public IList<IAttribute> Attributes { |
||||
get { return baseTypeParameter.Attributes; } |
||||
} |
||||
|
||||
public IMethod Method { |
||||
get { return owningMethod; } |
||||
} |
||||
|
||||
public IClass Class { |
||||
get { return owningClass; } |
||||
} |
||||
|
||||
public IList<IReturnType> Constraints { |
||||
get { return baseTypeParameter.Constraints; } |
||||
} |
||||
|
||||
public bool HasConstructableConstraint { |
||||
get { return baseTypeParameter.HasConstructableConstraint; } |
||||
} |
||||
|
||||
public bool HasReferenceTypeConstraint { |
||||
get { return baseTypeParameter.HasReferenceTypeConstraint; } |
||||
} |
||||
|
||||
public bool HasValueTypeConstraint { |
||||
get { return baseTypeParameter.HasValueTypeConstraint; } |
||||
} |
||||
|
||||
public IReturnType BoundTo { |
||||
get { return boundTo; } |
||||
set { |
||||
CheckBeforeMutation(); |
||||
boundTo = value; |
||||
} |
||||
} |
||||
|
||||
public ITypeParameter UnboundTypeParameter { |
||||
get { return baseTypeParameter.UnboundTypeParameter; } |
||||
} |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue