예제 #1
0
파일: visit.cs 프로젝트: isiguta/NRefactory
 public virtual object Visit(BlockConstant blockConstantDeclaration)
 {
     return(null);
 }
예제 #2
0
			public override object Visit(BlockConstant blockConstantDeclaration)
			{
				var result = new VariableDeclarationStatement();
				
				var location = LocationsBag.GetLocations(blockConstantDeclaration);
				if (location != null && location.Count > 0)
					result.AddChild(new CSharpModifierToken(Convert(location [0]), Modifiers.Const), VariableDeclarationStatement.ModifierRole);
				
				result.AddChild(ConvertToType(blockConstantDeclaration.TypeExpression), Roles.Type);
				
				var varInit = new VariableInitializer();
				varInit.AddChild(Identifier.Create(blockConstantDeclaration.Variable.Name, Convert(blockConstantDeclaration.Variable.Location)), Roles.Identifier);
				if (blockConstantDeclaration.Initializer != null) {
					if (location != null && location.Count > 1)
						varInit.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.Assign), Roles.Assign);
					varInit.AddChild((Expression)blockConstantDeclaration.Initializer.Accept(this), Roles.Expression);
				}
				
				result.AddChild(varInit, Roles.Variable);
				
				if (blockConstantDeclaration.Declarators != null) {
					foreach (var decl in blockConstantDeclaration.Declarators) {
						var loc = LocationsBag.GetLocations(decl);
						var init = new VariableInitializer();
						init.AddChild(Identifier.Create(decl.Variable.Name, Convert(decl.Variable.Location)), Roles.Identifier);
						if (decl.Initializer != null) {
							if (loc != null)
								init.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Assign), Roles.Assign);
							init.AddChild((Expression)decl.Initializer.Accept(this), Roles.Expression);
							if (loc != null && loc.Count > 1)
								result.AddChild(new CSharpTokenNode(Convert(loc [1]), Roles.Comma), Roles.Comma);
						} else {
							if (loc != null && loc.Count > 0)
								result.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Comma), Roles.Comma);
						}
						result.AddChild(init, Roles.Variable);
					}
				}
				if (location != null) {
					result.AddChild(new CSharpTokenNode(Convert(location [location.Count - 1]), Roles.Semicolon), Roles.Semicolon);
				} else {
					// parser error, set end node to max value.
					result.AddChild(new ErrorNode(), Roles.Error);
				}
				return result;
			}
예제 #3
0
		public virtual object Visit (BlockConstant blockConstantDeclaration)
		{
			return null;
		}