Browse Source

Fixed return type tokens

newNRvisualizers
Mike Krüger 15 years ago
parent
commit
280b79b8c8
  1. 19
      ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs
  2. 2
      ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs
  3. 11
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs
  4. 9
      ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs
  5. 1345
      ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.cs
  6. 15
      ICSharpCode.NRefactory/CSharp/Parser/mcs/cs-parser.jay
  7. 4
      ICSharpCode.NRefactory/CSharp/Parser/mcs/expression.cs
  8. 4
      ICSharpCode.NRefactory/CSharp/Parser/mcs/location.cs

19
ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs

@ -1065,6 +1065,25 @@ return (Test)null; @@ -1065,6 +1065,25 @@ return (Test)null;
i2 = result.Text.IndexOf (";") + ";".Length;
Assert.AreEqual (@"int a = 5,b = 6,c;", result.GetTextAt (i1, i2 - i1));
}
[Test()]
public void TestLocalVariableWithGenerics ()
{
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeLocalVariableDeclarationComma = true;
policy.SpaceAfterLocalVariableDeclarationComma = true;
var result = GetResult (policy, @"class Test {
void TestMe ()
{
List<Test> a;
}
}");
int i1 = result.Text.IndexOf ("List");
int i2 = result.Text.IndexOf (";") + ";".Length;
Assert.AreEqual (@"List<Test> a;", result.GetTextAt (i1, i2 - i1));
}
#region Constructors

2
ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.VB.Ast @@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.VB.Ast
public ClassType ClassType { get; set; }
public Identifier Name {
public Identifier NameToken {
get { return GetChildByRole(Roles.Identifier); }
set { SetChildByRole(Roles.Identifier, value); }
}

11
ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs

@ -68,7 +68,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -68,7 +68,16 @@ namespace ICSharpCode.NRefactory.CSharp
return GetChildByRole (Roles.Identifier).Name;
}
set {
SetChildByRole (Roles.Identifier, new Identifier(value, AstLocation.Empty));
SetChildByRole (Roles.Identifier, new Identifier (value, AstLocation.Empty));
}
}
public Identifier NameToken {
get {
return GetChildByRole (Roles.Identifier);
}
set {
SetChildByRole (Roles.Identifier, value);
}
}

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

@ -71,9 +71,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -71,9 +71,17 @@ namespace ICSharpCode.NRefactory.CSharp
{
if (texpr.TypeArguments == null || texpr.TypeArguments.Args == null)
return;
var loc = LocationsBag.GetLocations (texpr.TypeArguments);
if (loc != null && loc.Count >= 2)
result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 2]), 1), AstType.Roles.LChevron);
int i = 0;
foreach (var arg in texpr.TypeArguments.Args) {
result.AddChild (ConvertToType (arg), AstType.Roles.TypeArgument);
if (loc != null && i < loc.Count - 2)
result.AddChild (new CSharpTokenNode (Convert (loc [i++]), 1), AstType.Roles.Comma);
}
if (loc != null && loc.Count >= 2)
result.AddChild (new CSharpTokenNode (Convert (loc [loc.Count - 1]), 1), AstType.Roles.RChevron);
}
AstType ConvertToType (MemberName memberName)
@ -95,6 +103,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -95,6 +103,7 @@ namespace ICSharpCode.NRefactory.CSharp
AstType ConvertToType (Mono.CSharp.Expression typeName)
{
Console.WriteLine (typeName);
if (typeName is TypeExpression) {
var typeExpr = (Mono.CSharp.TypeExpression)typeName;
return new PrimitiveType (typeExpr.GetSignatureForError (), Convert (typeExpr.Location));

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

File diff suppressed because it is too large Load Diff

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

@ -143,6 +143,7 @@ namespace Mono.CSharp @@ -143,6 +143,7 @@ namespace Mono.CSharp
UsingsBag ubag;
List<Tuple<Modifiers, Location>> mod_locations;
Location parameterModifierLocation, savedLocation, savedOpenLocation, savedCloseLocation;
Stack<List<Location>> locationListStack = new Stack<List<Location>> (); // used for type parameters
%}
%token EOF
@ -2694,9 +2695,13 @@ opt_type_argument_list @@ -2694,9 +2695,13 @@ opt_type_argument_list
| OP_GENERICS_LT type_arguments OP_GENERICS_GT
{
if (lang_version < LanguageVersion.ISO_2)
FeatureIsNotAvailable (GetLocation ($1), "generics");
$$ = $2;
FeatureIsNotAvailable (GetLocation ($1), "generics");
var list = locationListStack.Pop ();
list.Add (GetLocation ($1));
list.Add (GetLocation ($2));
lbag.AddLocation ($2, list);
$$ = $2;;
}
| OP_GENERICS_LT error
{
@ -2711,13 +2716,15 @@ type_arguments @@ -2711,13 +2716,15 @@ type_arguments
TypeArguments type_args = new TypeArguments ();
type_args.Add ((FullNamedExpression) $1);
$$ = type_args;
locationListStack.Push (new List<Location> ());
}
| type_arguments COMMA type
{
TypeArguments type_args = (TypeArguments) $1;
type_args.Add ((FullNamedExpression) $3);
$$ = type_args;
}
locationListStack.Peek ().Add (GetLocation ($2));
}
;
//

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

@ -7141,9 +7141,7 @@ namespace Mono.CSharp @@ -7141,9 +7141,7 @@ namespace Mono.CSharp
FullNamedExpression texpr;
public FullNamedExpression FullNamedExpression {
get {
return texpr;
}
get { return texpr;}
}
public RefValueExpr (Expression expr, FullNamedExpression texpr, Location loc)

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

@ -732,7 +732,9 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format (" @@ -732,7 +732,9 @@ if (checkpoints.Length <= CheckpointIndex) throw new Exception (String.Format ("
public List<Location> GetLocations (object element)
{
List<Location> found;
if (element == null)
return null;
List<Location > found;
simple_locs.TryGetValue (element, out found);
return found;
}

Loading…
Cancel
Save