示例#1
0
 public AstImport(Source src, AstExpression importer, IReadOnlyList <AstArgument> args = null)
     : base(src)
 {
     Importer  = importer;
     Arguments = args;
 }
        bool TrySuggestMembers(FunctionCompiler fc, Expression dte, bool includeBlocks)
        {
            var pe = fc.ResolveExpression(dte, null);

            fc.Compiler.AstProcessor.Process();

            if (pe != null)
            {
                var extensionTypeMethods = FindAllExtensionTypeMethods(fc, dte.Source);
                switch (pe.ExpressionType)
                {
                case PartialExpressionType.Namespace: SuggestNamespaceMembers((pe as PartialNamespace).Namespace, includeBlocks); break;

                case PartialExpressionType.Type: SuggestTypeMembers((pe as PartialType).Type, AccessorLevel.Unknown, true, includeBlocks, true, extensionTypeMethods); break;

                case PartialExpressionType.Block: SuggestBlockItems((pe as PartialBlock).Block); break;

                case PartialExpressionType.Variable: SuggestTypeMembers((pe as PartialVariable).Variable.ValueType, AccessorLevel.Unknown, false, false, true, extensionTypeMethods); break;

                case PartialExpressionType.Parameter: SuggestTypeMembers((pe as PartialParameter).Function.Match(f => f.Parameters, l => l.Parameters)[(pe as PartialParameter).Index].Type, AccessorLevel.Unknown, false, false, true, extensionTypeMethods); break;

                case PartialExpressionType.Field: SuggestTypeMembers((pe as PartialField).Field.ReturnType, AccessorLevel.Unknown, false, false, true, extensionTypeMethods); break;

                case PartialExpressionType.Event: break;

                case PartialExpressionType.Property: SuggestTypeMembers((pe as PartialProperty).Property.ReturnType, AccessorLevel.Unknown, false, false, true, extensionTypeMethods); break;

                case PartialExpressionType.Indexer: SuggestTypeMembers((pe as PartialIndexer).Indexer.ReturnType, AccessorLevel.Unknown, false, false, true, extensionTypeMethods); break;

                case PartialExpressionType.ArrayElement: SuggestTypeMembers((pe as PartialArrayElement).ElementType, AccessorLevel.Unknown, false, false, true, extensionTypeMethods); break;

                case PartialExpressionType.MethodGroup: break;

                case PartialExpressionType.This:
                {
                    if (fc.Function != null && fc.Function.DeclaringType != null)
                    {
                        SuggestTypeMembers(fc.Function.DeclaringType, AccessorLevel.Private, fc.Function.IsStatic, false, true, extensionTypeMethods);
                    }
                }
                break;

                case PartialExpressionType.Value:
                {
                    SuggestTypeMembers((pe as PartialValue).Value.ReturnType, AccessorLevel.Unknown, false, false, true, extensionTypeMethods);

                    if (dte.ExpressionType == ExpressionType.Identifier)
                    {
                        var lastNamescope = Enumerable.Last(_context.NodePath).TypeOrNamespace;
                        if (lastNamescope != null)
                        {
                            var identifier = dte as AstIdentifier;
                            var pt         = _context.Compiler.NameResolver.TryResolveMemberRecursive(lastNamescope, identifier, null);
                            if (pt == null)
                            {
                                pt = _context.Compiler.NameResolver.TryResolveUsingNamespace(lastNamescope, identifier, null);
                            }
                            if (pt is PartialType)
                            {
                                SuggestTypeMembers((pt as PartialType).Type, AccessorLevel.Public, true, true, true, extensionTypeMethods);
                            }
                        }
                    }
                }
                break;

                default: return(false);
                }
                return(true);
            }

            return(false);
        }
示例#3
0
 public AstFixedArrayInitializer(Source src, AstExpression optionalElementType, AstExpression optionalSize,
                                 IReadOnlyList <AstExpression> optionalValues = null)
     : base(src)
 {
     OptionalElementType = optionalElementType;
     OptionalSize        = optionalSize;
     OptionalValues      = optionalValues;
 }