Browse Source

Fixed location bug.

newNRvisualizers
Mike Krüger 15 years ago
parent
commit
b1fa379e6b
  1. 9
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  2. 1138
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.cs
  3. 13
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-parser.jay

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

@ -91,10 +91,10 @@ namespace ICSharpCode.NRefactory.CSharp
{ {
AstType result; AstType result;
if (memberName.Left != null) { if (memberName.Left != null) {
result = new MemberType () { MemberName = memberName.Name }; result = new MemberType () { MemberNameToken = Identifier.Create (memberName.Name, Convert (memberName.Location)) };
result.AddChild (ConvertToType (memberName.Left), MemberType.TargetRole); result.AddChild (ConvertToType (memberName.Left), MemberType.TargetRole);
} else { } else {
result = new SimpleType () { Identifier = memberName.Name }; result = new SimpleType () { IdentifierToken = Identifier.Create (memberName.Name, Convert (memberName.Location)) };
} }
if (memberName.TypeArguments != null && !memberName.TypeArguments.IsEmpty) { if (memberName.TypeArguments != null && !memberName.TypeArguments.IsEmpty) {
foreach (var arg in memberName.TypeArguments.Args) { foreach (var arg in memberName.TypeArguments.Args) {
@ -210,7 +210,6 @@ namespace ICSharpCode.NRefactory.CSharp
result.AddChild ((Expression)arg.Expr.Accept (this), Attribute.Roles.Argument); result.AddChild ((Expression)arg.Expr.Accept (this), Attribute.Roles.Argument);
} }
} }
Console.WriteLine ("---");
if (attr.NamedArguments != null) { if (attr.NamedArguments != null) {
foreach (NamedArgument na in attr.NamedArguments) { foreach (NamedArgument na in attr.NamedArguments) {
var newArg = new NamedExpression (); var newArg = new NamedExpression ();
@ -2207,7 +2206,6 @@ namespace ICSharpCode.NRefactory.CSharp
} }
var p = (Parameter)parameters.FixedParameters [i]; var p = (Parameter)parameters.FixedParameters [i];
var location = LocationsBag.GetLocations (p); var location = LocationsBag.GetLocations (p);
ParameterDeclaration parameterDeclarationExpression = new ParameterDeclaration (); ParameterDeclaration parameterDeclarationExpression = new ParameterDeclaration ();
AddAttributeSection (parameterDeclarationExpression, p); AddAttributeSection (parameterDeclarationExpression, p);
switch (p.ModFlags) { switch (p.ModFlags) {
@ -2229,8 +2227,9 @@ namespace ICSharpCode.NRefactory.CSharp
default: default:
if (p.HasExtensionMethodModifier) { if (p.HasExtensionMethodModifier) {
parameterDeclarationExpression.ParameterModifier = ParameterModifier.This; parameterDeclarationExpression.ParameterModifier = ParameterModifier.This;
if (location != null) if (location != null) {
parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "this".Length), ParameterDeclaration.Roles.Keyword); parameterDeclarationExpression.AddChild (new CSharpTokenNode (Convert (location [0]), "this".Length), ParameterDeclaration.Roles.Keyword);
}
} }
break; break;
} }

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

File diff suppressed because it is too large Load Diff

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

@ -1626,7 +1626,6 @@ parameter_modifiers
: parameter_modifier : parameter_modifier
{ {
$$ = $1; $$ = $1;
parameterModifierLocation = GetLocation ($1);
} }
| parameter_modifiers parameter_modifier | parameter_modifiers parameter_modifier
{ {
@ -1656,14 +1655,14 @@ parameter_modifier
{ {
if ((valid_param_mod & ParameterModifierType.Ref) == 0) if ((valid_param_mod & ParameterModifierType.Ref) == 0)
Error_ParameterModifierNotValid ("ref", GetLocation ($1)); Error_ParameterModifierNotValid ("ref", GetLocation ($1));
parameterModifierLocation = GetLocation ($1);
$$ = Parameter.Modifier.REF; $$ = Parameter.Modifier.REF;
} }
| OUT | OUT
{ {
if ((valid_param_mod & ParameterModifierType.Out) == 0) if ((valid_param_mod & ParameterModifierType.Out) == 0)
Error_ParameterModifierNotValid ("out", GetLocation ($1)); Error_ParameterModifierNotValid ("out", GetLocation ($1));
parameterModifierLocation = GetLocation ($1);
$$ = Parameter.Modifier.OUT; $$ = Parameter.Modifier.OUT;
} }
| THIS | THIS
@ -1673,7 +1672,7 @@ parameter_modifier
if (lang_version <= LanguageVersion.ISO_2) if (lang_version <= LanguageVersion.ISO_2)
FeatureIsNotAvailable (GetLocation ($1), "extension methods"); FeatureIsNotAvailable (GetLocation ($1), "extension methods");
parameterModifierLocation = GetLocation ($1);
$$ = Parameter.Modifier.This; $$ = Parameter.Modifier.This;
} }
; ;
@ -4344,7 +4343,7 @@ class_declaration
FeatureIsNotAvailable (c.Location, "static classes"); FeatureIsNotAvailable (c.Location, "static classes");
} }
lbag.AddMember (current_class, GetModifierLocations (), GetLocation ($4)); lbag.AddMember (current_class, GetModifierLocations ());
push_current_class (c, $3); push_current_class (c, $3);
} }
opt_class_base opt_class_base
@ -4368,9 +4367,9 @@ class_declaration
opt_semicolon opt_semicolon
{ {
if ($15 != null) { if ($15 != null) {
lbag.AppendToMember (current_class, GetLocation ($11), GetLocation ($13), GetLocation ($15)); lbag.AppendToMember (current_class, GetLocation ($4), GetLocation ($11), GetLocation ($13), GetLocation ($15));
} else { } else {
lbag.AppendToMember (current_class, GetLocation ($11), GetLocation ($13)); lbag.AppendToMember (current_class, GetLocation ($4), GetLocation ($11), GetLocation ($13));
} }
$$ = pop_current_class (); $$ = pop_current_class ();
} }

Loading…
Cancel
Save