Пример #1
0
        public override void VisitStructDeclaration(StructDeclarationSyntax node)
        {
            StructWalker walker = this.CreateSyntaxWalker<StructWalker>(node);
            walker.Visit(node);
            this.Structs.Add(walker);

            base.VisitStructDeclaration(node);
        }
Пример #2
0
 public override void VisitStructDeclaration(StructDeclarationSyntax node)
 {
     if (compilation != null)
     {
         var type = compilation.GetSemanticModel(node.SyntaxTree).GetDeclaredSymbol(node);
         types.Add(type);                
     }
     typeDeclarations.Add(node);
     base.VisitStructDeclaration(node);
 }
        //public StructDeclarationTranslation() { }
        public StructDeclarationTranslation(StructDeclarationSyntax syntax, SyntaxTranslation parent) : base(syntax, parent)
        {              
            if(BaseList == null)
            {
                BaseList = new BaseListTranslation();
                BaseList.Parent = this;
                BaseList.Types = new SeparatedSyntaxListTranslation<BaseTypeSyntax, BaseTypeTranslation>();
                BaseList.Types.Parent = BaseList;
            }

            //BaseList.Types.Add(new BaseTypeTranslation() { SyntaxString = TC.IStruct });
        }
Пример #4
0
		/// <summary>
		///   Normalizes the <paramref name="structDeclaration" />.
		/// </summary>
		public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax structDeclaration)
		{
			structDeclaration = (StructDeclarationSyntax)base.VisitStructDeclaration(structDeclaration);

			if (structDeclaration.Modifiers.Any(SyntaxKind.PartialKeyword))
				return structDeclaration;

			var partialKeyword = SyntaxFactory.Token(SyntaxKind.PartialKeyword).WithTrailingSpace();
			partialKeyword = partialKeyword.WithLeadingTrivia(structDeclaration.Keyword.LeadingTrivia);
			structDeclaration = structDeclaration.WithModifiers(structDeclaration.Modifiers.Add(partialKeyword));
			return structDeclaration.WithKeyword(structDeclaration.Keyword.WithLeadingSpace());
		}
Пример #5
0
		/// <summary>
		///     Normalizes the <paramref name="structDeclaration" />.
		/// </summary>
		public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax structDeclaration)
		{
			structDeclaration = (StructDeclarationSyntax)base.VisitStructDeclaration(structDeclaration);

			if (!structDeclaration.Modifiers.Any(SyntaxKind.PartialKeyword))
			{
				var partialKeyword = SyntaxFactory.Token(SyntaxKind.PartialKeyword).WithTrailingSpace();
				structDeclaration = structDeclaration.WithModifiers(structDeclaration.Modifiers.Add(partialKeyword));
			}

			return structDeclaration;
		}
Пример #6
0
        private static StructNode GetStructNode(StructDeclarationSyntax EachStruct)
        {
            StructNode structnode = new StructNode();
            structnode.Name = EachStruct.Identifier.ToString();
            // For each member in that class
            foreach (var member in EachStruct.Members)
            {
                if (member is FieldDeclarationSyntax)
                {
                    FieldDeclarationSyntax fd = member as FieldDeclarationSyntax;

                    foreach (var field in GetFieldNodes(fd))
                    {
                        structnode.Fields.Add(field);
                    }
                }
                else if (member is MethodDeclarationSyntax)
                {
                    MethodDeclarationSyntax method = member as MethodDeclarationSyntax;
                    structnode.Methods.Add(GetMethodNode(method));
                }
                else if (member is PropertyDeclarationSyntax)
                {
                    PropertyDeclarationSyntax property = member as PropertyDeclarationSyntax;
                    structnode.Properties.Add(GetPropertyNode(property));
                }
                else if (member is EventFieldDeclarationSyntax)
                {
                    EventFieldDeclarationSyntax evnt = member as EventFieldDeclarationSyntax;
                    structnode.Events.Add(GetEventNode(evnt));
                }
            }
            if (EachStruct.BaseList != null)
            {
                foreach (var baseType in EachStruct.BaseList.Types)
                {
                    structnode.Links.Add(baseType.ToString());
                }
            }
            return structnode;
        }
Пример #7
0
			public override void VisitStructDeclaration(StructDeclarationSyntax node)
			{
				base.VisitStructDeclaration(node);
				_types.Add(node);
			}
        private static SyntaxNode HandleStructDeclaration(StructDeclarationSyntax node)
        {
            SyntaxToken triviaToken = node.Keyword;
            if (triviaToken.IsMissing)
            {
                return null;
            }

            SyntaxKind defaultVisibility = IsNestedType(node) ? SyntaxKind.PrivateKeyword : SyntaxKind.InternalKeyword;
            SyntaxTokenList modifiers = DeclarationModifiersHelper.AddModifier(node.Modifiers, ref triviaToken, defaultVisibility);
            return node
                .WithKeyword(triviaToken)
                .WithModifiers(modifiers)
                .WithoutFormatting();
        }
 public override void VisitStructDeclaration(StructDeclarationSyntax node)
 {
     CheckXmlDocForErrors(node, semanticModel.GetDeclaredSymbol(node));
     base.VisitStructDeclaration(node);
 }
Пример #10
0
 public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
 {
     this.AppendCompileIssue(node, IssueType.Error, IssueId.StructNotSupport);
     return node;
 }
 public override void VisitStructDeclaration(StructDeclarationSyntax node)
 {
     AsParent(node, node.Identifier.Text, () => base.VisitStructDeclaration(node), node.Identifier.GetLocation());
 }
Пример #12
0
 /// <summary>
 /// Returns the full name of the given struct.
 /// </summary>
 /// <param name="node">SyntaxNode</param>
 /// <returns>string</returns>
 public string GetFullStructName(StructDeclarationSyntax node)
 {
     string name = node.Identifier.ValueText;
     return this.GetFullQualifierNameOfSyntaxNode(node) + name;
 }
Пример #13
0
        public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
        {
            node = (StructDeclarationSyntax)base.VisitStructDeclaration(node);
            var typeDeclKindKeyword = node.Keyword;

            if (transformKind == TransformKind.StructDeclToClassDecl)
            {
                var classToken = SyntaxFactory.Token(typeDeclKindKeyword.LeadingTrivia, SyntaxKind.ClassKeyword, typeDeclKindKeyword.TrailingTrivia);

                return SyntaxFactory.ClassDeclaration(node.AttributeLists, node.Modifiers, classToken, node.Identifier,
                    node.TypeParameterList, node.BaseList, node.ConstraintClauses, node.OpenBraceToken, node.Members, node.CloseBraceToken,
                    node.SemicolonToken);
            }

            return node;
        }
Пример #14
0
      public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax structnode)
      {
        return VisitTypeDeclaration(structnode);
        //#region CodeContracts
        //Contract.Ensures(invariantmethod != null);
        //Contract.Assume(structnode != null);
        //#endregion CodeContracts

        //var newmems = structnode.Members;
        //var text = String.Format("\n[ContractInvariantMethod]\nprivate void {0}ObjectInvariantMethod() {{}}\n", classnode.Identifier.ToString());
        //var comp = SyntaxFactory.ParseCompilationUnit(text);
        //var objinv = comp.Members[0];
        //newmems = newmems.Add(objinv);
        //var newclass = structnode.WithMembers(newmems);
        //invariantmethod = (MethodDeclarationSyntax) newclass.Members.Last();
        //return newclass; // do not descend into class
      }
        private void ProcStructDeclarationSyntax(StructDeclarationSyntax syntax, int indentCount)
        {
            writeIndents(indentCount);
            writer.Write("interface ");
            writer.Write(syntax.Identifier);
            writer.Write(" {\n");

            if (syntax.BaseList != null && syntax.BaseList.Types.Count > 0)
            {
                throw new Exception("Not supported");
            }

            foreach (var m in syntax.Members)
            {
                procMemberDeclarationSyntax(m, indentCount + 1);
            }

            writeIndents(indentCount);
            writer.Write("}\n");
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitStructDeclaration(StructDeclarationSyntax node)
 {
     this.OnNodeVisited(node, this.type.IsInstanceOfType(node));
     base.VisitStructDeclaration(node);
 }
Пример #17
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitStructDeclaration(StructDeclarationSyntax node)
 {
     this.OnNodeVisited(node);
     if (!this.traverseRootOnly) base.VisitStructDeclaration(node);
 }
Пример #18
0
		public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
		{
			return VisitMemberDeclaration(node, base.VisitStructDeclaration(node));
		}
        public override void VisitStructDeclaration(StructDeclarationSyntax node)
        {
            if (SkipInnerTypeDeclaration(node)) { return; }

            _inheritanceRelationsips.AddFrom(node);

            var typeName = TypeNameText.From(node);
            var name = typeName.Identifier;
            var typeParam = typeName.TypeArguments;

            WriteLine($"class {name}{typeParam} <<struct>> {{");

            nestingDepth++;
            base.VisitStructDeclaration(node);
            nestingDepth--;

            WriteLine("}");
        }
			public override void VisitStructDeclaration (StructDeclarationSyntax node)
			{
				VisitBody (node);
			}
Пример #21
0
 /// <summary>
 /// Traverse AST node that represents struct declaration
 /// </summary>
 /// <param name="node">AST node.</param>
 public override void VisitStructDeclaration(StructDeclarationSyntax node)
 {
     try
     {
         if (!node.Identifier.Span.IsEmpty)
         {
             var symbol = _sm.GetDeclaredSymbol(node);
             // Structs can also be partial
             if (!_defined.Contains(symbol))
             {
                 _defined.Add(symbol);
                 var def = Def.For(symbol: symbol, type: "struct", name: symbol.Name).At(_path, node.Identifier.Span);
                 if (symbol.IsExported())
                 {
                     def.Exported = true;
                 }
                 AddDef(def, DocProcessor.ForClass(symbol));
             }
         }
         base.VisitStructDeclaration(node);
     }
     catch (Exception e)
     {
     }
 }
Пример #22
0
        private StructNode GetStructNode(StructDeclarationSyntax EachStruct)
        {
            StructNode structnode = new StructNode();
            structnode.StructName = EachStruct.Identifier.ToString();
            // For each member in that class
            foreach (var member in EachStruct.Members)
            {
                if (member is FieldDeclarationSyntax)
                {
                    FieldDeclarationSyntax fd = member as FieldDeclarationSyntax;

                    foreach (var field in GetFieldNodes(fd))
                    {
                        structnode.Fields.Add(field);
                    }
                }
                else if (member is MethodDeclarationSyntax)
                {
                    MethodDeclarationSyntax method = member as MethodDeclarationSyntax;
                    structnode.Methods.Add(GetMethodNode(method));
                }
            }
            if (EachStruct.BaseList != null)
            {
                foreach (var baseType in EachStruct.BaseList.Types)
                {
                    structnode.Links.Add(baseType.ToString());
                }
            }
            return structnode;
        }
Пример #23
0
        private Struct TransverseStructs(StructDeclarationSyntax sds)
        {
            Struct retStruct = new Struct();
            //public List<Delegate> Delegates { get; set; }
            //public List<Method> FunctionDefs { get; set; }
            //public Inheritance Inheritance { get; set; }
            //public List<Module> Modules { get; set; }
            //public string Name { get; set; }
            //public List<Preprocessor> Preprocessors { get; set; }
            //public List<Property> Properties { get; set; }
            //public List<Union> Unions { get; set; }
            retStruct.Name = sds.Identifier.ValueText;
            if (sds.HasLeadingTrivia)
            {
                SetOuterComments(retStruct, sds.GetLeadingTrivia().ToFullString());
            }

            if (sds.HasTrailingTrivia)
            {
                SetInnerComments(retStruct, sds.GetTrailingTrivia().ToFullString());
            }

            foreach (SyntaxToken st in sds.Modifiers)
            {
                string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText);
                Encapsulation encap;
                Qualifiers qual;
                if (System.Enum.TryParse<Encapsulation>(modifier, out encap))
                {
                    retStruct.Encapsulation.Add(encap);
                }
                else if (System.Enum.TryParse<Qualifiers>(modifier, out qual))
                {
                    retStruct.Qualifiers.Add(qual);
                }
            }

            var enums = from aEnu in sds.ChildNodes().OfType<EnumDeclarationSyntax>() select aEnu;
            foreach (EnumDeclarationSyntax eds in enums)
            {
                retStruct.Enums.Add(TraverseEnums(eds));
            }

            var structs = from aStruct in sds.ChildNodes().OfType<StructDeclarationSyntax>() select aStruct;
            foreach (StructDeclarationSyntax sdecs in structs)
            {
                retStruct.Structs.Add(TransverseStructs(sdecs));
            }

            var methods = from aMethod in sds.ChildNodes().OfType<MethodDeclarationSyntax>() select aMethod;
            foreach (MethodDeclarationSyntax mds in methods)
            {
                retStruct.Methods.Add(TransverseMethods(mds));
            }

            var fields = from aField in sds.ChildNodes().OfType<FieldDeclarationSyntax>() select aField;
            foreach (FieldDeclarationSyntax fds in fields)
            {
                retStruct.Fields.Add(TransverseVariables(fds));
            }

            //var properties = from aProperty in sds.ChildNodes().OfType<PropertyDeclarationSyntax>() select aProperty;
            //foreach (PropertyDeclarationSyntax pds in properties)
            //{
            //    //traverse attributes
            //}

            var constructors = from aConstructor in sds.ChildNodes().OfType<ConstructorDeclarationSyntax>() select aConstructor;
            foreach (ConstructorDeclarationSyntax cods in constructors)
            {
                retStruct.Constructors.Add(TransverseConstructors(cods));
            }

            var destructors = from aDestructor in sds.ChildNodes().OfType<DestructorDeclarationSyntax>() select aDestructor;
            foreach (DestructorDeclarationSyntax dds in destructors)
            {
                retStruct.Destructors.Add(TransverseDestructors(dds));
            }

            var classes = from aClass in sds.ChildNodes().OfType<ClassDeclarationSyntax>() select aClass;
            foreach (ClassDeclarationSyntax sds2 in classes)
            {
                retStruct.Classes.Add(TraverseClass(sds2));
            }

            return retStruct;
        }
            public override void VisitStructDeclaration(StructDeclarationSyntax node)
            {
                var memberNames = GetMemberNames(node);

                foreach (var token in memberNames)
                    AddName(token);

                base.VisitStructDeclaration(node);

                foreach (var token in memberNames)
                    RemoveName(token);
            }
 public override void VisitStructDeclaration(Microsoft.CodeAnalysis.CSharp.Syntax.StructDeclarationSyntax node)
 {
     base.VisitStructDeclaration(node);
     Colorize(node.Identifier, valueTypeColor);
 }
 public override void VisitStructDeclaration(StructDeclarationSyntax node)
 {
     bool isUnsafe = CheckModifiers(node.Modifiers);
     base.VisitStructDeclaration(node);
     MarkUnsafe(node.Modifiers, isUnsafe);
 }
 private static StructDeclarationSyntax SortMembers(StructDeclarationSyntax type)
 {
     var innerMembers = type.Members.ToList();
     innerMembers.Sort(StyleCop.Sort);
     type = type.WithMembers(SyntaxFactory.List(innerMembers));
     return type;
 }
Пример #28
0
 public override void VisitStructDeclaration(StructDeclarationSyntax node)
 {
     sb.AppendLine(node.Keyword.ValueText + " " + node.Identifier.ValueText);
     base.VisitStructDeclaration(node);
 }
            public override void VisitStructDeclaration(StructDeclarationSyntax node)
            {
                Debug.Assert(currentScope == null);
                DeclarationScope saveStaticInitScope = staticInitScope;
                DeclarationScope saveInstanceInitScope = instanceInitScope;
                DeclarationScope savePrimaryConstructorInitializerScope = primaryConstructorInitializerScope;

                staticInitScope = new DeclarationScope(null);

                DeclarationScope primaryConstructorParametersScope;
                instanceInitScope = new DeclarationScope(GetPrimaryConstructorParametersScopeForInitializers(node, node.ParameterList, out primaryConstructorParametersScope));

                if (primaryConstructorParametersScope == instanceInitScope.Parent)
                {
                    primaryConstructorInitializerScope = new DeclarationScope(instanceInitScope);
                }
                else
                {
                    primaryConstructorInitializerScope = new DeclarationScope(primaryConstructorParametersScope);
                }

                base.VisitStructDeclaration(node);

                staticInitScope = saveStaticInitScope;
                instanceInitScope = saveInstanceInitScope;
                primaryConstructorInitializerScope = savePrimaryConstructorInitializerScope;
                Debug.Assert(currentScope == null);
            }
Пример #30
0
 public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
 {
     if (node == null)
         return null;
     var symbol = m_model.GetDeclaredSymbol(node);
     node = (StructDeclarationSyntax)base.VisitStructDeclaration(node);
     if (!IsPrivateOrInternal(symbol.DeclaredAccessibility))
         node = (StructDeclarationSyntax)ApplyDocComment(node, symbol.GetDocumentationCommentId());
     return node;
 }
Пример #31
0
 public void Add(StructDeclarationSyntax node)
 {
     //throw new NotImplementedException();
     // nothing technically to do here atm?
 }