1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Collections.Generic;
6
using ICSharpCode.NRefactory.Ast;
8
namespace ICSharpCode.PythonBinding
10
public class PythonConstructorInfo
12
ConstructorDeclaration constructor;
13
List<FieldDeclaration> fields = new List<FieldDeclaration>();
15
PythonConstructorInfo(ConstructorDeclaration constructor, List<FieldDeclaration> fields)
17
this.constructor = constructor;
22
/// Gets the constructor information from a type declaration. Returns null if there is no
23
/// constructor defined or if there are no fields defined.
25
public static PythonConstructorInfo GetConstructorInfo(TypeDeclaration type)
27
List<FieldDeclaration> fields = new List<FieldDeclaration>();
28
ConstructorDeclaration constructor = null;
29
foreach (INode node in type.Children) {
30
ConstructorDeclaration currentConstructor = node as ConstructorDeclaration;
31
FieldDeclaration field = node as FieldDeclaration;
32
if (currentConstructor != null) {
33
constructor = currentConstructor;
34
} else if (field != null) {
39
if ((fields.Count > 0) || (constructor != null)) {
40
return new PythonConstructorInfo(constructor, fields);
45
public ConstructorDeclaration Constructor {
46
get { return constructor; }
49
public List<FieldDeclaration> Fields {
50
get { return fields; }