From 94bad6c21033b007232722099f4101cb12636f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Wed, 7 Dec 2011 22:12:41 +0100 Subject: [PATCH] Fixed "InactiveIf" unit test. --- .../Parser/mcs/cs-tokenizer.cs | 23 ++++++++----------- .../Parser/mcs/location.cs | 3 ++- .../PreprocessorDirectiveTests.cs | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs index b6a6f3eb0e..46bacca4f3 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs @@ -1825,11 +1825,11 @@ namespace Mono.CSharp { // skip over white space do { + endLine = line; + endCol = col; c = get_char (); } while (c == ' ' || c == '\t'); - - endLine = line; - endCol = col; + int pos = 0; while (c != -1 && c >= 'a' && c <= 'z') { id_builder[pos++] = (char) c; @@ -1870,17 +1870,13 @@ namespace Mono.CSharp return cmd; } - // skip over white space - while (c == ' ' || c == '\t') + while (c == ' ' || c == '\t') { c = get_char (); - + } int has_identifier_argument = (int)(cmd & PreprocessorDirective.RequiresArgument); int pos = 0; - endLine = line; - endCol = col; - while (c != -1 && c != '\n' && c != '\r') { if (c == '\\' && has_identifier_argument >= 0) { if (has_identifier_argument != 0) { @@ -1914,9 +1910,9 @@ namespace Mono.CSharp break; } - + endLine = line; - endCol = col; + endCol = col + 1; if (pos == value_builder.Length) Array.Resize (ref value_builder, pos * 2); @@ -1935,7 +1931,7 @@ namespace Mono.CSharp arg = arg.Trim (simple_whitespaces); } if (position_stack.Count == 0) - sbag.AddPreProcessorDirective (startLine, startCol, endLine, endCol + 1, cmd, arg); + sbag.AddPreProcessorDirective (startLine, startCol, endLine, endCol, cmd, arg); return cmd; } @@ -3348,7 +3344,7 @@ namespace Mono.CSharp if (ParsePreprocessingDirective (true)) continue; - sbag.StartComment (SpecialsBag.CommentType.Multi, false, line, col); + sbag.StartComment (SpecialsBag.CommentType.InactiveCode, false, line, 1); bool directive_expected = false; while ((c = get_char ()) != -1) { if (col == 1) { @@ -3359,6 +3355,7 @@ namespace Mono.CSharp // Eror_WrongPreprocessorLocation (); // return Token.ERROR; // } + sbag.PushCommentChar (c); continue; } diff --git a/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs b/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs index aac3a3d4f9..14759f5774 100644 --- a/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs +++ b/ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs @@ -477,7 +477,8 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" { Single, Multi, - Documentation + Documentation, + InactiveCode } public class Comment diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/PreprocessorDirectiveTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/PreprocessorDirectiveTests.cs index 13f5aab200..940ba7bacd 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/PreprocessorDirectiveTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/PreprocessorDirectiveTests.cs @@ -62,8 +62,8 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope Assert.AreEqual(PreProcessorDirectiveType.Endif, pp.Last().Type); Assert.AreEqual(string.Empty, pp.Last().Argument); - Assert.AreEqual(new TextLocation(4, 2), pp.First().StartLocation); - Assert.AreEqual(new TextLocation(4, 8), pp.First().EndLocation); + Assert.AreEqual(new TextLocation(4, 2), pp.Last().StartLocation); + Assert.AreEqual(new TextLocation(4, 8), pp.Last().EndLocation); } [Test]