public override object VisitCompilationUnit(ICSharpCode.NRefactory.Ast.CompilationUnit compilationUnit, object data)
			{
				//TODO: Imports, Comments
				compilationUnit.AcceptChildren (this, data);
				return cu;
			}
			public override object VisitTypeDeclaration(ICSharpCode.NRefactory.Ast.TypeDeclaration typeDeclaration, object data)
			{
				DomType type = new DomType (cu, 
				                            TranslateClassType (typeDeclaration.Type),
				                            (MonoDevelop.Projects.Dom.Modifiers)typeDeclaration.Modifier, 
				                            typeDeclaration.Name,
				                            new DomLocation (typeDeclaration.StartLocation.Line, typeDeclaration.StartLocation.Column), 
				                            currentNamespace.Count > 0 ? currentNamespace.Peek() : "",
				                            TranslateRegion (typeDeclaration.StartLocation, typeDeclaration.EndLocation));
				
				if (currentType.Count > 0) {
					currentType.Peek().Add (type);
				} else {
					cu.Add (type);
				}
				
				if (typeDeclaration.BaseTypes != null) {
					foreach (ICSharpCode.NRefactory.Ast.TypeReference baseType in typeDeclaration.BaseTypes) {
						if (type.BaseType == null) {
							type.BaseType = TranslateTypeReference (baseType);
						} else {
							type.AddInterfaceImplementation (TranslateTypeReference (baseType));
						}
					}
				}
				currentType.Push (type);
				typeDeclaration.AcceptChildren (this, data);
				currentType.Pop();
				
				return null;
			}
예제 #3
0
			public override object VisitTypeDeclaration (ICSharpCode.NRefactory.Ast.TypeDeclaration typeDeclaration, object data)
			{
				DomType newType = new DomType ();
				newType.SourceProjectDom = dom;
				newType.Name = typeDeclaration.Name;
				newType.Documentation = RetrieveDocumentation (typeDeclaration.StartLocation.Line);
				newType.Location = ConvertLocation (typeDeclaration.StartLocation);
				newType.ClassType = ConvertClassType (typeDeclaration.Type);
				DomRegion region = ConvertRegion (typeDeclaration.BodyStartLocation, typeDeclaration.EndLocation);
				region.End = new DomLocation (region.End.Line, region.End.Column);
				newType.BodyRegion = region;
				newType.Modifiers = ConvertModifiers (typeDeclaration.Modifier);
				
				
				AddAttributes (newType, typeDeclaration.Attributes);

				foreach (ICSharpCode.NRefactory.Ast.TemplateDefinition template in typeDeclaration.Templates) {
					TypeParameter parameter = ConvertTemplateDefinition (template);
					newType.AddTypeParameter (parameter);
				}

				if (typeDeclaration.BaseTypes != null) {

					foreach (ICSharpCode.NRefactory.Ast.TypeReference type in typeDeclaration.BaseTypes) {
						if (type == typeDeclaration.BaseTypes[0]) {
							newType.BaseType = ConvertReturnType (type);
						} else {
							newType.AddInterfaceImplementation (ConvertReturnType (type));
						}
					}
				}
				AddType (newType);

				// visit members
				typeStack.Push (newType);
				typeDeclaration.AcceptChildren (this, data);
				typeStack.Pop ();

				return null;
			}
//			public override object VisitUsing(ICSharpCode.NRefactory.Ast.Using usingDeclaration, object data)
//			{
//				DefaultUsing u = new DefaultUsing();
//				if (usingDeclaration.IsAlias)
//					u.Aliases[usingDeclaration.Name] = new ReturnType (usingDeclaration.Alias.Type);
//				else
//					u.Usings.Add(usingDeclaration.Name);
//				cu.Usings.Add(u);
//				return data;
//			}
			
//		ModifierEnum VisitModifier(ICSharpCode.SharpRefactory.Parser.Modifier m)
//		{
//			return (ModifierEnum)m;
//		}
			
			public override object VisitNamespaceDeclaration(ICSharpCode.NRefactory.Ast.NamespaceDeclaration namespaceDeclaration, object data)
			{
				string name;
				if (currentNamespace.Count == 0) {
					name = namespaceDeclaration.Name;
				} else {
					name = String.Concat((string)currentNamespace.Peek(), '.', namespaceDeclaration.Name);
				}
				currentNamespace.Push(name);
				object ret = namespaceDeclaration.AcceptChildren(this, data);
				currentNamespace.Pop();
				return ret;
			}
예제 #5
0
			public override object VisitNamespaceDeclaration (ICSharpCode.NRefactory.Ast.NamespaceDeclaration namespaceDeclaration, object data)
			{
				string[] splittedNamespace = namespaceDeclaration.Name.Split ('.');
				for (int i = splittedNamespace.Length; i > 0; i--) {
					DomUsing domUsing = new DomUsing ();
					domUsing.IsFromNamespace = true;
					domUsing.Region = ConvertRegion (namespaceDeclaration.StartLocation, namespaceDeclaration.EndLocation);
					domUsing.ValidRegion = domUsing.Region;
					domUsing.Add (String.Join (".", splittedNamespace, 0, i));
					((CompilationUnit)result.CompilationUnit).Add (domUsing);
				}
				namespaceEndLocationStack.Push (namespaceDeclaration.EndLocation);
				namespaceStack.Push (namespaceStack.Count == 0 ? namespaceDeclaration.Name : namespaceStack.Peek () + "." + namespaceDeclaration.Name);
				namespaceDeclaration.AcceptChildren (this, data);
				namespaceStack.Pop ();
				namespaceEndLocationStack.Pop ();
				return null;
			}