Browse Source

Fixed event declaration assign token location.

pull/32/merge
Mike Krüger 13 years ago
parent
commit
b3dee87537
  1. 11
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  2. 1110
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  3. 10
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

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

@ -1246,18 +1246,19 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1246,18 +1246,19 @@ namespace ICSharpCode.NRefactory.CSharp
EventDeclaration newEvent = new EventDeclaration ();
AddAttributeSection (newEvent, e);
var location = LocationsBag.GetMemberLocation (e);
int l = 0;
AddModifiers (newEvent, location);
if (location != null && location.Count > 0)
newEvent.AddChild (new CSharpTokenNode (Convert (location [0]), EventDeclaration.EventKeywordRole), EventDeclaration.EventKeywordRole);
newEvent.AddChild (new CSharpTokenNode (Convert (location [l++]), EventDeclaration.EventKeywordRole), EventDeclaration.EventKeywordRole);
newEvent.AddChild (ConvertToType (e.TypeExpression), Roles.Type);
VariableInitializer variable = new VariableInitializer ();
variable.AddChild (Identifier.Create (e.MemberName.Name, Convert (e.MemberName.Location)), Roles.Identifier);
if (e.Initializer != null) {
if (location != null && location.Count > 0)
variable.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.Assign), Roles.Assign);
if (location != null && location.Count > l)
variable.AddChild (new CSharpTokenNode (Convert (location [l++]), Roles.Assign), Roles.Assign);
variable.AddChild ((Expression)e.Initializer.Accept (this), Roles.Expression);
}
newEvent.AddChild (variable, Roles.Variable);
@ -1279,8 +1280,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1279,8 +1280,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
if (location != null && location.Count > 1)
newEvent.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.Semicolon), Roles.Semicolon);
if (location != null && location.Count > l)
newEvent.AddChild (new CSharpTokenNode (Convert (location [l++]), Roles.Semicolon), Roles.Semicolon);
typeStack.Peek ().AddChild (newEvent, Roles.TypeMemberRole);
}

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

File diff suppressed because it is too large Load Diff

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

@ -139,7 +139,7 @@ namespace Mono.CSharp @@ -139,7 +139,7 @@ namespace Mono.CSharp
//
LocationsBag lbag;
List<Tuple<Modifiers, Location>> mod_locations;
Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation;
Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation, savedEventAssignLocation;
Location savedAttrParenOpenLocation, savedAttrParenCloseLocation, savedOperatorLocation;
Stack<List<Location>> locationListStack = new Stack<List<Location>> (); // used for type parameters
Stack<Location> opt_intoStack = new Stack<Location> ();
@ -2387,8 +2387,11 @@ event_declaration @@ -2387,8 +2387,11 @@ event_declaration
current_event_field.DocComment = Lexer.consume_doc_comment ();
Lexer.doc_state = XmlCommentState.Allowed;
}
lbag.AddMember (current_event_field, GetModifierLocations (), GetLocation ($3), GetLocation ($9));
if (current_event_field.Initializer != null) {
lbag.AddMember (current_event_field, GetModifierLocations (), GetLocation ($3), savedEventAssignLocation, GetLocation ($9));
} else {
lbag.AddMember (current_event_field, GetModifierLocations (), GetLocation ($3), GetLocation ($9));
}
current_event_field = null;
}
| opt_attributes
@ -2439,6 +2442,7 @@ opt_event_initializer @@ -2439,6 +2442,7 @@ opt_event_initializer
event_variable_initializer
{
--lexer.parsing_block;
savedEventAssignLocation = GetLocation ($1);
current_event_field.Initializer = (Expression) $3;
}
;

Loading…
Cancel
Save