diff --git a/data/resources/StringResources.cz.resources b/data/resources/StringResources.cz.resources index 1fdbd8dacc..8e4df7f812 100644 Binary files a/data/resources/StringResources.cz.resources and b/data/resources/StringResources.cz.resources differ diff --git a/data/resources/StringResources.de.resources b/data/resources/StringResources.de.resources index 72acc63a0a..1a0f6a9533 100644 Binary files a/data/resources/StringResources.de.resources and b/data/resources/StringResources.de.resources differ diff --git a/data/resources/StringResources.es-mx.resources b/data/resources/StringResources.es-mx.resources index 5bd740b6ba..40943caa8f 100644 Binary files a/data/resources/StringResources.es-mx.resources and b/data/resources/StringResources.es-mx.resources differ diff --git a/data/resources/StringResources.es.resources b/data/resources/StringResources.es.resources index afb1a7af34..a415b410d0 100644 Binary files a/data/resources/StringResources.es.resources and b/data/resources/StringResources.es.resources differ diff --git a/data/resources/StringResources.fr.resources b/data/resources/StringResources.fr.resources index b32c1c1949..39ca25d7e0 100644 Binary files a/data/resources/StringResources.fr.resources and b/data/resources/StringResources.fr.resources differ diff --git a/data/resources/StringResources.it.resources b/data/resources/StringResources.it.resources index caafe344c5..90289e0fb8 100644 Binary files a/data/resources/StringResources.it.resources and b/data/resources/StringResources.it.resources differ diff --git a/data/resources/StringResources.kr.resources b/data/resources/StringResources.kr.resources index 3981e158bb..1bed6f62e0 100644 Binary files a/data/resources/StringResources.kr.resources and b/data/resources/StringResources.kr.resources differ diff --git a/data/resources/StringResources.nl.resources b/data/resources/StringResources.nl.resources index cf1daed4e3..42c74c9862 100644 Binary files a/data/resources/StringResources.nl.resources and b/data/resources/StringResources.nl.resources differ diff --git a/data/resources/StringResources.no.resources b/data/resources/StringResources.no.resources index 5b7a111625..1093a756dd 100644 Binary files a/data/resources/StringResources.no.resources and b/data/resources/StringResources.no.resources differ diff --git a/data/resources/StringResources.pl.resources b/data/resources/StringResources.pl.resources index f176d567e6..ef8908fe64 100644 Binary files a/data/resources/StringResources.pl.resources and b/data/resources/StringResources.pl.resources differ diff --git a/data/resources/StringResources.pt.resources b/data/resources/StringResources.pt.resources index 94aef9091f..e66a020220 100644 Binary files a/data/resources/StringResources.pt.resources and b/data/resources/StringResources.pt.resources differ diff --git a/data/resources/StringResources.ro.resources b/data/resources/StringResources.ro.resources index f29d84240c..ac3ce27108 100644 Binary files a/data/resources/StringResources.ro.resources and b/data/resources/StringResources.ro.resources differ diff --git a/data/resources/StringResources.se.resources b/data/resources/StringResources.se.resources index 56bf8c8bca..fe29512f8b 100644 Binary files a/data/resources/StringResources.se.resources and b/data/resources/StringResources.se.resources differ diff --git a/data/resources/StringResources.tr.resources b/data/resources/StringResources.tr.resources index 7c7671f2b8..217c311a1e 100644 Binary files a/data/resources/StringResources.tr.resources and b/data/resources/StringResources.tr.resources differ diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs index 845bf1f253..5faaa72deb 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/PackageFilesView.cs @@ -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 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); } /// diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs index 9c8cbd9ded..0de2ffafd5 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixDialogDesignerGenerator.cs @@ -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); diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs index 24fb450ef6..dd4c7c51ff 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs @@ -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; diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs index 3ed8890f2a..7da1746fb6 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs @@ -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 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 // 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) { diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultTextEditorProperties.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultTextEditorProperties.cs index 43e65b4424..04ff6d8179 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultTextEditorProperties.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/DefaultTextEditorProperties.cs @@ -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 } } + public int IndentationSize { + get { return indentationSize; } + set { indentationSize = value; } + } public IndentStyle IndentStyle { get { diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/ITextEditorProperties.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/ITextEditorProperties.cs index ef61ecf262..fc2e83214b 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/ITextEditorProperties.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/ITextEditorProperties.cs @@ -123,11 +123,22 @@ namespace ICSharpCode.TextEditor.Document set; } + /// + /// The width of a tab. + /// int TabIndent { // is wrapped in text editor control get; set; } + /// + /// The amount of spaces a tab is converted to if ConvertTabsToSpaces is true. + /// + int IndentationSize { + get; + set; + } + IndentStyle IndentStyle { // is wrapped in text editor control get; set; diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs index 4bd7df970c..dc57f689cb 100644 --- a/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs +++ b/src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs @@ -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 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 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 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 } 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 } } - // 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 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 } char[] escapeSequenceBuffer = new char[12]; - string ReadEscapeSequence(out char ch) + + /// + /// reads an escape sequence + /// + /// 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 + /// 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) + /// The escape sequence + 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 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 } 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 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 { diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs index a445102d21..7027918b11 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/CSharpParser.cs @@ -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)); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index d90b114451..56ea74e078 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -900,39 +900,39 @@ templates); } void TypeParameterList( -#line 2155 "cs.ATG" +#line 2170 "cs.ATG" List templates) { -#line 2157 "cs.ATG" +#line 2172 "cs.ATG" AttributeSection section; List attributes = new List(); Expect(23); while (la.kind == 18) { AttributeSection( -#line 2161 "cs.ATG" +#line 2176 "cs.ATG" out section); -#line 2161 "cs.ATG" +#line 2176 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2162 "cs.ATG" +#line 2177 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); while (la.kind == 14) { lexer.NextToken(); while (la.kind == 18) { AttributeSection( -#line 2163 "cs.ATG" +#line 2178 "cs.ATG" out section); -#line 2163 "cs.ATG" +#line 2178 "cs.ATG" attributes.Add(section); } Identifier(); -#line 2164 "cs.ATG" +#line 2179 "cs.ATG" templates.Add(new TemplateDefinition(t.val, attributes)); } Expect(22); @@ -965,22 +965,22 @@ out typeRef, false); } void TypeParameterConstraintsClause( -#line 2168 "cs.ATG" +#line 2183 "cs.ATG" List templates) { -#line 2169 "cs.ATG" +#line 2184 "cs.ATG" string name = ""; TypeReference type; Expect(127); Identifier(); -#line 2172 "cs.ATG" +#line 2187 "cs.ATG" name = t.val; Expect(9); TypeParameterConstraintsClauseBase( -#line 2174 "cs.ATG" +#line 2189 "cs.ATG" out type); -#line 2175 "cs.ATG" +#line 2190 "cs.ATG" TemplateDefinition td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -993,10 +993,10 @@ out type); while (la.kind == 14) { lexer.NextToken(); TypeParameterConstraintsClauseBase( -#line 2184 "cs.ATG" +#line 2199 "cs.ATG" out type); -#line 2185 "cs.ATG" +#line 2200 "cs.ATG" td = null; foreach (TemplateDefinition d in templates) { if (d.Name == name) { @@ -1330,33 +1330,33 @@ out r, canBeUnbound); } void TypeName( -#line 2098 "cs.ATG" +#line 2113 "cs.ATG" out TypeReference typeRef, bool canBeUnbound) { -#line 2099 "cs.ATG" +#line 2114 "cs.ATG" List typeArguments = null; string alias = null; string qualident; if ( -#line 2104 "cs.ATG" +#line 2119 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 2105 "cs.ATG" +#line 2120 "cs.ATG" alias = t.val; Expect(10); } Qualident( -#line 2108 "cs.ATG" +#line 2123 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2109 "cs.ATG" +#line 2124 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2111 "cs.ATG" +#line 2126 "cs.ATG" if (alias == null) { typeRef = new TypeReference(qualident, typeArguments); } else if (alias == "global") { @@ -1367,22 +1367,22 @@ out typeArguments, canBeUnbound); } while ( -#line 2120 "cs.ATG" +#line 2135 "cs.ATG" DotAndIdent()) { Expect(15); -#line 2121 "cs.ATG" +#line 2136 "cs.ATG" typeArguments = null; Qualident( -#line 2122 "cs.ATG" +#line 2137 "cs.ATG" out qualident); if (la.kind == 23) { TypeArgumentList( -#line 2123 "cs.ATG" +#line 2138 "cs.ATG" out typeArguments, canBeUnbound); } -#line 2124 "cs.ATG" +#line 2139 "cs.ATG" typeRef = new InnerClassTypeReference(typeRef, qualident, typeArguments); } } @@ -2485,14 +2485,14 @@ out name); } void NullableQuestionMark( -#line 2129 "cs.ATG" +#line 2144 "cs.ATG" ref TypeReference typeRef) { -#line 2130 "cs.ATG" +#line 2145 "cs.ATG" List typeArguments = new List(1); Expect(12); -#line 2134 "cs.ATG" +#line 2149 "cs.ATG" if (typeRef != null) typeArguments.Add(typeRef); typeRef = new TypeReference("System.Nullable", typeArguments); @@ -4139,8 +4139,8 @@ out Expression uExpr) { #line 1671 "cs.ATG" TypeReference type = null; - Expression expr; - ArrayList expressions = new ArrayList(); + Expression expr = null; + ArrayList expressions = new ArrayList(); uExpr = null; while (StartOf(30) || @@ -4197,11 +4197,28 @@ out type); expressions.Add(new CastExpression(type)); } } - PrimaryExpr( -#line 1697 "cs.ATG" + if ( +#line 1698 "cs.ATG" +LastExpressionIsUnaryMinus(expressions) && IsMostNegativeIntegerWithoutTypeSuffix()) { + Expect(2); + +#line 1701 "cs.ATG" + 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"); + } + + } else if (StartOf(31)) { + PrimaryExpr( +#line 1710 "cs.ATG" out expr); + } else SynErr(201); -#line 1697 "cs.ATG" +#line 1712 "cs.ATG" for (int i = 0; i < expressions.Count; ++i) { Expression nextExpression = i + 1 < expressions.Count ? (Expression)expressions[i + 1] : expr; if (expressions[i] is CastExpression) { @@ -4219,33 +4236,33 @@ out expr); } void ConditionalOrExpr( -#line 1969 "cs.ATG" +#line 1984 "cs.ATG" ref Expression outExpr) { -#line 1970 "cs.ATG" +#line 1985 "cs.ATG" Expression expr; ConditionalAndExpr( -#line 1972 "cs.ATG" +#line 1987 "cs.ATG" ref outExpr); while (la.kind == 26) { lexer.NextToken(); UnaryExpr( -#line 1972 "cs.ATG" +#line 1987 "cs.ATG" out expr); ConditionalAndExpr( -#line 1972 "cs.ATG" +#line 1987 "cs.ATG" ref expr); -#line 1972 "cs.ATG" +#line 1987 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalOr, expr); } } void PrimaryExpr( -#line 1714 "cs.ATG" +#line 1729 "cs.ATG" out Expression pexpr) { -#line 1716 "cs.ATG" +#line 1731 "cs.ATG" TypeReference type = null; List typeList = null; Expression expr; @@ -4254,479 +4271,479 @@ out Expression pexpr) { if (la.kind == 113) { lexer.NextToken(); -#line 1723 "cs.ATG" +#line 1738 "cs.ATG" pexpr = new PrimitiveExpression(true, "true"); } else if (la.kind == 72) { lexer.NextToken(); -#line 1724 "cs.ATG" +#line 1739 "cs.ATG" pexpr = new PrimitiveExpression(false, "false"); } else if (la.kind == 90) { lexer.NextToken(); -#line 1725 "cs.ATG" +#line 1740 "cs.ATG" pexpr = new PrimitiveExpression(null, "null"); } else if (la.kind == 2) { lexer.NextToken(); -#line 1726 "cs.ATG" +#line 1741 "cs.ATG" pexpr = new PrimitiveExpression(t.literalValue, t.val); } else if ( -#line 1727 "cs.ATG" +#line 1742 "cs.ATG" StartOfQueryExpression()) { QueryExpression( -#line 1728 "cs.ATG" +#line 1743 "cs.ATG" out pexpr); } else if ( -#line 1729 "cs.ATG" +#line 1744 "cs.ATG" IdentAndDoubleColon()) { Identifier(); -#line 1730 "cs.ATG" +#line 1745 "cs.ATG" type = new TypeReference(t.val); Expect(10); -#line 1731 "cs.ATG" +#line 1746 "cs.ATG" pexpr = new TypeReferenceExpression(type); Identifier(); -#line 1732 "cs.ATG" +#line 1747 "cs.ATG" if (type.Type == "global") { type.IsGlobal = true; type.Type = (t.val ?? "?"); } else type.Type += "." + (t.val ?? "?"); } else if (StartOf(17)) { Identifier(); -#line 1735 "cs.ATG" +#line 1750 "cs.ATG" pexpr = new IdentifierExpression(t.val); -#line 1736 "cs.ATG" +#line 1751 "cs.ATG" pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation; if (la.kind == 48) { ShortedLambdaExpression( -#line 1738 "cs.ATG" +#line 1753 "cs.ATG" (IdentifierExpression)pexpr, out pexpr); } } else if ( -#line 1739 "cs.ATG" +#line 1754 "cs.ATG" IsLambdaExpression()) { LambdaExpression( -#line 1740 "cs.ATG" +#line 1755 "cs.ATG" out pexpr); } else if (la.kind == 20) { lexer.NextToken(); Expr( -#line 1742 "cs.ATG" +#line 1757 "cs.ATG" out expr); Expect(21); -#line 1742 "cs.ATG" +#line 1757 "cs.ATG" pexpr = new ParenthesizedExpression(expr); - } else if (StartOf(31)) { + } else if (StartOf(32)) { -#line 1744 "cs.ATG" +#line 1759 "cs.ATG" string val = null; switch (la.kind) { case 52: { lexer.NextToken(); -#line 1746 "cs.ATG" +#line 1761 "cs.ATG" val = "bool"; break; } case 54: { lexer.NextToken(); -#line 1747 "cs.ATG" +#line 1762 "cs.ATG" val = "byte"; break; } case 57: { lexer.NextToken(); -#line 1748 "cs.ATG" +#line 1763 "cs.ATG" val = "char"; break; } case 62: { lexer.NextToken(); -#line 1749 "cs.ATG" +#line 1764 "cs.ATG" val = "decimal"; break; } case 66: { lexer.NextToken(); -#line 1750 "cs.ATG" +#line 1765 "cs.ATG" val = "double"; break; } case 75: { lexer.NextToken(); -#line 1751 "cs.ATG" +#line 1766 "cs.ATG" val = "float"; break; } case 82: { lexer.NextToken(); -#line 1752 "cs.ATG" +#line 1767 "cs.ATG" val = "int"; break; } case 87: { lexer.NextToken(); -#line 1753 "cs.ATG" +#line 1768 "cs.ATG" val = "long"; break; } case 91: { lexer.NextToken(); -#line 1754 "cs.ATG" +#line 1769 "cs.ATG" val = "object"; break; } case 102: { lexer.NextToken(); -#line 1755 "cs.ATG" +#line 1770 "cs.ATG" val = "sbyte"; break; } case 104: { lexer.NextToken(); -#line 1756 "cs.ATG" +#line 1771 "cs.ATG" val = "short"; break; } case 108: { lexer.NextToken(); -#line 1757 "cs.ATG" +#line 1772 "cs.ATG" val = "string"; break; } case 116: { lexer.NextToken(); -#line 1758 "cs.ATG" +#line 1773 "cs.ATG" val = "uint"; break; } case 117: { lexer.NextToken(); -#line 1759 "cs.ATG" +#line 1774 "cs.ATG" val = "ulong"; break; } case 120: { lexer.NextToken(); -#line 1760 "cs.ATG" +#line 1775 "cs.ATG" val = "ushort"; break; } } -#line 1761 "cs.ATG" +#line 1776 "cs.ATG" t.val = ""; Expect(15); Identifier(); -#line 1761 "cs.ATG" +#line 1776 "cs.ATG" pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); } else if (la.kind == 111) { lexer.NextToken(); -#line 1763 "cs.ATG" +#line 1778 "cs.ATG" pexpr = new ThisReferenceExpression(); } else if (la.kind == 51) { lexer.NextToken(); -#line 1765 "cs.ATG" +#line 1780 "cs.ATG" Expression retExpr = new BaseReferenceExpression(); if (la.kind == 15) { lexer.NextToken(); Identifier(); -#line 1767 "cs.ATG" +#line 1782 "cs.ATG" retExpr = new FieldReferenceExpression(retExpr, t.val); } else if (la.kind == 18) { lexer.NextToken(); Expr( -#line 1768 "cs.ATG" +#line 1783 "cs.ATG" out expr); -#line 1768 "cs.ATG" +#line 1783 "cs.ATG" List indices = new List(); if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1769 "cs.ATG" +#line 1784 "cs.ATG" out expr); -#line 1769 "cs.ATG" +#line 1784 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 1770 "cs.ATG" +#line 1785 "cs.ATG" retExpr = new IndexerExpression(retExpr, indices); - } else SynErr(201); + } else SynErr(202); -#line 1771 "cs.ATG" +#line 1786 "cs.ATG" pexpr = retExpr; } else if (la.kind == 89) { NewExpression( -#line 1774 "cs.ATG" +#line 1789 "cs.ATG" out expr); -#line 1774 "cs.ATG" +#line 1789 "cs.ATG" pexpr = expr; } else if (la.kind == 115) { lexer.NextToken(); Expect(20); if ( -#line 1778 "cs.ATG" +#line 1793 "cs.ATG" NotVoidPointer()) { Expect(123); -#line 1778 "cs.ATG" +#line 1793 "cs.ATG" type = new TypeReference("void"); } else if (StartOf(10)) { TypeWithRestriction( -#line 1779 "cs.ATG" +#line 1794 "cs.ATG" out type, true, true); - } else SynErr(202); + } else SynErr(203); Expect(21); -#line 1780 "cs.ATG" +#line 1795 "cs.ATG" pexpr = new TypeOfExpression(type); } else if (la.kind == 63) { lexer.NextToken(); Expect(20); Type( -#line 1782 "cs.ATG" +#line 1797 "cs.ATG" out type); Expect(21); -#line 1782 "cs.ATG" +#line 1797 "cs.ATG" pexpr = new DefaultValueExpression(type); } else if (la.kind == 105) { lexer.NextToken(); Expect(20); Type( -#line 1783 "cs.ATG" +#line 1798 "cs.ATG" out type); Expect(21); -#line 1783 "cs.ATG" +#line 1798 "cs.ATG" pexpr = new SizeOfExpression(type); } else if (la.kind == 58) { lexer.NextToken(); Expect(20); Expr( -#line 1784 "cs.ATG" +#line 1799 "cs.ATG" out expr); Expect(21); -#line 1784 "cs.ATG" +#line 1799 "cs.ATG" pexpr = new CheckedExpression(expr); } else if (la.kind == 118) { lexer.NextToken(); Expect(20); Expr( -#line 1785 "cs.ATG" +#line 1800 "cs.ATG" out expr); Expect(21); -#line 1785 "cs.ATG" +#line 1800 "cs.ATG" pexpr = new UncheckedExpression(expr); } else if (la.kind == 64) { lexer.NextToken(); AnonymousMethodExpr( -#line 1786 "cs.ATG" +#line 1801 "cs.ATG" out expr); -#line 1786 "cs.ATG" +#line 1801 "cs.ATG" pexpr = expr; - } else SynErr(203); - while (StartOf(32) || -#line 1797 "cs.ATG" + } else SynErr(204); + while (StartOf(33) || +#line 1812 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr) || -#line 1806 "cs.ATG" +#line 1821 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { if (la.kind == 31 || la.kind == 32) { if (la.kind == 31) { lexer.NextToken(); -#line 1790 "cs.ATG" +#line 1805 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); } else if (la.kind == 32) { lexer.NextToken(); -#line 1791 "cs.ATG" +#line 1806 "cs.ATG" pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); - } else SynErr(204); + } else SynErr(205); } else if (la.kind == 47) { lexer.NextToken(); Identifier(); -#line 1794 "cs.ATG" +#line 1809 "cs.ATG" pexpr = new PointerReferenceExpression(pexpr, t.val); } else if (la.kind == 15) { lexer.NextToken(); Identifier(); -#line 1795 "cs.ATG" +#line 1810 "cs.ATG" pexpr = new FieldReferenceExpression(pexpr, t.val); } else if ( -#line 1797 "cs.ATG" +#line 1812 "cs.ATG" IsGenericFollowedBy(Tokens.Dot) && IsTypeReferenceExpression(pexpr)) { TypeArgumentList( -#line 1798 "cs.ATG" +#line 1813 "cs.ATG" out typeList, false); Expect(15); Identifier(); -#line 1800 "cs.ATG" +#line 1815 "cs.ATG" pexpr = new FieldReferenceExpression(GetTypeReferenceExpression(pexpr, typeList), t.val); } else if (la.kind == 20) { lexer.NextToken(); -#line 1802 "cs.ATG" +#line 1817 "cs.ATG" List parameters = new List(); if (StartOf(24)) { Argument( -#line 1803 "cs.ATG" +#line 1818 "cs.ATG" out expr); -#line 1803 "cs.ATG" +#line 1818 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1804 "cs.ATG" +#line 1819 "cs.ATG" out expr); -#line 1804 "cs.ATG" +#line 1819 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 1805 "cs.ATG" +#line 1820 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters); } else if ( -#line 1806 "cs.ATG" +#line 1821 "cs.ATG" IsGenericFollowedBy(Tokens.OpenParenthesis)) { TypeArgumentList( -#line 1806 "cs.ATG" +#line 1821 "cs.ATG" out typeList, false); Expect(20); -#line 1807 "cs.ATG" +#line 1822 "cs.ATG" List parameters = new List(); if (StartOf(24)) { Argument( -#line 1808 "cs.ATG" +#line 1823 "cs.ATG" out expr); -#line 1808 "cs.ATG" +#line 1823 "cs.ATG" if (expr != null) {parameters.Add(expr);} while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1809 "cs.ATG" +#line 1824 "cs.ATG" out expr); -#line 1809 "cs.ATG" +#line 1824 "cs.ATG" if (expr != null) {parameters.Add(expr);} } } Expect(21); -#line 1810 "cs.ATG" +#line 1825 "cs.ATG" pexpr = new InvocationExpression(pexpr, parameters, typeList); } else { -#line 1813 "cs.ATG" +#line 1828 "cs.ATG" List indices = new List(); lexer.NextToken(); Expr( -#line 1815 "cs.ATG" +#line 1830 "cs.ATG" out expr); -#line 1815 "cs.ATG" +#line 1830 "cs.ATG" if (expr != null) { indices.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Expr( -#line 1816 "cs.ATG" +#line 1831 "cs.ATG" out expr); -#line 1816 "cs.ATG" +#line 1831 "cs.ATG" if (expr != null) { indices.Add(expr); } } Expect(19); -#line 1817 "cs.ATG" +#line 1832 "cs.ATG" pexpr = new IndexerExpression(pexpr, indices); } } } void QueryExpression( -#line 2205 "cs.ATG" +#line 2220 "cs.ATG" out Expression outExpr) { -#line 2206 "cs.ATG" +#line 2221 "cs.ATG" QueryExpression q = new QueryExpression(); outExpr = q; q.StartLocation = la.Location; QueryExpressionFromClause fromClause; QueryExpressionFromClause( -#line 2210 "cs.ATG" +#line 2225 "cs.ATG" out fromClause); -#line 2210 "cs.ATG" +#line 2225 "cs.ATG" q.FromClause = fromClause; QueryExpressionBody( -#line 2211 "cs.ATG" +#line 2226 "cs.ATG" q); -#line 2212 "cs.ATG" +#line 2227 "cs.ATG" q.EndLocation = t.EndLocation; } void ShortedLambdaExpression( -#line 1894 "cs.ATG" +#line 1909 "cs.ATG" IdentifierExpression ident, out Expression pexpr) { -#line 1895 "cs.ATG" +#line 1910 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; Expect(48); -#line 1900 "cs.ATG" +#line 1915 "cs.ATG" lambda.StartLocation = ident.StartLocation; lambda.Parameters.Add(new ParameterDeclarationExpression(null, ident.Identifier)); lambda.Parameters[0].StartLocation = ident.StartLocation; lambda.Parameters[0].EndLocation = ident.EndLocation; LambdaExpressionBody( -#line 1905 "cs.ATG" +#line 1920 "cs.ATG" lambda); } void LambdaExpression( -#line 1874 "cs.ATG" +#line 1889 "cs.ATG" out Expression outExpr) { -#line 1876 "cs.ATG" +#line 1891 "cs.ATG" LambdaExpression lambda = new LambdaExpression(); lambda.StartLocation = la.Location; ParameterDeclarationExpression p; @@ -4735,33 +4752,33 @@ out Expression outExpr) { Expect(20); if (StartOf(10)) { LambdaExpressionParameter( -#line 1884 "cs.ATG" +#line 1899 "cs.ATG" out p); -#line 1884 "cs.ATG" +#line 1899 "cs.ATG" if (p != null) lambda.Parameters.Add(p); while (la.kind == 14) { lexer.NextToken(); LambdaExpressionParameter( -#line 1886 "cs.ATG" +#line 1901 "cs.ATG" out p); -#line 1886 "cs.ATG" +#line 1901 "cs.ATG" if (p != null) lambda.Parameters.Add(p); } } Expect(21); Expect(48); LambdaExpressionBody( -#line 1891 "cs.ATG" +#line 1906 "cs.ATG" lambda); } void NewExpression( -#line 1821 "cs.ATG" +#line 1836 "cs.ATG" out Expression pexpr) { -#line 1822 "cs.ATG" +#line 1837 "cs.ATG" pexpr = null; List parameters = new List(); TypeReference type = null; @@ -4770,65 +4787,65 @@ out Expression pexpr) { Expect(89); if (StartOf(10)) { NonArrayType( -#line 1829 "cs.ATG" +#line 1844 "cs.ATG" out type); } if (la.kind == 16 || la.kind == 20) { if (la.kind == 20) { -#line 1835 "cs.ATG" +#line 1850 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); lexer.NextToken(); -#line 1836 "cs.ATG" +#line 1851 "cs.ATG" if (type == null) Error("Cannot use an anonymous type with arguments for the constructor"); if (StartOf(24)) { Argument( -#line 1837 "cs.ATG" +#line 1852 "cs.ATG" out expr); -#line 1837 "cs.ATG" +#line 1852 "cs.ATG" if (expr != null) { parameters.Add(expr); } while (la.kind == 14) { lexer.NextToken(); Argument( -#line 1838 "cs.ATG" +#line 1853 "cs.ATG" out expr); -#line 1838 "cs.ATG" +#line 1853 "cs.ATG" if (expr != null) { parameters.Add(expr); } } } Expect(21); -#line 1840 "cs.ATG" +#line 1855 "cs.ATG" pexpr = oce; if (la.kind == 16) { CollectionOrObjectInitializer( -#line 1841 "cs.ATG" +#line 1856 "cs.ATG" out expr); -#line 1841 "cs.ATG" +#line 1856 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; } } else { -#line 1842 "cs.ATG" +#line 1857 "cs.ATG" ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); CollectionOrObjectInitializer( -#line 1843 "cs.ATG" +#line 1858 "cs.ATG" out expr); -#line 1843 "cs.ATG" +#line 1858 "cs.ATG" oce.ObjectInitializer = (CollectionInitializerExpression)expr; -#line 1844 "cs.ATG" +#line 1859 "cs.ATG" pexpr = oce; } } else if (la.kind == 18) { lexer.NextToken(); -#line 1849 "cs.ATG" +#line 1864 "cs.ATG" ArrayCreateExpression ace = new ArrayCreateExpression(type); /* we must not change RankSpecifier on the null type reference*/ if (ace.CreateType.IsNull) { ace.CreateType = new TypeReference(""); } @@ -4839,91 +4856,91 @@ out expr); while (la.kind == 14) { lexer.NextToken(); -#line 1856 "cs.ATG" +#line 1871 "cs.ATG" dims += 1; } Expect(19); -#line 1857 "cs.ATG" +#line 1872 "cs.ATG" ranks.Add(dims); dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 1858 "cs.ATG" +#line 1873 "cs.ATG" ++dims; } Expect(19); -#line 1858 "cs.ATG" +#line 1873 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 1859 "cs.ATG" +#line 1874 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); CollectionInitializer( -#line 1860 "cs.ATG" +#line 1875 "cs.ATG" out expr); -#line 1860 "cs.ATG" +#line 1875 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } else if (StartOf(6)) { Expr( -#line 1861 "cs.ATG" +#line 1876 "cs.ATG" out expr); -#line 1861 "cs.ATG" +#line 1876 "cs.ATG" if (expr != null) parameters.Add(expr); while (la.kind == 14) { lexer.NextToken(); -#line 1862 "cs.ATG" +#line 1877 "cs.ATG" dims += 1; Expr( -#line 1863 "cs.ATG" +#line 1878 "cs.ATG" out expr); -#line 1863 "cs.ATG" +#line 1878 "cs.ATG" if (expr != null) parameters.Add(expr); } Expect(19); -#line 1865 "cs.ATG" +#line 1880 "cs.ATG" ranks.Add(dims); ace.Arguments = parameters; dims = 0; while (la.kind == 18) { lexer.NextToken(); while (la.kind == 14) { lexer.NextToken(); -#line 1866 "cs.ATG" +#line 1881 "cs.ATG" ++dims; } Expect(19); -#line 1866 "cs.ATG" +#line 1881 "cs.ATG" ranks.Add(dims); dims = 0; } -#line 1867 "cs.ATG" +#line 1882 "cs.ATG" ace.CreateType.RankSpecifier = ranks.ToArray(); if (la.kind == 16) { CollectionInitializer( -#line 1868 "cs.ATG" +#line 1883 "cs.ATG" out expr); -#line 1868 "cs.ATG" +#line 1883 "cs.ATG" ace.ArrayInitializer = (CollectionInitializerExpression)expr; } - } else SynErr(205); - } else SynErr(206); + } else SynErr(206); + } else SynErr(207); } void AnonymousMethodExpr( -#line 1936 "cs.ATG" +#line 1951 "cs.ATG" out Expression outExpr) { -#line 1938 "cs.ATG" +#line 1953 "cs.ATG" AnonymousMethodExpression expr = new AnonymousMethodExpression(); expr.StartLocation = t.Location; BlockStatement stmt; @@ -4934,438 +4951,438 @@ out Expression outExpr) { lexer.NextToken(); if (StartOf(11)) { FormalParameterList( -#line 1947 "cs.ATG" +#line 1962 "cs.ATG" p); -#line 1947 "cs.ATG" +#line 1962 "cs.ATG" expr.Parameters = p; } Expect(21); -#line 1949 "cs.ATG" +#line 1964 "cs.ATG" expr.HasParameterList = true; } BlockInsideExpression( -#line 1951 "cs.ATG" +#line 1966 "cs.ATG" out stmt); -#line 1951 "cs.ATG" +#line 1966 "cs.ATG" expr.Body = stmt; -#line 1952 "cs.ATG" +#line 1967 "cs.ATG" expr.EndLocation = t.Location; } void TypeArgumentList( -#line 2139 "cs.ATG" +#line 2154 "cs.ATG" out List types, bool canBeUnbound) { -#line 2141 "cs.ATG" +#line 2156 "cs.ATG" types = new List(); TypeReference type = null; Expect(23); if ( -#line 2146 "cs.ATG" +#line 2161 "cs.ATG" canBeUnbound && (la.kind == Tokens.GreaterThan || la.kind == Tokens.Comma)) { -#line 2147 "cs.ATG" +#line 2162 "cs.ATG" types.Add(TypeReference.Null); while (la.kind == 14) { lexer.NextToken(); -#line 2148 "cs.ATG" +#line 2163 "cs.ATG" types.Add(TypeReference.Null); } } else if (StartOf(10)) { Type( -#line 2149 "cs.ATG" +#line 2164 "cs.ATG" out type); -#line 2149 "cs.ATG" +#line 2164 "cs.ATG" if (type != null) { types.Add(type); } while (la.kind == 14) { lexer.NextToken(); Type( -#line 2150 "cs.ATG" +#line 2165 "cs.ATG" out type); -#line 2150 "cs.ATG" +#line 2165 "cs.ATG" if (type != null) { types.Add(type); } } - } else SynErr(207); + } else SynErr(208); Expect(22); } void LambdaExpressionParameter( -#line 1908 "cs.ATG" +#line 1923 "cs.ATG" out ParameterDeclarationExpression p) { -#line 1909 "cs.ATG" +#line 1924 "cs.ATG" Location start = la.Location; p = null; TypeReference type; if ( -#line 1913 "cs.ATG" +#line 1928 "cs.ATG" Peek(1).kind == Tokens.Comma || Peek(1).kind == Tokens.CloseParenthesis) { Identifier(); -#line 1915 "cs.ATG" +#line 1930 "cs.ATG" p = new ParameterDeclarationExpression(null, t.val); p.StartLocation = start; p.EndLocation = t.EndLocation; } else if (StartOf(10)) { Type( -#line 1918 "cs.ATG" +#line 1933 "cs.ATG" out type); Identifier(); -#line 1920 "cs.ATG" +#line 1935 "cs.ATG" p = new ParameterDeclarationExpression(type, t.val); p.StartLocation = start; p.EndLocation = t.EndLocation; - } else SynErr(208); + } else SynErr(209); } void LambdaExpressionBody( -#line 1926 "cs.ATG" +#line 1941 "cs.ATG" LambdaExpression lambda) { -#line 1927 "cs.ATG" +#line 1942 "cs.ATG" Expression expr; BlockStatement stmt; if (la.kind == 16) { BlockInsideExpression( -#line 1930 "cs.ATG" +#line 1945 "cs.ATG" out stmt); -#line 1930 "cs.ATG" +#line 1945 "cs.ATG" lambda.StatementBody = stmt; } else if (StartOf(6)) { Expr( -#line 1931 "cs.ATG" +#line 1946 "cs.ATG" out expr); -#line 1931 "cs.ATG" +#line 1946 "cs.ATG" lambda.ExpressionBody = expr; - } else SynErr(209); + } else SynErr(210); -#line 1933 "cs.ATG" +#line 1948 "cs.ATG" lambda.EndLocation = t.EndLocation; } void BlockInsideExpression( -#line 1955 "cs.ATG" +#line 1970 "cs.ATG" out BlockStatement outStmt) { -#line 1956 "cs.ATG" +#line 1971 "cs.ATG" Statement stmt = null; outStmt = null; -#line 1960 "cs.ATG" +#line 1975 "cs.ATG" if (compilationUnit != null) { Block( -#line 1961 "cs.ATG" +#line 1976 "cs.ATG" out stmt); -#line 1961 "cs.ATG" +#line 1976 "cs.ATG" outStmt = (BlockStatement)stmt; -#line 1962 "cs.ATG" +#line 1977 "cs.ATG" } else { Expect(16); -#line 1964 "cs.ATG" +#line 1979 "cs.ATG" lexer.SkipCurrentBlock(0); Expect(17); -#line 1966 "cs.ATG" +#line 1981 "cs.ATG" } } void ConditionalAndExpr( -#line 1975 "cs.ATG" +#line 1990 "cs.ATG" ref Expression outExpr) { -#line 1976 "cs.ATG" +#line 1991 "cs.ATG" Expression expr; InclusiveOrExpr( -#line 1978 "cs.ATG" +#line 1993 "cs.ATG" ref outExpr); while (la.kind == 25) { lexer.NextToken(); UnaryExpr( -#line 1978 "cs.ATG" +#line 1993 "cs.ATG" out expr); InclusiveOrExpr( -#line 1978 "cs.ATG" +#line 1993 "cs.ATG" ref expr); -#line 1978 "cs.ATG" +#line 1993 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.LogicalAnd, expr); } } void InclusiveOrExpr( -#line 1981 "cs.ATG" +#line 1996 "cs.ATG" ref Expression outExpr) { -#line 1982 "cs.ATG" +#line 1997 "cs.ATG" Expression expr; ExclusiveOrExpr( -#line 1984 "cs.ATG" +#line 1999 "cs.ATG" ref outExpr); while (la.kind == 29) { lexer.NextToken(); UnaryExpr( -#line 1984 "cs.ATG" +#line 1999 "cs.ATG" out expr); ExclusiveOrExpr( -#line 1984 "cs.ATG" +#line 1999 "cs.ATG" ref expr); -#line 1984 "cs.ATG" +#line 1999 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseOr, expr); } } void ExclusiveOrExpr( -#line 1987 "cs.ATG" +#line 2002 "cs.ATG" ref Expression outExpr) { -#line 1988 "cs.ATG" +#line 2003 "cs.ATG" Expression expr; AndExpr( -#line 1990 "cs.ATG" +#line 2005 "cs.ATG" ref outExpr); while (la.kind == 30) { lexer.NextToken(); UnaryExpr( -#line 1990 "cs.ATG" +#line 2005 "cs.ATG" out expr); AndExpr( -#line 1990 "cs.ATG" +#line 2005 "cs.ATG" ref expr); -#line 1990 "cs.ATG" +#line 2005 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.ExclusiveOr, expr); } } void AndExpr( -#line 1993 "cs.ATG" +#line 2008 "cs.ATG" ref Expression outExpr) { -#line 1994 "cs.ATG" +#line 2009 "cs.ATG" Expression expr; EqualityExpr( -#line 1996 "cs.ATG" +#line 2011 "cs.ATG" ref outExpr); while (la.kind == 28) { lexer.NextToken(); UnaryExpr( -#line 1996 "cs.ATG" +#line 2011 "cs.ATG" out expr); EqualityExpr( -#line 1996 "cs.ATG" +#line 2011 "cs.ATG" ref expr); -#line 1996 "cs.ATG" +#line 2011 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.BitwiseAnd, expr); } } void EqualityExpr( -#line 1999 "cs.ATG" +#line 2014 "cs.ATG" ref Expression outExpr) { -#line 2001 "cs.ATG" +#line 2016 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; RelationalExpr( -#line 2005 "cs.ATG" +#line 2020 "cs.ATG" ref outExpr); while (la.kind == 33 || la.kind == 34) { if (la.kind == 34) { lexer.NextToken(); -#line 2008 "cs.ATG" +#line 2023 "cs.ATG" op = BinaryOperatorType.InEquality; } else { lexer.NextToken(); -#line 2009 "cs.ATG" +#line 2024 "cs.ATG" op = BinaryOperatorType.Equality; } UnaryExpr( -#line 2011 "cs.ATG" +#line 2026 "cs.ATG" out expr); RelationalExpr( -#line 2011 "cs.ATG" +#line 2026 "cs.ATG" ref expr); -#line 2011 "cs.ATG" +#line 2026 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void RelationalExpr( -#line 2015 "cs.ATG" +#line 2030 "cs.ATG" ref Expression outExpr) { -#line 2017 "cs.ATG" +#line 2032 "cs.ATG" TypeReference type; Expression expr; BinaryOperatorType op = BinaryOperatorType.None; ShiftExpr( -#line 2022 "cs.ATG" +#line 2037 "cs.ATG" ref outExpr); - while (StartOf(33)) { - if (StartOf(34)) { + while (StartOf(34)) { + if (StartOf(35)) { if (la.kind == 23) { lexer.NextToken(); -#line 2024 "cs.ATG" +#line 2039 "cs.ATG" op = BinaryOperatorType.LessThan; } else if (la.kind == 22) { lexer.NextToken(); -#line 2025 "cs.ATG" +#line 2040 "cs.ATG" op = BinaryOperatorType.GreaterThan; } else if (la.kind == 36) { lexer.NextToken(); -#line 2026 "cs.ATG" +#line 2041 "cs.ATG" op = BinaryOperatorType.LessThanOrEqual; } else if (la.kind == 35) { lexer.NextToken(); -#line 2027 "cs.ATG" +#line 2042 "cs.ATG" op = BinaryOperatorType.GreaterThanOrEqual; - } else SynErr(210); + } else SynErr(211); UnaryExpr( -#line 2029 "cs.ATG" +#line 2044 "cs.ATG" out expr); ShiftExpr( -#line 2030 "cs.ATG" +#line 2045 "cs.ATG" ref expr); -#line 2031 "cs.ATG" +#line 2046 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } else { if (la.kind == 85) { lexer.NextToken(); TypeWithRestriction( -#line 2034 "cs.ATG" +#line 2049 "cs.ATG" out type, false, false); if ( -#line 2035 "cs.ATG" +#line 2050 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 2036 "cs.ATG" +#line 2051 "cs.ATG" ref type); } -#line 2037 "cs.ATG" +#line 2052 "cs.ATG" outExpr = new TypeOfIsExpression(outExpr, type); } else if (la.kind == 50) { lexer.NextToken(); TypeWithRestriction( -#line 2039 "cs.ATG" +#line 2054 "cs.ATG" out type, false, false); if ( -#line 2040 "cs.ATG" +#line 2055 "cs.ATG" la.kind == Tokens.Question && Tokens.CastFollower[Peek(1).kind] == false) { NullableQuestionMark( -#line 2041 "cs.ATG" +#line 2056 "cs.ATG" ref type); } -#line 2042 "cs.ATG" +#line 2057 "cs.ATG" outExpr = new CastExpression(type, outExpr, CastType.TryCast); - } else SynErr(211); + } else SynErr(212); } } } void ShiftExpr( -#line 2047 "cs.ATG" +#line 2062 "cs.ATG" ref Expression outExpr) { -#line 2049 "cs.ATG" +#line 2064 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; AdditiveExpr( -#line 2053 "cs.ATG" +#line 2068 "cs.ATG" ref outExpr); while (la.kind == 37 || -#line 2056 "cs.ATG" +#line 2071 "cs.ATG" IsShiftRight()) { if (la.kind == 37) { lexer.NextToken(); -#line 2055 "cs.ATG" +#line 2070 "cs.ATG" op = BinaryOperatorType.ShiftLeft; } else { Expect(22); Expect(22); -#line 2057 "cs.ATG" +#line 2072 "cs.ATG" op = BinaryOperatorType.ShiftRight; } UnaryExpr( -#line 2060 "cs.ATG" +#line 2075 "cs.ATG" out expr); AdditiveExpr( -#line 2060 "cs.ATG" +#line 2075 "cs.ATG" ref expr); -#line 2060 "cs.ATG" +#line 2075 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void AdditiveExpr( -#line 2064 "cs.ATG" +#line 2079 "cs.ATG" ref Expression outExpr) { -#line 2066 "cs.ATG" +#line 2081 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; MultiplicativeExpr( -#line 2070 "cs.ATG" +#line 2085 "cs.ATG" ref outExpr); while (la.kind == 4 || la.kind == 5) { if (la.kind == 4) { lexer.NextToken(); -#line 2073 "cs.ATG" +#line 2088 "cs.ATG" op = BinaryOperatorType.Add; } else { lexer.NextToken(); -#line 2074 "cs.ATG" +#line 2089 "cs.ATG" op = BinaryOperatorType.Subtract; } UnaryExpr( -#line 2076 "cs.ATG" +#line 2091 "cs.ATG" out expr); MultiplicativeExpr( -#line 2076 "cs.ATG" +#line 2091 "cs.ATG" ref expr); -#line 2076 "cs.ATG" +#line 2091 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void MultiplicativeExpr( -#line 2080 "cs.ATG" +#line 2095 "cs.ATG" ref Expression outExpr) { -#line 2082 "cs.ATG" +#line 2097 "cs.ATG" Expression expr; BinaryOperatorType op = BinaryOperatorType.None; @@ -5373,371 +5390,371 @@ ref Expression outExpr) { if (la.kind == 6) { lexer.NextToken(); -#line 2088 "cs.ATG" +#line 2103 "cs.ATG" op = BinaryOperatorType.Multiply; } else if (la.kind == 7) { lexer.NextToken(); -#line 2089 "cs.ATG" +#line 2104 "cs.ATG" op = BinaryOperatorType.Divide; } else { lexer.NextToken(); -#line 2090 "cs.ATG" +#line 2105 "cs.ATG" op = BinaryOperatorType.Modulus; } UnaryExpr( -#line 2092 "cs.ATG" +#line 2107 "cs.ATG" out expr); -#line 2092 "cs.ATG" +#line 2107 "cs.ATG" outExpr = new BinaryOperatorExpression(outExpr, op, expr); } } void TypeParameterConstraintsClauseBase( -#line 2196 "cs.ATG" +#line 2211 "cs.ATG" out TypeReference type) { -#line 2197 "cs.ATG" +#line 2212 "cs.ATG" TypeReference t; type = null; if (la.kind == 109) { lexer.NextToken(); -#line 2199 "cs.ATG" +#line 2214 "cs.ATG" type = TypeReference.StructConstraint; } else if (la.kind == 59) { lexer.NextToken(); -#line 2200 "cs.ATG" +#line 2215 "cs.ATG" type = TypeReference.ClassConstraint; } else if (la.kind == 89) { lexer.NextToken(); Expect(20); Expect(21); -#line 2201 "cs.ATG" +#line 2216 "cs.ATG" type = TypeReference.NewConstraint; } else if (StartOf(10)) { Type( -#line 2202 "cs.ATG" +#line 2217 "cs.ATG" out t); -#line 2202 "cs.ATG" +#line 2217 "cs.ATG" type = t; - } else SynErr(212); + } else SynErr(213); } void QueryExpressionFromClause( -#line 2215 "cs.ATG" +#line 2230 "cs.ATG" out QueryExpressionFromClause fc) { -#line 2216 "cs.ATG" +#line 2231 "cs.ATG" fc = new QueryExpressionFromClause(); fc.StartLocation = la.Location; Expect(137); QueryExpressionFromOrJoinClause( -#line 2220 "cs.ATG" +#line 2235 "cs.ATG" fc); -#line 2221 "cs.ATG" +#line 2236 "cs.ATG" fc.EndLocation = t.EndLocation; } void QueryExpressionBody( -#line 2251 "cs.ATG" +#line 2266 "cs.ATG" QueryExpression q) { -#line 2252 "cs.ATG" +#line 2267 "cs.ATG" QueryExpressionFromClause fromClause; QueryExpressionWhereClause whereClause; QueryExpressionLetClause letClause; QueryExpressionJoinClause joinClause; QueryExpressionSelectClause selectClause; QueryExpressionGroupClause groupClause; QueryExpressionIntoClause intoClause; - while (StartOf(35)) { + while (StartOf(36)) { if (la.kind == 137) { QueryExpressionFromClause( -#line 2258 "cs.ATG" +#line 2273 "cs.ATG" out fromClause); -#line 2258 "cs.ATG" +#line 2273 "cs.ATG" SafeAdd(q, q.FromLetWhereClauses, fromClause); } else if (la.kind == 127) { QueryExpressionWhereClause( -#line 2259 "cs.ATG" +#line 2274 "cs.ATG" out whereClause); -#line 2259 "cs.ATG" +#line 2274 "cs.ATG" SafeAdd(q, q.FromLetWhereClauses, whereClause); } else if (la.kind == 141) { QueryExpressionLetClause( -#line 2260 "cs.ATG" +#line 2275 "cs.ATG" out letClause); -#line 2260 "cs.ATG" +#line 2275 "cs.ATG" SafeAdd(q, q.FromLetWhereClauses, letClause); } else { QueryExpressionJoinClause( -#line 2261 "cs.ATG" +#line 2276 "cs.ATG" out joinClause); -#line 2261 "cs.ATG" +#line 2276 "cs.ATG" SafeAdd(q, q.FromLetWhereClauses, joinClause); } } if (la.kind == 140) { QueryExpressionOrderByClause( -#line 2263 "cs.ATG" +#line 2278 "cs.ATG" q); } if (la.kind == 133) { QueryExpressionSelectClause( -#line 2264 "cs.ATG" +#line 2279 "cs.ATG" out selectClause); -#line 2264 "cs.ATG" +#line 2279 "cs.ATG" q.SelectOrGroupClause = selectClause; } else if (la.kind == 134) { QueryExpressionGroupClause( -#line 2265 "cs.ATG" +#line 2280 "cs.ATG" out groupClause); -#line 2265 "cs.ATG" +#line 2280 "cs.ATG" q.SelectOrGroupClause = groupClause; - } else SynErr(213); + } else SynErr(214); if (la.kind == 136) { QueryExpressionIntoClause( -#line 2267 "cs.ATG" +#line 2282 "cs.ATG" out intoClause); -#line 2267 "cs.ATG" +#line 2282 "cs.ATG" q.IntoClause = intoClause; } } void QueryExpressionFromOrJoinClause( -#line 2241 "cs.ATG" +#line 2256 "cs.ATG" QueryExpressionFromOrJoinClause fjc) { -#line 2242 "cs.ATG" +#line 2257 "cs.ATG" TypeReference type; Expression expr; -#line 2244 "cs.ATG" +#line 2259 "cs.ATG" fjc.Type = null; Identifier(); -#line 2246 "cs.ATG" +#line 2261 "cs.ATG" fjc.Identifier = t.val; Expect(81); Expr( -#line 2248 "cs.ATG" +#line 2263 "cs.ATG" out expr); -#line 2248 "cs.ATG" +#line 2263 "cs.ATG" fjc.InExpression = expr; } void QueryExpressionJoinClause( -#line 2224 "cs.ATG" +#line 2239 "cs.ATG" out QueryExpressionJoinClause jc) { -#line 2225 "cs.ATG" +#line 2240 "cs.ATG" jc = new QueryExpressionJoinClause(); jc.StartLocation = la.Location; Expression expr; Expect(142); QueryExpressionFromOrJoinClause( -#line 2230 "cs.ATG" +#line 2245 "cs.ATG" jc); Expect(143); Expr( -#line 2232 "cs.ATG" +#line 2247 "cs.ATG" out expr); -#line 2232 "cs.ATG" +#line 2247 "cs.ATG" jc.OnExpression = expr; Expect(144); Expr( -#line 2234 "cs.ATG" +#line 2249 "cs.ATG" out expr); -#line 2234 "cs.ATG" +#line 2249 "cs.ATG" jc.EqualsExpression = expr; if (la.kind == 136) { lexer.NextToken(); Identifier(); -#line 2236 "cs.ATG" +#line 2251 "cs.ATG" jc.IntoIdentifier = t.val; } -#line 2238 "cs.ATG" +#line 2253 "cs.ATG" jc.EndLocation = t.EndLocation; } void QueryExpressionWhereClause( -#line 2270 "cs.ATG" +#line 2285 "cs.ATG" out QueryExpressionWhereClause wc) { -#line 2271 "cs.ATG" +#line 2286 "cs.ATG" Expression expr; wc = new QueryExpressionWhereClause(); wc.StartLocation = la.Location; Expect(127); Expr( -#line 2274 "cs.ATG" +#line 2289 "cs.ATG" out expr); -#line 2274 "cs.ATG" +#line 2289 "cs.ATG" wc.Condition = expr; -#line 2275 "cs.ATG" +#line 2290 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionLetClause( -#line 2278 "cs.ATG" +#line 2293 "cs.ATG" out QueryExpressionLetClause wc) { -#line 2279 "cs.ATG" +#line 2294 "cs.ATG" Expression expr; wc = new QueryExpressionLetClause(); wc.StartLocation = la.Location; Expect(141); Identifier(); -#line 2282 "cs.ATG" +#line 2297 "cs.ATG" wc.Identifier = t.val; Expect(3); Expr( -#line 2284 "cs.ATG" +#line 2299 "cs.ATG" out expr); -#line 2284 "cs.ATG" +#line 2299 "cs.ATG" wc.Expression = expr; -#line 2285 "cs.ATG" +#line 2300 "cs.ATG" wc.EndLocation = t.EndLocation; } void QueryExpressionOrderByClause( -#line 2288 "cs.ATG" +#line 2303 "cs.ATG" QueryExpression q) { -#line 2289 "cs.ATG" +#line 2304 "cs.ATG" QueryExpressionOrdering ordering; Expect(140); QueryExpressionOrderingClause( -#line 2292 "cs.ATG" +#line 2307 "cs.ATG" out ordering); -#line 2292 "cs.ATG" +#line 2307 "cs.ATG" SafeAdd(q, q.Orderings, ordering); while (la.kind == 14) { lexer.NextToken(); QueryExpressionOrderingClause( -#line 2294 "cs.ATG" +#line 2309 "cs.ATG" out ordering); -#line 2294 "cs.ATG" +#line 2309 "cs.ATG" SafeAdd(q, q.Orderings, ordering); } } void QueryExpressionSelectClause( -#line 2308 "cs.ATG" +#line 2323 "cs.ATG" out QueryExpressionSelectClause sc) { -#line 2309 "cs.ATG" +#line 2324 "cs.ATG" Expression expr; sc = new QueryExpressionSelectClause(); sc.StartLocation = la.Location; Expect(133); Expr( -#line 2312 "cs.ATG" +#line 2327 "cs.ATG" out expr); -#line 2312 "cs.ATG" +#line 2327 "cs.ATG" sc.Projection = expr; -#line 2313 "cs.ATG" +#line 2328 "cs.ATG" sc.EndLocation = t.EndLocation; } void QueryExpressionGroupClause( -#line 2316 "cs.ATG" +#line 2331 "cs.ATG" out QueryExpressionGroupClause gc) { -#line 2317 "cs.ATG" +#line 2332 "cs.ATG" Expression expr; gc = new QueryExpressionGroupClause(); gc.StartLocation = la.Location; Expect(134); Expr( -#line 2320 "cs.ATG" +#line 2335 "cs.ATG" out expr); -#line 2320 "cs.ATG" +#line 2335 "cs.ATG" gc.Projection = expr; Expect(135); Expr( -#line 2322 "cs.ATG" +#line 2337 "cs.ATG" out expr); -#line 2322 "cs.ATG" +#line 2337 "cs.ATG" gc.GroupBy = expr; -#line 2323 "cs.ATG" +#line 2338 "cs.ATG" gc.EndLocation = t.EndLocation; } void QueryExpressionIntoClause( -#line 2326 "cs.ATG" +#line 2341 "cs.ATG" out QueryExpressionIntoClause ic) { -#line 2327 "cs.ATG" +#line 2342 "cs.ATG" ic = new QueryExpressionIntoClause(); ic.StartLocation = la.Location; Expect(136); Identifier(); -#line 2330 "cs.ATG" +#line 2345 "cs.ATG" ic.IntoIdentifier = t.val; -#line 2331 "cs.ATG" +#line 2346 "cs.ATG" ic.ContinuedQuery = new QueryExpression(); -#line 2332 "cs.ATG" +#line 2347 "cs.ATG" ic.ContinuedQuery.StartLocation = la.Location; QueryExpressionBody( -#line 2333 "cs.ATG" +#line 2348 "cs.ATG" ic.ContinuedQuery); -#line 2334 "cs.ATG" +#line 2349 "cs.ATG" ic.ContinuedQuery.EndLocation = t.EndLocation; -#line 2335 "cs.ATG" +#line 2350 "cs.ATG" ic.EndLocation = t.EndLocation; } void QueryExpressionOrderingClause( -#line 2298 "cs.ATG" +#line 2313 "cs.ATG" out QueryExpressionOrdering ordering) { -#line 2299 "cs.ATG" +#line 2314 "cs.ATG" Expression expr; ordering = new QueryExpressionOrdering(); ordering.StartLocation = la.Location; Expr( -#line 2301 "cs.ATG" +#line 2316 "cs.ATG" out expr); -#line 2301 "cs.ATG" +#line 2316 "cs.ATG" ordering.Criteria = expr; if (la.kind == 138 || la.kind == 139) { if (la.kind == 138) { lexer.NextToken(); -#line 2302 "cs.ATG" +#line 2317 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Ascending; } else { lexer.NextToken(); -#line 2303 "cs.ATG" +#line 2318 "cs.ATG" ordering.Direction = QueryExpressionOrderingDirection.Descending; } } -#line 2305 "cs.ATG" +#line 2320 "cs.ATG" ordering.EndLocation = t.EndLocation; } @@ -5954,19 +5971,20 @@ out expr); case 198: s = "invalid ResourceAcquisition"; break; case 199: s = "invalid SwitchLabel"; break; case 200: s = "invalid CatchClauses"; break; - case 201: s = "invalid PrimaryExpr"; break; + case 201: s = "invalid UnaryExpr"; break; case 202: s = "invalid PrimaryExpr"; break; case 203: s = "invalid PrimaryExpr"; break; case 204: s = "invalid PrimaryExpr"; break; - case 205: s = "invalid NewExpression"; break; + case 205: s = "invalid PrimaryExpr"; break; case 206: s = "invalid NewExpression"; break; - case 207: s = "invalid TypeArgumentList"; break; - case 208: s = "invalid LambdaExpressionParameter"; break; - case 209: s = "invalid LambdaExpressionBody"; break; - case 210: s = "invalid RelationalExpr"; break; + case 207: s = "invalid NewExpression"; break; + case 208: s = "invalid TypeArgumentList"; break; + case 209: s = "invalid LambdaExpressionParameter"; break; + case 210: s = "invalid LambdaExpressionBody"; break; case 211: s = "invalid RelationalExpr"; break; - case 212: s = "invalid TypeParameterConstraintsClauseBase"; break; - case 213: s = "invalid QueryExpressionBody"; break; + case 212: s = "invalid RelationalExpr"; break; + case 213: s = "invalid TypeParameterConstraintsClauseBase"; break; + case 214: s = "invalid QueryExpressionBody"; break; default: s = "error " + errorNumber; break; } @@ -6010,6 +6028,7 @@ out expr); {x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, T,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,T,T,x, x,x,T,T, T,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,T,T,T, x,x,x,x, x,x,x,x, x,x,T,x, T,T,T,x, T,x,x,T, x,T,x,T, T,T,T,x, T,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, {x,T,T,x, T,T,T,x, x,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, x,T,T,x, T,T,T,T, T,T,T,x, x,x,x,x, T,x,T,T, T,T,T,T, x,x,T,x, x,x,T,T, x,T,T,T, x,x,x,x, x,x,x,x, x,T,T,x, T,T,x,x, T,x,T,T, T,T,T,T, T,T,T,T, T,T,x,x, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, {x,x,x,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,T, T,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, + {x,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,x,T,x, x,T,T,x, x,x,T,T, T,x,T,x, x,x,x,x, T,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,T,T,T, x,x,x,x, x,x,x,x, x,x,T,x, T,T,x,x, T,x,x,T, x,T,x,T, T,T,T,x, T,x,x,x, x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,T, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,x, T,x,x,x, x,x,x,x, T,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,T,x, T,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x}, diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index 04ab044318..dac6d4ab71 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -1669,8 +1669,8 @@ Expr UnaryExpr (. TypeReference type = null; - Expression expr; - ArrayList expressions = new ArrayList(); + Expression expr = null; + ArrayList expressions = new ArrayList(); uExpr = null; .) = @@ -1694,20 +1694,35 @@ UnaryExpr ) } - PrimaryExpr (. 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 + ) + (. 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; + } + .) . diff --git a/src/Libraries/NRefactory/Project/Src/Parser/gen.bat b/src/Libraries/NRefactory/Project/Src/Parser/gen.bat index 2c32b7a095..363aa1220f 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/gen.bat +++ b/src/Libraries/NRefactory/Project/Src/Parser/gen.bat @@ -22,6 +22,3 @@ del VBNET.ATG :exit pause cd .. -rem pushd ..\..\.. -rem %windir%\microsoft.net\framework\v2.0.50727\msbuild -rem popd \ No newline at end of file diff --git a/src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs b/src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs index 410c1ee276..06e56fa573 100644 --- a/src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs +++ b/src/Libraries/NRefactory/Test/Lexer/CSharp/CustomLexerTests.cs @@ -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 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] diff --git a/src/Libraries/NRefactory/Test/Lexer/CSharp/NumberLexerTest.cs b/src/Libraries/NRefactory/Test/Lexer/CSharp/NumberLexerTest.cs index 7b53e21112..5e4505c4b4 100644 --- a/src/Libraries/NRefactory/Test/Lexer/CSharp/NumberLexerTest.cs +++ b/src/Libraries/NRefactory/Test/Lexer/CSharp/NumberLexerTest.cs @@ -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 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 { 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'); } } } diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs index 9988053544..22dcd5a93c 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs @@ -34,6 +34,15 @@ namespace ICSharpCode.NRefactory.Tests.Ast CheckSimpleObjectCreateExpression(ParseUtilCSharp.ParseExpression("new MyObject(1, 2, 3)")); } + [Test] + public void CSharpNullableObjectCreateExpressionTest() + { + ObjectCreateExpression oce = ParseUtilCSharp.ParseExpression("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() { diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/PrimitiveExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/PrimitiveExpressionTests.cs index 8b78886c42..13b739131f 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/PrimitiveExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/PrimitiveExpressionTests.cs @@ -50,6 +50,40 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual('\u0356', (char)pe.Value); } + [Test] + public void IntMinValueTest() + { + PrimitiveExpression pe = ParseUtilCSharp.ParseExpression("-2147483648"); + Assert.AreEqual(-2147483648, (int)pe.Value); + } + + [Test] + public void IntMaxValueTest() + { + PrimitiveExpression pe = ParseUtilCSharp.ParseExpression("2147483647"); + Assert.AreEqual(2147483647, (int)pe.Value); + + pe = ParseUtilCSharp.ParseExpression("2147483648"); + Assert.AreEqual(2147483648, (uint)pe.Value); + } + + [Test] + public void LongMinValueTest() + { + PrimitiveExpression pe = ParseUtilCSharp.ParseExpression("-9223372036854775808"); + Assert.AreEqual(-9223372036854775808, (long)pe.Value); + } + + [Test] + public void LongMaxValueTest() + { + PrimitiveExpression pe = ParseUtilCSharp.ParseExpression("9223372036854775807"); + Assert.AreEqual(9223372036854775807, (long)pe.Value); + + pe = ParseUtilCSharp.ParseExpression("9223372036854775808"); + Assert.AreEqual(9223372036854775808, (ulong)pe.Value); + } + [Test] public void CSharpStringTest1() { diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs index d33ae03de9..fab35fca47 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs @@ -5,6 +5,7 @@ // $Revision$ // +using ICSharpCode.TextEditor.Document; using System; using System.Collections; using System.Collections.Generic; @@ -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 // 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). diff --git a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs index 56e98d310d..fe3f2c7572 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs @@ -5,18 +5,17 @@ // $Revision$ // +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; using MSBuild = Microsoft.Build.BuildEngine; -using Import = System.Collections.Generic.KeyValuePair; 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) { diff --git a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs index dd5f40896d..04b3ad139d 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs @@ -344,6 +344,7 @@ namespace ICSharpCode.SharpDevelop.Project return property; } } + location = PropertyStorageLocations.Unknown; group = null; return null; diff --git a/src/Main/Base/Project/Src/Project/Solution/AbstractSolutionFolder.cs b/src/Main/Base/Project/Src/Project/Solution/AbstractSolutionFolder.cs index e7c6b89164..276981caf9 100644 --- a/src/Main/Base/Project/Src/Project/Solution/AbstractSolutionFolder.cs +++ b/src/Main/Base/Project/Src/Project/Solution/AbstractSolutionFolder.cs @@ -26,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Project /// /// 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. /// [Browsable(false)] diff --git a/src/Main/Base/Project/Src/Services/AmbienceService/CodeDOMGeneratorUtility.cs b/src/Main/Base/Project/Src/Services/AmbienceService/CodeDOMGeneratorUtility.cs index 666937bacb..f5a8c4c6eb 100644 --- a/src/Main/Base/Project/Src/Services/AmbienceService/CodeDOMGeneratorUtility.cs +++ b/src/Main/Base/Project/Src/Services/AmbienceService/CodeDOMGeneratorUtility.cs @@ -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 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; } } diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 125b0bc14f..179396e478 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -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) diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs index 216f5aa7d3..f1c0783898 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextEditorProperties.cs @@ -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 } set { properties.Set("TabsToSpaces", value); + indentationString = null; } } public bool MouseWheelScrollDown { @@ -333,3 +354,4 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } } + diff --git a/src/Main/StartUp/Project/Resources/StringResources.resources b/src/Main/StartUp/Project/Resources/StringResources.resources index 5f129642c2..eddce427f0 100644 Binary files a/src/Main/StartUp/Project/Resources/StringResources.resources and b/src/Main/StartUp/Project/Resources/StringResources.resources differ