Browse Source

RefactoringService now accepts any ResolveResult.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1387 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
e8c9d5e35c
  1. 8
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs
  2. 10
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/NRefactoryToBooConverter.csproj
  3. 30
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Test/MemberTests.cs
  4. 5
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Test/TestHelper.cs
  5. 26
      src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs

8
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs

@ -117,6 +117,10 @@ namespace NRefactoryToBooConverter @@ -117,6 +117,10 @@ namespace NRefactoryToBooConverter
if (val is double) {
return new B.DoubleLiteralExpression(GetLexicalInfo(pe), (double)val, false);
}
if (val is decimal) {
AddWarning(pe, "Converting decimal literal to double literal");
return new B.DoubleLiteralExpression(GetLexicalInfo(pe), (double)(decimal)val);
}
AddError(pe, "Unknown primitive literal of type " + val.GetType().FullName);
return null;
}
@ -520,14 +524,14 @@ namespace NRefactoryToBooConverter @@ -520,14 +524,14 @@ namespace NRefactoryToBooConverter
{
AddError(checkedExpression, "Using 'checked' inside an expression is not supported by boo, " +
"use the checked {} block instead.");
return null;
return MakeMethodCall("checked", ConvertExpression(checkedExpression.Expression));
}
public object Visit(UncheckedExpression uncheckedExpression, object data)
{
AddError(uncheckedExpression, "Using 'unchecked' inside an expression is not supported by boo, " +
"use the unchecked {} block instead.");
return null;
return MakeMethodCall("unchecked", ConvertExpression(uncheckedExpression.Expression));
}
}
}

10
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/NRefactoryToBooConverter.csproj

@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<NoStdLib>False</NoStdLib>
<DebugType>None</DebugType>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>105906176</BaseAddress>
@ -17,7 +16,6 @@ @@ -17,7 +16,6 @@
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
@ -29,6 +27,14 @@ @@ -29,6 +27,14 @@
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>Full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugType>None</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />

30
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Test/MemberTests.cs

@ -134,6 +134,18 @@ namespace NRefactoryToBooConverter.Tests @@ -134,6 +134,18 @@ namespace NRefactoryToBooConverter.Tests
TestInClass("public static void Run() {}", "public static def Run() as System.Void:\n\tpass");
}
[Test]
public void AbstractMethod()
{
TestInClass("public abstract void Run();", "public abstract def Run() as System.Void:\n\tpass");
}
[Test]
public void AbstractMethodInInterface()
{
TestInInterface("void Run();", "def Run() as System.Void");
}
[Test]
public void StaticMethodInStaticClass()
{
@ -214,6 +226,18 @@ namespace NRefactoryToBooConverter.Tests @@ -214,6 +226,18 @@ namespace NRefactoryToBooConverter.Tests
"[AA]\npublic Text as System.String:\n\t[BB]\n\tget:\n\t\tpass\n\t[CC]\n\tset:\n\t\tpass");
}
[Test]
public void AbstractProperty()
{
TestInClass("public abstract string Prop { get; }", "public abstract Prop as System.String:\n\tget:\n\t\tpass");
}
[Test]
public void AbstractPropertyInInterface()
{
TestInInterface("string Prop { get; }", "Prop as System.String:\n\tget");
}
[Test]
public void ReadOnlyIndexer()
{
@ -251,6 +275,12 @@ namespace NRefactoryToBooConverter.Tests @@ -251,6 +275,12 @@ namespace NRefactoryToBooConverter.Tests
TestInClass("[LookHere] event EventHandler Closed;", "[LookHere]\nprivate event Closed as EventHandler");
}
[Test]
public void EventInInterface()
{
TestInInterface("event EventHandler Closed;", "event Closed as EventHandler");
}
[Test]
public void PInvoke()
{

5
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Test/TestHelper.cs

@ -65,6 +65,11 @@ namespace NRefactoryToBooConverter.Tests @@ -65,6 +65,11 @@ namespace NRefactoryToBooConverter.Tests
Assert.AreEqual(output.Replace("??", ConverterSettings.DefaultNameGenerationPrefix), ConvertVB(input));
}
protected void TestInInterface(string input, string output)
{
Test("public interface ClassName {\n" + input + "\n}", "public interface ClassName:\n\t" + output.Replace("\n", "\n\t"));
}
protected void TestInClass(string input, string output)
{
Test("public class ClassName {\n" + input + "\n}", "public class ClassName:\n\t" + output.Replace("\n", "\n\t"));

26
src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs

@ -86,9 +86,35 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -86,9 +86,35 @@ namespace ICSharpCode.SharpDevelop.Refactoring
/// </summary>
public static List<Reference> FindReferences(IClass @class, IProgressMonitor progressMonitor)
{
if (@class == null)
throw new ArgumentNullException("class");
return RunFindReferences(@class, null, false, progressMonitor);
}
/// <summary>
/// Find all references to the resolved entity.
/// </summary>
public static List<Reference> FindReferences(ResolveResult entity, IProgressMonitor progressMonitor)
{
if (entity == null)
throw new ArgumentNullException("entity");
if (entity is LocalResolveResult) {
return RunFindReferences(entity.CallingClass, (entity as LocalResolveResult).Field, true, progressMonitor);
} else if (entity is TypeResolveResult) {
return FindReferences((entity as TypeResolveResult).ResolvedClass, progressMonitor);
} else if (entity is MemberResolveResult) {
return FindReferences((entity as MemberResolveResult).ResolvedMember, progressMonitor);
} else if (entity is MethodResolveResult) {
IMethod method = (entity as MethodResolveResult).GetMethodIfSingleOverload();
if (method != null) {
return FindReferences(method, progressMonitor);
}
} else if (entity is MixedResolveResult) {
return FindReferences((entity as MixedResolveResult).PrimaryResult, progressMonitor);
}
return null;
}
/// <summary>
/// Find all references to the specified local variable.
/// </summary>

Loading…
Cancel
Save