Browse Source

Fixed "InactiveIf" unit test.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
94bad6c210
  1. 23
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs
  2. 3
      ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs
  3. 4
      ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/PreprocessorDirectiveTests.cs

23
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs

@ -1825,11 +1825,11 @@ namespace Mono.CSharp @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -3359,6 +3355,7 @@ namespace Mono.CSharp
// Eror_WrongPreprocessorLocation ();
// return Token.ERROR;
// }
sbag.PushCommentChar (c);
continue;
}

3
ICSharpCode.NRefactory.CSharp/Parser/mcs/location.cs

@ -477,7 +477,8 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" @@ -477,7 +477,8 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format ("
{
Single,
Multi,
Documentation
Documentation,
InactiveCode
}
public class Comment

4
ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/PreprocessorDirectiveTests.cs

@ -62,8 +62,8 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -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]

Loading…
Cancel
Save