Browse Source

Fixed constructor this/base unit test.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
eb5f2577eb
  1. 4
      ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ConstructorDeclaration.cs
  2. 12
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
  3. 2
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs
  4. 13
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  5. 8320
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  6. 6
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay
  7. 4
      ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs
  8. 3
      ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs

4
ICSharpCode.NRefactory.CSharp/Ast/TypeMembers/ConstructorDeclaration.cs

@ -57,6 +57,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,6 +57,10 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public CSharpTokenNode ColonToken {
get { return GetChildByRole (Roles.Colon); }
}
public ConstructorInitializer Initializer {
get { return GetChildByRole (InitializerRole); }
set { SetChildByRole( InitializerRole, value); }

12
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs

@ -730,7 +730,17 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -730,7 +730,17 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
return wrapper.Result;
}
}
if (node == null) {
var constructor = Unit.GetNodeAt<ConstructorDeclaration> (location.Line, location.Column - 3);
Console.WriteLine (constructor);
Console.WriteLine (constructor.ColonToken.IsNull);
Console.WriteLine (constructor.Initializer.IsNull);
if (constructor != null && !constructor.ColonToken.IsNull && constructor.Initializer.IsNull) {
wrapper.AddCustom ("this");
wrapper.AddCustom ("base");
return wrapper.Result;
}
}
CSharpResolver csResolver;
if (node != null) {
var nodes = new List<AstNode> ();

2
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngineBase.cs

@ -175,7 +175,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -175,7 +175,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (!IsInsideType (currentType, location))
currentType = null;
}
this.currentMember = null;
if (this.currentType != null) {
foreach (var member in currentType.Members) {
@ -190,7 +189,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -190,7 +189,6 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
if (!IsInsideType (currentMember, location))
currentMember = null;
}
var stack = GetBracketStack (GetMemberTextToCaret ().Item1);
if (stack.Count == 0)
currentMember = null;

13
ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs

@ -1075,14 +1075,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1075,14 +1075,15 @@ namespace ICSharpCode.NRefactory.CSharp
if (initializerLocation != null)
newConstructor.AddChild (new CSharpTokenNode (Convert (initializerLocation[0]), 1), ConstructorDeclaration.Roles.Colon);
// this and base has the same length
initializer.AddChild (new CSharpTokenNode (Convert (c.Initializer.Location), "this".Length), ConstructorDeclaration.Roles.Keyword);
if (initializerLocation != null)
if (initializerLocation != null && initializerLocation.Count > 1) {
// this and base has the same length
initializer.AddChild (new CSharpTokenNode (Convert (c.Initializer.Location), "this".Length), ConstructorDeclaration.Roles.Keyword);
initializer.AddChild (new CSharpTokenNode (Convert (initializerLocation[1]), 1), ConstructorDeclaration.Roles.LPar);
AddArguments (initializer, LocationsBag.GetLocations (c.Initializer.Arguments), c.Initializer.Arguments);
if (initializerLocation != null)
AddArguments (initializer, LocationsBag.GetLocations (c.Initializer.Arguments), c.Initializer.Arguments);
initializer.AddChild (new CSharpTokenNode (Convert (initializerLocation[2]), 1), ConstructorDeclaration.Roles.RPar);
newConstructor.AddChild (initializer, ConstructorDeclaration.InitializerRole);
newConstructor.AddChild (initializer, ConstructorDeclaration.InitializerRole);
}
}
if (c.Block != null)

8320
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs

File diff suppressed because it is too large Load Diff

6
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

@ -2256,6 +2256,12 @@ constructor_initializer @@ -2256,6 +2256,12 @@ constructor_initializer
$$ = new ConstructorThisInitializer ((Arguments) $5, GetLocation ($2));
lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3), GetLocation ($6));
}
| COLON error
{
Error_SyntaxError (yyToken);
$$ = new ConstructorThisInitializer (null, GetLocation ($1));
lbag.AddLocation ($$, GetLocation ($1));
}
| error
{
Error_SyntaxError (yyToken);

4
ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs

@ -241,7 +241,9 @@ namespace Mono.CSharp { @@ -241,7 +241,9 @@ namespace Mono.CSharp {
public char GetChar (int position)
{
return buffer[position];
if (buffer_start <= position && position < buffer.Length)
return buffer[position];
return '\0';
}
public char[] ReadChars (int fromPosition, int toPosition)

3
ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionBugTests.cs

@ -4098,14 +4098,13 @@ namespace Test @@ -4098,14 +4098,13 @@ namespace Test
});
}
[Ignore("Fixme!")]
[Test()]
public void TestConstructorThisBase ()
{
CombinedProviderTest (
@"class Program
{
public Program ()$ : t$
public Program () : $t$
{
}
}", provider => {

Loading…
Cancel
Save