Browse Source

Merged SD 2.2 revision 2624:2639 to trunk.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2644 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
a5290c48e6
  1. BIN
      data/resources/StringResources.cz.resources
  2. BIN
      data/resources/StringResources.de.resources
  3. BIN
      data/resources/StringResources.es-mx.resources
  4. BIN
      data/resources/StringResources.es.resources
  5. BIN
      data/resources/StringResources.fr.resources
  6. BIN
      data/resources/StringResources.it.resources
  7. BIN
      data/resources/StringResources.kr.resources
  8. BIN
      data/resources/StringResources.nl.resources
  9. BIN
      data/resources/StringResources.no.resources
  10. BIN
      data/resources/StringResources.pl.resources
  11. BIN
      data/resources/StringResources.pt.resources
  12. BIN
      data/resources/StringResources.ro.resources
  13. BIN
      data/resources/StringResources.se.resources
  14. BIN
      data/resources/StringResources.tr.resources
  15. 4
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs
  16. 2
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs
  17. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs
  18. 6
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs
  19. 5
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultTextEditorProperties.cs
  20. 11
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/ITextEditorProperties.cs
  21. 132
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs
  22. 21
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs
  23. 837
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  24. 47
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  25. 3
      src/Libraries/NRefactory/Project/Src/Parser/gen.bat
  26. 48
      src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs
  27. 30
      src/Libraries/NRefactory/Test/Lexer/CSharp/NumberLexerTest.cs
  28. 9
      src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs
  29. 34
      src/Libraries/NRefactory/Test/Parser/Expressions/PrimitiveExpressionTests.cs
  30. 10
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs
  31. 11
      src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs
  32. 1
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  33. 2
      src/Main/Base/Project/Src/Project/Solution/AbstractSolutionFolder.cs
  34. 13
      src/Main/Base/Project/Src/Services/AmbienceService/CodeDOMGeneratorUtility.cs
  35. 11
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
  36. 28
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs
  37. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

BIN
data/resources/StringResources.cz.resources

Binary file not shown.

BIN
data/resources/StringResources.de.resources

Binary file not shown.

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

BIN
data/resources/StringResources.fr.resources

Binary file not shown.

BIN
data/resources/StringResources.it.resources

Binary file not shown.

BIN
data/resources/StringResources.kr.resources

Binary file not shown.

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

BIN
data/resources/StringResources.no.resources

Binary file not shown.

BIN
data/resources/StringResources.pl.resources

Binary file not shown.

BIN
data/resources/StringResources.pt.resources

Binary file not shown.

BIN
data/resources/StringResources.ro.resources

Binary file not shown.

BIN
data/resources/StringResources.se.resources

Binary file not shown.

BIN
data/resources/StringResources.tr.resources

Binary file not shown.

4
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs

@ -114,7 +114,7 @@ namespace ICSharpCode.WixBinding @@ -114,7 +114,7 @@ namespace ICSharpCode.WixBinding
{
if (!UpdateOpenFile(document)) {
ITextEditorProperties properties = SharpDevelopTextEditorProperties.Instance;
document.Save(properties.LineTerminator, properties.ConvertTabsToSpaces, properties.TabIndent);
document.Save(properties.LineTerminator, properties.ConvertTabsToSpaces, properties.IndentationSize);
}
packageFilesControl.IsDirty = false;
}
@ -297,7 +297,7 @@ namespace ICSharpCode.WixBinding @@ -297,7 +297,7 @@ namespace ICSharpCode.WixBinding
string GetWixXml(XmlElement element)
{
ITextEditorProperties properties = SharpDevelopTextEditorProperties.Instance;
return WixDocument.GetXml(element, properties.LineTerminator, properties.ConvertTabsToSpaces, properties.TabIndent);
return WixDocument.GetXml(element, properties.LineTerminator, properties.ConvertTabsToSpaces, properties.IndentationSize);
}
/// <summary>

2
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs

@ -74,7 +74,7 @@ namespace ICSharpCode.WixBinding @@ -74,7 +74,7 @@ namespace ICSharpCode.WixBinding
}
// Get the replacement dialog xml.
ITextEditorProperties properties = view.TextEditorControl.TextEditorProperties;
string replacementXml = WixDocument.GetXml(dialogElement, properties.LineTerminator, properties.ConvertTabsToSpaces, properties.TabIndent);
string replacementXml = WixDocument.GetXml(dialogElement, properties.LineTerminator, properties.ConvertTabsToSpaces, properties.IndentationSize);
// Replace the xml and select the inserted text.
WixDocumentEditor editor = new WixDocumentEditor(view.TextEditorControl.ActiveTextAreaControl);

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

@ -982,7 +982,7 @@ namespace ICSharpCode.XmlEditor @@ -982,7 +982,7 @@ namespace ICSharpCode.XmlEditor
{
XmlTextWriter writer = new XmlTextWriter(textWriter);
if (xmlEditor.TextEditorProperties.ConvertTabsToSpaces) {
writer.Indentation = xmlEditor.TextEditorProperties.TabIndent;
writer.Indentation = xmlEditor.TextEditorProperties.IndentationSize;
writer.IndentChar = ' ';
} else {
writer.Indentation = 1;

6
src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.TextEditor.Actions @@ -25,7 +25,7 @@ namespace ICSharpCode.TextEditor.Actions
StringBuilder indent = new StringBuilder();
if (document.TextEditorProperties.ConvertTabsToSpaces) {
int tabIndent = document.TextEditorProperties.TabIndent;
int tabIndent = document.TextEditorProperties.IndentationSize;
if (textArea != null) {
int column = textArea.TextView.GetVisualColumn(textArea.Caret.Line, textArea.Caret.Column);
indent.Append(new String(' ', tabIndent - column % tabIndent));
@ -144,7 +144,7 @@ namespace ICSharpCode.TextEditor.Actions @@ -144,7 +144,7 @@ namespace ICSharpCode.TextEditor.Actions
charactersToRemove = 1;
} else if(document.GetCharAt(line.Offset) == ' ') {
int leadingSpaces = 1;
int tabIndent = document.TextEditorProperties.TabIndent;
int tabIndent = document.TextEditorProperties.IndentationSize;
for (leadingSpaces = 1; leadingSpaces < line.Length && document.GetCharAt(line.Offset + leadingSpaces) == ' '; leadingSpaces++) {
// deliberately empty
}
@ -195,7 +195,7 @@ namespace ICSharpCode.TextEditor.Actions @@ -195,7 +195,7 @@ namespace ICSharpCode.TextEditor.Actions
// column is updated to that column.
LineSegment line = textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);
string startOfLine = textArea.Document.GetText(line.Offset,textArea.Caret.Offset - line.Offset);
int tabIndent = textArea.Document.TextEditorProperties.TabIndent;
int tabIndent = textArea.Document.TextEditorProperties.IndentationSize;
int currentColumn = textArea.Caret.Column;
int remainder = currentColumn % tabIndent;
if (remainder == 0) {

5
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultTextEditorProperties.cs

@ -19,6 +19,7 @@ namespace ICSharpCode.TextEditor.Document @@ -19,6 +19,7 @@ namespace ICSharpCode.TextEditor.Document
public class DefaultTextEditorProperties : ITextEditorProperties
{
int tabIndent = 4;
int indentationSize = 4;
IndentStyle indentStyle = IndentStyle.Smart;
DocumentSelectionMode documentSelectionMode = DocumentSelectionMode.Normal;
Encoding encoding = System.Text.Encoding.UTF8;
@ -73,6 +74,10 @@ namespace ICSharpCode.TextEditor.Document @@ -73,6 +74,10 @@ namespace ICSharpCode.TextEditor.Document
}
}
public int IndentationSize {
get { return indentationSize; }
set { indentationSize = value; }
}
public IndentStyle IndentStyle {
get {

11
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/ITextEditorProperties.cs

@ -123,11 +123,22 @@ namespace ICSharpCode.TextEditor.Document @@ -123,11 +123,22 @@ namespace ICSharpCode.TextEditor.Document
set;
}
/// <summary>
/// The width of a tab.
/// </summary>
int TabIndent { // is wrapped in text editor control
get;
set;
}
/// <summary>
/// The amount of spaces a tab is converted to if ConvertTabsToSpaces is true.
/// </summary>
int IndentationSize {
get;
set;
}
IndentStyle IndentStyle { // is wrapped in text editor control
get;
set;

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

@ -21,7 +21,8 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -21,7 +21,8 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
void ReadPreProcessingDirective()
{
Location start = new Location(Col - 1, Line);
string directive = ReadIdent('#');
bool canBeKeyword;
string directive = ReadIdent('#', out canBeKeyword);
string argument = ReadToEndOfLine();
this.specialTracker.AddPreprocessingDirective(directive, argument.Trim(), start, new Location(start.X + directive.Length + argument.Length, start.Y));
}
@ -80,7 +81,8 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -80,7 +81,8 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
if (ch == '"') {
token = ReadVerbatimString();
} else if (Char.IsLetterOrDigit(ch) || ch == '_') {
token = new Token(Tokens.Identifier, x - 1, y, ReadIdent(ch));
bool canBeKeyword;
token = new Token(Tokens.Identifier, x - 1, y, ReadIdent(ch, out canBeKeyword));
} else {
errors.Error(y, x, String.Format("Unexpected char in Lexer.Next() : {0}", ch));
continue;
@ -89,13 +91,16 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -89,13 +91,16 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
break;
default:
ch = (char)nextChar;
if (Char.IsLetter(ch) || ch == '_') {
if (Char.IsLetter(ch) || ch == '_' || ch == '\\') {
int x = Col - 1; // Col was incremented above, but we want the start of the identifier
int y = Line;
string s = ReadIdent(ch);
int keyWordToken = Keywords.GetToken(s);
if (keyWordToken >= 0) {
return new Token(keyWordToken, x, y, s);
bool canBeKeyword;
string s = ReadIdent(ch, out canBeKeyword);
if (canBeKeyword) {
int keyWordToken = Keywords.GetToken(s);
if (keyWordToken >= 0) {
return new Token(keyWordToken, x, y, s);
}
}
return new Token(Tokens.Identifier, x, y, s);
} else if (Char.IsDigit(ch)) {
@ -120,16 +125,39 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -120,16 +125,39 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
const int MAX_IDENTIFIER_LENGTH = 512;
char[] identBuffer = new char[MAX_IDENTIFIER_LENGTH];
string ReadIdent(char ch)
string ReadIdent(char ch, out bool canBeKeyword)
{
int peek;
int curPos = 1;
identBuffer[0] = ch;
while (IsIdentifierPart(peek = ReaderPeek())) {
ReaderRead();
int curPos = 0;
canBeKeyword = true;
while (true) {
if (ch == '\\') {
peek = ReaderPeek();
if (peek != 'u' && peek != 'U') {
errors.Error(Line, Col, "Identifiers can only contain unicode escape sequences");
}
canBeKeyword = false;
string surrogatePair;
ReadEscapeSequence(out ch, out surrogatePair);
if (surrogatePair != null) {
if (!char.IsLetterOrDigit(surrogatePair, 0)) {
errors.Error(Line, Col, "Unicode escape sequences in identifiers cannot be used to represent characters that are invalid in identifiers");
}
for (int i = 0; i < surrogatePair.Length - 1; i++) {
if (curPos < MAX_IDENTIFIER_LENGTH) {
identBuffer[curPos++] = surrogatePair[i];
}
}
ch = surrogatePair[surrogatePair.Length - 1];
} else {
if (!IsIdentifierPart(ch)) {
errors.Error(Line, Col, "Unicode escape sequences in identifiers cannot be used to represent characters that are invalid in identifiers");
}
}
}
if (curPos < MAX_IDENTIFIER_LENGTH) {
identBuffer[curPos++] = (char)peek;
identBuffer[curPos++] = ch;
} else {
errors.Error(Line, Col, String.Format("Identifier too long"));
while (IsIdentifierPart(ReaderPeek())) {
@ -137,6 +165,12 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -137,6 +165,12 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
}
break;
}
peek = ReaderPeek();
if (IsIdentifierPart(peek) || peek == '\\') {
ch = (char)ReaderRead();
} else {
break;
}
}
return new String(identBuffer, 0, curPos);
}
@ -286,29 +320,26 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -286,29 +320,26 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
}
}
// Try to determine a parsable value using ranges. (Quick hack!)
double d = 0;
// Try to determine a parsable value using ranges.
ulong result;
if (ishex) {
ulong result;
if (ulong.TryParse(digit, NumberStyles.HexNumber, null, out result)) {
d = result;
} else {
if (!ulong.TryParse(digit, NumberStyles.HexNumber, null, out result)) {
errors.Error(y, x, String.Format("Can't parse hexadecimal constant {0}", digit));
return new Token(Tokens.Literal, x, y, stringValue.ToString(), 0);
}
} else {
if (!Double.TryParse(digit, NumberStyles.Integer, null, out d)) {
if (!ulong.TryParse(digit, NumberStyles.Integer, null, out result)) {
errors.Error(y, x, String.Format("Can't parse integral constant {0}", digit));
return new Token(Tokens.Literal, x, y, stringValue.ToString(), 0);
}
}
if (d < long.MinValue || d > long.MaxValue) {
if (result > long.MaxValue) {
islong = true;
isunsigned = true;
} else if (d < uint.MinValue || d > uint.MaxValue) {
} else if (result > uint.MaxValue) {
islong = true;
} else if (d < int.MinValue || d > int.MaxValue) {
} else if (result > int.MaxValue) {
isunsigned = true;
}
@ -377,8 +408,13 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -377,8 +408,13 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
if (ch == '\\') {
originalValue.Append('\\');
originalValue.Append(ReadEscapeSequence(out ch));
sb.Append(ch);
string surrogatePair;
originalValue.Append(ReadEscapeSequence(out ch, out surrogatePair));
if (surrogatePair != null) {
sb.Append(surrogatePair);
} else {
sb.Append(ch);
}
} else if (ch == '\n') {
errors.Error(y, x, String.Format("No new line is allowed inside a string literal"));
break;
@ -431,14 +467,28 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -431,14 +467,28 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
}
char[] escapeSequenceBuffer = new char[12];
string ReadEscapeSequence(out char ch)
/// <summary>
/// reads an escape sequence
/// </summary>
/// <param name="ch">The character represented by the escape sequence,
/// or '\0' if there was an error or the escape sequence represents a character that
/// can be represented only be a suggorate pair</param>
/// <param name="surrogatePair">Null, except when the character represented
/// by the escape sequence can only be represented by a surrogate pair (then the string
/// contains the surrogate pair)</param>
/// <returns>The escape sequence</returns>
string ReadEscapeSequence(out char ch, out string surrogatePair)
{
surrogatePair = null;
int nextChar = ReaderRead();
if (nextChar == -1) {
errors.Error(Line, Col, String.Format("End of file reached inside escape sequence"));
ch = '\0';
return String.Empty;
}
int number;
char c = (char)nextChar;
int curPos = 1;
escapeSequenceBuffer[0] = c;
@ -478,8 +528,9 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -478,8 +528,9 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
break;
case 'u':
case 'x':
// 16 bit unicode character
c = (char)ReaderRead();
int number = GetHexNumber(c);
number = GetHexNumber(c);
escapeSequenceBuffer[curPos++] = c;
if (number < 0) {
@ -497,6 +548,27 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -497,6 +548,27 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
}
ch = (char)number;
break;
case 'U':
// 32 bit unicode character
number = 0;
for (int i = 0; i < 8; ++i) {
if (IsHex((char)ReaderPeek())) {
c = (char)ReaderRead();
int idx = GetHexNumber(c);
escapeSequenceBuffer[curPos++] = c;
number = 16 * number + idx;
} else {
errors.Error(Line, Col - 1, String.Format("Invalid char in literal : {0}", (char)ReaderPeek()));
break;
}
}
if (number > 0xffff) {
ch = '\0';
surrogatePair = char.ConvertFromUtf32(number);
} else {
ch = (char)number;
}
break;
default:
errors.Error(Line, Col, String.Format("Unexpected escape sequence : {0}", c));
ch = '\0';
@ -518,7 +590,11 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -518,7 +590,11 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
char chValue = ch;
string escapeSequence = String.Empty;
if (ch == '\\') {
escapeSequence = ReadEscapeSequence(out chValue);
string surrogatePair;
escapeSequence = ReadEscapeSequence(out chValue, out surrogatePair);
if (surrogatePair != null) {
errors.Error(y, x, String.Format("The unicode character must be represented by a surrogate pair and does not fit into a System.Char"));
}
}
unchecked {

21
src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs

@ -546,6 +546,27 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -546,6 +546,27 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
}
}
bool IsMostNegativeIntegerWithoutTypeSuffix()
{
Token token = la;
if (token.kind == Tokens.Literal) {
return token.val == "2147483648" || token.val == "9223372036854775808";
} else {
return false;
}
}
bool LastExpressionIsUnaryMinus(System.Collections.ArrayList expressions)
{
if (expressions.Count == 0) return false;
UnaryOperatorExpression uoe = expressions[expressions.Count - 1] as UnaryOperatorExpression;
if (uoe != null) {
return uoe.Op == UnaryOperatorType.Minus;
} else {
return false;
}
}
bool StartOfQueryExpression()
{
return la.kind == Tokens.From && IsIdentifierToken(Peek(1));

837
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

File diff suppressed because it is too large Load Diff

47
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -1669,8 +1669,8 @@ Expr<out Expression expr> @@ -1669,8 +1669,8 @@ Expr<out Expression expr>
UnaryExpr<out Expression uExpr>
(.
TypeReference type = null;
Expression expr;
ArrayList expressions = new ArrayList();
Expression expr = null;
ArrayList expressions = new ArrayList();
uExpr = null;
.)
=
@ -1694,20 +1694,35 @@ UnaryExpr<out Expression uExpr> @@ -1694,20 +1694,35 @@ UnaryExpr<out Expression uExpr>
)
}
PrimaryExpr<out expr> (. for (int i = 0; i < expressions.Count; ++i) {
Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr;
if (expressions[i] is CastExpression) {
((CastExpression)expressions[i]).Expression = nextExpression;
} else {
((UnaryOperatorExpression)expressions[i]).Expression = nextExpression;
}
}
if (expressions.Count > 0) {
uExpr = (Expression)expressions[0];
} else {
uExpr = expr;
}
.)
/* special rule (2.4.4.2) to allow writing int.MinValue and long.MinValue */
( IF (LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix())
Literal
(.
expressions.RemoveAt(expressions.Count - 1);
if (t.literalValue is uint) {
expr = new PrimitiveExpression(int.MinValue, int.MinValue.ToString());
} else if (t.literalValue is ulong) {
expr = new PrimitiveExpression(long.MinValue, long.MinValue.ToString());
} else {
throw new Exception("t.literalValue must be uint or ulong");
}
.)
| PrimaryExpr<out expr>
)
(. for (int i = 0; i < expressions.Count; ++i) {
Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr;
if (expressions[i] is CastExpression) {
((CastExpression)expressions[i]).Expression = nextExpression;
} else {
((UnaryOperatorExpression)expressions[i]).Expression = nextExpression;
}
}
if (expressions.Count > 0) {
uExpr = (Expression)expressions[0];
} else {
uExpr = expr;
}
.)
.

3
src/Libraries/NRefactory/Project/Src/Parser/gen.bat

@ -22,6 +22,3 @@ del VBNET.ATG @@ -22,6 +22,3 @@ del VBNET.ATG
:exit
pause
cd ..
rem pushd ..\..\..
rem %windir%\microsoft.net\framework\v2.0.50727\msbuild
rem popd

48
src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs

@ -32,13 +32,15 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -32,13 +32,15 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
Assert.AreEqual(Tokens.EOF, lexer.NextToken().kind);
}
[Test]
public void TestIdentifier()
void CheckIdentifier(string text, string actualIdentifier)
{
ILexer lexer = GenerateLexer(new StringReader("a_Bc05"));
ILexer lexer = GenerateLexer(new StringReader(text));
Token t = lexer.NextToken();
Assert.AreEqual(Tokens.Identifier, t.kind);
Assert.AreEqual("a_Bc05", t.val);
Assert.AreEqual(actualIdentifier, t.val);
t = lexer.NextToken();
Assert.AreEqual(Tokens.EOF, t.kind);
Assert.AreEqual("", lexer.Errors.ErrorOutput);
}
[Test]
@ -51,32 +53,46 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -51,32 +53,46 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
Assert.AreEqual("yield", t.val);
}
[Test]
public void TestIdentifier()
{
CheckIdentifier("a_Bc05", "a_Bc05");
}
[Test]
public void TestIdentifierStartingWithUnderscore()
{
ILexer lexer = GenerateLexer(new StringReader("_Bc05"));
Token t = lexer.NextToken();
Assert.AreEqual(Tokens.Identifier, t.kind);
Assert.AreEqual("_Bc05", t.val);
CheckIdentifier("_Bc05", "_Bc05");
}
[Test]
public void TestIdentifierStartingWithEscapeSequence()
{
CheckIdentifier(@"\u006cexer", "lexer");
}
[Test]
public void TestIdentifierContainingEscapeSequence()
{
CheckIdentifier(@"l\U00000065xer", "lexer");
}
[Test]
public void TestKeyWordAsIdentifier()
{
ILexer lexer = GenerateLexer(new StringReader("@int"));
Token t = lexer.NextToken();
Assert.AreEqual(Tokens.Identifier, t.kind);
Assert.AreEqual("int", t.val);
CheckIdentifier("@int", "int");
}
[Test]
public void TestKeywordWithEscapeSequenceIsIdentifier()
{
CheckIdentifier(@"i\u006et", "int");
}
[Test]
public void TestKeyWordAsIdentifierStartingWithUnderscore()
{
ILexer lexer = GenerateLexer(new StringReader("@_int"));
Token t = lexer.NextToken();
Assert.AreEqual(Tokens.Identifier, t.kind);
Assert.AreEqual("_int", t.val);
CheckIdentifier("@_int", "_int");
}
[Test]

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

@ -60,8 +60,11 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -60,8 +60,11 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
}
[Test]
public void TestOctalInteger()
public void TestNonOctalInteger()
{
// C# does not have octal integers, so 077 should parse to 77
Assert.IsTrue(077 == 77);
CheckToken("077", 077);
CheckToken("056", 056);
}
@ -92,6 +95,17 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -92,6 +95,17 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
CheckToken("0xf244636f446c6d58", 0xf244636f446c6d58);
}
[Test]
public void TestLongInteger()
{
CheckToken("9223372036854775807", 9223372036854775807); // long.MaxValue
CheckToken("9223372036854775808", 9223372036854775808); // long.MaxValue+1
CheckToken("18446744073709551615", 18446744073709551615); // ulong.MaxValue
CheckToken("18446744073709551616f", 18446744073709551616f); // ulong.MaxValue+1 as float
CheckToken("18446744073709551616d", 18446744073709551616d); // ulong.MaxValue+1 as double
CheckToken("18446744073709551616m", 18446744073709551616m); // ulong.MaxValue+1 as decimal
}
[Test]
public void TestDouble()
{
@ -124,6 +138,20 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp @@ -124,6 +138,20 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.CSharp
{
CheckToken(@"@""-->""""<--""", @"-->""<--");
CheckToken(@"""-->\""<--""", "-->\"<--");
CheckToken(@"""\U00000041""", "\U00000041");
CheckToken(@"""\U00010041""", "\U00010041");
}
[Test]
public void TestCharLiteral()
{
CheckToken(@"'a'", 'a');
CheckToken(@"'\u0041'", '\u0041');
CheckToken(@"'\x41'", '\x41');
CheckToken(@"'\x041'", '\x041');
CheckToken(@"'\x0041'", '\x0041');
CheckToken(@"'\U00000041'", '\U00000041');
}
}
}

9
src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs

@ -34,6 +34,15 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -34,6 +34,15 @@ namespace ICSharpCode.NRefactory.Tests.Ast
CheckSimpleObjectCreateExpression(ParseUtilCSharp.ParseExpression<ObjectCreateExpression>("new MyObject(1, 2, 3)"));
}
[Test]
public void CSharpNullableObjectCreateExpressionTest()
{
ObjectCreateExpression oce = ParseUtilCSharp.ParseExpression<ObjectCreateExpression>("new IntPtr?(1)");
Assert.AreEqual("System.Nullable", oce.CreateType.SystemType);
Assert.AreEqual(1, oce.CreateType.GenericTypes.Count);
Assert.AreEqual("IntPtr", oce.CreateType.GenericTypes[0].Type);
}
[Test]
public void CSharpInvalidNestedObjectCreateExpressionTest()
{

34
src/Libraries/NRefactory/Test/Parser/Expressions/PrimitiveExpressionTests.cs

@ -50,6 +50,40 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -50,6 +50,40 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual('\u0356', (char)pe.Value);
}
[Test]
public void IntMinValueTest()
{
PrimitiveExpression pe = ParseUtilCSharp.ParseExpression<PrimitiveExpression>("-2147483648");
Assert.AreEqual(-2147483648, (int)pe.Value);
}
[Test]
public void IntMaxValueTest()
{
PrimitiveExpression pe = ParseUtilCSharp.ParseExpression<PrimitiveExpression>("2147483647");
Assert.AreEqual(2147483647, (int)pe.Value);
pe = ParseUtilCSharp.ParseExpression<PrimitiveExpression>("2147483648");
Assert.AreEqual(2147483648, (uint)pe.Value);
}
[Test]
public void LongMinValueTest()
{
PrimitiveExpression pe = ParseUtilCSharp.ParseExpression<PrimitiveExpression>("-9223372036854775808");
Assert.AreEqual(-9223372036854775808, (long)pe.Value);
}
[Test]
public void LongMaxValueTest()
{
PrimitiveExpression pe = ParseUtilCSharp.ParseExpression<PrimitiveExpression>("9223372036854775807");
Assert.AreEqual(9223372036854775807, (long)pe.Value);
pe = ParseUtilCSharp.ParseExpression<PrimitiveExpression>("9223372036854775808");
Assert.AreEqual(9223372036854775808, (ulong)pe.Value);
}
[Test]
public void CSharpStringTest1()
{

10
src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.TextEditor.Document;
using System;
using System.Collections;
using System.Collections.Generic;
@ -12,8 +13,8 @@ using System.Drawing; @@ -12,8 +13,8 @@ using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project;
@ -372,6 +373,13 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -372,6 +373,13 @@ namespace ICSharpCode.SharpDevelop.Gui
// Parse twice so that tags used in included standard header are parsed
string parsedContent = StringParser.Parse(StringParser.Parse(content));
if (parsedContent != null) {
if (SharpDevelopTextEditorProperties.Instance.IndentationString != "\t") {
parsedContent = parsedContent.Replace("\t", SharpDevelopTextEditorProperties.Instance.IndentationString);
}
}
// when newFile.Name is "${Path}/${FileName}", there might be a useless '/' in front of the file name
// if the file is created when no project is opened. So we remove single '/' or '\', but not double
// '\\' (project is saved on network share).

11
src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs

@ -5,18 +5,17 @@ @@ -5,18 +5,17 @@
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using Import = System.Collections.Generic.KeyValuePair<System.String, System.String>;
using MSBuild = Microsoft.Build.BuildEngine;
using Import = System.Collections.Generic.KeyValuePair<string, string>;
namespace ICSharpCode.SharpDevelop.Internal.Templates
{
@ -358,7 +357,11 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates @@ -358,7 +357,11 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates
} else {
// Textual content
StreamWriter sr = new StreamWriter(File.Create(fileName), ParserService.DefaultFileEncoding);
sr.Write(StringParser.Parse(StringParser.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}})));
string fileContent = StringParser.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}});
if (SharpDevelopTextEditorProperties.Instance.IndentationString != "\t") {
fileContent = fileContent.Replace("\t", SharpDevelopTextEditorProperties.Instance.IndentationString);
}
sr.Write(fileContent);
sr.Close();
}
} catch (Exception ex) {

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

@ -344,6 +344,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -344,6 +344,7 @@ namespace ICSharpCode.SharpDevelop.Project
return property;
}
}
location = PropertyStorageLocations.Unknown;
group = null;
return null;

2
src/Main/Base/Project/Src/Project/Solution/AbstractSolutionFolder.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -26,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Project
/// <summary>
/// Gets the object used for thread-safe synchronization.
/// All members lock on this object, but if you manipulate underlying structures
/// Thread-safe members lock on this object, but if you manipulate underlying structures
/// (such as the MSBuild project for MSBuildBasedProjects) directly, you will have to lock on this object.
/// </summary>
[Browsable(false)]

13
src/Main/Base/Project/Src/Services/AmbienceService/CodeDOMGeneratorUtility.cs

@ -10,7 +10,6 @@ using System.CodeDom; @@ -10,7 +10,6 @@ using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
using System.Text;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
@ -25,18 +24,8 @@ namespace ICSharpCode.SharpDevelop @@ -25,18 +24,8 @@ namespace ICSharpCode.SharpDevelop
options.BracingStyle = AmbienceService.CodeGenerationProperties.Get("StartBlockOnSameLine", true) ? "Block" : "C";
options.ElseOnClosing = AmbienceService.CodeGenerationProperties.Get("ElseOnClosing", true);
options.IndentString = SharpDevelopTextEditorProperties.Instance.IndentationString;
SharpDevelopTextEditorProperties docProperties = SharpDevelopTextEditorProperties.Instance;
if (docProperties.ConvertTabsToSpaces) {
StringBuilder indentationString = new StringBuilder();
for (int i = 0; i < docProperties.IndentationSize; ++i) {
indentationString.Append(' ');
}
options.IndentString = indentationString.ToString();
} else {
options.IndentString = "\t";
}
return options;
}
}

11
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -101,14 +101,21 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -101,14 +101,21 @@ namespace ICSharpCode.SharpDevelop.Debugging
public static event EventHandler DebugStopped;
static void OnDebugStarted(object sender, EventArgs e)
{
// OnDebugStarted runs on the main thread, but for some reason we
// have to delay the layout change a bit to work around SD2-1325
WorkbenchSingleton.SafeThreadAsyncCall(OnDebugStartedInvoked);
if (DebugStarted != null)
DebugStarted(null, EventArgs.Empty);
}
static void OnDebugStartedInvoked()
{
WorkbenchSingleton.Workbench.WorkbenchLayout.StoreConfiguration();
oldLayoutConfiguration = LayoutConfiguration.CurrentLayoutName;
LayoutConfiguration.CurrentLayoutName = "Debug";
ClearDebugMessages();
if (DebugStarted != null)
DebugStarted(null, e);
}
static void OnDebugStopped(object sender, EventArgs e)

28
src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs

@ -49,17 +49,37 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -49,17 +49,37 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
return properties.Get("TabIndent", 4);
}
set {
// FIX: don't allow to set tab size to zero as this will cause divide by zero exceptions in the text control.
// Zero isn't a setting that makes sense, anyway.
if (value < 1) value = 1;
properties.Set("TabIndent", value);
}
}
public int IndentationSize {
get {
return properties.Get("IndentationSize", 4);
}
get { return properties.Get("IndentationSize", 4); }
set {
if (value < 1) value = 1;
properties.Set("IndentationSize", value);
indentationString = null;
}
}
string indentationString;
public string IndentationString {
get {
if (indentationString == null) {
SharpDevelopTextEditorProperties p = new SharpDevelopTextEditorProperties();
if (p.ConvertTabsToSpaces)
return new string(' ', p.IndentationSize);
else
return "\t";
}
return indentationString;
}
}
public IndentStyle IndentStyle {
get {
return properties.Get("IndentStyle", IndentStyle.Smart);
@ -189,6 +209,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -189,6 +209,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
set {
properties.Set("TabsToSpaces", value);
indentationString = null;
}
}
public bool MouseWheelScrollDown {
@ -333,3 +354,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -333,3 +354,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
}

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save