Наследование: ICSharpCode.NRefactory.Ast.AbstractNode
Пример #1
0
        static Ast.AbstractNode CreateSuppressAttribute(ICompilationUnit cu, FxCopTaskTag tag)
        {
            //System.Diagnostics.CodeAnalysis.SuppressMessageAttribute
            bool importedCodeAnalysis = CheckImports(cu);

            // [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId:="fileIdentifier"]
            Ast.Attribute a = new Ast.Attribute {
                Name = importedCodeAnalysis ? AttributeName : NamespaceName + "." + AttributeName,
                PositionalArguments =
                {
                    new Ast.PrimitiveExpression(tag.Category, tag.Category),
                    new Ast.PrimitiveExpression(tag.CheckID,  tag.CheckID)
                }
            };
            if (tag.MessageID != null)
            {
                a.NamedArguments.Add(new Ast.NamedArgumentExpression("MessageId",
                                                                     new Ast.PrimitiveExpression(tag.MessageID, tag.MessageID)));
            }

            return(new Ast.AttributeSection {
                AttributeTarget = tag.MemberName == null ? "assembly" : null,
                Attributes = { a }
            });
        }
Пример #2
0
        private void UpdatePluginInfoAttribute(ICSharpCode.NRefactory.Ast.Attribute attribute)
        {
            Debug.Assert(attribute.Name == PLUGIN_INFO);

            var namedArguments = attribute.NamedArguments;

            var oldArguments = new List <NamedArgumentExpression>();

            foreach (var argument in namedArguments)
            {
                if (argument.Name == NAME || argument.Name == CATEGORY || argument.Name == VERSION)
                {
                    oldArguments.Add(argument);
                }
            }

            foreach (var argument in oldArguments)
            {
                namedArguments.Remove(argument);
            }

            namedArguments.Insert(0, new NamedArgumentExpression(NAME, new PrimitiveExpression(FName, FName)));
            namedArguments.Insert(1, new NamedArgumentExpression(CATEGORY, new PrimitiveExpression(FCategory, FCategory)));
            if (!string.IsNullOrEmpty(FVersion))
            {
                namedArguments.Insert(2, new NamedArgumentExpression(VERSION, new PrimitiveExpression(FVersion, FVersion)));
            }
        }
Пример #3
0
        private static PluginInfoAttribute ConvertAttributeToPluginInfo(ICSharpCode.NRefactory.Ast.Attribute attribute)
        {
            Debug.Assert(attribute.Name == PLUGIN_INFO);

            var pluginInfo = new PluginInfoAttribute();

            foreach (var argument in attribute.NamedArguments)
            {
                var expression = argument.Expression as PrimitiveExpression;
                if (expression != null)
                {
                    if (argument.Name == NAME)
                    {
                        pluginInfo.Name = expression.Value as string;
                    }
                    else if (argument.Name == CATEGORY)
                    {
                        pluginInfo.Category = expression.Value as string;
                    }
                    else if (argument.Name == VERSION)
                    {
                        pluginInfo.Version = expression.Value as string;
                    }
                }
            }

            return(pluginInfo);
        }
Пример #4
0
 public override object TrackedVisitAttribute(Attribute attribute, object data)
 {
     string name = attribute.Name;
     if (name.IndexOf('.') != -1)
         Add(name);
     return base.TrackedVisitAttribute(attribute, data);
 }
        public override object VisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
        {
            if (usings != null && !usings.ContainsKey("System.Runtime.InteropServices"))
            {
                UsingDeclaration @using = new UsingDeclaration("System.Runtime.InteropServices");
                addedUsings.Add(@using);
                base.VisitUsingDeclaration(@using, data);
            }

            MethodDeclaration method = new MethodDeclaration(declareDeclaration.Name, declareDeclaration.Modifier,
                                                             declareDeclaration.TypeReference, declareDeclaration.Parameters,
                                                             declareDeclaration.Attributes);

            if ((method.Modifier & Modifiers.Visibility) == 0)
            {
                method.Modifier |= Modifiers.Public;
            }
            method.Modifier |= Modifiers.Extern | Modifiers.Static;

            if (method.TypeReference.IsNull)
            {
                method.TypeReference = new TypeReference("System.Void");
            }

            Attribute att = new Attribute("DllImport", null, null);

            att.PositionalArguments.Add(CreateStringLiteral(declareDeclaration.Library));
            if (declareDeclaration.Alias.Length > 0)
            {
                att.NamedArguments.Add(new NamedArgumentExpression("EntryPoint", CreateStringLiteral(declareDeclaration.Alias)));
            }
            switch (declareDeclaration.Charset)
            {
            case CharsetModifier.Auto:
                att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
                                                                   new FieldReferenceExpression(new IdentifierExpression("CharSet"),
                                                                                                "Auto")));
                break;

            case CharsetModifier.Unicode:
                att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
                                                                   new FieldReferenceExpression(new IdentifierExpression("CharSet"),
                                                                                                "Unicode")));
                break;

            default:
                att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
                                                                   new FieldReferenceExpression(new IdentifierExpression("CharSet"),
                                                                                                "Ansi")));
                break;
            }
            att.NamedArguments.Add(new NamedArgumentExpression("SetLastError", new PrimitiveExpression(true, true.ToString())));
            att.NamedArguments.Add(new NamedArgumentExpression("ExactSpelling", new PrimitiveExpression(true, true.ToString())));
            AttributeSection sec = new AttributeSection(null, null);

            sec.Attributes.Add(att);
            method.Attributes.Add(sec);
            ReplaceCurrentNode(method);
            return(base.VisitMethodDeclaration(method, data));
        }
Пример #6
0
        public override object VisitAttribute(Attribute attribute, object data)
        {
            foreach (Expression argument in attribute.NamedArguments)
                argument.Parent = attribute;
            foreach (Expression argument in attribute.PositionalArguments)
                argument.Parent = attribute;

            return base.VisitAttribute(attribute, data);
        }
 private AttributeSection CreateAttributeSection(string attributeName, List<Expression> args)
 {
     Attribute attribute = new Attribute(attributeName, args, null);
     List<Attribute> attributes = new List<Attribute>();
     attributes.Add(attribute);
     AttributeSection attributeSection = new AttributeSection("", attributes);
     attribute.Parent = attributeSection;
     return attributeSection;
 }
 public override object TrackedVisitAttribute(Attribute attribute, object data)
 {
     string name = attribute.Name;
     if (name.StartsWith("System."))
     {
         string newName = name.Substring(name.LastIndexOf('.') + 1);
         attribute.Name = newName;
         AddUsing(attribute, data, name);
     }
     return base.TrackedVisitAttribute(attribute, data);
 }
Пример #9
0
        private static AttributeSection CreateAreaAttributeCode(string attributeName, string argumentName, Expression valueExpression)
        {
            NamedArgumentExpression argument = new NamedArgumentExpression(argumentName, valueExpression);
            Attribute attribute = new Attribute(attributeName, new List <Expression>(), new List <NamedArgumentExpression>());

            attribute.NamedArguments.Add(argument);
            AttributeSection attributeSection = new AttributeSection("IDontKnow", new List <Attribute>());

            attributeSection.Attributes.Add(attribute);
            return(attributeSection);
        }
Пример #10
0
        public override object VisitAttribute(Attribute attribute, object data)
        {
            var typeName = attribute.Name;

            if (!typeName.EndsWith("Attribute"))
            {
                typeName = typeName + "Attribute";
            }

            AddIdentifierFromString(typeName, 0);
            return(base.VisitAttribute(attribute, data));
        }
        public static T add_Attribute <T>(this T attributedNode, string attributeName, string parameterName, string parameterValue)  where T : AttributedNode
        {
            var namedArgument = new NamedArgumentExpression();

            namedArgument.Name       = parameterName;
            namedArgument.Expression = parameterValue.ast_Primitive();
            var attribute = new ICSharpCode.NRefactory.Ast.Attribute();

            attribute.Name = attributeName;
            attribute.NamedArguments.Add(namedArgument);
            attributedNode.add_Attribute(attribute);
            return(attributedNode);
        }
Пример #12
0
        private void UpdatePluginInfoAttribute(ICSharpCode.NRefactory.Ast.Attribute attribute)
        {
            Debug.Assert(attribute.Name == PLUGIN_INFO);

            var namedArguments = attribute.NamedArguments;

            //when cloning from a template
            //remove the dummy helps and tags
            var removeHelpAndTags = false;
            var oldArguments      = new List <NamedArgumentExpression>();

            foreach (var argument in namedArguments)
            {
                if (argument.Name == NAME)
                {
                    oldArguments.Add(argument);
                    var expr = (PrimitiveExpression)argument.Expression;
                    if (expr.StringValue.StartsWith("\"Template"))
                    {
                        removeHelpAndTags = true;
                    }
                }
                else if (argument.Name == CATEGORY || argument.Name == VERSION || argument.Name == HELP || argument.Name == TAGS)
                {
                    oldArguments.Add(argument);
                }
            }

            foreach (var argument in oldArguments)
            {
                if (argument.Name == HELP || argument.Name == TAGS)
                {
                    if (removeHelpAndTags)
                    {
                        namedArguments.Remove(argument);
                    }
                }
                else
                {
                    namedArguments.Remove(argument);
                }
            }

            namedArguments.Insert(0, new NamedArgumentExpression(NAME, new PrimitiveExpression(FName, FName)));
            namedArguments.Insert(1, new NamedArgumentExpression(CATEGORY, new PrimitiveExpression(FCategory, FCategory)));
            if (!string.IsNullOrEmpty(FVersion))
            {
                namedArguments.Insert(2, new NamedArgumentExpression(VERSION, new PrimitiveExpression(FVersion, FVersion)));
            }
        }
Пример #13
0
        private static AttributeSection CreateControllerAttributeCode(string attributeName, string argumentName, Expression valueExpression)
        {
            var argument = new NamedArgumentExpression(argumentName, valueExpression);

            var attribute = new Attribute(attributeName, new List <Expression>(), new List <NamedArgumentExpression>());

            attribute.NamedArguments.Add(argument);

            var attributeSection = new AttributeSection();

            attributeSection.Attributes.Add(attribute);

            return(attributeSection);
        }
Пример #14
0
        public override object TrackedVisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
        {
            TypeDeclaration typeDeclaration = (TypeDeclaration) methodDeclaration.Parent;
            string testcase = "junit.framework.TestCase";
            if (typeDeclaration != null && ((IsDerivedFrom(typeDeclaration, testcase) &&
                                             !(typeDeclaration.Name.StartsWith("Abstract"))) || IsAllTestRunner(typeDeclaration.Name)))
            {
                if (methodDeclaration.Name == "main" || methodDeclaration.Name == "suite")
                    RemoveCurrentNode();

                else if (methodDeclaration.Name.StartsWith("test"))
                {
                    MethodDeclaration replaced = methodDeclaration;
                    Attribute attr = new Attribute("NUnit.Framework.Test", null, null);
                    List<Attribute> attributes = new List<Attribute>();
                    attributes.Add(attr);
                    AttributeSection testAttribute = new AttributeSection(null, attributes);
                    replaced.Attributes.Add(testAttribute);
                    AstUtil.RemoveModifierFrom(replaced, Modifiers.Static);

                    ReplaceCurrentNode(replaced);
                }
                else if (methodDeclaration.Name == "setUp" || methodDeclaration.Name == "tearDown")
                {
                    if (Mode == "DotNet")
                    {
                        MethodDeclaration replaced = methodDeclaration;
                        replaced.Modifier = Modifiers.Public;

                        string attributeName = "NUnit.Framework.SetUp";
                        if (methodDeclaration.Name == "tearDown")
                            attributeName = "NUnit.Framework.TearDown";

                        Attribute attribute = new Attribute(attributeName, null, null);
                        List<Attribute> attributes = new List<Attribute>();
                        attributes.Add(attribute);
                        AttributeSection attributeSection = new AttributeSection(null, attributes);
                        replaced.Attributes.Add(attributeSection);

                        ReplaceCurrentNode(replaced);
                    }
                    else if (Mode == "IKVM")
                    {
                        methodDeclaration.Modifier = Modifiers.Protected | Modifiers.Override;
                    }
                }
            }
            return null;
        }
Пример #15
0
 public object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute a, object data)
 {
     B.Attribute att = new B.Attribute(GetLexicalInfo(a), a.Name);
     att.EndSourceLocation = GetLocation(a.EndLocation);
     ConvertExpressions(a.PositionalArguments, att.Arguments);
     foreach (NamedArgumentExpression nae in a.NamedArguments)
     {
         B.Expression expr = ConvertExpression(nae.Expression);
         if (expr != null)
         {
             att.NamedArguments.Add(new B.ExpressionPair(new B.ReferenceExpression(nae.Name), expr));
         }
     }
     return(att);
 }
Пример #16
0
        public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
        {
            if (IsDerivedFrom(typeDeclaration, "junit.framework.TestCase"))
            {
                if (!(typeDeclaration.Name.StartsWith("Abstract")))
                {
                    TypeDeclaration newType = typeDeclaration;
                    Attribute attr = new Attribute("NUnit.Framework.TestFixture", null, null);
                    List<Attribute> attributes = new List<Attribute>();
                    attributes.Add(attr);
                    AttributeSection attrSection = new AttributeSection(null, attributes);
                    newType.Attributes.Add(attrSection);

                    ReplaceCurrentNode(newType);
                }
            }
            return base.TrackedVisitTypeDeclaration(typeDeclaration, data);
        }
        public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
        {
            int index = GetBaseTypeIndex(typeDeclaration, serializableType);
            if (index != -1)
            {
                Removeables.Add(serializableType);
                if (typeDeclaration.Type == ClassType.Class)
                {
                    List<Attribute> attributes = new List<Attribute>();
                    Attribute attribute = new Attribute("System.SerializableAttribute", null, null);
                    attributes.Add(attribute);
                    AttributeSection attributeSection = new AttributeSection("", attributes);

                    typeDeclaration.Attributes.Add(attributeSection);
                    attributeSection.Parent = typeDeclaration;
                }
                typeDeclaration = RemoveBaseTypeFrom(typeDeclaration, (TypeReference) typeDeclaration.BaseTypes[index]);
            }
            return base.TrackedVisitTypeDeclaration(typeDeclaration, data);
        }
Пример #18
0
        public void VisitTypeDeclaration_AControllerWithRestRoutesAttribute_ExtractsRestRoutesData()
        {
            var routeName                 = "restController";
            var routeCollection           = "/part1/<key>/part2";
            var routeIdentifier           = "<id>";
            var routeRestVerbResolverType = typeof(CustomRestVerbResolver).FullName;

            var type = new TypeDeclaration(Modifiers.Public | Modifiers.Partial, new List <AttributeSection>())
            {
                Name = ControllerName
            };
            var attribute = new Attribute("RestRoutes", new List <Expression>(), new List <NamedArgumentExpression>());

            attribute.PositionalArguments.AddRange(new Expression[]
            {
                new PrimitiveExpression("restController", "restController"),
                new PrimitiveExpression("/part1/<key>/part2", "/part1/<key>/part2"),
                new PrimitiveExpression("<id>", "<id>"),
                new TypeOfExpression(new TypeReference(routeRestVerbResolverType))
            });

            var section = new AttributeSection();

            section.Attributes.Add(attribute);
            type.Attributes.Add(section);

            typeResolver.Expect(r => r.Resolve(Arg <TypeReference> .Matches(t => t.Type == routeRestVerbResolverType))).Return(
                routeRestVerbResolverType);

            visitor.VisitTypeDeclaration(type, null);

            treeService.AssertWasCalled(
                s => s.PushNode(Arg <ControllerTreeNode> .Matches(
                                    n => n.Name == ControllerName &&
                                    n.RestRoutesDescriptor.Name == routeName &&
                                    n.RestRoutesDescriptor.Collection == routeCollection &&
                                    n.RestRoutesDescriptor.Identifier == routeIdentifier &&
                                    n.RestRoutesDescriptor.RestVerbResolverType == routeRestVerbResolverType)));
            treeService.AssertWasCalled(s => s.PopNode());
        }
 private bool IsMatch(Attribute left, Attribute right)
 {
     return(left.Name == right.Name);
 }
 public object VisitAttribute(Attribute attribute, object data)
 {
     throw new NotImplementedException();
 }
Пример #21
0
        /// <summary>
        ///   Parses the specified entity.
        /// </summary>
        /// <param name = "entity">The entity.</param>
        /// <param name = "reader">The reader.</param>
        public override void Parse(BaseEntity entity, TextReader reader)
        {
            EnumerationEntity enumerationEntity = (EnumerationEntity)entity;

            if (enumerationEntity == null)
            {
                throw new ArgumentException("EnumerationEntity expected", "entity");
            }

            IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, reader);

            parser.Parse();

            // Extract the special nodes (comment, etc)
            List <ISpecial> specials = parser.Lexer.SpecialTracker.RetrieveSpecials();

            this.CodeDomSpecialParser = new CodeDomSpecialParser(specials);

            // Parse the compilation unit
            CompilationUnit cu = parser.CompilationUnit;

            foreach (INode child1 in cu.Children)
            {
                NamespaceDeclaration namespaceDeclaration = child1 as NamespaceDeclaration;
                if (namespaceDeclaration == null)
                {
                    continue;
                }
                foreach (INode child2 in child1.Children)
                {
                    TypeDeclaration declaration = child2 as TypeDeclaration;
                    if (declaration == null)
                    {
                        continue;
                    }
                    if (declaration.Type != ClassType.Enum)
                    {
                        continue;
                    }

                    // Extract basic informations
                    enumerationEntity.BaseType = declaration.BaseTypes.Count > 0 ? declaration.BaseTypes [0].Type : "int";

                    // Extract attributes
                    Attribute attribute = FindAttribute(declaration, "Flags");
                    enumerationEntity.Flags = (attribute != null);

                    IEnumerable <Comment> comments = this.GetDocumentationCommentsBefore(declaration);
                    AppendComment(entity, comments);

                    // Append each values
                    foreach (INode child3 in declaration.Children)
                    {
                        FieldDeclaration fieldDeclaration = child3 as FieldDeclaration;
                        if (fieldDeclaration == null)
                        {
                            continue;
                        }

                        EnumerationValueEntity valueEntity = new EnumerationValueEntity();
                        valueEntity.Name = fieldDeclaration.Fields [0].Name;
                        Expression expression = fieldDeclaration.Fields [0].Initializer;
                        if (expression != null)
                        {
                            CodeDomExpressionPrinter printer = new CodeDomExpressionPrinter();
                            expression.AcceptVisitor(printer, null);
                            valueEntity.Value = printer.ToString();
                        }

                        comments = this.GetDocumentationCommentsBefore(fieldDeclaration);
                        AppendComment(valueEntity, comments);

                        enumerationEntity.Values.Add(valueEntity);
                    }
                }
            }

            // Ensure that availability is set on entity.
            entity.AdjustAvailability();
        }
    private static AttributeSection CreateAreaAttributeCode(string attributeName, string argumentName, Expression valueExpression)
    {
      NamedArgumentExpression argument = new NamedArgumentExpression(argumentName, valueExpression);
	  Attribute attribute = new Attribute(attributeName, new List<Expression>(), new List<NamedArgumentExpression>());
      attribute.NamedArguments.Add(argument);
	  AttributeSection attributeSection = new AttributeSection("IDontKnow", new List<Attribute>());
      attributeSection.Attributes.Add(attribute);
      return attributeSection;
    }
		static Ast.AbstractNode CreateSuppressAttribute(ICompilationUnit cu, FxCopTaskTag tag)
		{
			//System.Diagnostics.CodeAnalysis.SuppressMessageAttribute
			bool importedCodeAnalysis = CheckImports(cu);
			
			// [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId:="fileIdentifier"]
			Ast.Attribute a = new Ast.Attribute {
				Name = importedCodeAnalysis ? AttributeName : NamespaceName + "." + AttributeName,
				PositionalArguments = {
					new Ast.PrimitiveExpression(tag.Category, tag.Category),
					new Ast.PrimitiveExpression(tag.CheckID, tag.CheckID)
				}
			};
			if (tag.MessageID != null) {
				a.NamedArguments.Add(new Ast.NamedArgumentExpression("MessageId",
				                                                     new Ast.PrimitiveExpression(tag.MessageID, tag.MessageID)));
			}
			
			return new Ast.AttributeSection {
				AttributeTarget = tag.MemberName == null ? "assembly" : null,
				Attributes = { a }
			};
		}
Пример #24
0
	void Attribute(
#line  2544 "VBNET.ATG" 
out ASTAttribute attribute) {

#line  2545 "VBNET.ATG" 
		string name;
		List<Expression> positional = new List<Expression>();
		List<NamedArgumentExpression> named = new List<NamedArgumentExpression>();
		
		if (la.kind == 117) {
			lexer.NextToken();
			Expect(16);
		}
		Qualident(
#line  2550 "VBNET.ATG" 
out name);
		if (la.kind == 25) {
			AttributeArguments(
#line  2551 "VBNET.ATG" 
positional, named);
		}

#line  2553 "VBNET.ATG" 
		attribute  = new ASTAttribute(name, positional, named);
		
	}
Пример #25
0
 public override object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute attribute, object data)
 {
     list[new PossibleTypeReference(attribute.Name)] = data;
     list[new PossibleTypeReference(attribute.Name + "Attribute")] = data;
     return(base.VisitAttribute(attribute, data));
 }
        public override object VisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
        {
            if (usings != null && !usings.ContainsKey("System.Runtime.InteropServices")) {
                UsingDeclaration @using = new UsingDeclaration("System.Runtime.InteropServices");
                addedUsings.Add(@using);
                base.VisitUsingDeclaration(@using, data);
            }

            MethodDeclaration method = new MethodDeclaration();
            method.Attributes = declareDeclaration.Attributes;
            method.Parameters = declareDeclaration.Parameters;
            method.TypeReference = declareDeclaration.TypeReference;
            method.Modifier = declareDeclaration.Modifier;
            method.Name = declareDeclaration.Name;

            if ((method.Modifier & Modifiers.Visibility) == 0)
                method.Modifier |= Modifiers.Public;
            method.Modifier |= Modifiers.Extern | Modifiers.Static;

            if (method.TypeReference.IsNull) {
                method.TypeReference = new TypeReference("System.Void", true);
            }

            Attribute att = new Attribute("DllImport", null, null);
            att.PositionalArguments.Add(CreateStringLiteral(declareDeclaration.Library));
            if (declareDeclaration.Alias.Length > 0) {
                att.NamedArguments.Add(new NamedArgumentExpression("EntryPoint", CreateStringLiteral(declareDeclaration.Alias)));
            }
            switch (declareDeclaration.Charset) {
                case CharsetModifier.Auto:
                    att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
                                                                       new MemberReferenceExpression(new IdentifierExpression("CharSet"),
                                                                                                     "Auto")));
                    break;
                case CharsetModifier.Unicode:
                    att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
                                                                       new MemberReferenceExpression(new IdentifierExpression("CharSet"),
                                                                                                     "Unicode")));
                    break;
                default:
                    att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
                                                                       new MemberReferenceExpression(new IdentifierExpression("CharSet"),
                                                                                                     "Ansi")));
                    break;
            }
            att.NamedArguments.Add(new NamedArgumentExpression("SetLastError", new PrimitiveExpression(true, true.ToString())));
            att.NamedArguments.Add(new NamedArgumentExpression("ExactSpelling", new PrimitiveExpression(true, true.ToString())));
            var attributeSection = new AttributeSection();
            attributeSection.Attributes = new List<Attribute>().add(att);
            method.Attributes.Add(attributeSection);
            ReplaceCurrentNode(method);
            return base.VisitMethodDeclaration(method, data);
        }
 public override object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute attribute, object data)
 {
     possibleTypeReferences.Add(new TypeReference(attribute.Name));
     possibleTypeReferences.Add(new TypeReference(attribute.Name + "Attribute"));
     return(base.VisitAttribute(attribute, data));
 }
 private bool IsMatch(Attribute left, Attribute right)
 {
     return left.Name == right.Name;
 }
 public object VisitAttribute(Attribute attribute, object data)
 {
     throw new NotImplementedException ();
 }
Пример #30
0
	void Attribute(
#line  2078 "VBNET.ATG" 
out ASTAttribute attribute) {

#line  2079 "VBNET.ATG" 
		string name;
		List<Expression> positional = new List<Expression>();
		List<NamedArgumentExpression> named = new List<NamedArgumentExpression>();
		
		if (la.kind == 199) {
			lexer.NextToken();
			Expect(10);
		}
		Qualident(
#line  2084 "VBNET.ATG" 
out name);
		if (la.kind == 24) {
			AttributeArguments(
#line  2085 "VBNET.ATG" 
positional, named);
		}

#line  2086 "VBNET.ATG" 
		attribute  = new ASTAttribute(name, positional, named); 
	}
		private static AttributeSection CreateControllerAttributeCode(string attributeName, string argumentName, Expression valueExpression)
		{
			var argument = new NamedArgumentExpression(argumentName, valueExpression);
			
			var attribute = new Attribute(attributeName, new List<Expression>(), new List<NamedArgumentExpression>());
			attribute.NamedArguments.Add(argument);
			
			var attributeSection = new AttributeSection();
			attributeSection.Attributes.Add(attribute);
			
			return attributeSection;
		}
Пример #32
0
	void Attribute(
#line  241 "cs.ATG" 
out ASTAttribute attribute) {

#line  242 "cs.ATG" 
		string qualident;
		string alias = null;
		

#line  246 "cs.ATG" 
		Location startPos = la.Location; 
		if (
#line  247 "cs.ATG" 
IdentAndDoubleColon()) {
			Identifier();

#line  248 "cs.ATG" 
			alias = t.val; 
			Expect(10);
		}
		Qualident(
#line  251 "cs.ATG" 
out qualident);

#line  252 "cs.ATG" 
		List<Expression> positional = new List<Expression>();
		List<NamedArgumentExpression> named = new List<NamedArgumentExpression>();
		string name = (alias != null && alias != "global") ? alias + "." + qualident : qualident;
		
		if (la.kind == 20) {
			AttributeArguments(
#line  256 "cs.ATG" 
positional, named);
		}

#line  257 "cs.ATG" 
		attribute = new ASTAttribute(name, positional, named); 
		attribute.StartLocation = startPos;
		attribute.EndLocation = t.EndLocation;
		
	}
Пример #33
0
 public virtual object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute attribute, object data)
 {
     throw new global::System.NotImplementedException("Attribute");
 }
Пример #34
0
	void Attribute(
#line  2785 "VBNET.ATG" 
out ASTAttribute attribute) {

#line  2786 "VBNET.ATG" 
		string name;
		List<Expression> positional = new List<Expression>();
		List<NamedArgumentExpression> named = new List<NamedArgumentExpression>();
		
		if (la.kind == 130) {
			lexer.NextToken();
			Expect(26);
		}
		Qualident(
#line  2791 "VBNET.ATG" 
out name);
		if (la.kind == 37) {
			AttributeArguments(
#line  2792 "VBNET.ATG" 
positional, named);
		}

#line  2794 "VBNET.ATG" 
		attribute  = new ASTAttribute(name, positional, named);
		
	}
		public void VisitTypeDeclaration_AControllerWithRestRoutesAttribute_ExtractsRestRoutesData()
		{
			var routeName = "restController";
			var routeCollection = "/part1/<key>/part2";
			var routeIdentifier = "<id>";
			var routeRestVerbResolverType = typeof(CustomRestVerbResolver).FullName;

			var type = new TypeDeclaration(Modifiers.Public | Modifiers.Partial, new List<AttributeSection>()) { Name = ControllerName };
			var attribute = new Attribute("RestRoutes", new List<Expression>(), new List<NamedArgumentExpression>());
			attribute.PositionalArguments.AddRange(new Expression[]
			{
				new PrimitiveExpression("restController", "restController"),
				new PrimitiveExpression("/part1/<key>/part2", "/part1/<key>/part2"),
				new PrimitiveExpression("<id>", "<id>"),
				new TypeOfExpression(new TypeReference(routeRestVerbResolverType))
			});

			var section = new AttributeSection();
			section.Attributes.Add(attribute);
			type.Attributes.Add(section);

			typeResolver.Expect(r => r.Resolve(Arg<TypeReference>.Matches(t => t.Type == routeRestVerbResolverType))).Return(
				routeRestVerbResolverType);

			visitor.VisitTypeDeclaration(type, null);

			treeService.AssertWasCalled(
				s => s.PushNode(Arg<ControllerTreeNode>.Matches(
					n => n.Name == ControllerName && 
						 n.RestRoutesDescriptor.Name == routeName &&
						 n.RestRoutesDescriptor.Collection == routeCollection &&
						 n.RestRoutesDescriptor.Identifier == routeIdentifier &&
						 n.RestRoutesDescriptor.RestVerbResolverType == routeRestVerbResolverType)));
			treeService.AssertWasCalled(s => s.PopNode());
		}
Пример #36
0
	void Attribute(
//#line  2846 "VBNET.ATG" 
out ASTAttribute attribute) {

//#line  2848 "VBNET.ATG" 
		string name;
		List<Expression> positional = new List<Expression>();
		List<NamedArgumentExpression> named = new List<NamedArgumentExpression>();
		Location startLocation = la.Location;
		
		if (la.kind == 130) {
			lexer.NextToken();
			Expect(26);
		}
		Qualident(
//#line  2854 "VBNET.ATG" 
out name);
		if (la.kind == 37) {
			AttributeArguments(
//#line  2855 "VBNET.ATG" 
positional, named);
		}

//#line  2857 "VBNET.ATG" 
		attribute  = new ASTAttribute(name, positional, named) { StartLocation = startLocation, EndLocation = t.EndLocation };
		
	}
Пример #37
0
 public override object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute attribute, object data)
 {
     return(base.VisitAttribute(attribute, data));
 }