Browse Source

Use List<SwitchSection> and List<CatchClause> instead of ArrayLists.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@722 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
2e819f05f1
  1. 24
      src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/SwitchStatement.cs
  2. 13
      src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/TryCatchStatement.cs
  3. 8
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  4. 8
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  5. 14
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  6. 14
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

24
src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/SwitchStatement.cs

@ -7,15 +7,14 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Collections; using System.Collections.Generic;
namespace ICSharpCode.NRefactory.Parser.AST namespace ICSharpCode.NRefactory.Parser.AST
{ {
public class SwitchStatement : Statement public class SwitchStatement : Statement
{ {
Expression switchExpression; Expression switchExpression;
// List<SwitchSection> switchSections; List<SwitchSection> switchSections;
ArrayList switchSections;
public Expression SwitchExpression { public Expression SwitchExpression {
get { get {
@ -26,16 +25,16 @@ namespace ICSharpCode.NRefactory.Parser.AST
} }
} }
public ArrayList SwitchSections { public List<SwitchSection> SwitchSections {
get { get {
return switchSections; return switchSections;
} }
set { set {
switchSections = value == null ? new ArrayList(1) : value; switchSections = value ?? new List<SwitchSection>(1);
} }
} }
public SwitchStatement(Expression switchExpression, ArrayList switchSections) public SwitchStatement(Expression switchExpression, List<SwitchSection> switchSections)
{ {
this.SwitchExpression = switchExpression; this.SwitchExpression = switchExpression;
this.SwitchSections = switchSections; this.SwitchSections = switchSections;
@ -44,7 +43,7 @@ namespace ICSharpCode.NRefactory.Parser.AST
public SwitchStatement(Expression switchExpression) public SwitchStatement(Expression switchExpression)
{ {
this.SwitchExpression = switchExpression; this.SwitchExpression = switchExpression;
this.switchSections = new ArrayList(1); this.switchSections = new List<SwitchSection>(1);
} }
public override object AcceptVisitor(IASTVisitor visitor, object data) public override object AcceptVisitor(IASTVisitor visitor, object data)
@ -62,24 +61,23 @@ namespace ICSharpCode.NRefactory.Parser.AST
public class SwitchSection : BlockStatement public class SwitchSection : BlockStatement
{ {
// List<CaseLabel> switchLabels; List<CaseLabel> switchLabels;
ArrayList switchLabels;
public ArrayList SwitchLabels { public List<CaseLabel> SwitchLabels {
get { get {
return switchLabels; return switchLabels;
} }
set { set {
switchLabels = value == null ? new ArrayList(1) : value; switchLabels = value ?? new List<CaseLabel>(1);
} }
} }
public SwitchSection() public SwitchSection()
{ {
switchLabels = new ArrayList(1); switchLabels = new List<CaseLabel>(1);
} }
public SwitchSection(ArrayList switchLabels) public SwitchSection(List<CaseLabel> switchLabels)
{ {
SwitchLabels = switchLabels; SwitchLabels = switchLabels;
} }

13
src/Libraries/NRefactory/Project/Src/Parser/AST/General/Statements/TryCatchStatement.cs

@ -7,15 +7,14 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Collections; using System.Collections.Generic;
namespace ICSharpCode.NRefactory.Parser.AST namespace ICSharpCode.NRefactory.Parser.AST
{ {
public class TryCatchStatement : Statement public class TryCatchStatement : Statement
{ {
Statement statementBlock; Statement statementBlock;
// List<CatchClause> catchClauses; List<CatchClause> catchClauses;
ArrayList catchClauses;
Statement finallyBlock; Statement finallyBlock;
public Statement StatementBlock { public Statement StatementBlock {
@ -27,12 +26,12 @@ namespace ICSharpCode.NRefactory.Parser.AST
} }
} }
public ArrayList CatchClauses { public List<CatchClause> CatchClauses {
get { get {
return catchClauses; return catchClauses;
} }
set { set {
catchClauses = value == null ? new ArrayList(1) : value; catchClauses = value ?? new List<CatchClause>(1);
} }
} }
@ -45,14 +44,14 @@ namespace ICSharpCode.NRefactory.Parser.AST
} }
} }
public TryCatchStatement(Statement statementBlock, ArrayList catchClauses, Statement finallyBlock) public TryCatchStatement(Statement statementBlock, List<CatchClause> catchClauses, Statement finallyBlock)
{ {
this.StatementBlock = statementBlock; this.StatementBlock = statementBlock;
this.CatchClauses = catchClauses; this.CatchClauses = catchClauses;
this.FinallyBlock = finallyBlock; this.FinallyBlock = finallyBlock;
} }
public TryCatchStatement(Statement statementBlock, ArrayList catchClauses) : this(statementBlock, catchClauses, null) public TryCatchStatement(Statement statementBlock, List<CatchClause> catchClauses) : this(statementBlock, catchClauses, null)
{ {
} }

8
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

@ -3907,7 +3907,7 @@ out elseStatement);
lexer.NextToken(); lexer.NextToken();
#line 1867 "cs.ATG" #line 1867 "cs.ATG"
ArrayList switchSections = new ArrayList(); SwitchSection switchSection; List<SwitchSection> switchSections = new List<SwitchSection>(); SwitchSection switchSection;
Expect(20); Expect(20);
Expr( Expr(
#line 1868 "cs.ATG" #line 1868 "cs.ATG"
@ -4304,7 +4304,7 @@ out Statement tryStatement) {
#line 1969 "cs.ATG" #line 1969 "cs.ATG"
Statement blockStmt = null, finallyStmt = null; Statement blockStmt = null, finallyStmt = null;
ArrayList catchClauses = null; List<CatchClause> catchClauses = null;
Expect(113); Expect(113);
Block( Block(
@ -4382,10 +4382,10 @@ out expr);
void CatchClauses( void CatchClauses(
#line 1984 "cs.ATG" #line 1984 "cs.ATG"
out ArrayList catchClauses) { out List<CatchClause> catchClauses) {
#line 1986 "cs.ATG" #line 1986 "cs.ATG"
catchClauses = new ArrayList(); catchClauses = new List<CatchClause>();
Expect(55); Expect(55);

8
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -1864,7 +1864,7 @@ EmbeddedStatement<out Statement statement>
EmbeddedStatement<out embeddedStatement> EmbeddedStatement<out embeddedStatement>
[ "else" EmbeddedStatement<out elseStatement> ] [ "else" EmbeddedStatement<out elseStatement> ]
(. statement = elseStatement != null ? (Statement)new IfElseStatement(expr, embeddedStatement, elseStatement) : (Statement)new IfElseStatement(expr, embeddedStatement); .) (. statement = elseStatement != null ? (Statement)new IfElseStatement(expr, embeddedStatement, elseStatement) : (Statement)new IfElseStatement(expr, embeddedStatement); .)
| "switch" (. ArrayList switchSections = new ArrayList(); SwitchSection switchSection; .) | "switch" (. List<SwitchSection> switchSections = new List<SwitchSection>(); SwitchSection switchSection; .)
"(" Expr<out expr> ")" "(" Expr<out expr> ")"
"{" { SwitchSection<out switchSection> (. switchSections.Add(switchSection); .) } "{" { SwitchSection<out switchSection> (. switchSections.Add(switchSection); .) }
"}" (. statement = new SwitchStatement(expr, switchSections); .) "}" (. statement = new SwitchStatement(expr, switchSections); .)
@ -1967,7 +1967,7 @@ SwitchLabel<out CaseLabel label>
TryStatement<out Statement tryStatement> TryStatement<out Statement tryStatement>
(. (.
Statement blockStmt = null, finallyStmt = null; Statement blockStmt = null, finallyStmt = null;
ArrayList catchClauses = null; List<CatchClause> catchClauses = null;
.) .)
= =
"try" Block<out blockStmt> "try" Block<out blockStmt>
@ -1981,9 +1981,9 @@ TryStatement<out Statement tryStatement>
.) .)
. .
CatchClauses<out ArrayList catchClauses> CatchClauses<out List<CatchClause> catchClauses>
(. (.
catchClauses = new ArrayList(); catchClauses = new List<CatchClause>();
.) .)
= =
"catch" (. string identifier; "catch" (. string identifier;

14
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

@ -5391,13 +5391,13 @@ out expr);
EndOfStmt(); EndOfStmt();
#line 2560 "VBNET.ATG" #line 2560 "VBNET.ATG"
ArrayList selectSections = new ArrayList(); List<SwitchSection> selectSections = new List<SwitchSection>();
Statement block = null; Statement block = null;
while (la.kind == 57) { while (la.kind == 57) {
#line 2564 "VBNET.ATG" #line 2564 "VBNET.ATG"
ArrayList caseClauses = null; List<CaseLabel> caseClauses = null;
lexer.NextToken(); lexer.NextToken();
CaseClauses( CaseClauses(
#line 2565 "VBNET.ATG" #line 2565 "VBNET.ATG"
@ -5630,7 +5630,7 @@ localVariableDeclaration.Variables);
out Statement tryStatement) { out Statement tryStatement) {
#line 2817 "VBNET.ATG" #line 2817 "VBNET.ATG"
Statement blockStmt = null, finallyStmt = null;ArrayList catchClauses = null; Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
Expect(175); Expect(175);
EndOfStmt(); EndOfStmt();
@ -5760,10 +5760,10 @@ out type);
void CaseClauses( void CaseClauses(
#line 2746 "VBNET.ATG" #line 2746 "VBNET.ATG"
out ArrayList caseClauses) { out List<CaseLabel> caseClauses) {
#line 2748 "VBNET.ATG" #line 2748 "VBNET.ATG"
caseClauses = new ArrayList(); caseClauses = new List<CaseLabel>();
CaseLabel caseClause = null; CaseLabel caseClause = null;
CaseClause( CaseClause(
@ -5971,10 +5971,10 @@ out sexpr);
void CatchClauses( void CatchClauses(
#line 2830 "VBNET.ATG" #line 2830 "VBNET.ATG"
out ArrayList catchClauses) { out List<CatchClause> catchClauses) {
#line 2832 "VBNET.ATG" #line 2832 "VBNET.ATG"
catchClauses = new ArrayList(); catchClauses = new List<CatchClause>();
TypeReference type = null; TypeReference type = null;
Statement blockStmt = null; Statement blockStmt = null;
Expression expr = null; Expression expr = null;

14
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -2557,11 +2557,11 @@ EmbeddedStatement<out Statement statement>
) )
| /* 10.8.2 */ | /* 10.8.2 */
"Select" [ "Case" ] Expr<out expr> EndOfStmt "Select" [ "Case" ] Expr<out expr> EndOfStmt
(.ArrayList selectSections = new ArrayList(); (.List<SwitchSection> selectSections = new List<SwitchSection>();
Statement block = null; Statement block = null;
.) .)
{ {
(.ArrayList caseClauses = null; .) (.List<CaseLabel> caseClauses = null; .)
"Case" CaseClauses<out caseClauses> [ IF(IsNotStatementSeparator()) ":" ] EndOfStmt "Case" CaseClauses<out caseClauses> [ IF(IsNotStatementSeparator()) ":" ] EndOfStmt
(. (.
SwitchSection selectSection = new SwitchSection(caseClauses); SwitchSection selectSection = new SwitchSection(caseClauses);
@ -2743,9 +2743,9 @@ ResumeStatement<out ResumeStatement resumeStatement>
. .
/* 18.8.2 */ /* 18.8.2 */
CaseClauses<out ArrayList caseClauses> CaseClauses<out List<CaseLabel> caseClauses>
(. (.
caseClauses = new ArrayList(); caseClauses = new List<CaseLabel>();
CaseLabel caseClause = null; CaseLabel caseClause = null;
.) = .) =
CaseClause<out caseClause> (. caseClauses.Add(caseClause); .) CaseClause<out caseClause> (. caseClauses.Add(caseClause); .)
@ -2814,7 +2814,7 @@ WithStatement<out Statement withStatement>
/* 10.10.1 */ /* 10.10.1 */
TryStatement<out Statement tryStatement> TryStatement<out Statement tryStatement>
(. (.
Statement blockStmt = null, finallyStmt = null;ArrayList catchClauses = null; Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
.) = .) =
"Try" EndOfStmt "Try" EndOfStmt
Block<out blockStmt> Block<out blockStmt>
@ -2827,9 +2827,9 @@ TryStatement<out Statement tryStatement>
. .
/* 10.10.1.2 */ /* 10.10.1.2 */
CatchClauses<out ArrayList catchClauses> CatchClauses<out List<CatchClause> catchClauses>
(. (.
catchClauses = new ArrayList(); catchClauses = new List<CatchClause>();
TypeReference type = null; TypeReference type = null;
Statement blockStmt = null; Statement blockStmt = null;
Expression expr = null; Expression expr = null;

Loading…
Cancel
Save