public override object Visit(AttributeSection attributeSection, object data)
        {
            DebugOutput(attributeSection);
            AppendIndentation();sourceText.Append("<");
            if (attributeSection.AttributeTarget != null && attributeSection.AttributeTarget.Length > 0) {
                sourceText.Append(attributeSection.AttributeTarget);
                sourceText.Append(": ");
            }
            for (int j = 0; j < attributeSection.Attributes.Count; ++j) {
                ICSharpCode.SharpRefactory.Parser.AST.Attribute attr = (ICSharpCode.SharpRefactory.Parser.AST.Attribute)attributeSection.Attributes[j];

                sourceText.Append(attr.Name);
                sourceText.Append("(");
                for (int i = 0; i < attr.PositionalArguments.Count; ++i) {
                    Expression expr = (Expression)attr.PositionalArguments[i];
                    sourceText.Append(expr.AcceptVisitor(this, data).ToString());
                    if (i + 1 < attr.PositionalArguments.Count) {
                        sourceText.Append(", ");
                    }
                }

                for (int i = 0; i < attr.NamedArguments.Count; ++i) {
                    NamedArgument named = (NamedArgument)attr.NamedArguments[i];
                    sourceText.Append(named.Name);
                    sourceText.Append("=");
                    sourceText.Append(named.Expr.AcceptVisitor(this, data).ToString());
                    if (i + 1 < attr.NamedArguments.Count) {
                        sourceText.Append(", ");
                    }
                }
                sourceText.Append(")");
                if (j + 1 < attributeSection.Attributes.Count) {
                    sourceText.Append(", ");
                }
            }
            sourceText.Append("> ");
            if (generateAttributeUnderScore) {
                sourceText.Append("_");
            }
            AppendNewLine();
            return null;
        }
 public override object Visit(AttributeSection attributeSection, object data)
 {
     return null;
 }
 public override object Visit(AttributeSection attributeSection, object data)
 {
     Console.WriteLine(attributeSection.ToString());
     return attributeSection.AcceptChildren(this, data);
 }
 public virtual object Visit(AttributeSection attributeSection, object data)
 {
     return data;
 }
Example #5
0
	void AttributeSection(
#line  631 "cs.ATG" 
out AttributeSection section) {

#line  633 "cs.ATG" 
		string attributeTarget = "";
		ArrayList attributes = new ArrayList();
		ICSharpCode.SharpRefactory.Parser.AST.Attribute attribute;
		
		
		Expect(16);

#line  639 "cs.ATG" 
		Point startPos = t.Location; 
		if (
#line  640 "cs.ATG" 
IsLocalAttrTarget()) {
			if (la.kind == 68) {
				lexer.NextToken();

#line  641 "cs.ATG" 
				attributeTarget = "event";
			} else if (la.kind == 100) {
				lexer.NextToken();

#line  642 "cs.ATG" 
				attributeTarget = "return";
			} else {
				lexer.NextToken();

#line  643 "cs.ATG" 
				if (t.val != "field"    || t.val != "method" ||
				  t.val != "module"   || t.val != "param"  ||
				  t.val != "property" || t.val != "type")
				Error("attribute target specifier (event, return, field," +
				      "method, module, param, property, or type) expected");
				attributeTarget = t.val;
				
			}
			Expect(9);
		}
		Attribute(
#line  653 "cs.ATG" 
out attribute);

#line  653 "cs.ATG" 
		attributes.Add(attribute); 
		while (
#line  654 "cs.ATG" 
NotFinalComma()) {
			Expect(12);
			Attribute(
#line  654 "cs.ATG" 
out attribute);

#line  654 "cs.ATG" 
			attributes.Add(attribute); 
		}
		if (la.kind == 12) {
			lexer.NextToken();
		}
		Expect(17);

#line  656 "cs.ATG" 
		section = new AttributeSection(attributeTarget, attributes);
		section.StartLocation = startPos;
		section.EndLocation = t.EndLocation;
		
	}
Example #6
0
	void GlobalAttributeSection() {
		Expect(16);

#line  574 "cs.ATG" 
		Point startPos = t.Location; 
		Expect(1);

#line  574 "cs.ATG" 
		if (t.val != "assembly") Error("global attribute target specifier (\"assembly\") expected");
		string attributeTarget = t.val;
		ArrayList attributes = new ArrayList();
		ICSharpCode.SharpRefactory.Parser.AST.Attribute attribute;
		
		Expect(9);
		Attribute(
#line  579 "cs.ATG" 
out attribute);

#line  579 "cs.ATG" 
		attributes.Add(attribute); 
		while (
#line  580 "cs.ATG" 
NotFinalComma()) {
			Expect(12);
			Attribute(
#line  580 "cs.ATG" 
out attribute);

#line  580 "cs.ATG" 
			attributes.Add(attribute); 
		}
		if (la.kind == 12) {
			lexer.NextToken();
		}
		Expect(17);

#line  582 "cs.ATG" 
		AttributeSection section = new AttributeSection(attributeTarget, attributes);
		section.StartLocation = startPos;
		section.EndLocation = t.EndLocation;
		compilationUnit.AddChild(section);
		
	}
        public override object Visit(AttributeSection section, object data)
        {
            outputFormatter.Indent();
            outputFormatter.PrintToken(Tokens.OpenSquareBracket);
            if (section.AttributeTarget != null && section.AttributeTarget != String.Empty) {
                outputFormatter.PrintIdentifier(section.AttributeTarget);
                outputFormatter.PrintToken(Tokens.Colon);
                outputFormatter.Space();
            }
            Debug.Assert(section.Attributes != null);
            for (int j = 0; j < section.Attributes.Count; ++j) {
                ICSharpCode.SharpRefactory.Parser.AST.Attribute a = (ICSharpCode.SharpRefactory.Parser.AST.Attribute)section.Attributes[j];
                outputFormatter.PrintIdentifier(a.Name);
                if (a.PositionalArguments != null && a.PositionalArguments.Count > 0) {
                    outputFormatter.PrintToken(Tokens.OpenParenthesis);
                    this.AppendCommaSeparatedList(a.PositionalArguments);

                    if (a.NamedArguments != null && a.NamedArguments.Count > 0) {
                        if (a.PositionalArguments.Count > 0) {
                            outputFormatter.PrintToken(Tokens.Comma);
                            outputFormatter.Space();
                        }
                        for (int i = 0; i < a.NamedArguments.Count; ++i) {
                            NamedArgument n = (NamedArgument)a.NamedArguments[i];
                            outputFormatter.PrintIdentifier(n.Name);
                            outputFormatter.Space();
                            outputFormatter.PrintToken(Tokens.Assign);
                            outputFormatter.Space();
                            n.Expr.AcceptVisitor(this, data);
                            if (i + 1 < a.NamedArguments.Count) {
                                outputFormatter.PrintToken(Tokens.Comma);
                                outputFormatter.Space();
                            }
                        }
                    }
                    outputFormatter.PrintToken(Tokens.CloseParenthesis);
                }
                if (j + 1 < section.Attributes.Count) {
                    outputFormatter.PrintToken(Tokens.Comma);
                    outputFormatter.Space();
                }
            }
            outputFormatter.PrintToken(Tokens.CloseSquareBracket);
            outputFormatter.NewLine();
            return null;
        }