Ejemplo n.º 1
0
        protected override object VisitMethodDeclaration(MethodDeclarationSyntax node)
        {
            // FunctionDeclarationParameter[] Parameters;
            var doc = DeclarationItemDescription.Parse(node);
            //if (doc != null)
            //    throw new NotSupportedException();


            var methodSymbol = (IMethodSymbol)ModelExtensions.GetDeclaredSymbol(context.RoslynModel, node);


            var mi = context.Roslyn_ResolveMethod(methodSymbol) as MethodInfo;

            if (mi == null)
            {
                throw new NotSupportedException();
            }

#warning 'Zarejestrować nazwy parametrów'
            var body = Visit(node.Body) as IStatement;


            return(new MethodDeclaration(mi, body));

#if OLD
            Parameters = rVisit(methodSymbol.Parameters.AsEnumerable());

            //var rrt = methodSymbol.ReturnType;
            //var aaaa = context.RoslynCompilation.GetTypeByMetadataName(rrt.Name);
            //var fullTypeName = methodSymbol.ReturnType.ToDisplayString();
            //// LangType rt = new LangType();
            //var hhh = methodSymbol.Parameters.ToArray();

            var name = _Name(node.Identifier);
            var mod  = VisitModifiers(node.Modifiers);
            var rt   = _ResolveLangType(node.ReturnType);


            //var p1 = Visit(node.ParameterList);
            //   var Parameters = Visit(node.ParameterList) as FunctionDeclarationParameter[];


            var old = context.Arguments.ToArray();
            context.Arguments.AddRange(Parameters);



            context.Arguments = old.ToList();

            return(new MethodDeclaration(
                       name,
                       mod,
                       rt,
                       Parameters,
                       body));

            throw new NotImplementedException();
#endif
        }
Ejemplo n.º 2
0
        protected override object VisitConversionOperatorDeclaration(ConversionOperatorDeclarationSyntax node)
        {
            var doc          = DeclarationItemDescription.Parse(node);
            var methodSymbol = (IMethodSymbol)ModelExtensions.GetDeclaredSymbol(context.RoslynModel, node);

            var mi = context.Roslyn_ResolveMethod(methodSymbol) as MethodInfo;

            if (mi == null)
            {
                throw new NotSupportedException();
            }

#warning 'Zarejestrować nazwy parametrów'
            var body = Visit(node.Body) as IStatement;

            return(new MethodDeclaration(mi, body));
        }
Ejemplo n.º 3
0
        protected override object VisitPropertyDeclaration(PropertyDeclarationSyntax node)
        {
            var info   = ModelExtensions.GetSymbolInfo(context.RoslynModel, node.Type);
            var symbol = info.Symbol as ITypeSymbol;

            if (symbol == null)
            {
                throw new NotSupportedException();
            }
            var tt = context.Roslyn_ResolveType(symbol);

            var propertyName = _Name(node.Identifier);
            var mod          = VisitModifiers(node.Modifiers);
            var accessors    = node.AccessorList.Accessors.Select(i => Visit(i) as CsharpPropertyDeclarationAccessor).ToArray();
            var type         = _ResolveLangType(node.Type);

            var doc         = DeclarationItemDescription.Parse(node);
            var declaration = new CsharpPropertyDeclaration(propertyName, type, accessors, mod, doc);

            return(declaration);
        }