Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5334 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
38 changed files with 526 additions and 82 deletions
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using Boo.Lang.Compiler.Steps; |
||||
|
||||
namespace Grunwald.BooBinding.CodeCompletion |
||||
{ |
||||
/// <summary>
|
||||
/// The Boo 'BindNamespaces' step will remove imports that cannot be resolved.
|
||||
/// However, we need to keep those imports available for use inside SharpDevelop.
|
||||
/// </summary>
|
||||
public class BindNamespacesWithoutRemovingErrors : BindNamespaces |
||||
{ |
||||
public override void OnImport(Boo.Lang.Compiler.Ast.Import import) |
||||
{ |
||||
base.OnImport(import); |
||||
ReplaceCurrentNode(import); // prevent removal of import
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using Grunwald.BooBinding.CodeCompletion; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
|
||||
namespace Grunwald.BooBinding.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class ExpressionFinderTests |
||||
{ |
||||
const string code = "class A:\n\tpublic simple = 1\n// comment\ndef main():\n\tpass"; |
||||
ExpressionFinder ef = new ExpressionFinder(); |
||||
|
||||
void FindFull(string program, string location, string expectedExpression, ExpressionContext expectedContext) |
||||
{ |
||||
int pos = program.IndexOf(location); |
||||
if (pos < 0) Assert.Fail("location not found in program"); |
||||
ExpressionResult er = ef.FindFullExpression(program, pos); |
||||
Assert.AreEqual(expectedExpression, er.Expression); |
||||
if (expectedContext != null) { |
||||
Assert.AreEqual(expectedContext, er.Context); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void Simple() |
||||
{ |
||||
FindFull(code, "mple = 1", "simple", ExpressionContext.Default); |
||||
} |
||||
|
||||
[Test] |
||||
public void SimpleBeginningOfExpression() |
||||
{ |
||||
FindFull(code, "simple = 1", "simple", ExpressionContext.Default); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoMatchForComment1() |
||||
{ |
||||
FindFull(code, "// comment", null, null); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoMatchForComment2() |
||||
{ |
||||
FindFull(code, "/ comment", null, null); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoMatchForComment3() |
||||
{ |
||||
FindFull(code, " comment", null, null); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoMatchForComment4() |
||||
{ |
||||
FindFull(code, "comment", null, null); |
||||
} |
||||
} |
||||
} |
@ -1,10 +0,0 @@
@@ -1,10 +0,0 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<LastOpenVersion>8.0.50215</LastOpenVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<StartAction>Program</StartAction> |
||||
<StartProgram>D:\Corsavy\SharpDevelop\bin\SharpDevelop.exe</StartProgram> |
||||
<StartArguments>D:\Corsavy\SharpDevelop\src\Libraries\NRefactory\NRefactory.sln</StartArguments> |
||||
</PropertyGroup> |
||||
</Project> |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.CodeDom; |
||||
using ICSharpCode.NRefactory.Ast; |
||||
using ICSharpCode.NRefactory.Visitors; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.NRefactory.Tests.Output.CodeDOM.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class CodeDOMTypeReferenceTest |
||||
{ |
||||
[TestAttribute] |
||||
public void InnerClassTypeReferencTest() |
||||
{ |
||||
InnerClassTypeReference ictr = new InnerClassTypeReference( |
||||
new TypeReference("OuterClass", new List<TypeReference> { new TypeReference("String") }), |
||||
"InnerClass", |
||||
new List<TypeReference> { new TypeReference("Int32"), new TypeReference("Int64") }); |
||||
Assert.AreEqual("OuterClass<String>+InnerClass<Int32,Int64>", ictr.ToString()); |
||||
CodeTypeOfExpression result = (CodeTypeOfExpression)new TypeOfExpression(ictr).AcceptVisitor(new CodeDomVisitor(), null); |
||||
Assert.AreEqual("OuterClass`1+InnerClass`2", result.Type.BaseType); |
||||
Assert.AreEqual(3, result.Type.TypeArguments.Count); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.NRefactory.Ast; |
||||
using ICSharpCode.NRefactory.PrettyPrinter; |
||||
using ICSharpCode.SharpDevelop.Dom.Refactoring; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class ImplementInterfaceTests |
||||
{ |
||||
[Test] |
||||
public void NestedInterfaceInGenericClass() |
||||
{ |
||||
// See SD2-1626
|
||||
DefaultProjectContent pc = new DefaultProjectContent(); |
||||
pc.ReferencedContents.Add(SharedProjectContentRegistryForTests.Instance.Mscorlib); |
||||
|
||||
DefaultCompilationUnit cu = new DefaultCompilationUnit(pc); |
||||
DefaultClass container = new DefaultClass(cu, "TestClass"); |
||||
container.TypeParameters.Add(new DefaultTypeParameter(container, "T", 0)); |
||||
|
||||
DefaultClass innerClass = new DefaultClass(cu, container); |
||||
innerClass.FullyQualifiedName = "TestClass.INestedInterface"; |
||||
innerClass.ClassType = ClassType.Interface; |
||||
innerClass.TypeParameters.Add(new DefaultTypeParameter(innerClass, "T", 0)); |
||||
innerClass.Properties.Add(new DefaultProperty(innerClass, "P") { |
||||
ReturnType = new GenericReturnType(innerClass.TypeParameters[0]), |
||||
CanGet = true |
||||
}); |
||||
container.InnerClasses.Add(innerClass); |
||||
pc.AddClassToNamespaceList(container); |
||||
|
||||
DefaultClass targetClass = new DefaultClass(cu, "TargetClass"); |
||||
List<AbstractNode> nodes = new List<AbstractNode>(); |
||||
|
||||
IReturnType interf = new SearchClassReturnType(pc, targetClass, 0, 0, "TestClass.INestedInterface", 1); |
||||
interf = new ConstructedReturnType(interf, new IReturnType[] { SharedProjectContentRegistryForTests.Instance.Mscorlib.GetClass("System.String", 0).DefaultReturnType }); |
||||
|
||||
CSharpCodeGenerator codeGen = new CSharpCodeGenerator(); |
||||
codeGen.ImplementInterface(nodes, interf, true, targetClass); |
||||
|
||||
Assert.AreEqual(1, nodes.Count); |
||||
CSharpOutputVisitor output = new CSharpOutputVisitor(); |
||||
output.Options.IndentationChar = ' '; |
||||
output.Options.IndentSize = 2; |
||||
nodes[0].AcceptVisitor(output, null); |
||||
Assert.AreEqual("string TestClass<string>.INestedInterface.P {\n get {\n throw new NotImplementedException();\n }\n}", output.Text.Replace("\r", "").Trim()); |
||||
} |
||||
} |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue