Browse Source

Fixed bug introduced in revision 2688 that could cause non-partial classes to become a CompoundClass with two identical parts when the file is edited.

This caused symptoms like seeing fields and properties twice in the code completion drop-down, seeing method overloads twice; and indirectly caused several problems with the Rename refactoring.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2699 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
60d3c8b7e3
  1. 1
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs
  2. 21
      src/Libraries/NRefactory/Test/Lexer/CSharp/NumberLexerTest.cs
  3. 1
      src/Main/Base/Project/Src/Project/AbstractProject.cs
  4. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/CompoundClass.cs
  5. 12
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs

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

@ -421,6 +421,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -421,6 +421,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
sb.Append(ch);
}
} else if (ch == '\n') {
HandleLineEnd(ch); // ensure line numbers are still correct after the error
errors.Error(y, x, String.Format("No new line is allowed inside a string literal"));
break;
} else {

21
src/Libraries/NRefactory/Test/Lexer/CSharp/NumberLexerTest.cs

@ -143,6 +143,27 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -143,6 +143,27 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
CheckToken(@"""\U00010041""", "\U00010041");
}
[Test]
public void TestInvalidString()
{
// ensure that line numbers are correct after newline in string
ILexer l = GenerateLexer(new StringReader("\"\n\"\n;"));
Token t = l.NextToken();
Assert.AreEqual(Tokens.Literal, t.kind);
Assert.AreEqual(new Location(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(Tokens.Literal, t.kind);
Assert.AreEqual(new Location(1, 2), t.Location);
t = l.NextToken();
Assert.AreEqual(Tokens.Semicolon, t.kind);
Assert.AreEqual(new Location(1, 3), t.Location);
t = l.NextToken();
Assert.AreEqual(Tokens.EOF, t.kind);
}
[Test]
public void TestCharLiteral()
{

1
src/Main/Base/Project/Src/Project/AbstractProject.cs

@ -441,6 +441,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -441,6 +441,7 @@ namespace ICSharpCode.SharpDevelop.Project
return ItemType.None;
}
[Browsable(false)]
public virtual int MinimumSolutionVersion {
get { return 9; }
}

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/CompoundClass.cs

@ -7,6 +7,8 @@ @@ -7,6 +7,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
namespace ICSharpCode.SharpDevelop.Dom
{

12
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs

@ -342,14 +342,16 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -342,14 +342,16 @@ namespace ICSharpCode.SharpDevelop.Dom
}
//LoggingService.Debug("Added new part!");
return;
} else {
if (addClass.IsPartial || language.ImplicitPartialClasses) {
LoggingService.Info("Duplicate class " + fullyQualifiedName);
}
} else if (existingClass.CompilationUnit.FileName != addClass.CompilationUnit.FileName) {
// Instead of overwriting a class with another, treat both parts as partial.
// This fixes SD2-1217.
// But if the classes are in the same file, this is an update and we need to replace
// the class!
if (!(addClass.IsPartial || language.ImplicitPartialClasses)) {
LoggingService.Info("Duplicate class " + fullyQualifiedName);
}
// Merge existing non-partial class with addClass

Loading…
Cancel
Save