Browse Source

Work around MSBuild CopyToOutputDirectory bug.

Fixed NRefactory unit tests.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1584 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
6f4e2a4736
  1. 4
      src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/Boo.InterpreterAddIn.booproj
  2. 11
      src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/PostBuildEvent.proj
  3. 1
      src/AddIns/BackendBindings/Boo/BooBinding/Project/PostBuildEvent.proj
  4. 4
      src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj
  5. 11
      src/AddIns/DisplayBindings/FormsDesigner/Project/PostBuildEvent.proj
  6. 2
      src/Libraries/NRefactory/NRefactoryASTGenerator/AST/GlobalLevel.cs
  7. 2
      src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Node.cs
  8. 12
      src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs
  9. 7
      src/Libraries/NRefactory/NRefactoryASTGenerator/Main.cs
  10. 9
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs
  11. 22
      src/Libraries/NRefactory/Project/Src/Parser/AST/Generated.cs
  12. 2
      src/Libraries/NRefactory/Project/Src/Parser/Location.cs
  13. 43
      src/Libraries/NRefactory/Test/Lexer/CSharp/LexerPositionTests.cs
  14. 29
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerPositionTests.cs
  15. 1
      src/Libraries/NRefactory/Test/NRefactoryTests.csproj
  16. 15
      src/Libraries/NRefactory/Test/Output/SpecialOutputVisitor.cs
  17. 7
      src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs
  18. 7
      src/Libraries/NRefactory/Test/Parser/GlobalScope/NamespaceDeclarationTests.cs
  19. 5
      src/Libraries/NRefactory/Test/Parser/GlobalScope/OptionDeclarationTests.cs
  20. 7
      src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs
  21. 5
      src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs
  22. 1
      src/Libraries/NRefactory/Test/Parser/ParseUtilCSharp.cs
  23. 5
      src/Libraries/NRefactory/Test/Parser/ParseUtilVBNet.cs
  24. 7
      src/Libraries/NRefactory/Test/Parser/SkipMethodBodiesTest.cs
  25. 7
      src/Libraries/NRefactory/Test/Parser/TypeLevel/ConstructorDeclarationTests.cs
  26. 7
      src/Libraries/NRefactory/Test/Parser/TypeLevel/DeclareDeclarationTests.cs
  27. 7
      src/Libraries/NRefactory/Test/Parser/TypeLevel/DestructorDeclarationTests.cs
  28. 7
      src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs
  29. 7
      src/Libraries/NRefactory/Test/Parser/TypeLevel/FieldDeclarationTests.cs
  30. 7
      src/Libraries/NRefactory/Test/Parser/TypeLevel/IndexerDeclarationTests.cs
  31. 7
      src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs
  32. 7
      src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs
  33. 7
      src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs
  34. 68
      src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs
  35. 19
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs
  36. 75
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserPanel.cs

4
src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/Boo.InterpreterAddIn.booproj

@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
<SpecificVersion>False</SpecificVersion>
</ProjectReference>
<Content Include="Boo.Interpreter.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
<ProjectReference Include="..\..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
@ -62,6 +62,8 @@ @@ -62,6 +62,8 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<Content Include="PostBuildEvent.proj" />
</ItemGroup>
<Import Project="$(BooBinPath)\Boo.Microsoft.Build.targets" />
<Import Project="PostBuildEvent.proj" />
</Project>

11
src/AddIns/BackendBindings/Boo/Boo.InterpreterAddIn/Project/PostBuildEvent.proj

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PrepareForRunDependsOn>$(PrepareForRunDependsOn);MyPostBuildTarget</PrepareForRunDependsOn>
</PropertyGroup>
<ItemGroup>
<MyCopyItem Include="$(MSBuildProjectDirectory)\*.addin" />
</ItemGroup>
<Target Name="MyPostBuildTarget">
<Copy SourceFiles="@(MyCopyItem)" DestinationFolder="$(OutputPath)" />
</Target>
</Project>

1
src/AddIns/BackendBindings/Boo/BooBinding/Project/PostBuildEvent.proj

@ -9,6 +9,5 @@ @@ -9,6 +9,5 @@
</ItemGroup>
<Target Name="MyPostBuildTarget">
<Copy SourceFiles="@(MyCopyItem)" DestinationFolder="$(OutputPath)" />
<Delete Files="$(OutputPath)\FormsDesigner.addin" ContinueOnError="True"/>
</Target>
</Project>

4
src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj

@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
<Compile Include="Src\Services\UIService.cs" />
<Compile Include="Src\ToolboxProvider.cs" />
<None Include="FormsDesigner.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<Compile Include="Src\DesignerGenerator\VBNetDesignerGenerator.cs" />
<Compile Include="Src\DesignerLoader\DesignerLoaderProvider.cs" />
@ -126,6 +126,8 @@ @@ -126,6 +126,8 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<Content Include="PostBuildEvent.proj" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<Import Project="PostBuildEvent.proj" />
</Project>

11
src/AddIns/DisplayBindings/FormsDesigner/Project/PostBuildEvent.proj

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PrepareForRunDependsOn>$(PrepareForRunDependsOn);MyPostBuildTarget</PrepareForRunDependsOn>
</PropertyGroup>
<ItemGroup>
<MyCopyItem Include="$(MSBuildProjectDirectory)\*.addin" />
</ItemGroup>
<Target Name="MyPostBuildTarget">
<Copy SourceFiles="@(MyCopyItem)" DestinationFolder="$(OutputPath)" />
</Target>
</Project>

2
src/Libraries/NRefactory/NRefactoryASTGenerator/AST/GlobalLevel.cs

@ -55,7 +55,7 @@ namespace NRefactoryASTGenerator.AST @@ -55,7 +55,7 @@ namespace NRefactoryASTGenerator.AST
ClassType type;
List<TypeReference> baseTypes;
List<TemplateDefinition> templates;
Point bodyStartLocation;
Location bodyStartLocation;
public TypeDeclaration(Modifier modifier, List<AttributeSection> attributes) : base(modifier, attributes) {}
}

2
src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Node.cs

@ -12,7 +12,7 @@ namespace NRefactoryASTGenerator.AST @@ -12,7 +12,7 @@ namespace NRefactoryASTGenerator.AST
{
interface INode {}
interface INullable {}
struct Point {}
struct Location {}
enum Modifier { None }

12
src/Libraries/NRefactory/NRefactoryASTGenerator/AST/TypeLevel.cs

@ -95,8 +95,8 @@ namespace NRefactoryASTGenerator.AST @@ -95,8 +95,8 @@ namespace NRefactoryASTGenerator.AST
EventAddRegion addRegion;
EventRemoveRegion removeRegion;
EventRaiseRegion raiseRegion;
Point bodyStart;
Point bodyEnd;
Location bodyStart;
Location bodyEnd;
public EventDeclaration(TypeReference typeReference, string name, Modifier modifier, List<AttributeSection> attributes, List<ParameterDeclarationExpression> parameters)
: base(modifier, attributes, name, parameters)
@ -203,8 +203,8 @@ namespace NRefactoryASTGenerator.AST @@ -203,8 +203,8 @@ namespace NRefactoryASTGenerator.AST
{
List<InterfaceImplementation> interfaceImplementations;
TypeReference typeReference;
Point bodyStart;
Point bodyEnd;
Location bodyStart;
Location bodyEnd;
PropertyGetRegion getRegion;
PropertySetRegion setRegion;
@ -254,8 +254,8 @@ namespace NRefactoryASTGenerator.AST @@ -254,8 +254,8 @@ namespace NRefactoryASTGenerator.AST
List<ParameterDeclarationExpression> parameters;
List<InterfaceImplementation> interfaceImplementations;
TypeReference typeReference;
Point bodyStart;
Point bodyEnd;
Location bodyStart;
Location bodyEnd;
PropertyGetRegion getRegion;
PropertySetRegion setRegion;

7
src/Libraries/NRefactory/NRefactoryASTGenerator/Main.cs

@ -45,7 +45,6 @@ namespace NRefactoryASTGenerator @@ -45,7 +45,6 @@ namespace NRefactoryASTGenerator
cns.Imports.Add(new CodeNamespaceImport("System"));
cns.Imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
cns.Imports.Add(new CodeNamespaceImport("System.Diagnostics"));
cns.Imports.Add(new CodeNamespaceImport("System.Drawing"));
foreach (Type type in nodeTypes) {
if (type.GetCustomAttributes(typeof(CustomImplementationAttribute), false).Length == 0) {
CodeTypeDeclaration ctd = new CodeTypeDeclaration(type.Name);
@ -423,7 +422,7 @@ namespace NRefactoryASTGenerator @@ -423,7 +422,7 @@ namespace NRefactoryASTGenerator
}
// initialize fields that were not initialized by parameter
foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic)) {
if (field.FieldType.IsValueType && field.FieldType != typeof(Point))
if (field.FieldType.IsValueType && field.FieldType != typeof(Location))
continue;
if (Array.Exists(ctor.GetParameters(), delegate(ParameterInfo p) { return field.Name == p.Name; }))
continue;
@ -456,8 +455,8 @@ namespace NRefactoryASTGenerator @@ -456,8 +455,8 @@ namespace NRefactoryASTGenerator
}
} else if (field.FieldType.FullName.StartsWith("System.Collections.Generic.List")) {
code = "new List<" + field.FieldType.GetGenericArguments()[0].Name + ">()";
} else if (field.FieldType == typeof(Point)) {
code = "new Point(-1, -1)";
} else if (field.FieldType == typeof(Location)) {
code = "Location.Empty";
} else {
code = field.FieldType.Name + ".Null";
}

9
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs

@ -33,6 +33,9 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -33,6 +33,9 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
{
int nextChar;
char ch;
bool hadLineEnd = false;
if (Line == 1 && Col == 1) hadLineEnd = true; // beginning of document
while ((nextChar = ReaderRead()) != -1) {
Token token;
@ -42,7 +45,13 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -42,7 +45,13 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
continue;
case '\r':
case '\n':
if (hadLineEnd) {
// second line end before getting to a token
// -> here was a blank line
specialTracker.AddEndOfLine(new Location(Line, Col));
}
HandleLineEnd((char)nextChar);
hadLineEnd = true;
continue;
case '/':
int peek = ReaderPeek();

22
src/Libraries/NRefactory/Project/Src/Parser/AST/Generated.cs

@ -1532,8 +1532,8 @@ namespace ICSharpCode.NRefactory.Parser.AST { @@ -1532,8 +1532,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
addRegion = EventAddRegion.Null;
removeRegion = EventRemoveRegion.Null;
raiseRegion = EventRaiseRegion.Null;
bodyStart = new Location(-1, -1);
bodyEnd = new Location(-1, -1);
bodyStart = Location.Empty;
bodyEnd = Location.Empty;
}
public EventDeclaration(TypeReference typeReference, Modifier modifier, List<ParameterDeclarationExpression> parameters, List<AttributeSection> attributes, string name, List<InterfaceImplementation> interfaceImplementations) :
@ -1543,8 +1543,8 @@ namespace ICSharpCode.NRefactory.Parser.AST { @@ -1543,8 +1543,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
addRegion = EventAddRegion.Null;
removeRegion = EventRemoveRegion.Null;
raiseRegion = EventRaiseRegion.Null;
bodyStart = new Location(-1, -1);
bodyEnd = new Location(-1, -1);
bodyStart = Location.Empty;
bodyEnd = Location.Empty;
}
public bool HasAddRegion {
@ -2319,8 +2319,8 @@ namespace ICSharpCode.NRefactory.Parser.AST { @@ -2319,8 +2319,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
Parameters = parameters;
interfaceImplementations = new List<InterfaceImplementation>();
typeReference = TypeReference.Null;
bodyStart = new Location(-1, -1);
bodyEnd = new Location(-1, -1);
bodyStart = Location.Empty;
bodyEnd = Location.Empty;
getRegion = PropertyGetRegion.Null;
setRegion = PropertySetRegion.Null;
}
@ -2331,8 +2331,8 @@ namespace ICSharpCode.NRefactory.Parser.AST { @@ -2331,8 +2331,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
Parameters = parameters;
Modifier = modifier;
interfaceImplementations = new List<InterfaceImplementation>();
bodyStart = new Location(-1, -1);
bodyEnd = new Location(-1, -1);
bodyStart = Location.Empty;
bodyEnd = Location.Empty;
getRegion = PropertyGetRegion.Null;
setRegion = PropertySetRegion.Null;
}
@ -3123,8 +3123,8 @@ namespace ICSharpCode.NRefactory.Parser.AST { @@ -3123,8 +3123,8 @@ namespace ICSharpCode.NRefactory.Parser.AST {
base(modifier, attributes, name, parameters) {
interfaceImplementations = new List<InterfaceImplementation>();
typeReference = TypeReference.Null;
bodyStart = new Location(-1, -1);
bodyEnd = new Location(-1, -1);
bodyStart = Location.Empty;
bodyEnd = Location.Empty;
getRegion = PropertyGetRegion.Null;
setRegion = PropertySetRegion.Null;
}
@ -3858,7 +3858,7 @@ namespace ICSharpCode.NRefactory.Parser.AST { @@ -3858,7 +3858,7 @@ namespace ICSharpCode.NRefactory.Parser.AST {
name = "";
baseTypes = new List<TypeReference>();
templates = new List<TemplateDefinition>();
bodyStartLocation = new Location(-1, -1);
bodyStartLocation = Location.Empty;
}
public override object AcceptVisitor(IAstVisitor visitor, object data) {

2
src/Libraries/NRefactory/Project/Src/Parser/Location.cs

@ -14,7 +14,7 @@ namespace ICSharpCode.NRefactory.Parser @@ -14,7 +14,7 @@ namespace ICSharpCode.NRefactory.Parser
/// </summary>
public struct Location
{
public static readonly Location Empty = new Location(0, 0);
public static readonly Location Empty = new Location(-1, -1);
public Location(int column, int line)
{

43
src/Libraries/NRefactory/Test/Lexer/CSharp/LexerPositionTests.cs

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
@ -28,7 +27,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -28,7 +27,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
{
ILexer l = GenerateLexer("public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
}
[Test]
public void Test2()
@ -36,7 +35,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -36,7 +35,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
ILexer l = GenerateLexer("public static");
Token t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(8, 1), t.Location);
Assert.AreEqual(new Location(8, 1), t.Location);
}
[Test]
public void TestReturn()
@ -44,77 +43,77 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -44,77 +43,77 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
ILexer l = GenerateLexer("public\nstatic");
Token t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(1, 2), t.Location);
Assert.AreEqual(new Location(1, 2), t.Location);
}
[Test]
public void TestSpace()
{
ILexer l = GenerateLexer(" public");
Token t = l.NextToken();
Assert.AreEqual(new Point(3, 1), t.Location);
Assert.AreEqual(new Location(3, 1), t.Location);
}
[Test]
public void TestOctNumber()
{
ILexer l = GenerateLexer("0142");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
}
[Test]
public void TestHexNumber()
{
ILexer l = GenerateLexer("0x142 public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(7, 1), t.Location);
Assert.AreEqual(new Location(7, 1), t.Location);
}
[Test]
public void TestHexNumberChar()
{
ILexer l = GenerateLexer("\'\\x224\' public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(9, 1), t.Location);
Assert.AreEqual(new Location(9, 1), t.Location);
}
[Test]
public void TestFloationPointNumber()
{
ILexer l = GenerateLexer("0.142 public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(7, 1), t.Location);
Assert.AreEqual(new Location(7, 1), t.Location);
}
[Test]
public void TestVerbatimString()
{
ILexer l = GenerateLexer("@\"a\"\"a\" public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(9, 1), t.Location);
Assert.AreEqual(new Location(9, 1), t.Location);
}
[Test]
public void TestAtIdent()
{
ILexer l = GenerateLexer("@public =");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(9, 1), t.Location);
Assert.AreEqual(new Location(9, 1), t.Location);
}
[Test]
public void TestNoFloationPointNumber()
{
ILexer l = GenerateLexer("5.a");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(2, 1), t.Location);
Assert.AreEqual(new Location(2, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(3, 1), t.Location);
Assert.AreEqual(new Location(3, 1), t.Location);
}
[Test]
public void TestNumber()
@ -122,7 +121,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -122,7 +121,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
ILexer l = GenerateLexer("142\nstatic");
Token t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(1, 2), t.Location);
Assert.AreEqual(new Location(1, 2), t.Location);
}
[Test]
public void TestNumber2()
@ -130,14 +129,14 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -130,14 +129,14 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
ILexer l = GenerateLexer("14 static");
Token t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(4, 1), t.Location);
Assert.AreEqual(new Location(4, 1), t.Location);
}
[Test]
public void TestOperator()
{
ILexer l = GenerateLexer("<<=");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
Assert.AreEqual(Tokens.EOF, l.NextToken().kind);
}
}

29
src/Libraries/NRefactory/Test/Lexer/VBNet/LexerPositionTests.cs

@ -6,12 +6,9 @@ @@ -6,12 +6,9 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.CSharp;
using ICSharpCode.NRefactory.PrettyPrinter;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.Lexer.VB
{
@ -28,7 +25,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -28,7 +25,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
{
ILexer l = GenerateLexer("public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
}
[Test]
public void Test2()
@ -36,7 +33,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -36,7 +33,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
ILexer l = GenerateLexer("public static");
Token t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(8, 1), t.Location);
Assert.AreEqual(new Location(8, 1), t.Location);
}
[Test]
public void TestReturn()
@ -45,41 +42,41 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -45,41 +42,41 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Token t = l.NextToken();
t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(1, 2), t.Location);
Assert.AreEqual(new Location(1, 2), t.Location);
}
[Test]
public void TestSpace()
{
ILexer l = GenerateLexer(" public");
Token t = l.NextToken();
Assert.AreEqual(new Point(3, 1), t.Location);
Assert.AreEqual(new Location(3, 1), t.Location);
}
[Test]
public void TestOctNumber()
{
ILexer l = GenerateLexer("0142");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
}
[Test]
public void TestFloationPointNumber()
{
ILexer l = GenerateLexer("0.142 public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(7, 1), t.Location);
Assert.AreEqual(new Location(7, 1), t.Location);
}
[Test]
public void TestNoFloationPointNumber()
{
ILexer l = GenerateLexer("5.a");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
Assert.AreEqual(new Location(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(2, 1), t.Location);
Assert.AreEqual(new Location(2, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(3, 1), t.Location);
Assert.AreEqual(new Location(3, 1), t.Location);
}
[Test]
public void TestNumber()
@ -88,7 +85,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -88,7 +85,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Token t = l.NextToken();
t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(1, 2), t.Location);
Assert.AreEqual(new Location(1, 2), t.Location);
}
[Test]
public void TestNumber2()
@ -96,7 +93,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -96,7 +93,7 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
ILexer l = GenerateLexer("14 static");
Token t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(4, 1), t.Location);
Assert.AreEqual(new Location(4, 1), t.Location);
}
}
}

1
src/Libraries/NRefactory/Test/NRefactoryTests.csproj

@ -37,7 +37,6 @@ @@ -37,7 +37,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="nunit.framework">
<HintPath>..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>

15
src/Libraries/NRefactory/Test/Output/SpecialOutputVisitor.cs

@ -47,6 +47,18 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -47,6 +47,18 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
parser.Dispose();
}
[Test]
public void BlankLine()
{
TestProgram("using A;\n\nusing B;");
}
[Test]
public void BlankLineAtBeginning()
{
TestProgram("\nusing A;\n\nusing B;");
}
[Test]
public void SimpleComments()
{
@ -58,9 +70,10 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -58,9 +70,10 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
"// after class");
}
[Test, Ignore("Requires BlankLine to work correctly")]
[Test]
public void BlockComment()
{
System.Diagnostics.Debugger.Break();
TestProgram("/* before class */\n" +
"class A\n" +
"{\n" +

7
src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/GlobalScope/NamespaceDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

5
src/Libraries/NRefactory/Test/Parser/GlobalScope/OptionDeclarationTests.cs

@ -6,13 +6,10 @@ @@ -6,13 +6,10 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

5
src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs

@ -6,13 +6,10 @@ @@ -6,13 +6,10 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

1
src/Libraries/NRefactory/Test/Parser/ParseUtilCSharp.cs

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;

5
src/Libraries/NRefactory/Test/Parser/ParseUtilVBNet.cs

@ -6,13 +6,10 @@ @@ -6,13 +6,10 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/SkipMethodBodiesTest.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/TypeLevel/ConstructorDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/TypeLevel/DeclareDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/TypeLevel/DestructorDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/TypeLevel/FieldDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/TypeLevel/IndexerDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

7
src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs

@ -6,13 +6,8 @@ @@ -6,13 +6,8 @@
// </file>
using System;
using System.Drawing;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.AST
{

68
src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
@ -423,5 +424,72 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -423,5 +424,72 @@ namespace ICSharpCode.SharpDevelop.Gui
node.Delete();
}
}
#region Static methods for saving/restoring expanded state
// example ViewStateString:
// [Main[ICSharpCode.SharpDevelop[Src[Gui[Pads[ProjectBrowser[]]]]Services[]]]]
// -> every node name is terminated by opening bracket
// -> only expanded nodes are included in the view state string
// -> after an opening bracket, an identifier or closing bracket must follow
// -> after a closing bracket, an identifier or closing bracket must follow
// -> nodes whose text contains '[' can not be saved
public static string GetViewStateString(TreeView treeView)
{
if (treeView.Nodes.Count == 0) return "";
StringBuilder b = new StringBuilder();
WriteViewStateString(b, treeView.Nodes[0]);
return b.ToString();
}
static void WriteViewStateString(StringBuilder b, TreeNode node)
{
b.Append('[');
foreach (TreeNode subNode in node.Nodes) {
if (subNode.IsExpanded && subNode.Text.IndexOf('[') < 0) {
b.Append(subNode.Text);
WriteViewStateString(b, subNode);
}
}
b.Append(']');
}
public static void ApplyViewStateString(string viewState, TreeView treeView)
{
if (viewState.Length == 0)
return;
int i = 0;
ApplyViewStateString(treeView.Nodes[0], viewState, ref i);
System.Diagnostics.Debug.Assert(i == viewState.Length - 1);
}
static void ApplyViewStateString(TreeNode node, string viewState, ref int pos)
{
if (viewState[pos++] != '[')
throw new ArgumentException("pos must point to '['");
// expect an identifier or an closing bracket
while (viewState[pos] != ']') {
StringBuilder nameBuilder = new StringBuilder();
char ch;
while ((ch = viewState[pos++]) != '[') {
nameBuilder.Append(ch);
}
pos -= 1; // go back to '[' character
string nodeText = nameBuilder.ToString();
// find the node in question
TreeNode subNode = null;
if (node != null) {
foreach (TreeNode n in node.Nodes) {
if (n.Text == nodeText) {
subNode = n;
break;
}
}
}
if (subNode != null) {
subNode.Expand();
}
ApplyViewStateString(subNode, viewState, ref pos);
// pos now points to the closing bracket of the inner view state
pos += 1; // move to next character
}
}
#endregion
}
}

19
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs

@ -140,7 +140,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -140,7 +140,10 @@ namespace ICSharpCode.SharpDevelop.Project
public void RefreshView()
{
if (treeView.Nodes.Count > 0) {
Properties memento = new Properties();
StoreViewState(memento);
ViewSolution(((AbstractProjectBrowserTreeNode)treeView.Nodes[0]).Solution);
ReadViewState(memento);
}
}
@ -412,6 +415,22 @@ namespace ICSharpCode.SharpDevelop.Project @@ -412,6 +415,22 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
/// <summary>
/// Writes the current view state into the memento.
/// </summary>
public void StoreViewState(Properties memento)
{
memento.Set("ProjectBrowserState", ExtTreeView.GetViewStateString(treeView));
}
/// <summary>
/// Reads the view state from the memento.
/// </summary>
public void ReadViewState(Properties memento)
{
ExtTreeView.ApplyViewStateString(memento.Get("ProjectBrowserState", ""), treeView);
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.

75
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserPanel.cs

@ -6,11 +6,9 @@ @@ -6,11 +6,9 @@
// </file>
using System;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.Project
{
@ -85,7 +83,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -85,7 +83,8 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary>
public void StoreViewState(Properties memento)
{
memento.Set("ProjectBrowserState", GetViewStateString(projectBrowserControl.TreeView));
projectBrowserControl.StoreViewState(memento);
memento.Set("ProjectBrowserState", ExtTreeView.GetViewStateString(projectBrowserControl.TreeView));
}
/// <summary>
@ -93,72 +92,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -93,72 +92,8 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary>
public void ReadViewState(Properties memento)
{
ApplyViewStateString(memento.Get("ProjectBrowserState", ""), projectBrowserControl.TreeView);
}
// example ViewStateString:
// [Main[ICSharpCode.SharpDevelop[Src[Gui[Pads[ProjectBrowser[]]]]Services[]]]]
// -> every node name is terminated by opening bracket
// -> only expanded nodes are included in the view state string
// -> after an opening bracket, an identifier or closing bracket must follow
// -> after a closing bracket, an identifier or closing bracket must follow
// -> nodes whose text contains '[' can not be saved
public static string GetViewStateString(TreeView treeView)
{
if (treeView.Nodes.Count == 0) return "";
StringBuilder b = new StringBuilder();
WriteViewStateString(b, treeView.Nodes[0]);
return b.ToString();
}
static void WriteViewStateString(StringBuilder b, TreeNode node)
{
b.Append('[');
foreach (TreeNode subNode in node.Nodes) {
if (subNode.IsExpanded && subNode.Text.IndexOf('[') < 0) {
b.Append(subNode.Text);
WriteViewStateString(b, subNode);
}
}
b.Append(']');
}
public static void ApplyViewStateString(string viewState, TreeView treeView)
{
if (viewState.Length == 0)
return;
int i = 0;
ApplyViewStateString(treeView.Nodes[0], viewState, ref i);
System.Diagnostics.Debug.Assert(i == viewState.Length - 1);
}
static void ApplyViewStateString(TreeNode node, string viewState, ref int pos)
{
if (viewState[pos++] != '[')
throw new ArgumentException("pos must point to '['");
// expect an identifier or an closing bracket
while (viewState[pos] != ']') {
StringBuilder nameBuilder = new StringBuilder();
char ch;
while ((ch = viewState[pos++]) != '[') {
nameBuilder.Append(ch);
}
pos -= 1; // go back to '[' character
string nodeText = nameBuilder.ToString();
// find the node in question
TreeNode subNode = null;
if (node != null) {
foreach (TreeNode n in node.Nodes) {
if (n.Text == nodeText) {
subNode = n;
break;
}
}
}
if (subNode != null) {
subNode.Expand();
}
ApplyViewStateString(subNode, viewState, ref pos);
// pos now points to the closing bracket of the inner view state
pos += 1; // move to next character
}
projectBrowserControl.ReadViewState(memento);
ExtTreeView.ApplyViewStateString(memento.Get("ProjectBrowserState", ""), projectBrowserControl.TreeView);
}
public void Clear()

Loading…
Cancel
Save