Browse Source

Fixed SD2-401: Using aliases for classes.

Usings like "using StringCollection = System.Collections.Generic.List<string>" are now valid and code completion works correctly for them.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@329 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
20199d196a
  1. 3
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/ExpressionFinder.cs
  2. 23
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerSecondaryDisplayBinding.cs
  3. 5
      src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs
  4. 6
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs
  5. 28
      src/Libraries/NRefactory/Project/Src/Parser/AST/General/GlobalScope/UsingDeclaration.cs
  6. 253
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  7. 10
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  8. 101
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  9. 10
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  10. 2
      src/Libraries/NRefactory/Test/NRefactoryTests.csproj
  11. 44
      src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs
  12. 2
      src/Main/Base/Project/Src/Dom/ClassFinder.cs
  13. 8
      src/Main/Base/Project/Src/Dom/IClass.cs
  14. 4
      src/Main/Base/Project/Src/Dom/IUsing.cs
  15. 35
      src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs
  16. 29
      src/Main/Base/Project/Src/Dom/Implementations/DefaultUsing.cs
  17. 3
      src/Main/Base/Project/Src/Dom/Implementations/SearchClassReturnType.cs
  18. 9
      src/Main/Base/Project/Src/Dom/Implementations/SpecificReturnType.cs
  19. 13
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs
  20. 26
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs
  21. 17
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/TypeVisitor.cs
  22. 3
      src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/BaseTypesNode.cs
  23. 39
      src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs
  24. 4
      src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs
  25. 2
      src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs
  26. 72
      src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/AbstractClassImplementorCodeGenerator.cs
  27. 217
      src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/InterfaceImplementorCodeGenerator.cs

3
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Parser/ExpressionFinder.cs

@ -69,7 +69,8 @@ namespace CSharpBinding.Parser
genericPart = null; genericPart = null;
} }
ClassFinder finder = new ClassFinder(fileName, text, typeStart); ClassFinder finder = new ClassFinder(fileName, text, typeStart);
IClass c = finder.SearchClass(nonGenericClassName); IReturnType t = finder.SearchType(nonGenericClassName);
IClass c = (t != null) ? t.GetUnderlyingClass() : null;
if (c != null) { if (c != null) {
ExpressionContext context = ExpressionContext.TypeDerivingFrom(c, true); ExpressionContext context = ExpressionContext.TypeDerivingFrom(c, true);
if (context.ShowEntry(c)) { if (context.ShowEntry(c)) {

23
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/FormDesignerSecondaryDisplayBinding.cs

@ -56,28 +56,11 @@ namespace ICSharpCode.FormDesigner
return null; return null;
} }
static Hashtable oldTypes = new Hashtable();
public static bool BaseClassIsFormOrControl(IClass c) public static bool BaseClassIsFormOrControl(IClass c)
{ {
if (c == null || oldTypes.Contains(c.FullyQualifiedName)) { IProjectContent pc = ProjectContentRegistry.GetExistingProjectContent(new AssemblyName("System.Windows.Forms"));
oldTypes.Clear(); return c.IsTypeInInheritanceTree(pc.GetClass("System.Windows.Forms.Form")) ||
return false; c.IsTypeInInheritanceTree(pc.GetClass("System.Windows.Forms.UserControl"));
}
oldTypes.Add(c.FullyQualifiedName, null);
foreach (string baseType in c.BaseTypes) {
IClass type = ParserService.CurrentProjectContent.SearchType(baseType, c, c.Region != null ? c.Region.BeginLine : 0, c.Region != null ? c.Region.BeginColumn : 0);
string typeName = type != null ? type.FullyQualifiedName : baseType;
if (typeName == "System.Windows.Forms.Form" ||
typeName == "System.Windows.Forms.UserControl" ||
BaseClassIsFormOrControl(type)) {
oldTypes.Clear();
return true;
}
}
oldTypes.Clear();
return false;
} }
public bool CanAttachTo(IViewContent viewContent) public bool CanAttachTo(IViewContent viewContent)

5
src/Libraries/NRefactory/Project/Src/Output/CSharp/CSharpOutputVisitor.cs

@ -246,14 +246,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Using); outputFormatter.PrintToken(Tokens.Using);
outputFormatter.Space(); outputFormatter.Space();
outputFormatter.PrintIdentifier(u.Name);
if (u.IsAlias) { if (u.IsAlias) {
outputFormatter.PrintIdentifier(u.Alias);
outputFormatter.Space(); outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign); outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space(); outputFormatter.Space();
nodeTracker.TrackedVisit(u.Alias, data);
} }
outputFormatter.PrintIdentifier(u.Name);
outputFormatter.PrintToken(Tokens.Semicolon); outputFormatter.PrintToken(Tokens.Semicolon);
outputFormatter.NewLine(); outputFormatter.NewLine();
return null; return null;

6
src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs

@ -230,13 +230,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Imports); outputFormatter.PrintToken(Tokens.Imports);
outputFormatter.Space(); outputFormatter.Space();
for (int i = 0; i < usingDeclaration.Usings.Count; ++i) { for (int i = 0; i < usingDeclaration.Usings.Count; ++i) {
outputFormatter.PrintIdentifier(((Using)usingDeclaration.Usings[i]).Name);
if (((Using)usingDeclaration.Usings[i]).IsAlias) { if (((Using)usingDeclaration.Usings[i]).IsAlias) {
outputFormatter.PrintIdentifier(((Using)usingDeclaration.Usings[i]).Alias);
outputFormatter.Space(); outputFormatter.Space();
outputFormatter.PrintToken(Tokens.As); outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space(); outputFormatter.Space();
nodeTracker.TrackedVisit(((Using)usingDeclaration.Usings[i]).Alias, data);
} }
outputFormatter.PrintIdentifier(((Using)usingDeclaration.Usings[i]).Name);
if (i + 1 < usingDeclaration.Usings.Count) { if (i + 1 < usingDeclaration.Usings.Count) {
outputFormatter.PrintToken(Tokens.Comma); outputFormatter.PrintToken(Tokens.Comma);
outputFormatter.Space(); outputFormatter.Space();

28
src/Libraries/NRefactory/Project/Src/Parser/AST/General/GlobalScope/UsingDeclaration.cs

@ -7,14 +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 Using : AbstractNode public class Using : AbstractNode
{ {
string name; string name;
string alias; TypeReference alias;
public string Name { public string Name {
get { get {
@ -25,23 +25,22 @@ namespace ICSharpCode.NRefactory.Parser.AST
} }
} }
public string Alias { public TypeReference Alias {
get { get {
return alias; return alias;
} }
set { set {
alias = value == null ? String.Empty : value; alias = TypeReference.CheckNull(value);
} }
} }
public bool IsAlias { public bool IsAlias {
get { get {
Debug.Assert(alias != null); return !alias.IsNull;
return alias.Length > 0;
} }
} }
public Using(string name, string alias) public Using(string name, TypeReference alias)
{ {
this.Name = name; this.Name = name;
this.Alias = alias; this.Alias = alias;
@ -66,15 +65,14 @@ namespace ICSharpCode.NRefactory.Parser.AST
public class UsingDeclaration : AbstractNode public class UsingDeclaration : AbstractNode
{ {
// List<Using> namespaces; List<Using> usings;
ArrayList usings;
public ArrayList Usings { public List<Using> Usings {
get { get {
return usings; return usings;
} }
set { set {
usings = value == null ? new ArrayList(1) : value; usings = value == null ? new List<Using>(1) : value;
} }
} }
@ -82,14 +80,14 @@ namespace ICSharpCode.NRefactory.Parser.AST
{ {
} }
public UsingDeclaration(string nameSpace, string alias) public UsingDeclaration(string nameSpace, TypeReference alias)
{ {
Debug.Assert(nameSpace != null); Debug.Assert(nameSpace != null);
usings = new ArrayList(1); usings = new List<Using>(1);
usings.Add(new Using(nameSpace, alias)); usings.Add(new Using(nameSpace, alias));
} }
public UsingDeclaration(ArrayList usings) public UsingDeclaration(List<Using> usings)
{ {
this.Usings = usings; this.Usings = usings;
} }
@ -101,7 +99,7 @@ namespace ICSharpCode.NRefactory.Parser.AST
public override string ToString() public override string ToString()
{ {
return String.Format("[UsingDeclaration: Namespace={0}]", return String.Format("[UsingDeclaration: Usings={0}]",
GetCollectionString(usings)); GetCollectionString(usings));
} }
} }

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

@ -453,31 +453,28 @@ IsGlobalAttrTarget()) {
void UsingDirective() { void UsingDirective() {
#line 562 "cs.ATG" #line 562 "cs.ATG"
string qualident = null, aliasident = null; string qualident = null; TypeReference aliasedType = null;
Expect(119); Expect(119);
#line 565 "cs.ATG" #line 565 "cs.ATG"
Point startPos = t.Location; Point startPos = t.Location;
if ( Qualident(
#line 566 "cs.ATG" #line 566 "cs.ATG"
IsAssignment()) { out qualident);
if (la.kind == 3) {
lexer.NextToken(); lexer.NextToken();
NonArrayType(
#line 566 "cs.ATG"
aliasident = t.val;
Expect(3);
}
Qualident(
#line 567 "cs.ATG" #line 567 "cs.ATG"
out qualident); out aliasedType);
}
Expect(11); Expect(11);
#line 569 "cs.ATG" #line 569 "cs.ATG"
if (qualident != null && qualident.Length > 0) { if (qualident != null && qualident.Length > 0) {
INode node; INode node;
if (aliasident != null) { if (aliasedType != null) {
node = new UsingDeclaration(aliasident, qualident); node = new UsingDeclaration(qualident, aliasedType);
} else { } else {
node = new UsingDeclaration(qualident); node = new UsingDeclaration(qualident);
} }
@ -614,6 +611,46 @@ DotAndIdent()) {
qualident = qualidentBuilder.ToString(); qualident = qualidentBuilder.ToString();
} }
void NonArrayType(
#line 920 "cs.ATG"
out TypeReference type) {
#line 922 "cs.ATG"
string name;
int pointer = 0;
type = null;
if (la.kind == 1 || la.kind == 89 || la.kind == 106) {
ClassType(
#line 927 "cs.ATG"
out type);
} else if (StartOf(4)) {
SimpleType(
#line 928 "cs.ATG"
out name);
#line 928 "cs.ATG"
type = new TypeReference(name);
} else if (la.kind == 121) {
lexer.NextToken();
Expect(6);
#line 929 "cs.ATG"
pointer = 1; type = new TypeReference("void");
} else SynErr(126);
while (
#line 932 "cs.ATG"
IsPointer()) {
Expect(6);
#line 933 "cs.ATG"
++pointer;
}
#line 935 "cs.ATG"
if (type != null) { type.PointerNestingLevel = pointer; }
}
void Attribute( void Attribute(
#line 601 "cs.ATG" #line 601 "cs.ATG"
out ASTAttribute attribute) { out ASTAttribute attribute) {
@ -649,7 +686,7 @@ List<Expression> positional, List<NamedArgumentExpression> named) {
Expression expr; Expression expr;
Expect(19); Expect(19);
if (StartOf(4)) { if (StartOf(5)) {
if ( if (
#line 621 "cs.ATG" #line 621 "cs.ATG"
IsAssignment()) { IsAssignment()) {
@ -684,11 +721,11 @@ IsAssignment()) {
#line 633 "cs.ATG" #line 633 "cs.ATG"
name = t.val; name = t.val;
Expect(3); Expect(3);
} else if (StartOf(4)) { } else if (StartOf(5)) {
#line 635 "cs.ATG" #line 635 "cs.ATG"
if (nameFound) Error("no positional argument after named argument"); if (nameFound) Error("no positional argument after named argument");
} else SynErr(126); } else SynErr(127);
Expr( Expr(
#line 636 "cs.ATG" #line 636 "cs.ATG"
out expr); out expr);
@ -712,7 +749,7 @@ out Expression expr) {
UnaryExpr( UnaryExpr(
#line 1880 "cs.ATG" #line 1880 "cs.ATG"
out expr); out expr);
if (StartOf(5)) { if (StartOf(6)) {
ConditionalOrExpr( ConditionalOrExpr(
#line 1883 "cs.ATG" #line 1883 "cs.ATG"
ref expr); ref expr);
@ -729,7 +766,7 @@ out expr2);
#line 1883 "cs.ATG" #line 1883 "cs.ATG"
expr = new ConditionalExpression(expr, expr1, expr2); expr = new ConditionalExpression(expr, expr1, expr2);
} }
} else if (StartOf(6)) { } else if (StartOf(7)) {
#line 1885 "cs.ATG" #line 1885 "cs.ATG"
AssignmentOperatorType op; Expression val; AssignmentOperatorType op; Expression val;
@ -742,7 +779,7 @@ out val);
#line 1885 "cs.ATG" #line 1885 "cs.ATG"
expr = new AssignmentExpression(expr, op, val); expr = new AssignmentExpression(expr, op, val);
} else SynErr(127); } else SynErr(128);
} }
void AttributeSection( void AttributeSection(
@ -889,7 +926,7 @@ Modifiers m) {
if (t.val == "partial") { m.Add(Modifier.Partial, t.Location); } if (t.val == "partial") { m.Add(Modifier.Partial, t.Location); }
break; break;
} }
default: SynErr(128); break; default: SynErr(129); break;
} }
} }
@ -952,7 +989,7 @@ templates);
newType.EndLocation = t.Location; newType.EndLocation = t.Location;
compilationUnit.BlockEnd(); compilationUnit.BlockEnd();
} else if (StartOf(7)) { } else if (StartOf(8)) {
#line 734 "cs.ATG" #line 734 "cs.ATG"
m.Check(Modifier.StructsInterfacesEnumsDelegates); m.Check(Modifier.StructsInterfacesEnumsDelegates);
@ -1091,14 +1128,14 @@ NotVoidPointer()) {
#line 798 "cs.ATG" #line 798 "cs.ATG"
delegateDeclr.ReturnType = new TypeReference("void", 0, null); delegateDeclr.ReturnType = new TypeReference("void", 0, null);
} else if (StartOf(8)) { } else if (StartOf(9)) {
Type( Type(
#line 799 "cs.ATG" #line 799 "cs.ATG"
out type); out type);
#line 799 "cs.ATG" #line 799 "cs.ATG"
delegateDeclr.ReturnType = type; delegateDeclr.ReturnType = type;
} else SynErr(129); } else SynErr(130);
Expect(1); Expect(1);
#line 801 "cs.ATG" #line 801 "cs.ATG"
@ -1109,7 +1146,7 @@ out type);
templates); templates);
} }
Expect(19); Expect(19);
if (StartOf(9)) { if (StartOf(10)) {
FormalParameterList( FormalParameterList(
#line 806 "cs.ATG" #line 806 "cs.ATG"
p); p);
@ -1132,7 +1169,7 @@ templates);
compilationUnit.AddChild(delegateDeclr); compilationUnit.AddChild(delegateDeclr);
} }
} else SynErr(130); } else SynErr(131);
} }
void TypeParameterList( void TypeParameterList(
@ -1253,7 +1290,7 @@ out type);
#line 838 "cs.ATG" #line 838 "cs.ATG"
AttributeSection section; AttributeSection section;
Expect(15); Expect(15);
while (StartOf(10)) { while (StartOf(11)) {
#line 841 "cs.ATG" #line 841 "cs.ATG"
List<AttributeSection> attributes = new List<AttributeSection>(); List<AttributeSection> attributes = new List<AttributeSection>();
@ -1267,7 +1304,7 @@ out section);
#line 844 "cs.ATG" #line 844 "cs.ATG"
attributes.Add(section); attributes.Add(section);
} }
while (StartOf(11)) { while (StartOf(12)) {
MemberModifier( MemberModifier(
#line 845 "cs.ATG" #line 845 "cs.ATG"
m); m);
@ -1310,7 +1347,7 @@ out typeRef);
#line 862 "cs.ATG" #line 862 "cs.ATG"
AttributeSection section; AttributeSection section;
Expect(15); Expect(15);
while (StartOf(12)) { while (StartOf(13)) {
#line 865 "cs.ATG" #line 865 "cs.ATG"
List<AttributeSection> attributes = new List<AttributeSection>(); List<AttributeSection> attributes = new List<AttributeSection>();
@ -1324,7 +1361,7 @@ out section);
#line 868 "cs.ATG" #line 868 "cs.ATG"
attributes.Add(section); attributes.Add(section);
} }
while (StartOf(11)) { while (StartOf(12)) {
MemberModifier( MemberModifier(
#line 869 "cs.ATG" #line 869 "cs.ATG"
m); m);
@ -1364,7 +1401,7 @@ out typeRef);
void InterfaceBody() { void InterfaceBody() {
Expect(15); Expect(15);
while (StartOf(13)) { while (StartOf(14)) {
InterfaceMemberDecl(); InterfaceMemberDecl();
} }
Expect(16); Expect(16);
@ -1440,7 +1477,7 @@ out string name) {
name = "char"; name = "char";
break; break;
} }
default: SynErr(131); break; default: SynErr(132); break;
} }
} }
@ -1487,7 +1524,7 @@ out TypeReference type) {
ClassType( ClassType(
#line 903 "cs.ATG" #line 903 "cs.ATG"
out type); out type);
} else if (StartOf(14)) { } else if (StartOf(4)) {
SimpleType( SimpleType(
#line 904 "cs.ATG" #line 904 "cs.ATG"
out name); out name);
@ -1500,7 +1537,7 @@ out name);
#line 905 "cs.ATG" #line 905 "cs.ATG"
pointer = 1; type = new TypeReference("void"); pointer = 1; type = new TypeReference("void");
} else SynErr(132); } else SynErr(133);
#line 906 "cs.ATG" #line 906 "cs.ATG"
List<int> r = new List<int>(); List<int> r = new List<int>();
@ -1527,7 +1564,7 @@ IsPointerOrDims()) {
#line 910 "cs.ATG" #line 910 "cs.ATG"
r.Add(i); r.Add(i);
} else SynErr(133); } else SynErr(134);
} }
#line 913 "cs.ATG" #line 913 "cs.ATG"
@ -1592,7 +1629,7 @@ out p);
#line 968 "cs.ATG" #line 968 "cs.ATG"
paramsFound = true; p.Attributes = attributes; parameter.Add(p); paramsFound = true; p.Attributes = attributes; parameter.Add(p);
} else SynErr(134); } else SynErr(135);
} }
} else if (la.kind == 93) { } else if (la.kind == 93) {
ParameterArray( ParameterArray(
@ -1601,7 +1638,7 @@ out p);
#line 971 "cs.ATG" #line 971 "cs.ATG"
p.Attributes = attributes; parameter.Add(p); p.Attributes = attributes; parameter.Add(p);
} else SynErr(135); } else SynErr(136);
} }
void ClassType( void ClassType(
@ -1627,7 +1664,7 @@ out r);
#line 1014 "cs.ATG" #line 1014 "cs.ATG"
typeRef = new TypeReference("string"); typeRef = new TypeReference("string");
} else SynErr(136); } else SynErr(137);
} }
void TypeName( void TypeName(
@ -1771,7 +1808,7 @@ Modifiers m) {
m.Add(Modifier.Volatile, t.Location); m.Add(Modifier.Volatile, t.Location);
break; break;
} }
default: SynErr(137); break; default: SynErr(138); break;
} }
} }
@ -1808,13 +1845,13 @@ m, attributes);
out stmt); out stmt);
} else if (la.kind == 11) { } else if (la.kind == 11) {
lexer.NextToken(); lexer.NextToken();
} else SynErr(138); } else SynErr(139);
#line 1296 "cs.ATG" #line 1296 "cs.ATG"
d.Body = (BlockStatement)stmt; d.Body = (BlockStatement)stmt;
compilationUnit.AddChild(d); compilationUnit.AddChild(d);
} else SynErr(139); } else SynErr(140);
} }
void StructMemberDecl( void StructMemberDecl(
@ -1895,7 +1932,7 @@ out qualident);
templates); templates);
} }
Expect(19); Expect(19);
if (StartOf(9)) { if (StartOf(10)) {
FormalParameterList( FormalParameterList(
#line 1081 "cs.ATG" #line 1081 "cs.ATG"
p); p);
@ -1927,7 +1964,7 @@ templates);
out stmt); out stmt);
} else if (la.kind == 11) { } else if (la.kind == 11) {
lexer.NextToken(); lexer.NextToken();
} else SynErr(140); } else SynErr(141);
#line 1096 "cs.ATG" #line 1096 "cs.ATG"
compilationUnit.BlockEnd(); compilationUnit.BlockEnd();
@ -1987,7 +2024,7 @@ out addBlock, out removeBlock);
#line 1115 "cs.ATG" #line 1115 "cs.ATG"
eventDecl.BodyEnd = t.EndLocation; eventDecl.BodyEnd = t.EndLocation;
} else SynErr(141); } else SynErr(142);
#line 1116 "cs.ATG" #line 1116 "cs.ATG"
compilationUnit.BlockEnd(); compilationUnit.BlockEnd();
@ -2006,7 +2043,7 @@ IdentAndLPar()) {
#line 1124 "cs.ATG" #line 1124 "cs.ATG"
string name = t.val; Point startPos = t.Location; string name = t.val; Point startPos = t.Location;
Expect(19); Expect(19);
if (StartOf(9)) { if (StartOf(10)) {
#line 1124 "cs.ATG" #line 1124 "cs.ATG"
m.Check(Modifier.Constructors); m.Check(Modifier.Constructors);
@ -2038,7 +2075,7 @@ out init);
out stmt); out stmt);
} else if (la.kind == 11) { } else if (la.kind == 11) {
lexer.NextToken(); lexer.NextToken();
} else SynErr(142); } else SynErr(143);
#line 1136 "cs.ATG" #line 1136 "cs.ATG"
cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd);
@ -2089,7 +2126,7 @@ out stmt);
#line 1148 "cs.ATG" #line 1148 "cs.ATG"
stmt = null; stmt = null;
} else SynErr(143); } else SynErr(144);
#line 1151 "cs.ATG" #line 1151 "cs.ATG"
List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>(); List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
@ -2109,7 +2146,7 @@ out stmt);
TypeDecl( TypeDecl(
#line 1166 "cs.ATG" #line 1166 "cs.ATG"
m, attributes); m, attributes);
} else if (StartOf(8)) { } else if (StartOf(9)) {
Type( Type(
#line 1167 "cs.ATG" #line 1167 "cs.ATG"
out type); out type);
@ -2148,7 +2185,7 @@ out secondType);
#line 1175 "cs.ATG" #line 1175 "cs.ATG"
secondName = t.val; secondName = t.val;
} else if (la.kind == 20) { } else if (la.kind == 20) {
} else SynErr(144); } else SynErr(145);
#line 1183 "cs.ATG" #line 1183 "cs.ATG"
Point endPos = t.Location; Point endPos = t.Location;
@ -2159,7 +2196,7 @@ out secondType);
out stmt); out stmt);
} else if (la.kind == 11) { } else if (la.kind == 11) {
lexer.NextToken(); lexer.NextToken();
} else SynErr(145); } else SynErr(146);
#line 1186 "cs.ATG" #line 1186 "cs.ATG"
List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>(); List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
@ -2251,7 +2288,7 @@ out qualident);
templates); templates);
} }
Expect(19); Expect(19);
if (StartOf(9)) { if (StartOf(10)) {
FormalParameterList( FormalParameterList(
#line 1233 "cs.ATG" #line 1233 "cs.ATG"
p); p);
@ -2282,7 +2319,7 @@ templates);
out stmt); out stmt);
} else if (la.kind == 11) { } else if (la.kind == 11) {
lexer.NextToken(); lexer.NextToken();
} else SynErr(146); } else SynErr(147);
#line 1245 "cs.ATG" #line 1245 "cs.ATG"
methodDeclaration.Body = (BlockStatement)stmt; methodDeclaration.Body = (BlockStatement)stmt;
@ -2345,9 +2382,9 @@ out getRegion, out setRegion);
indexer.SetRegion = setRegion; indexer.SetRegion = setRegion;
compilationUnit.AddChild(indexer); compilationUnit.AddChild(indexer);
} else SynErr(147); } else SynErr(148);
} else SynErr(148); } else SynErr(149);
} else SynErr(149); } else SynErr(150);
} }
void InterfaceMemberDecl() { void InterfaceMemberDecl() {
@ -2396,7 +2433,7 @@ NotVoidPointer()) {
templates); templates);
} }
Expect(19); Expect(19);
if (StartOf(9)) { if (StartOf(10)) {
FormalParameterList( FormalParameterList(
#line 1322 "cs.ATG" #line 1322 "cs.ATG"
parameters); parameters);
@ -2419,7 +2456,7 @@ templates);
compilationUnit.AddChild(md); compilationUnit.AddChild(md);
} else if (StartOf(18)) { } else if (StartOf(18)) {
if (StartOf(8)) { if (StartOf(9)) {
Type( Type(
#line 1332 "cs.ATG" #line 1332 "cs.ATG"
out type); out type);
@ -2438,7 +2475,7 @@ out type);
templates); templates);
} }
Expect(19); Expect(19);
if (StartOf(9)) { if (StartOf(10)) {
FormalParameterList( FormalParameterList(
#line 1339 "cs.ATG" #line 1339 "cs.ATG"
parameters); parameters);
@ -2475,7 +2512,7 @@ out getBlock, out setBlock);
#line 1350 "cs.ATG" #line 1350 "cs.ATG"
pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation;
} else SynErr(150); } else SynErr(151);
} else if (la.kind == 109) { } else if (la.kind == 109) {
lexer.NextToken(); lexer.NextToken();
Expect(17); Expect(17);
@ -2500,7 +2537,7 @@ out getBlock, out setBlock);
#line 1354 "cs.ATG" #line 1354 "cs.ATG"
id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation; id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;
} else SynErr(151); } else SynErr(152);
} else { } else {
lexer.NextToken(); lexer.NextToken();
@ -2520,7 +2557,7 @@ out type);
#line 1360 "cs.ATG" #line 1360 "cs.ATG"
ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation;
} }
} else SynErr(152); } else SynErr(153);
} }
void EnumMemberDecl( void EnumMemberDecl(
@ -2590,47 +2627,7 @@ out name);
#line 945 "cs.ATG" #line 945 "cs.ATG"
name = "bool"; name = "bool";
} else SynErr(153);
}
void NonArrayType(
#line 920 "cs.ATG"
out TypeReference type) {
#line 922 "cs.ATG"
string name;
int pointer = 0;
type = null;
if (la.kind == 1 || la.kind == 89 || la.kind == 106) {
ClassType(
#line 927 "cs.ATG"
out type);
} else if (StartOf(14)) {
SimpleType(
#line 928 "cs.ATG"
out name);
#line 928 "cs.ATG"
type = new TypeReference(name);
} else if (la.kind == 121) {
lexer.NextToken();
Expect(6);
#line 929 "cs.ATG"
pointer = 1; type = new TypeReference("void");
} else SynErr(154); } else SynErr(154);
while (
#line 932 "cs.ATG"
IsPointer()) {
Expect(6);
#line 933 "cs.ATG"
++pointer;
}
#line 935 "cs.ATG"
if (type != null) { type.PointerNestingLevel = pointer; }
} }
void FixedParameter( void FixedParameter(
@ -3234,7 +3231,7 @@ out Expression initializerExpression) {
#line 1528 "cs.ATG" #line 1528 "cs.ATG"
TypeReference type = null; Expression expr = null; initializerExpression = null; TypeReference type = null; Expression expr = null; initializerExpression = null;
if (StartOf(4)) { if (StartOf(5)) {
Expr( Expr(
#line 1530 "cs.ATG" #line 1530 "cs.ATG"
out initializerExpression); out initializerExpression);
@ -3668,19 +3665,19 @@ out expr);
#line 1698 "cs.ATG" #line 1698 "cs.ATG"
ArrayList initializer = null; ArrayList iterator = null; ArrayList initializer = null; ArrayList iterator = null;
Expect(19); Expect(19);
if (StartOf(4)) { if (StartOf(5)) {
ForInitializer( ForInitializer(
#line 1699 "cs.ATG" #line 1699 "cs.ATG"
out initializer); out initializer);
} }
Expect(11); Expect(11);
if (StartOf(4)) { if (StartOf(5)) {
Expr( Expr(
#line 1700 "cs.ATG" #line 1700 "cs.ATG"
out expr); out expr);
} }
Expect(11); Expect(11);
if (StartOf(4)) { if (StartOf(5)) {
ForIterator( ForIterator(
#line 1701 "cs.ATG" #line 1701 "cs.ATG"
out iterator); out iterator);
@ -3752,7 +3749,7 @@ out expr);
Expect(11); Expect(11);
} else if (la.kind == 99) { } else if (la.kind == 99) {
lexer.NextToken(); lexer.NextToken();
if (StartOf(4)) { if (StartOf(5)) {
Expr( Expr(
#line 1714 "cs.ATG" #line 1714 "cs.ATG"
out expr); out expr);
@ -3763,7 +3760,7 @@ out expr);
statement = new ReturnStatement(expr); statement = new ReturnStatement(expr);
} else if (la.kind == 110) { } else if (la.kind == 110) {
lexer.NextToken(); lexer.NextToken();
if (StartOf(4)) { if (StartOf(5)) {
Expr( Expr(
#line 1715 "cs.ATG" #line 1715 "cs.ATG"
out expr); out expr);
@ -3772,7 +3769,7 @@ out expr);
#line 1715 "cs.ATG" #line 1715 "cs.ATG"
statement = new ThrowStatement(expr); statement = new ThrowStatement(expr);
} else if (StartOf(4)) { } else if (StartOf(5)) {
StatementExpr( StatementExpr(
#line 1717 "cs.ATG" #line 1717 "cs.ATG"
out statement); out statement);
@ -3917,7 +3914,7 @@ out stmt);
#line 1750 "cs.ATG" #line 1750 "cs.ATG"
initializer.Add(stmt); initializer.Add(stmt);
} else if (StartOf(4)) { } else if (StartOf(5)) {
StatementExpr( StatementExpr(
#line 1751 "cs.ATG" #line 1751 "cs.ATG"
out stmt); out stmt);
@ -4008,7 +4005,7 @@ out Statement stmt) {
UnaryExpr( UnaryExpr(
#line 1869 "cs.ATG" #line 1869 "cs.ATG"
out expr); out expr);
if (StartOf(6)) { if (StartOf(7)) {
#line 1872 "cs.ATG" #line 1872 "cs.ATG"
AssignmentOperatorType op; Expression val; AssignmentOperatorType op; Expression val;
@ -4079,7 +4076,7 @@ IsLocalVarDecl()) {
LocalVariableDecl( LocalVariableDecl(
#line 1849 "cs.ATG" #line 1849 "cs.ATG"
out stmt); out stmt);
} else if (StartOf(4)) { } else if (StartOf(5)) {
Expr( Expr(
#line 1850 "cs.ATG" #line 1850 "cs.ATG"
out expr); out expr);
@ -4558,7 +4555,7 @@ out expr);
int dims = 0; int dims = 0;
ArrayList rank = new ArrayList(); ArrayList rank = new ArrayList();
ArrayList parameterExpression = new ArrayList(); ArrayList parameterExpression = new ArrayList();
if (StartOf(4)) { if (StartOf(5)) {
Expr( Expr(
#line 2002 "cs.ATG" #line 2002 "cs.ATG"
out expr); out expr);
@ -4661,7 +4658,7 @@ NotVoidPointer()) {
#line 2029 "cs.ATG" #line 2029 "cs.ATG"
type = new TypeReference("void"); type = new TypeReference("void");
} else if (StartOf(8)) { } else if (StartOf(9)) {
Type( Type(
#line 2030 "cs.ATG" #line 2030 "cs.ATG"
out type); out type);
@ -4848,7 +4845,7 @@ out Expression outExpr) {
outExpr = expr; outExpr = expr;
Expect(19); Expect(19);
if (StartOf(9)) { if (StartOf(10)) {
FormalParameterList( FormalParameterList(
#line 2089 "cs.ATG" #line 2089 "cs.ATG"
p); p);
@ -5232,7 +5229,7 @@ out TypeReference type) {
#line 2306 "cs.ATG" #line 2306 "cs.ATG"
type = new TypeReference("struct"); type = new TypeReference("struct");
} else if (StartOf(8)) { } else if (StartOf(9)) {
Type( Type(
#line 2307 "cs.ATG" #line 2307 "cs.ATG"
out t); out t);
@ -5417,21 +5414,21 @@ out t);
case 123: s = "\"while\" expected"; break; case 123: s = "\"while\" expected"; break;
case 124: s = "??? expected"; break; case 124: s = "??? expected"; break;
case 125: s = "invalid NamespaceMemberDecl"; break; case 125: s = "invalid NamespaceMemberDecl"; break;
case 126: s = "invalid AttributeArguments"; break; case 126: s = "invalid NonArrayType"; break;
case 127: s = "invalid Expr"; break; case 127: s = "invalid AttributeArguments"; break;
case 128: s = "invalid TypeModifier"; break; case 128: s = "invalid Expr"; break;
case 129: s = "invalid TypeDecl"; break; case 129: s = "invalid TypeModifier"; break;
case 130: s = "invalid TypeDecl"; break; case 130: s = "invalid TypeDecl"; break;
case 131: s = "invalid IntegralType"; break; case 131: s = "invalid TypeDecl"; break;
case 132: s = "invalid Type"; break; case 132: s = "invalid IntegralType"; break;
case 133: s = "invalid Type"; break; case 133: s = "invalid Type"; break;
case 134: s = "invalid FormalParameterList"; break; case 134: s = "invalid Type"; break;
case 135: s = "invalid FormalParameterList"; break; case 135: s = "invalid FormalParameterList"; break;
case 136: s = "invalid ClassType"; break; case 136: s = "invalid FormalParameterList"; break;
case 137: s = "invalid MemberModifier"; break; case 137: s = "invalid ClassType"; break;
case 138: s = "invalid ClassMemberDecl"; break; case 138: s = "invalid MemberModifier"; break;
case 139: s = "invalid ClassMemberDecl"; break; case 139: s = "invalid ClassMemberDecl"; break;
case 140: s = "invalid StructMemberDecl"; break; case 140: s = "invalid ClassMemberDecl"; break;
case 141: s = "invalid StructMemberDecl"; break; case 141: s = "invalid StructMemberDecl"; break;
case 142: s = "invalid StructMemberDecl"; break; case 142: s = "invalid StructMemberDecl"; break;
case 143: s = "invalid StructMemberDecl"; break; case 143: s = "invalid StructMemberDecl"; break;
@ -5441,11 +5438,11 @@ out t);
case 147: s = "invalid StructMemberDecl"; break; case 147: s = "invalid StructMemberDecl"; break;
case 148: s = "invalid StructMemberDecl"; break; case 148: s = "invalid StructMemberDecl"; break;
case 149: s = "invalid StructMemberDecl"; break; case 149: s = "invalid StructMemberDecl"; break;
case 150: s = "invalid InterfaceMemberDecl"; break; case 150: s = "invalid StructMemberDecl"; break;
case 151: s = "invalid InterfaceMemberDecl"; break; case 151: s = "invalid InterfaceMemberDecl"; break;
case 152: s = "invalid InterfaceMemberDecl"; break; case 152: s = "invalid InterfaceMemberDecl"; break;
case 153: s = "invalid SimpleType"; break; case 153: s = "invalid InterfaceMemberDecl"; break;
case 154: s = "invalid NonArrayType"; break; case 154: s = "invalid SimpleType"; break;
case 155: s = "invalid EventAccessorDecls"; break; case 155: s = "invalid EventAccessorDecls"; break;
case 156: s = "invalid ConstructorInitializer"; break; case 156: s = "invalid ConstructorInitializer"; break;
case 157: s = "invalid OverloadableOperator"; break; case 157: s = "invalid OverloadableOperator"; break;
@ -5492,6 +5489,7 @@ out t);
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,T,T, x,x,x,x, x,x,T,T, T,x,x,x, x,T,x,x, x,T,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,T,T, x,x,x,x, x,x,T,T, T,x,x,x, x,T,x,x, x,T,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x},
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,x,T, x,x,x,x, x,x,T,T, T,x,x,x, x,T,x,x, x,T,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, x,x,x,T, x,x,x,x, x,x,T,T, T,x,x,x, x,T,x,x, x,T,x,T, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x},
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,x, x,x,T,T, T,x,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,x, x,x,T,T, T,x,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x},
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x},
{x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, T,x,x,T, T,x,x,x, T,x,T,x, T,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, T,x,T,T, x,x,T,x, x,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x}, {x,T,T,x, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,T, x,x,T,T, x,x,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,x, T,x,x,T, T,x,x,x, T,x,T,x, T,x,x,x, x,x,T,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, T,T,x,x, x,x,x,x, x,x,x,x, T,x,T,T, x,x,T,x, x,T,x,T, x,T,T,T, T,x,T,x, x,x,x,x, x,x},
{x,x,x,x, T,T,T,T, T,T,x,T, T,T,x,x, T,x,T,x, T,T,T,x, T,T,x,T, T,T,x,x, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x}, {x,x,x,x, T,T,T,T, T,T,x,T, T,T,x,x, T,x,T,x, T,T,T,x, T,T,x,T, T,T,x,x, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
{x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x}, {x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
@ -5502,7 +5500,6 @@ out t);
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,x, T,x,T,T, T,T,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,T,x, x,x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,T, x,x,x,x, T,x,T,T, T,T,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,T,x, x,x},
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,T,x, T,x,x,T, x,T,T,x, T,x,T,x, T,x,T,T, T,T,x,x, x,T,x,x, x,x,T,x, T,T,T,x, x,T,x,T, x,T,x,x, T,x,T,T, T,T,x,x, T,T,T,x, x,T,T,T, x,x,x,x, x,x,T,T, x,T,T,x, T,T,T,x, x,x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,T,x, T,x,x,T, x,T,T,x, T,x,T,x, T,x,T,T, T,T,x,x, x,T,x,x, x,x,T,x, T,T,T,x, x,T,x,T, x,T,x,x, T,x,T,T, T,T,x,x, T,T,T,x, x,T,T,T, x,x,x,x, x,x,T,T, x,T,T,x, T,T,T,x, x,x},
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,x,x,x, T,x,x,x, T,x,x,T, x,x,x,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, x,T,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,x,T,x, x,x,x,x, x,x,T,T, x,x,T,x, x,T,x,x, x,x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,x,x,x, T,x,x,x, T,x,x,T, x,x,x,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,T, x,T,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,x,T,x, x,x,x,x, x,x,T,T, x,x,T,x, x,T,x,x, x,x},
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,x,x,x, x,x,x,x, x,x,T,T, x,x,T,x, x,x,x,x, x,x},
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,T,x,T, x,x,x,x, x,x,T,x, T,x,T,x, x,x,T,x, x,x,x,x, x,x,T,T, x,x,T,x, x,T,x,x, x,x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, T,x,x,x, x,T,x,x, x,T,x,T, x,x,x,x, x,x,T,x, T,x,T,x, x,x,T,x, x,x,x,x, x,x,T,T, x,x,T,x, x,T,x,x, x,x},
{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,T,T,x, T,x,T,x, T,x,T,T, T,x,x,x, x,T,x,x, x,x,T,x, T,T,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,x,T,T, x,x,x,x, x,x,T,T, x,x,T,x, x,T,x,x, x,x}, {x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, T,x,x,T, x,T,T,x, T,x,T,x, T,x,T,T, T,x,x,x, x,T,x,x, x,x,T,x, T,T,x,x, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, T,x,T,x, x,x,T,T, x,x,x,x, x,x,T,T, x,x,T,x, x,T,x,x, x,x},
{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x}, {x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,T,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},

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

@ -559,17 +559,17 @@ CS
UsingDirective UsingDirective
(. (.
string qualident = null, aliasident = null; string qualident = null; TypeReference aliasedType = null;
.) .)
= =
"using" (. Point startPos = t.Location; .) "using" (. Point startPos = t.Location; .)
[ IF (IsAssignment()) ident (. aliasident = t.val; .) "=" ] /*--- using alias directive */ Qualident<out qualident>
Qualident<out qualident> [ "=" NonArrayType<out aliasedType> ]
";" (. ";" (.
if (qualident != null && qualident.Length > 0) { if (qualident != null && qualident.Length > 0) {
INode node; INode node;
if (aliasident != null) { if (aliasedType != null) {
node = new UsingDeclaration(aliasident, qualident); node = new UsingDeclaration(qualident, aliasedType);
} else { } else {
node = new UsingDeclaration(qualident); node = new UsingDeclaration(qualident);
} }

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

@ -315,7 +315,7 @@ ref val);
void ImportsStmt() { void ImportsStmt() {
#line 474 "VBNET.ATG" #line 474 "VBNET.ATG"
ArrayList usings = new ArrayList(); List<Using> usings = new List<Using>();
Expect(107); Expect(107);
@ -488,26 +488,23 @@ out Using u) {
#line 496 "VBNET.ATG" #line 496 "VBNET.ATG"
string qualident = null; string qualident = null;
string aliasident = null; TypeReference aliasedType = null;
u = null; u = null;
if (
#line 500 "VBNET.ATG"
IsAssignment()) {
Identifier();
#line 500 "VBNET.ATG"
aliasident = t.val;
Expect(11);
}
Qualident( Qualident(
#line 501 "VBNET.ATG" #line 500 "VBNET.ATG"
out qualident); out qualident);
if (la.kind == 11) {
lexer.NextToken();
TypeName(
#line 501 "VBNET.ATG"
out aliasedType);
}
#line 503 "VBNET.ATG" #line 503 "VBNET.ATG"
if (qualident != null && qualident.Length > 0) { if (qualident != null && qualident.Length > 0) {
if (aliasident != null) { if (aliasedType != null) {
u = new Using(aliasident, qualident); u = new Using(qualident, aliasedType);
} else { } else {
u = new Using(qualident); u = new Using(qualident);
} }
@ -515,18 +512,6 @@ out qualident);
} }
void Identifier() {
if (la.kind == 2) {
lexer.NextToken();
} else if (la.kind == 169) {
lexer.NextToken();
} else if (la.kind == 50) {
lexer.NextToken();
} else if (la.kind == 69) {
lexer.NextToken();
} else SynErr(209);
}
void Qualident( void Qualident(
#line 2732 "VBNET.ATG" #line 2732 "VBNET.ATG"
out string qualident) { out string qualident) {
@ -555,6 +540,26 @@ out name);
qualident = qualidentBuilder.ToString(); qualident = qualidentBuilder.ToString();
} }
void TypeName(
#line 1928 "VBNET.ATG"
out TypeReference typeref) {
#line 1929 "VBNET.ATG"
ArrayList rank = null; typeref = null;
NonArrayTypeName(
#line 1931 "VBNET.ATG"
out typeref);
ArrayTypeModifiers(
#line 1932 "VBNET.ATG"
out rank);
#line 1934 "VBNET.ATG"
if (rank != null && typeref != null) {
typeref.RankSpecifier = (int[])rank.ToArray(typeof(int));
}
}
void NamespaceBody() { void NamespaceBody() {
while (StartOf(1)) { while (StartOf(1)) {
NamespaceMemberDecl(); NamespaceMemberDecl();
@ -694,7 +699,7 @@ Modifiers m) {
m.Add(Modifier.Sealed, t.Location); m.Add(Modifier.Sealed, t.Location);
break; break;
} }
default: SynErr(210); break; default: SynErr(209); break;
} }
} }
@ -957,7 +962,7 @@ out type);
#line 700 "VBNET.ATG" #line 700 "VBNET.ATG"
delegateDeclr.ReturnType = type; delegateDeclr.ReturnType = type;
} }
} else SynErr(211); } else SynErr(210);
#line 702 "VBNET.ATG" #line 702 "VBNET.ATG"
delegateDeclr.EndLocation = t.EndLocation; delegateDeclr.EndLocation = t.EndLocation;
@ -968,7 +973,7 @@ out type);
break; break;
} }
default: SynErr(212); break; default: SynErr(211); break;
} }
} }
@ -1019,6 +1024,18 @@ template);
} }
} }
void Identifier() {
if (la.kind == 2) {
lexer.NextToken();
} else if (la.kind == 169) {
lexer.NextToken();
} else if (la.kind == 50) {
lexer.NextToken();
} else if (la.kind == 69) {
lexer.NextToken();
} else SynErr(212);
}
void TypeParameterConstraints( void TypeParameterConstraints(
#line 572 "VBNET.ATG" #line 572 "VBNET.ATG"
TemplateDefinition template) { TemplateDefinition template) {
@ -1055,26 +1072,6 @@ out constraint);
} else SynErr(213); } else SynErr(213);
} }
void TypeName(
#line 1928 "VBNET.ATG"
out TypeReference typeref) {
#line 1929 "VBNET.ATG"
ArrayList rank = null; typeref = null;
NonArrayTypeName(
#line 1931 "VBNET.ATG"
out typeref);
ArrayTypeModifiers(
#line 1932 "VBNET.ATG"
out rank);
#line 1934 "VBNET.ATG"
if (rank != null && typeref != null) {
typeref.RankSpecifier = (int[])rank.ToArray(typeof(int));
}
}
void ClassBaseType( void ClassBaseType(
#line 882 "VBNET.ATG" #line 882 "VBNET.ATG"
out TypeReference typeRef) { out TypeReference typeRef) {
@ -7150,10 +7147,10 @@ out blockStmt);
case 206: s = "invalid NamespaceMemberDecl"; break; case 206: s = "invalid NamespaceMemberDecl"; break;
case 207: s = "invalid OptionValue"; break; case 207: s = "invalid OptionValue"; break;
case 208: s = "invalid EndOfStmt"; break; case 208: s = "invalid EndOfStmt"; break;
case 209: s = "invalid Identifier"; break; case 209: s = "invalid TypeModifier"; break;
case 210: s = "invalid TypeModifier"; break; case 210: s = "invalid NonModuleDeclaration"; break;
case 211: s = "invalid NonModuleDeclaration"; break; case 211: s = "invalid NonModuleDeclaration"; break;
case 212: s = "invalid NonModuleDeclaration"; break; case 212: s = "invalid Identifier"; break;
case 213: s = "invalid TypeParameterConstraints"; break; case 213: s = "invalid TypeParameterConstraints"; break;
case 214: s = "invalid PrimitiveTypeName"; break; case 214: s = "invalid PrimitiveTypeName"; break;
case 215: s = "invalid MemberModifier"; break; case 215: s = "invalid MemberModifier"; break;

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

@ -471,7 +471,7 @@ EndOfStmt =
. .
ImportsStmt ImportsStmt
(.ArrayList usings = new ArrayList(); (.List<Using> usings = new List<Using>();
.) = .) =
"Imports" "Imports"
(. (.
@ -494,15 +494,15 @@ ImportsStmt
ImportClause<out Using u> ImportClause<out Using u>
(. (.
string qualident = null; string qualident = null;
string aliasident = null; TypeReference aliasedType = null;
u = null; u = null;
.) = .) =
[ IF (IsAssignment()) Identifier (. aliasident = t.val; .) "=" ]
Qualident<out qualident> Qualident<out qualident>
[ "=" TypeName<out aliasedType> ]
(. (.
if (qualident != null && qualident.Length > 0) { if (qualident != null && qualident.Length > 0) {
if (aliasident != null) { if (aliasedType != null) {
u = new Using(aliasident, qualident); u = new Using(qualident, aliasedType);
} else { } else {
u = new Using(qualident); u = new Using(qualident);
} }

2
src/Libraries/NRefactory/Test/NRefactoryTests.csproj

@ -17,7 +17,7 @@
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG</DefineConstants> <DefineConstants>DEBUG</DefineConstants>
<OutputPath>C:\corsavy\trunk\SharpDevelop\bin</OutputPath> <OutputPath>..\..\..\..\bin\</OutputPath>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors> <TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

44
src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs

@ -25,34 +25,42 @@ namespace ICSharpCode.NRefactory.Tests.AST
Assert.IsTrue(u.Children[0] is UsingDeclaration); Assert.IsTrue(u.Children[0] is UsingDeclaration);
UsingDeclaration ud = (UsingDeclaration)u.Children[0]; UsingDeclaration ud = (UsingDeclaration)u.Children[0];
Assert.AreEqual(1, ud.Usings.Count); Assert.AreEqual(1, ud.Usings.Count);
Assert.IsTrue(!((Using)ud.Usings[0]).IsAlias); Assert.IsTrue(!ud.Usings[0].IsAlias);
Assert.AreEqual("System", ((Using)ud.Usings[0]).Name); Assert.AreEqual("System", ud.Usings[0].Name);
Assert.IsTrue(u.Children[1] is UsingDeclaration); Assert.IsTrue(u.Children[1] is UsingDeclaration);
ud = (UsingDeclaration)u.Children[1]; ud = (UsingDeclaration)u.Children[1];
Assert.AreEqual(1, ud.Usings.Count); Assert.AreEqual(1, ud.Usings.Count);
Assert.IsTrue(!((Using)ud.Usings[0]).IsAlias); Assert.IsTrue(!ud.Usings[0].IsAlias);
Assert.AreEqual("My.Name.Space", ((Using)ud.Usings[0]).Name); Assert.AreEqual("My.Name.Space", ud.Usings[0].Name);
} }
void CheckTwoSimpleAliases(CompilationUnit u) void CheckAliases(CompilationUnit u)
{ {
Assert.AreEqual(2, u.Children.Count); Assert.AreEqual(3, u.Children.Count);
Assert.IsTrue(u.Children[0] is UsingDeclaration); Assert.IsTrue(u.Children[0] is UsingDeclaration);
UsingDeclaration ud = (UsingDeclaration)u.Children[0]; UsingDeclaration ud = (UsingDeclaration)u.Children[0];
Assert.AreEqual(1, ud.Usings.Count); Assert.AreEqual(1, ud.Usings.Count);
Assert.IsTrue(((Using)ud.Usings[0]).IsAlias); Assert.IsTrue(((Using)ud.Usings[0]).IsAlias);
Assert.AreEqual("TESTME", ((Using)ud.Usings[0]).Alias); Assert.AreEqual("TESTME", ud.Usings[0].Name);
Assert.AreEqual("System", ((Using)ud.Usings[0]).Name); Assert.AreEqual("System", ud.Usings[0].Alias.Type);
Assert.IsTrue(u.Children[1] is UsingDeclaration); Assert.IsTrue(u.Children[1] is UsingDeclaration);
ud = (UsingDeclaration)u.Children[1]; ud = (UsingDeclaration)u.Children[1];
Assert.AreEqual(1, ud.Usings.Count); Assert.AreEqual(1, ud.Usings.Count);
Assert.IsTrue(((Using)ud.Usings[0]).IsAlias); Assert.IsTrue(((Using)ud.Usings[0]).IsAlias);
Assert.AreEqual("myAlias", ((Using)ud.Usings[0]).Alias); Assert.AreEqual("myAlias", ud.Usings[0].Name);
Assert.AreEqual("My.Name.Space", ((Using)ud.Usings[0]).Name); Assert.AreEqual("My.Name.Space", ud.Usings[0].Alias.Type);
Assert.IsTrue(u.Children[2] is UsingDeclaration);
ud = (UsingDeclaration)u.Children[2];
Assert.AreEqual(1, ud.Usings.Count);
Assert.IsTrue(((Using)ud.Usings[0]).IsAlias);
Assert.AreEqual("StringCollection", ud.Usings[0].Name);
Assert.AreEqual("System.Collections.Generic.List", ud.Usings[0].Alias.Type);
Assert.AreEqual("System.String", ud.Usings[0].Alias.GenericTypes[0].SystemType);
} }
#region C# #region C#
@ -69,7 +77,7 @@ namespace ICSharpCode.NRefactory.Tests.AST
public void CSharpDeclarationTest() public void CSharpDeclarationTest()
{ {
string program = "using System;\n" + string program = "using System;\n" +
"using My.Name.Space;\n"; "using My.Name.Space;\n";
IParser parser = ParserFactory.CreateParser(SupportedLanguages.CSharp, new StringReader(program)); IParser parser = ParserFactory.CreateParser(SupportedLanguages.CSharp, new StringReader(program));
parser.Parse(); parser.Parse();
@ -81,12 +89,13 @@ namespace ICSharpCode.NRefactory.Tests.AST
public void CSharpUsingAliasDeclarationTest() public void CSharpUsingAliasDeclarationTest()
{ {
string program = "using TESTME=System;\n" + string program = "using TESTME=System;\n" +
"using myAlias=My.Name.Space;\n"; "using myAlias=My.Name.Space;\n" +
"using StringCollection = System.Collections.Generic.List<string>;\n";
IParser parser = ParserFactory.CreateParser(SupportedLanguages.CSharp, new StringReader(program)); IParser parser = ParserFactory.CreateParser(SupportedLanguages.CSharp, new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
CheckAliases(parser.CompilationUnit);
} }
#endregion #endregion
@ -103,7 +112,7 @@ namespace ICSharpCode.NRefactory.Tests.AST
public void VBNetDeclarationTest() public void VBNetDeclarationTest()
{ {
string program = "Imports System\n" + string program = "Imports System\n" +
"Imports My.Name.Space\n"; "Imports My.Name.Space\n";
IParser parser = ParserFactory.CreateParser(SupportedLanguages.VBNet, new StringReader(program)); IParser parser = ParserFactory.CreateParser(SupportedLanguages.VBNet, new StringReader(program));
parser.Parse(); parser.Parse();
@ -115,12 +124,13 @@ namespace ICSharpCode.NRefactory.Tests.AST
public void VBNetUsingAliasDeclarationTest() public void VBNetUsingAliasDeclarationTest()
{ {
string program = "Imports TESTME=System\n" + string program = "Imports TESTME=System\n" +
"Imports myAlias=My.Name.Space\n"; "Imports myAlias=My.Name.Space\n" +
"Imports StringCollection = System.Collections.Generic.List(Of string)\n";
IParser parser = ParserFactory.CreateParser(SupportedLanguages.VBNet, new StringReader(program)); IParser parser = ParserFactory.CreateParser(SupportedLanguages.VBNet, new StringReader(program));
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
CheckAliases(parser.CompilationUnit);
} }
[Test] [Test]
@ -131,7 +141,7 @@ namespace ICSharpCode.NRefactory.Tests.AST
parser.Parse(); parser.Parse();
Assert.AreEqual("", parser.Errors.ErrorOutput); Assert.AreEqual("", parser.Errors.ErrorOutput);
// TODO : Extend test ... // TODO : Extend test ...
} }
#endregion #endregion
} }

2
src/Main/Base/Project/Src/Dom/ClassFinder.cs

@ -65,7 +65,7 @@ namespace ICSharpCode.SharpDevelop.Dom
return projectContent.GetClass(fullName); return projectContent.GetClass(fullName);
} }
public IClass SearchClass(string name) public IReturnType SearchType(string name)
{ {
return projectContent.SearchType(name, callingClass, cu, caretLine, caretColumn); return projectContent.SearchType(name, callingClass, cu, caretLine, caretColumn);
} }

8
src/Main/Base/Project/Src/Dom/IClass.cs

@ -64,7 +64,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
/// <summary>Gets the class associated with the base type with the same index.</summary> /// <summary>Gets the class associated with the base type with the same index.</summary>
IClass GetBaseClass(int index); IReturnType GetBaseType(int index);
List<IClass> InnerClasses { List<IClass> InnerClasses {
get; get;
@ -102,6 +102,10 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
IReturnType BaseType {
get;
}
IClass GetInnermostClass(int caretLine, int caretColumn); IClass GetInnermostClass(int caretLine, int caretColumn);
List<IClass> GetAccessibleTypes(IClass callingClass); List<IClass> GetAccessibleTypes(IClass callingClass);
@ -114,7 +118,5 @@ namespace ICSharpCode.SharpDevelop.Dom
/// <summary>Return true if the specified class is a base class of this class; otherwise return false.</summary> /// <summary>Return true if the specified class is a base class of this class; otherwise return false.</summary>
/// <remarks>Returns false when possibleBaseClass is null.</remarks> /// <remarks>Returns false when possibleBaseClass is null.</remarks>
bool IsTypeInInheritanceTree(IClass possibleBaseClass); bool IsTypeInInheritanceTree(IClass possibleBaseClass);
List<IMember> GetAccessibleMembers(IClass callingClass, bool showStatic);
} }
} }

4
src/Main/Base/Project/Src/Dom/IUsing.cs

@ -20,11 +20,11 @@ namespace ICSharpCode.SharpDevelop.Dom
get; get;
} }
SortedList<string, string> Aliases { SortedList<string, IReturnType> Aliases {
get; get;
} }
IClass SearchType(string partitialTypeName); IReturnType SearchType(string partitialTypeName);
string SearchNamespace(string partitialNamespaceName); string SearchNamespace(string partitialNamespaceName);
} }
} }

35
src/Main/Base/Project/Src/Dom/Implementations/DefaultClass.cs

@ -246,7 +246,7 @@ namespace ICSharpCode.SharpDevelop.Dom
// used to prevent StackOverflowException because SearchType might search for inner classes in the base type // used to prevent StackOverflowException because SearchType might search for inner classes in the base type
bool blockBaseClassSearch = false; bool blockBaseClassSearch = false;
public IClass GetBaseClass(int index) public IReturnType GetBaseType(int index)
{ {
if (blockBaseClassSearch) if (blockBaseClassSearch)
return null; return null;
@ -260,6 +260,13 @@ namespace ICSharpCode.SharpDevelop.Dom
IClass cachedBaseClass; IClass cachedBaseClass;
public IReturnType BaseType {
get {
IClass baseClass = cachedBaseClass;
return (baseClass != null) ? baseClass.DefaultReturnType : null;
}
}
public IClass BaseClass { public IClass BaseClass {
get { get {
Debug.Assert(ProjectContent != null); Debug.Assert(ProjectContent != null);
@ -267,7 +274,8 @@ namespace ICSharpCode.SharpDevelop.Dom
if (BaseTypes.Count > 0) { if (BaseTypes.Count > 0) {
if (UseInheritanceCache && cachedBaseClass != null) if (UseInheritanceCache && cachedBaseClass != null)
return cachedBaseClass; return cachedBaseClass;
IClass baseClass = GetBaseClass(0); IReturnType baseType = GetBaseType(0);
IClass baseClass = (baseType != null) ? baseType.GetUnderlyingClass() : null;
if (baseClass != null && baseClass.ClassType != ClassType.Interface) { if (baseClass != null && baseClass.ClassType != ClassType.Interface) {
if (UseInheritanceCache) if (UseInheritanceCache)
cachedBaseClass = baseClass; cachedBaseClass = baseClass;
@ -374,6 +382,7 @@ namespace ICSharpCode.SharpDevelop.Dom
return types; return types;
} }
/*
public List<IMember> GetAccessibleMembers(IClass callingClass, bool showStatic) public List<IMember> GetAccessibleMembers(IClass callingClass, bool showStatic)
{ {
List<IMember> members = new List<IMember>(); List<IMember> members = new List<IMember>();
@ -408,20 +417,23 @@ namespace ICSharpCode.SharpDevelop.Dom
if (ClassType == ClassType.Interface && !showStatic) { if (ClassType == ClassType.Interface && !showStatic) {
foreach (string s in BaseTypes) { foreach (string s in BaseTypes) {
IClass baseClass = ProjectContent.SearchType(s, this, Region != null ? Region.BeginLine : -1, Region != null ? Region.BeginColumn : -1); IReturnType baseType = ProjectContent.SearchType(s, this, Region != null ? Region.BeginLine : -1, Region != null ? Region.BeginColumn : -1);
if (baseClass != null && baseClass.ClassType == ClassType.Interface) { List<IMember> baseTypeMembers = new List<IMember>();
members.AddRange(baseClass.GetAccessibleMembers(callingClass, showStatic).ToArray()); if (baseType != null && baseType.GetUnderlyingClass() != null && baseType.GetUnderlyingClass().ClassType == ClassType.Interface) {
//members.AddRange(baseClass.GetAccessibleMembers(callingClass, showStatic).ToArray());
} }
} }
} else { } else {
IClass baseClass = BaseClass; IClass baseClass = BaseClass;
if (baseClass != null) { if (baseClass != null) {
members.AddRange(baseClass.GetAccessibleMembers(callingClass, showStatic).ToArray()); members.AddRange(baseClass.GetAccessibleMembers(callingClass, showStatic));
} }
} }
return members; return members;
} }
*/
public class ClassInheritanceEnumerator : IEnumerator<IClass>, IEnumerable<IClass> public class ClassInheritanceEnumerator : IEnumerator<IClass>, IEnumerable<IClass>
{ {
@ -494,18 +506,19 @@ namespace ICSharpCode.SharpDevelop.Dom
BaseType baseTypeStruct = baseTypeQueue.Dequeue(); BaseType baseTypeStruct = baseTypeQueue.Dequeue();
IClass baseType; IClass baseClass;
if (baseTypeStruct.parent == null) { if (baseTypeStruct.parent == null) {
baseType = ProjectContentRegistry.Mscorlib.GetClass(baseTypeStruct.name); baseClass = ProjectContentRegistry.Mscorlib.GetClass(baseTypeStruct.name);
} else { } else {
baseType = baseTypeStruct.parent.ProjectContent.SearchType(baseTypeStruct.name, baseTypeStruct.parent, 1, 1); IReturnType baseType = baseTypeStruct.parent.ProjectContent.SearchType(baseTypeStruct.name, baseTypeStruct.parent, 1, 1);
baseClass = (baseType != null) ? baseType.GetUnderlyingClass() : null;
} }
if (baseType == null || finishedClasses.Contains(baseType)) { if (baseClass == null || finishedClasses.Contains(baseClass)) {
// prevent enumerating interfaces multiple times and endless loops when // prevent enumerating interfaces multiple times and endless loops when
// circular inheritance is found // circular inheritance is found
return MoveNext(); return MoveNext();
} else { } else {
currentClass = baseType; currentClass = baseClass;
finishedClasses.Add(currentClass); finishedClasses.Add(currentClass);
PutBaseClassesOnStack(currentClass); PutBaseClassesOnStack(currentClass);

29
src/Main/Base/Project/Src/Dom/Implementations/DefaultUsing.cs

@ -29,7 +29,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
List<string> usings = new List<string>(); List<string> usings = new List<string>();
SortedList<string, string> aliases = new SortedList<string, string>(); SortedList<string, IReturnType> aliases = new SortedList<string, IReturnType>();
public IRegion Region { public IRegion Region {
get { get {
@ -43,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
} }
public SortedList<string, string> Aliases { public SortedList<string, IReturnType> Aliases {
get { get {
return aliases; return aliases;
} }
@ -51,13 +51,15 @@ namespace ICSharpCode.SharpDevelop.Dom
public string SearchNamespace(string partitialNamespaceName) public string SearchNamespace(string partitialNamespaceName)
{ {
foreach (KeyValuePair<string, string> entry in aliases) { foreach (KeyValuePair<string, IReturnType> entry in aliases) {
if (!entry.Value.IsDefaultReturnType)
continue;
string aliasString = entry.Key; string aliasString = entry.Key;
if (projectContent.Language.NameComparer.Equals(partitialNamespaceName, aliasString)) if (projectContent.Language.NameComparer.Equals(partitialNamespaceName, aliasString))
return entry.Value; return entry.Value.FullyQualifiedName;
if (partitialNamespaceName.Length > aliasString.Length) { if (partitialNamespaceName.Length > aliasString.Length) {
if (projectContent.Language.NameComparer.Equals(partitialNamespaceName.Substring(0, aliasString.Length + 1), aliasString + ".")) { if (projectContent.Language.NameComparer.Equals(partitialNamespaceName.Substring(0, aliasString.Length + 1), aliasString + ".")) {
string nsName = nsName = String.Concat(entry.Value, partitialNamespaceName.Remove(0, aliasString.Length)); string nsName = nsName = String.Concat(entry.Value.FullyQualifiedName, partitialNamespaceName.Remove(0, aliasString.Length));
if (projectContent.NamespaceExists(nsName)) { if (projectContent.NamespaceExists(nsName)) {
return nsName; return nsName;
} }
@ -74,16 +76,19 @@ namespace ICSharpCode.SharpDevelop.Dom
return null; return null;
} }
public IClass SearchType(string partitialTypeName) public IReturnType SearchType(string partitialTypeName)
{ {
foreach (KeyValuePair<string, string> entry in aliases) { foreach (KeyValuePair<string, IReturnType> entry in aliases) {
string aliasString = entry.Key; string aliasString = entry.Key;
if (projectContent.Language.NameComparer.Equals(partitialTypeName, aliasString)) {
return entry.Value;
}
if (partitialTypeName.Length > aliasString.Length) { if (partitialTypeName.Length > aliasString.Length) {
if (projectContent.Language.NameComparer.Equals(partitialTypeName.Substring(0, aliasString.Length + 1), aliasString + ".")) { if (projectContent.Language.NameComparer.Equals(partitialTypeName.Substring(0, aliasString.Length + 1), aliasString + ".")) {
string className = String.Concat(entry.Value, partitialTypeName.Remove(0, aliasString.Length)); string className = String.Concat(entry.Value, partitialTypeName.Remove(0, aliasString.Length));
IClass c = projectContent.GetClass(className); IClass c = projectContent.GetClass(className);
if (c != null) { if (c != null) {
return c; return c.DefaultReturnType;
} }
} }
} }
@ -92,7 +97,7 @@ namespace ICSharpCode.SharpDevelop.Dom
foreach (string str in usings) { foreach (string str in usings) {
IClass c = projectContent.GetClass(str + "." + partitialTypeName); IClass c = projectContent.GetClass(str + "." + partitialTypeName);
if (c != null) { if (c != null) {
return c; return c.DefaultReturnType;
} }
} }
} else { } else {
@ -110,7 +115,7 @@ namespace ICSharpCode.SharpDevelop.Dom
if (c != null) { if (c != null) {
c = projectContent.GetClass(str + "." + partitialTypeName); c = projectContent.GetClass(str + "." + partitialTypeName);
if (c != null) { if (c != null) {
return c; return c.DefaultReturnType;
} }
} }
} }
@ -125,10 +130,10 @@ namespace ICSharpCode.SharpDevelop.Dom
builder.Append(str); builder.Append(str);
builder.Append(", "); builder.Append(", ");
} }
foreach (KeyValuePair<string, string> p in aliases) { foreach (KeyValuePair<string, IReturnType> p in aliases) {
builder.Append(p.Key); builder.Append(p.Key);
builder.Append("="); builder.Append("=");
builder.Append(p.Value); builder.Append(p.Value.ToString());
builder.Append(", "); builder.Append(", ");
} }
builder.Length -= 2; // remove last ", " builder.Length -= 2; // remove last ", "

3
src/Main/Base/Project/Src/Dom/Implementations/SearchClassReturnType.cs

@ -62,8 +62,7 @@ namespace ICSharpCode.SharpDevelop.Dom
// TODO: Cache BaseType until a new CompilationUnit is generated (static counter in ParserService) // TODO: Cache BaseType until a new CompilationUnit is generated (static counter in ParserService)
public override IReturnType BaseType { public override IReturnType BaseType {
get { get {
IClass c = pc.SearchType(name, declaringClass, caretLine, caretColumn); return pc.SearchType(name, declaringClass, caretLine, caretColumn);
return (c != null) ? c.DefaultReturnType : null;
} }
} }

9
src/Main/Base/Project/Src/Dom/Implementations/SpecificReturnType.cs

@ -221,7 +221,14 @@ namespace ICSharpCode.SharpDevelop.Dom
public override string ToString() public override string ToString()
{ {
return String.Format("[SpecificReturnType: {0}<{1}>]", baseType, typeParameters); string r = "[SpecificReturnType: ";
r += baseType;
r += "<";
for (int i = 0; i < typeParameters.Count; i++) {
if (i > 0) r += ",";
r += typeParameters[i];
}
return r + ">]";
} }
} }
} }

13
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryASTConvertVisitor.cs

@ -164,7 +164,10 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
Debug.Assert(data is DefaultUsing); Debug.Assert(data is DefaultUsing);
DefaultUsing us = (DefaultUsing)data; DefaultUsing us = (DefaultUsing)data;
if (u.IsAlias) { if (u.IsAlias) {
us.Aliases[u.Name] = u.Alias; IReturnType rt = CreateReturnType(u.Alias);
if (rt != null) {
us.Aliases[u.Name] = rt;
}
} else { } else {
us.Usings.Add(u.Name); us.Usings.Add(u.Name);
} }
@ -550,9 +553,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
IReturnType CreateReturnType(AST.TypeReference reference, IMethod method) IReturnType CreateReturnType(AST.TypeReference reference, IMethod method)
{ {
IClass c = GetCurrentClass(); IClass c = GetCurrentClass();
if (c == null) if (c == null) {
return null; return TypeVisitor.CreateReturnType(reference, new DefaultClass(cu, "___DummyClass"), method, 1, 1, cu.ProjectContent, true);
return TypeVisitor.CreateReturnType(reference, c, method, c.Region.BeginLine + 1, 1, cu.ProjectContent, true); } else {
return TypeVisitor.CreateReturnType(reference, c, method, c.Region.BeginLine + 1, 1, cu.ProjectContent, true);
}
} }
IReturnType CreateReturnType(AST.TypeReference reference) IReturnType CreateReturnType(AST.TypeReference reference)

26
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs

@ -441,9 +441,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
ResolveResult result2 = null; ResolveResult result2 = null;
IClass c = SearchClass(identifier); IReturnType t = SearchType(identifier);
if (c != null) { if (t != null) {
result2 = new TypeResolveResult(callingClass, callingMember, c); result2 = new TypeResolveResult(callingClass, callingMember, t);
} else { } else {
if (callingClass != null) { if (callingClass != null) {
if (callingMember is IMethod) { if (callingMember is IMethod) {
@ -652,6 +652,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
/// use the usings and the name of the namespace to find a class /// use the usings and the name of the namespace to find a class
/// </remarks> /// </remarks>
public IClass SearchClass(string name) public IClass SearchClass(string name)
{
IReturnType t = SearchType(name);
return (t != null) ? t.GetUnderlyingClass() : null;
}
public IReturnType SearchType(string name)
{ {
return projectContent.SearchType(name, callingClass, cu, caretLine, caretColumn); return projectContent.SearchType(name, callingClass, cu, caretLine, caretColumn);
} }
@ -898,10 +904,18 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
inStatic = callingMember.IsStatic; inStatic = callingMember.IsStatic;
if (callingClass != null) { if (callingClass != null) {
if (!inStatic) { ArrayList members = new ArrayList();
result.AddRange(callingClass.GetAccessibleMembers(callingClass, false)); IReturnType t = callingClass.DefaultReturnType;
members.AddRange(t.GetMethods());
members.AddRange(t.GetFields());
members.AddRange(t.GetEvents());
members.AddRange(t.GetProperties());
members.AddRange(t.GetIndexers());
foreach (IMember m in members) {
if ((m.IsStatic || !inStatic) && m.IsAccessible(callingClass, true)) {
result.Add(m);
}
} }
result.AddRange(callingClass.GetAccessibleMembers(callingClass, true));
} }
foreach (KeyValuePair<string, List<LocalLookupVariable>> pair in lookupTableVisitor.Variables) { foreach (KeyValuePair<string, List<LocalLookupVariable>> pair in lookupTableVisitor.Variables) {
if (pair.Value != null && pair.Value.Count > 0) { if (pair.Value != null && pair.Value.Count > 0) {

17
src/Main/Base/Project/Src/Dom/NRefactoryResolver/TypeVisitor.cs

@ -426,11 +426,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (resolver.CallingClass == null) { if (resolver.CallingClass == null) {
return null; return null;
} }
IClass baseClass = resolver.CallingClass.BaseClass; return resolver.CallingClass.BaseType;
if (baseClass == null) {
return null;
}
return baseClass.DefaultReturnType;
} }
public override object Visit(ObjectCreateExpression objectCreateExpression, object data) public override object Visit(ObjectCreateExpression objectCreateExpression, object data)
@ -519,11 +515,13 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
t = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.SystemType); t = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.SystemType);
} else { } else {
IClass c; IClass c;
if (reference.IsGlobal) if (reference.IsGlobal) {
c = projectContent.GetClass(reference.SystemType); c = projectContent.GetClass(reference.SystemType);
else t = (c != null) ? c.DefaultReturnType : null;
c = projectContent.SearchType(reference.SystemType, callingClass, caretLine, caretColumn); } else {
if (c == null) { t = projectContent.SearchType(reference.SystemType, callingClass, caretLine, caretColumn);
}
if (t == null) {
if (reference.GenericTypes.Count == 0 && !reference.IsArrayType) { if (reference.GenericTypes.Count == 0 && !reference.IsArrayType) {
// reference to namespace is possible // reference to namespace is possible
if (reference.IsGlobal) { if (reference.IsGlobal) {
@ -537,7 +535,6 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
return null; return null;
} }
t = c.DefaultReturnType;
} }
} }
} }

3
src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/BaseTypesNode.cs

@ -64,7 +64,8 @@ namespace ICSharpCode.SharpDevelop.Gui
if (content != null) { if (content != null) {
int count = c.BaseTypes.Count; int count = c.BaseTypes.Count;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
IClass baseClass = c.GetBaseClass(i); IReturnType baseType = c.GetBaseType(i);
IClass baseClass = (baseType != null) ? baseType.GetUnderlyingClass() : null;
if (baseClass != null) { if (baseClass != null) {
new ClassNode(project, baseClass).AddTo(this); new ClassNode(project, baseClass).AddTo(this);
} }

39
src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs

@ -454,7 +454,22 @@ namespace ICSharpCode.Core
if (language.ShowInNamespaceCompletion(c)) if (language.ShowInNamespaceCompletion(c))
list.Add(c); list.Add(c);
if (language.ImportModules && c.ClassType == ClassType.Module) { if (language.ImportModules && c.ClassType == ClassType.Module) {
list.AddRange(c.GetAccessibleMembers(null, true)); foreach (IMember m in c.Methods) {
if (m.IsAccessible(null, false))
list.Add(m);
}
foreach (IMember m in c.Events) {
if (m.IsAccessible(null, false))
list.Add(m);
}
foreach (IMember m in c.Fields) {
if (m.IsAccessible(null, false))
list.Add(m);
}
foreach (IMember m in c.Properties) {
if (m.IsAccessible(null, false))
list.Add(m);
}
} }
} }
foreach (string subns in ns.SubNamespaces) { foreach (string subns in ns.SubNamespaces) {
@ -534,7 +549,7 @@ namespace ICSharpCode.Core
return null; return null;
} }
public IClass SearchType(string name, IClass curType, int caretLine, int caretColumn) public IReturnType SearchType(string name, IClass curType, int caretLine, int caretColumn)
{ {
if (curType == null) { if (curType == null) {
return SearchType(name, null, null, caretLine, caretColumn); return SearchType(name, null, null, caretLine, caretColumn);
@ -542,7 +557,7 @@ namespace ICSharpCode.Core
return SearchType(name, curType, curType.CompilationUnit, caretLine, caretColumn); return SearchType(name, curType, curType.CompilationUnit, caretLine, caretColumn);
} }
public IClass SearchType(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn) public IReturnType SearchType(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn)
{ {
if (name == null || name.Length == 0) { if (name == null || name.Length == 0) {
return null; return null;
@ -551,7 +566,7 @@ namespace ICSharpCode.Core
// Try if name is already the full type name // Try if name is already the full type name
IClass c = GetClass(name); IClass c = GetClass(name);
if (c != null) { if (c != null) {
return c; return c.DefaultReturnType;
} }
if (curType != null) { if (curType != null) {
// Try parent namespaces of the current class // Try parent namespaces of the current class
@ -565,7 +580,7 @@ namespace ICSharpCode.Core
curnamespace.Append(name); curnamespace.Append(name);
c = GetClass(curnamespace.ToString()); c = GetClass(curnamespace.ToString());
if (c != null) { if (c != null) {
return c; return c.DefaultReturnType;
} }
// remove class name again to try next namespace // remove class name again to try next namespace
curnamespace.Length -= name.Length; curnamespace.Length -= name.Length;
@ -576,7 +591,7 @@ namespace ICSharpCode.Core
while ((curType = curType.BaseClass) != null) { while ((curType = curType.BaseClass) != null) {
foreach (IClass innerClass in curType.InnerClasses) { foreach (IClass innerClass in curType.InnerClasses) {
if (language.NameComparer.Equals(innerClass.Name, name)) if (language.NameComparer.Equals(innerClass.Name, name))
return innerClass; return innerClass.DefaultReturnType;
} }
} }
} }
@ -585,17 +600,17 @@ namespace ICSharpCode.Core
// Combine name with usings // Combine name with usings
foreach (IUsing u in unit.Usings) { foreach (IUsing u in unit.Usings) {
if (u != null) { if (u != null) {
c = u.SearchType(name); IReturnType r = u.SearchType(name);
if (c != null) { if (r != null) {
return c; return r;
} }
} }
} }
} }
if (defaultImports != null) { if (defaultImports != null) {
c = defaultImports.SearchType(name); IReturnType r = defaultImports.SearchType(name);
if (c != null) { if (r != null) {
return c; return r;
} }
} }
return null; return null;

4
src/Main/Base/Project/Src/Services/ParserService/IProjectContent.cs

@ -72,8 +72,8 @@ namespace ICSharpCode.Core
void AddNamespaceContents(ArrayList list, string subNameSpace, LanguageProperties language, bool lookInReferences); void AddNamespaceContents(ArrayList list, string subNameSpace, LanguageProperties language, bool lookInReferences);
string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn); string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn);
IClass SearchType(string name, IClass curType, int caretLine, int caretColumn); IReturnType SearchType(string name, IClass curType, int caretLine, int caretColumn);
IClass SearchType(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn); IReturnType SearchType(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn);
Position GetPosition(string fullMemberName); Position GetPosition(string fullMemberName);
} }

2
src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.Core
string baseType = c.BaseTypes[i]; string baseType = c.BaseTypes[i];
if (pc.Language.NameComparer.Equals(baseType, baseClassName) || if (pc.Language.NameComparer.Equals(baseType, baseClassName) ||
pc.Language.NameComparer.Equals(baseType, baseClassFullName)) { pc.Language.NameComparer.Equals(baseType, baseClassFullName)) {
IClass possibleBaseClass = c.GetBaseClass(i); IReturnType possibleBaseClass = c.GetBaseType(i);
if (possibleBaseClass != null && if (possibleBaseClass != null &&
possibleBaseClass.FullyQualifiedName == baseClass.FullyQualifiedName) { possibleBaseClass.FullyQualifiedName == baseClass.FullyQualifiedName) {
list.Add(c); list.Add(c);

72
src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/AbstractClassImplementorCodeGenerator.cs

@ -39,23 +39,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
public AbstractClassImplementorCodeGenerator(IClass currentClass) : base(currentClass) public AbstractClassImplementorCodeGenerator(IClass currentClass) : base(currentClass)
{ {
for (int i = 0; i < currentClass.BaseTypes.Count; i++) {
IReturnType baseType = currentClass.GetBaseType(i);
foreach (string className in currentClass.BaseTypes) { IClass baseClass = (baseType != null) ? baseType.GetUnderlyingClass() : null;
IClass baseType = ParserService.CurrentProjectContent.GetClass(className); if (baseClass != null && baseClass.ClassType == ClassType.Class && baseClass.IsAbstract) {
if (baseType == null) {
this.unit = currentClass == null ? null : currentClass.CompilationUnit;
if (unit != null) {
foreach (IUsing u in unit.Usings) {
baseType = u.SearchType(className);
if (baseType != null) {
break;
}
}
}
}
if (baseType != null && baseType.ClassType == ClassType.Class && baseType.IsAbstract) {
Content.Add(new ClassWrapper(baseType)); Content.Add(new ClassWrapper(baseType));
} }
} }
@ -65,30 +52,11 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{ {
for (int i = 0; i < items.Count; ++i) { for (int i = 0; i < items.Count; ++i) {
ClassWrapper cw = (ClassWrapper)items[i]; ClassWrapper cw = (ClassWrapper)items[i];
Queue interfaces = new Queue(); GenerateInterface(cw.ClassType, fileExtension);
interfaces.Enqueue(cw.Class);
while (interfaces.Count > 0) {
IClass intf = (IClass)interfaces.Dequeue();
GenerateInterface(intf, fileExtension);
/*
// search an enqueue all base interfaces
foreach (string interfaceName in intf.BaseTypes) {
IClass baseType = null;
foreach (IUsing u in unit.Usings) {
baseType = u.SearchType(interfaceName);
if (baseType != null) {
break;
}
}
if (baseType != null) {
interfaces.Enqueue(baseType);
}
}*/
}
} }
} }
void GenerateInterface(IClass intf, string fileExtension) void GenerateInterface(IReturnType intf, string fileExtension)
{ {
Return();Return(); Return();Return();
@ -99,7 +67,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
} }
++numOps; ++numOps;
foreach (IProperty property in intf.Properties) { foreach (IProperty property in intf.GetProperties()) {
if (!property.IsAbstract) { if (!property.IsAbstract) {
continue; continue;
} }
@ -183,14 +151,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
} else { } else {
editActionHandler.InsertChar('}');++numOps; editActionHandler.InsertChar('}');++numOps;
} }
Return(); Return();
Return(); Return();
IndentLine(); IndentLine();
} }
for (int i = 0; i < intf.Methods.Count; ++i) { foreach (IMethod method in intf.GetMethods()) {
IMethod method = intf.Methods[i];
string parameters = String.Empty; string parameters = String.Empty;
string returnType = (fileExtension == ".vb" ? vba : csa).Convert(method.ReturnType); string returnType = (fileExtension == ".vb" ? vba : csa).Convert(method.ReturnType);
if (!method.IsAbstract) { if (!method.IsAbstract) {
@ -249,13 +216,9 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
} else { } else {
editActionHandler.InsertChar('}');++numOps; editActionHandler.InsertChar('}');++numOps;
} }
if (i + 1 < intf.Methods.Count) { Return();
Return(); Return();
Return(); IndentLine();
IndentLine();
} else {
IndentLine();
}
} }
Return(); Return();
if (fileExtension == ".vb") { if (fileExtension == ".vb") {
@ -294,21 +257,22 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
class ClassWrapper class ClassWrapper
{ {
IClass c; IReturnType c;
public IClass Class { public IReturnType ClassType {
get { get {
return c; return c;
} }
} }
public ClassWrapper(IClass c) public ClassWrapper(IReturnType c)
{ {
this.c = c; this.c = c;
} }
public override string ToString() public override string ToString()
{ {
IAmbience ambience = AmbienceService.CurrentAmbience;
return AmbienceService.CurrentAmbience.Convert(c); ambience.ConversionFlags = ConversionFlags.None;
return ambience.Convert(c);
} }
} }
} }

217
src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/InterfaceImplementorCodeGenerator.cs

@ -39,28 +39,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
public InterfaceImplementorCodeGenerator(IClass currentClass) : base(currentClass) public InterfaceImplementorCodeGenerator(IClass currentClass) : base(currentClass)
{ {
for (int i = 0; i < currentClass.BaseTypes.Count; i++) {
IReturnType baseType = currentClass.GetBaseType(i);
foreach (string className in currentClass.BaseTypes) { IClass baseClass = (baseType != null) ? baseType.GetUnderlyingClass() : null;
IClass baseType = ParserService.CurrentProjectContent.GetClass(className); if (baseClass != null && baseClass.ClassType == ClassType.Interface) {
if (baseType == null) {
baseType = ParserService.CurrentProjectContent.GetClass(currentClass.Namespace + "." + className);
}
if (baseType == null) {
this.unit = currentClass == null ? null : currentClass.CompilationUnit;
if (unit != null) {
foreach (IUsing u in unit.Usings) {
baseType = u.SearchType(className);
if (baseType != null) {
break;
}
}
}
}
if (baseType != null && baseType.ClassType == ClassType.Interface) {
Content.Add(new ClassWrapper(baseType)); Content.Add(new ClassWrapper(baseType));
} }
} }
@ -70,129 +52,168 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{ {
for (int i = 0; i < items.Count; ++i) { for (int i = 0; i < items.Count; ++i) {
ClassWrapper cw = (ClassWrapper)items[i]; ClassWrapper cw = (ClassWrapper)items[i];
Queue interfaces = new Queue(); GenerateInterface(cw.ClassType, fileExtension);
interfaces.Enqueue(cw.Class);
while (interfaces.Count > 0) {
IClass intf = (IClass)interfaces.Dequeue();
GenerateInterface(intf);
// search an enqueue all base interfaces
foreach (string interfaceName in intf.BaseTypes) {
// first look if the interface is in the same namespace
IClass baseType = ParserService.CurrentProjectContent.GetClass(intf.Namespace + "." + interfaceName);
if (baseType == null && unit != null && unit.Usings != null) {
foreach (IUsing u in unit.Usings) {
baseType = u.SearchType(interfaceName);
if (baseType != null) {
break;
}
}
}
if (baseType != null) {
interfaces.Enqueue(baseType);
}
}
}
} }
} }
void GenerateInterface(IClass intf) void GenerateInterface(IReturnType intf, string fileExtension)
{ {
Return(); Return();
Return(); Return();
editActionHandler.InsertString("#region " + intf.FullyQualifiedName + " interface implementation\n\t\t");++numOps; editActionHandler.InsertString("#region " + intf.FullyQualifiedName + " interface implementation\n\t\t");++numOps;
foreach (IProperty property in intf.Properties) { foreach (IProperty property in intf.GetProperties()) {
string returnType = csa.Convert(property.ReturnType); if (!property.IsAbstract) {
editActionHandler.InsertString("public " + returnType + " " + property.Name);++numOps; continue;
if (StartCodeBlockInSameLine) { }
editActionHandler.InsertString(" {");++numOps; string returnType = (fileExtension == ".vb" ? vba : csa).Convert(property.ReturnType);
if (property.IsProtected) {
if (fileExtension == ".vb") {
editActionHandler.InsertString("Protected ");
} else {
editActionHandler.InsertString("protected ");
}
++numOps;
} else { } else {
Return(); if (fileExtension == ".vb") {
editActionHandler.InsertString("{");++numOps; editActionHandler.InsertString("Public ");
} else {
editActionHandler.InsertString("public ");
}
++numOps;
} }
Return();
if (property.CanGet) { if (fileExtension == ".vb") {
editActionHandler.InsertString("\tget");++numOps; editActionHandler.InsertString("override " + returnType + " " + property.Name);
if (StartCodeBlockInSameLine) { if (StartCodeBlockInSameLine) {
editActionHandler.InsertString(" {");++numOps; editActionHandler.InsertString(" {");++numOps;
} else { } else {
Return(); Return();
editActionHandler.InsertString("{");++numOps; editActionHandler.InsertString("{");++numOps;
} }
Return(); } else {
Indent();Indent(); editActionHandler.InsertString("Overrides Property " + property.Name + " As " + returnType + "\n");
editActionHandler.InsertString("return " + GetReturnValue(returnType) +";");++numOps; }
Return(); ++numOps;
Indent(); if (property.CanGet) {
editActionHandler.InsertString("}");++numOps; if (fileExtension == ".vb") {
Return(); editActionHandler.InsertString("\tGet");++numOps;
Return();
editActionHandler.InsertString("\t\tReturn " + GetReturnValue(returnType));++numOps;
Return();
editActionHandler.InsertString("\tEnd Get");++numOps;
Return();
} else {
editActionHandler.InsertString("\tget");++numOps;
if (StartCodeBlockInSameLine) {
editActionHandler.InsertString(" {");++numOps;
} else {
Return();
editActionHandler.InsertString("{");++numOps;
}
Return();
editActionHandler.InsertString("\t\treturn " + GetReturnValue(returnType) +";");++numOps;
Return();
editActionHandler.InsertString("\t}");++numOps;
Return();
}
} }
if (property.CanSet) { if (property.CanSet) {
Indent(); if (fileExtension == ".vb") {
editActionHandler.InsertString("set");++numOps; editActionHandler.InsertString("\tSet");++numOps;
if (StartCodeBlockInSameLine) { Return();
editActionHandler.InsertString(" {");++numOps; editActionHandler.InsertString("\tEnd Set");++numOps;
Return();
} else { } else {
editActionHandler.InsertString("\tset");++numOps;
if (StartCodeBlockInSameLine) {
editActionHandler.InsertString(" {");++numOps;
} else {
Return();
editActionHandler.InsertString("{");++numOps;
}
Return();
editActionHandler.InsertString("\t}");++numOps;
Return(); Return();
editActionHandler.InsertString("{");++numOps;
} }
Return();
Indent();
editActionHandler.InsertString("}");++numOps;
Return();
} }
editActionHandler.InsertChar('}');++numOps; if (fileExtension == ".vb") {
editActionHandler.InsertString("End Property");++numOps;
} else {
editActionHandler.InsertChar('}');++numOps;
}
Return(); Return();
Return(); Return();
IndentLine(); IndentLine();
} }
for (int i = 0; i < intf.Methods.Count; ++i) { foreach (IMethod method in intf.GetMethods()) {
IMethod method = intf.Methods[i];
string parameters = String.Empty; string parameters = String.Empty;
string returnType = csa.Convert(method.ReturnType); string returnType = (fileExtension == ".vb" ? vba : csa).Convert(method.ReturnType);
if (!method.IsAbstract) {
continue;
}
for (int j = 0; j < method.Parameters.Count; ++j) { for (int j = 0; j < method.Parameters.Count; ++j) {
parameters += csa.Convert(method.Parameters[j]); parameters += (fileExtension == ".vb" ? vba : csa).Convert(method.Parameters[j]);
if (j + 1 < method.Parameters.Count) { if (j + 1 < method.Parameters.Count) {
parameters += ", "; parameters += ", ";
} }
} }
if (method.IsProtected) {
editActionHandler.InsertString("public " + returnType + " " + method.Name + "(" + parameters + ")");++numOps; if (fileExtension == ".vb") {
if (StartCodeBlockInSameLine) { editActionHandler.InsertString("Protected ");
editActionHandler.InsertString(" {");++numOps; } else {
editActionHandler.InsertString("protected ");
}
} else { } else {
if (fileExtension == ".vb") {
editActionHandler.InsertString("Public ");
} else {
editActionHandler.InsertString("public ");
}
}
bool isSub = returnType == "void";
if (fileExtension == ".vb") {
editActionHandler.InsertString("Overrides " + (isSub ? "Sub " : "Function ") + method.Name + "(" + parameters + ") As " + returnType);++numOps;
Return();
} else {
editActionHandler.InsertString("override " + returnType + " " + method.Name + "(" + parameters + ")");++numOps;
if (StartCodeBlockInSameLine) {
editActionHandler.InsertString(" {");++numOps;
} else {
Return();
editActionHandler.InsertString("{");++numOps;
}
Return(); Return();
editActionHandler.InsertString("{");++numOps;
} }
Return();
switch (returnType) { switch (returnType) {
case "void": case "void":
break; break;
default: default:
Indent(); if (fileExtension == ".vb") {
editActionHandler.InsertString("return " + GetReturnValue(returnType) + ";");++numOps; editActionHandler.InsertString("Return " + GetReturnValue(returnType));++numOps;
} else {
editActionHandler.InsertString("return " + GetReturnValue(returnType) + ";");++numOps;
}
break; break;
} }
Return(); Return();
editActionHandler.InsertChar('}');++numOps; if (fileExtension == ".vb") {
if (i + 1 < intf.Methods.Count) { editActionHandler.InsertString("End " + (isSub ? "Sub" : "Function"));
Return();
Return();
IndentLine();
} else { } else {
IndentLine(); editActionHandler.InsertChar('}');++numOps;
} }
Return();
Return();
IndentLine();
} }
Return(); Return();
@ -227,13 +248,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
class ClassWrapper class ClassWrapper
{ {
IClass c; IReturnType c;
public IClass Class { public IReturnType ClassType {
get { get {
return c; return c;
} }
} }
public ClassWrapper(IClass c) public ClassWrapper(IReturnType c)
{ {
this.c = c; this.c = c;
} }

Loading…
Cancel
Save