Esempio n. 1
0
        /// <param name="cdgen">Can be null.</param>
        /// <param name="ctxt"></param>
        /// <param name="ac"></param>
        /// <param name="timeout">int.MinValue, if the param shall not be used</param>
        public static void DoTimeoutableCompletionTask(ICompletionDataGenerator cdgen, ResolutionContext ctxt, Action ac, int timeout = int.MinValue)
        {
            ctxt.CancelOperation = false;

            if (timeout == int.MinValue)
            {
                timeout = CompletionOptions.Instance.CompletionTimeout;
            }

            if (timeout < 0)
            {
                ac();
                return;
            }

            var task = Task.Factory.StartNew(ac);

            if (!task.Wait(timeout))
            {
                ctxt.CancelOperation = true;
                if (cdgen != null)
                {
                    cdgen.NotifyTimeout();
                }
                task.Wait();
            }
        }
Esempio n. 2
0
		/// <summary>
		/// Generates the completion data.
		/// </summary>
		/// <param name="alreadyCheckedCompletionContext">Set to <c>false</c> if you already ensured that completion can occur in the current editing context.</param>
		public static bool GenerateCompletionData(IEditorData editor, 
			ICompletionDataGenerator completionDataGen, char triggerChar, bool alreadyCheckedCompletionContext = false)
		{
			if(!alreadyCheckedCompletionContext && !IsCompletionAllowed(editor, triggerChar))
				return false;

			IBlockNode _b = null;
			bool inNonCode;

			var sr = FindCurrentCaretContext(editor, ref _b, out inNonCode);

			if (inNonCode)
				return false;

			if (_b == null || editor.CaretLocation > _b.EndLocation) {
				_b = editor.SyntaxTree;
			}

			var complVis = new CompletionProviderVisitor (completionDataGen, editor, triggerChar) { scopedBlock = _b };
			if (sr is INode)
				(sr as INode).Accept (complVis);
			else if (sr is IStatement)
				(sr as IStatement).Accept (complVis);
			else if (sr is IExpression)
				(sr as IExpression).Accept (complVis);

			if (complVis.GeneratedProvider == null)
				return false;

			complVis.GeneratedProvider.BuildCompletionData(editor, triggerChar);

			return true;
		}
        public static void AddFloatingTypeProperties(int TypeToken, ISemantic rr, ICompletionDataGenerator cdg, INode relatedNode = null, bool DontAddInitProperty = false)
        {
            var intType = new DTokenDeclaration(TypeToken);

            if (!DontAddInitProperty)
            {
                var prop_Init = new DVariable()
                {
                    Type        = intType,
                    Initializer = new PostfixExpression_Access()
                    {
                        PostfixForeExpression = new TokenExpression(TypeToken),
                        AccessExpression      = new IdentifierExpression("nan")
                    }
                };

                if (relatedNode != null)
                {
                    prop_Init.AssignFrom(relatedNode);
                }

                // Override the initializer variable's name and description
                prop_Init.Name        = "init";
                prop_Init.Description = "A type's or variable's static initializer expression";

                cdg.Add(prop_Init);
            }

            CreateArtificialProperties(FloatingTypeProps, cdg, intType);
        }
        public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.ImportBindings imbBind)
            : base(gen)
        {
            this.impBind = imbBind;
        }
 public ImportStatementCompletionProvider(
     ICompletionDataGenerator gen,
     ImportStatement.ImportBindings imbBind)
     : base(gen)
 {
     this.impBind = imbBind;
 }
Esempio n. 6
0
 public CtrlSpaceCompletionProvider(ICompletionDataGenerator cdg, IBlockNode b, MemberFilter vis = MemberFilter.All, params byte[] specialKeywords)
     : base(cdg)
 {
     this.curBlock        = b;
     visibleMembers       = vis;
     this.specialKeywords = specialKeywords;
 }
 public CtrlSpaceCompletionProvider(ICompletionDataGenerator cdg, IBlockNode b, IStatement stmt, MemberFilter vis = MemberFilter.All)
     : base(cdg)
 {
     this.curBlock  = b;
     this.curStmt   = stmt;
     visibleMembers = vis;
 }
 public CompletionProviderVisitor(ICompletionDataGenerator cdg, IEditorData ed, char enteredChar = '\0')
 {
     this.ed          = ed;
     this.cdgen       = cdg;
     this.triggerChar = enteredChar;
     this.shownKeywords.Push(BlockMemberFilter);
 }
        public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.Import imp)
            : base(gen)
        {
            this.imp = imp;
        }
 public ImportStatementCompletionProvider(
     ICompletionDataGenerator gen,
     ImportStatement.Import imp)
     : base(gen)
 {
     this.imp = imp;
 }
        /// <summary>
        /// Adds init, max, min to the completion list
        /// </summary>
        public static void AddIntegralTypeProperties(int TypeToken, ISemantic rr, ICompletionDataGenerator cdg, INode relatedNode = null, bool DontAddInitProperty = false)
        {
            var intType = new DTokenDeclaration(TypeToken);

            if (!DontAddInitProperty)
            {
                var prop_Init = new DVariable()
                {
                    Type = intType, Initializer = new IdentifierExpression(0, LiteralFormat.Scalar)
                };

                if (relatedNode != null)
                {
                    prop_Init.AssignFrom(relatedNode);
                }

                // Override the initializer variable's name and description
                prop_Init.Name        = "init";
                prop_Init.Description = "A type's or variable's static initializer expression";

                cdg.Add(prop_Init);
            }

            CreateArtificialProperties(IntegralProps, cdg, intType);
        }
Esempio n. 12
0
 public MemberCompletionProvider(ICompletionDataGenerator cdg, ISyntaxRegion sr, IBlockNode b, IStatement stmt)
     : base(cdg)
 {
     AccessExpression = sr;
     ScopedBlock = b;
     ScopedStatement = stmt;
 }
        public static void EnumChildren(ICompletionDataGenerator cdgen,ResolutionContext ctxt, UserDefinedType udt, bool isVarInstance, 
			MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums)
        {
            var scan = new MemberCompletionEnumeration(ctxt, cdgen) { isVarInst = isVarInstance };

            scan.DeepScanClass(udt, vis);
        }
		public CompletionProviderVisitor(ICompletionDataGenerator cdg, IEditorData ed, char enteredChar = '\0')
		{
			this.ed = ed;
			this.cdgen = cdg;
			this.triggerChar = enteredChar;
			this.shownKeywords.Push(BlockMemberFilter);
		}
 public CtrlSpaceCompletionProvider(ICompletionDataGenerator cdg, IBlockNode b, IStatement stmt, MemberFilter vis = MemberFilter.All)
     : base(cdg)
 {
     this.curBlock = b;
     this.curStmt = stmt;
     visibleMembers = vis;
 }
        public static void EnumChildren(ICompletionDataGenerator cdgen,ResolutionContext ctxt, IBlockNode block, bool isVarInstance,
			MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums, bool publicImports = false)
        {
            var scan = new MemberCompletionEnumeration(ctxt, cdgen) { isVarInst = isVarInstance };

            scan.ScanBlock(block, CodeLocation.Empty, vis, publicImports);
        }
        public static AbstractCompletionProvider BuildCompletionData(ICompletionDataGenerator dataGen, IEditorData editor, string EnteredText)
        {
            var provider = Create(dataGen, editor, EnteredText);

            if (provider != null)
                provider.BuildCompletionData(editor, EnteredText);

            return provider;
        }
        public static void EnumChildren(ICompletionDataGenerator cdgen,ResolutionContext ctxt, UserDefinedType udt, 
			MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums)
        {
            vis ^= MemberFilter.TypeParameters;

            var scan = new MemberCompletionEnumeration(ctxt, cdgen) { isVarInst = udt.NonStaticAccess };

            scan.DeepScanClass(udt, vis);
        }
Esempio n. 19
0
 public static void ListProperties(ICompletionDataGenerator gen, MemberFilter vis, AbstractType t, bool isVariableInstance)
 {
     foreach (var n in ListProperties(t, !isVariableInstance))
     {
         if (AbstractVisitor.CanAddMemberOfType(vis, n))
         {
             gen.Add(n);
         }
     }
 }
Esempio n. 20
0
        public static void EnumChildren(ICompletionDataGenerator cdgen, ResolutionContext ctxt, UserDefinedType udt, bool isVarInstance,
                                        MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums)
        {
            var scan = new MemberCompletionEnumeration(ctxt, cdgen)
            {
                isVarInst = isVarInstance
            };

            scan.DeepScanClass(udt, vis);
        }
Esempio n. 21
0
        public static void EnumChildren(ICompletionDataGenerator cdgen, ResolutionContext ctxt, IBlockNode block, bool isVarInstance,
                                        MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums, bool publicImports = false)
        {
            var scan = new MemberCompletionEnumeration(ctxt, cdgen)
            {
                isVarInst = isVarInstance
            };

            scan.ScanBlock(block, CodeLocation.Empty, vis, publicImports);
        }
            public StructVis(TemplateIntermediateType structType,List<int> tkn,ICompletionDataGenerator gen,ResolutionContext ctxt)
                : base(ctxt)
            {
                this.alreadyTakenNames = tkn;
                this.gen = gen;

                if (CompletionOptions.Instance.ShowStructMembersInStructInitOnly)
                    this.DeepScanClass(structType, MemberFilter.Variables, false);
                else
                    IterateThroughScopeLayers(CodeLocation.Empty, MemberFilter.All);
            }
Esempio n. 23
0
            public static void AddArrayProperties(ResolveResult rr, ICompletionDataGenerator cdg, ArrayDecl ArrayDecl = null)
            {
                CreateArtificialProperties(ArrayProps, cdg, ArrayDecl);

                cdg.Add(new DVariable
                {
                    Name        = "ptr",
                    Description = "Returns pointer to the array",
                    Type        = new PointerDecl(ArrayDecl == null ? new DTokenDeclaration(DTokens.Void) : ArrayDecl.ValueType)
                });
            }
        public static void AddArrayProperties(ISemantic rr, ICompletionDataGenerator cdg, ArrayDecl ArrayDecl = null)
        {
            CreateArtificialProperties(ArrayProps, cdg, ArrayDecl);

            cdg.Add(new DVariable
            {
                Name = "ptr",
                Description = "Returns pointer to the array",
                Type = new PointerDecl(ArrayDecl == null ? new DTokenDeclaration(DTokens.Void) : ArrayDecl.ValueType)
            });
        }
        public static AbstractCompletionProvider BuildCompletionData(ICompletionDataGenerator dataGen, IEditorData editor, string EnteredText)
        {
            var provider = Create(dataGen, editor, EnteredText);

            if (provider != null)
            {
                provider.BuildCompletionData(editor, EnteredText);
            }

            return(provider);
        }
Esempio n. 26
0
 public static void Generate(ISemantic rr, ResolutionContext ctxt, IEditorData ed, ICompletionDataGenerator gen)
 {
     if(ed.ParseCache!=null)
         foreach (var pc in ed.ParseCache)
             if (pc != null && pc.UfcsCache != null && pc.UfcsCache.CachedMethods != null)
             {
                 var r=pc.UfcsCache.FindFitting(ctxt, ed.CaretLocation, rr);
                 if(r!=null)
                     foreach (var m in r)
                         gen.Add(m);
             }
 }
        public static void EnumChildren(ICompletionDataGenerator cdgen, ResolutionContext ctxt, UserDefinedType udt,
                                        MemberFilter vis = MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.Enums)
        {
            vis ^= MemberFilter.TypeParameters;

            var scan = new MemberCompletionEnumeration(ctxt, cdgen)
            {
                isVarInst = udt.NonStaticAccess
            };

            scan.DeepScanClass(udt, vis);
        }
Esempio n. 28
0
        /// <summary>
        /// Generates the completion data.
        /// </summary>
        /// <param name="alreadyCheckedCompletionContext">Set to <c>false</c> if you already ensured that completion can occur in the current editing context.</param>
        public static bool GenerateCompletionData(IEditorData editor,
                                                  ICompletionDataGenerator completionDataGen, char triggerChar, bool alreadyCheckedCompletionContext = false)
        {
            if (!alreadyCheckedCompletionContext && !IsCompletionAllowed(editor, triggerChar))
            {
                return(false);
            }

            IBlockNode _b = null;
            IStatement _s;
            bool       inNonCode;

            var sr = FindCurrentCaretContext(editor, ref _b, out _s, out inNonCode);

            if (inNonCode)
            {
                return(false);
            }

            if (editor.CaretLocation > _b.EndLocation)
            {
                _b = editor.SyntaxTree;
                _s = null;
            }

            var complVis = new CompletionProviderVisitor(completionDataGen, triggerChar)
            {
                scopedBlock = _b, scopedStatement = _s
            };

            if (sr is INode)
            {
                (sr as INode).Accept(complVis);
            }
            else if (sr is IStatement)
            {
                (sr as IStatement).Accept(complVis);
            }
            else if (sr is IExpression)
            {
                (sr as IExpression).Accept(complVis);
            }

            if (complVis.GeneratedProvider == null)
            {
                return(false);
            }

            complVis.GeneratedProvider.BuildCompletionData(editor, triggerChar);

            return(true);
        }
        public static void EnumAllAvailableMembers(ICompletionDataGenerator cdgen, IBlockNode ScopedBlock
			, IStatement ScopedStatement,
			CodeLocation Caret,
		    ParseCacheView CodeCache,
			MemberFilter VisibleMembers,
			ConditionalCompilationFlags compilationEnvironment = null)
        {
            var ctxt = ResolutionContext.Create(CodeCache, compilationEnvironment, ScopedBlock, ScopedStatement);

            var en = new MemberCompletionEnumeration(ctxt, cdgen) {isVarInst = true};

            en.IterateThroughScopeLayers(Caret, VisibleMembers);
        }
Esempio n. 30
0
            // Associative Arrays' properties have to be inserted manually

            static void CreateArtificialProperties(StaticProperty[] Properties, ICompletionDataGenerator cdg, ITypeDeclaration DefaultPropType = null)
            {
                foreach (var prop in Properties)
                {
                    var p = new DVariable()
                    {
                        Name        = prop.Name,
                        Description = prop.Description,
                        Type        = prop.OverrideType != null ? prop.OverrideType : DefaultPropType
                    };

                    cdg.Add(p);
                }
            }
Esempio n. 31
0
        /// <summary>
        /// Generates the completion data.
        /// </summary>
        /// <param name="checkForCompletionAllowed">Set to <c>false</c> if you already ensured that completion can occur in the current editing context.</param>
        public static bool GenerateCompletionData(IEditorData editor, 
			ICompletionDataGenerator completionDataGen, char triggerChar, bool alreadyCheckedCompletionContext = false)
        {
            if(!alreadyCheckedCompletionContext && !IsCompletionAllowed(editor, triggerChar))
                return false;

            var provider = AbstractCompletionProvider.Create(completionDataGen, editor, triggerChar);

            if (provider == null)
                return false;

            provider.BuildCompletionData(editor, triggerChar);

            return true;
        }
            public StructVis(TemplateIntermediateType structType, List <int> tkn, ICompletionDataGenerator gen, ResolutionContext ctxt)
                : base(ctxt)
            {
                this.alreadyTakenNames = tkn;
                this.gen = gen;

                if (CompletionOptions.Instance.ShowStructMembersInStructInitOnly)
                {
                    this.DeepScanClass(structType, MemberFilter.Variables, false);
                }
                else
                {
                    IterateThroughScopeLayers(CodeLocation.Empty, MemberFilter.All);
                }
            }
Esempio n. 33
0
        public static void EnumAllAvailableMembers(ICompletionDataGenerator cdgen, IBlockNode ScopedBlock
                                                   , IStatement ScopedStatement,
                                                   CodeLocation Caret,
                                                   ParseCacheView CodeCache,
                                                   MemberFilter VisibleMembers,
                                                   ConditionalCompilationFlags compilationEnvironment = null)
        {
            var ctxt = ResolutionContext.Create(CodeCache, compilationEnvironment, ScopedBlock, ScopedStatement);

            var en = new MemberCompletionEnumeration(ctxt, cdgen)
            {
                isVarInst = true
            };

            en.IterateThroughScopeLayers(Caret, VisibleMembers);
        }
Esempio n. 34
0
        /// <summary>
        /// Generates the completion data.
        /// </summary>
        /// <param name="checkForCompletionAllowed">Set to <c>false</c> if you already ensured that completion can occur in the current editing context.</param>
        public static bool GenerateCompletionData(IEditorData editor,
                                                  ICompletionDataGenerator completionDataGen, char triggerChar, bool alreadyCheckedCompletionContext = false)
        {
            if (!alreadyCheckedCompletionContext && !IsCompletionAllowed(editor, triggerChar))
            {
                return(false);
            }

            var provider = AbstractCompletionProvider.Create(completionDataGen, editor, triggerChar);

            if (provider == null)
            {
                return(false);
            }

            provider.BuildCompletionData(editor, triggerChar);

            return(true);
        }
Esempio n. 35
0
            /// <summary>
            /// Adds init, sizeof, alignof, mangleof, stringof to the completion list
            /// </summary>
            public static void AddGenericProperties(ResolveResult rr, ICompletionDataGenerator cdg, INode relatedNode = null, bool DontAddInitProperty = false)
            {
                if (!DontAddInitProperty)
                {
                    var prop_Init = new DVariable();

                    if (relatedNode != null)
                    {
                        prop_Init.AssignFrom(relatedNode);
                    }

                    // Override the initializer variable's name and description
                    prop_Init.Name        = "init";
                    prop_Init.Description = "A type's or variable's static initializer expression";

                    cdg.Add(prop_Init);
                }

                CreateArtificialProperties(GenericProps, cdg);
            }
        /// <summary>
        /// Adds init, sizeof, alignof, mangleof, stringof to the completion list
        /// </summary>
        public static void AddGenericProperties(ISemantic rr, ICompletionDataGenerator cdg, INode relatedNode = null, bool DontAddInitProperty = false)
        {
            if (!DontAddInitProperty)
            {
                var prop_Init = new DVariable();

                if (relatedNode != null)
                    prop_Init.AssignFrom(relatedNode);

                // Override the initializer variable's name and description
                prop_Init.Name = "init";
                prop_Init.Description = "A type's or variable's static initializer expression";

                cdg.Add(prop_Init);
            }

            CreateArtificialProperties(GenericProps, cdg);
        }
 public LabelVisitor(ICompletionDataGenerator gen)
 {
     this.gen = gen;
 }
Esempio n. 38
0
 public static void ListProperties(ICompletionDataGenerator gen, ResolutionContext ctxt, MemberFilter vis, AbstractType t, bool isVariableInstance)
 {
     foreach (var n in ListProperties(t, ctxt, !isVariableInstance))
         if (AbstractVisitor.CanAddMemberOfType(vis, n))
             gen.Add(n);
 }
 protected MemberCompletionEnumeration(ResolutionContext ctxt, ICompletionDataGenerator gen)
     : base(ctxt)
 {
     this.gen = gen;
 }
		public CtrlSpaceCompletionProvider(ICompletionDataGenerator cdg) : base(cdg) { }
Esempio n. 41
0
 public AttributeCompletionProvider(DAttribute attr, ICompletionDataGenerator gen) : base(gen)
 {
     this.Attribute = attr;
 }
Esempio n. 42
0
        //public TraitsExpression TraitsExpr;

        public TraitsExpressionCompletionProvider(ICompletionDataGenerator gen) : base(gen)
        {
        }
Esempio n. 43
0
 public static void AddClassTypeProperties(ICompletionDataGenerator cdg, INode relatedNode = null)
 {
     CreateArtificialProperties(ClassTypeProps, cdg);
 }
Esempio n. 44
0
 public InlineAsmCompletionProvider(AbstractStatement gs, ICompletionDataGenerator gen) : base(gen)
 {
     this.gs = gs;
 }
Esempio n. 45
0
 public AbstractCompletionSupport(ICompletionDataGenerator CompletionDataGenerator)
 {
     this.CompletionDataGenerator = CompletionDataGenerator;
 }
 public PropertyAttributeCompletionProvider(ICompletionDataGenerator cdg)
     : base(cdg)
 {
 }
Esempio n. 47
0
 public VersionSpecificationCompletionProvider(ICompletionDataGenerator gen) : base(gen)
 {
 }
        /// <summary>
        /// Adds init, max, min to the completion list
        /// </summary>
        public static void AddIntegralTypeProperties(int TypeToken, ISemantic rr, ICompletionDataGenerator cdg, INode relatedNode = null, bool DontAddInitProperty = false)
        {
            var intType = new DTokenDeclaration(TypeToken);

            if (!DontAddInitProperty)
            {
                var prop_Init = new DVariable() { Type = intType, Initializer = new IdentifierExpression(0, LiteralFormat.Scalar) };

                if (relatedNode != null)
                    prop_Init.AssignFrom(relatedNode);

                // Override the initializer variable's name and description
                prop_Init.Name = "init";
                prop_Init.Description = "A type's or variable's static initializer expression";

                cdg.Add(prop_Init);
            }

            CreateArtificialProperties(IntegralProps, cdg, intType);
        }
        // Associative Arrays' properties have to be inserted manually
        static void CreateArtificialProperties(StaticProperty[] Properties, ICompletionDataGenerator cdg, ITypeDeclaration DefaultPropType = null)
        {
            foreach (var prop in Properties)
            {
                var p = new DVariable()
                {
                    Name = prop.Name,
                    Description = prop.Description,
                    Type = prop.OverrideType != null ? prop.OverrideType : DefaultPropType
                };

                cdg.Add(p);
            }
        }
Esempio n. 50
0
            public static void AddAssocArrayProperties(ResolveResult rr, ICompletionDataGenerator cdg, ArrayDecl ad)
            {
                var ll = new List <INode>();

                ll.Add(new DVariable()
                {
                    Name        = "sizeof",
                    Description = "Returns the size of the reference to the associative array; it is typically 8.",
                    Type        = new IdentifierDeclaration("size_t"),
                    Initializer = new IdentifierExpression(8, LiteralFormat.Scalar)
                });

                /*ll.Add(new DVariable() {
                 *      Name="length",
                 *      Description="Returns number of values in the associative array. Unlike for dynamic arrays, it is read-only.",
                 *      Type=new IdentifierDeclaration("size_t")
                 * });*/

                if (ad != null)
                {
                    ll.Add(new DVariable()
                    {
                        Name        = "keys",
                        Description = "Returns dynamic array, the elements of which are the keys in the associative array.",
                        Type        = new ArrayDecl()
                        {
                            ValueType = ad.KeyType
                        }
                    });

                    ll.Add(new DVariable()
                    {
                        Name        = "values",
                        Description = "Returns dynamic array, the elements of which are the values in the associative array.",
                        Type        = new ArrayDecl()
                        {
                            ValueType = ad.ValueType
                        }
                    });

                    ll.Add(new DVariable()
                    {
                        Name        = "rehash",
                        Description = "Reorganizes the associative array in place so that lookups are more efficient. rehash is effective when, for example, the program is done loading up a symbol table and now needs fast lookups in it. Returns a reference to the reorganized array.",
                        Type        = ad
                    });

                    ll.Add(new DVariable()
                    {
                        Name        = "byKey",
                        Description = "Returns a delegate suitable for use as an Aggregate to a ForeachStatement which will iterate over the keys of the associative array.",
                        Type        = new DelegateDeclaration()
                        {
                            ReturnType = new ArrayDecl()
                            {
                                ValueType = ad.KeyType
                            }
                        }
                    });

                    ll.Add(new DVariable()
                    {
                        Name        = "byValue",
                        Description = "Returns a delegate suitable for use as an Aggregate to a ForeachStatement which will iterate over the values of the associative array.",
                        Type        = new DelegateDeclaration()
                        {
                            ReturnType = new ArrayDecl()
                            {
                                ValueType = ad.ValueType
                            }
                        }
                    });

                    ll.Add(new DMethod()
                    {
                        Name        = "get",
                        Description = "Looks up key; if it exists returns corresponding value else evaluates and returns defaultValue.",
                        Type        = ad.ValueType,
                        Parameters  = new List <INode> {
                            new DVariable()
                            {
                                Name = "key",
                                Type = ad.KeyType
                            },
                            new DVariable()
                            {
                                Name       = "defaultValue",
                                Type       = ad.ValueType,
                                Attributes = new List <DAttribute> {
                                    new DAttribute(DTokens.Lazy)
                                }
                            }
                        }
                    });
                }

                foreach (var prop in ll)
                {
                    cdg.Add(prop);
                }
            }
        public static void AddAssocArrayProperties(ISemantic rr, ICompletionDataGenerator cdg, ArrayDecl ad)
        {
            var ll = new List<INode>();

            /*ll.Add(new DVariable()
            {
                Name = "sizeof",
                Description = "Returns the size of the reference to the associative array; it is typically 8.",
                Type = new IdentifierDeclaration("size_t"),
                Initializer = new IdentifierExpression(8, LiteralFormat.Scalar)
            });*/

            ll.Add(new DVariable() {
                Name="length",
                Description="Returns number of values in the associative array. Unlike for dynamic arrays, it is read-only.",
                Type = new IdentifierDeclaration("size_t"),
                Initializer= ad!=null? ad.KeyExpression : null
            });

            if (ad != null)
            {
                ll.Add(new DVariable()
                {
                    Name = "keys",
                    Description = "Returns dynamic array, the elements of which are the keys in the associative array.",
                    Type = new ArrayDecl() { ValueType = ad.KeyType }
                });

                ll.Add(new DVariable()
                {
                    Name = "values",
                    Description = "Returns dynamic array, the elements of which are the values in the associative array.",
                    Type = new ArrayDecl() { ValueType = ad.ValueType }
                });

                ll.Add(new DVariable()
                {
                    Name = "rehash",
                    Description = "Reorganizes the associative array in place so that lookups are more efficient. rehash is effective when, for example, the program is done loading up a symbol table and now needs fast lookups in it. Returns a reference to the reorganized array.",
                    Type = ad
                });

                ll.Add(new DVariable()
                {
                    Name = "byKey",
                    Description = "Returns a delegate suitable for use as an Aggregate to a ForeachStatement which will iterate over the keys of the associative array.",
                    Type = new DelegateDeclaration() { ReturnType = new ArrayDecl() { ValueType = ad.KeyType } }
                });

                ll.Add(new DVariable()
                {
                    Name = "byValue",
                    Description = "Returns a delegate suitable for use as an Aggregate to a ForeachStatement which will iterate over the values of the associative array.",
                    Type = new DelegateDeclaration() { ReturnType = new ArrayDecl() { ValueType = ad.ValueType } }
                });

                ll.Add(new DMethod()
                {
                    Name = "get",
                    Description = "Looks up key; if it exists returns corresponding value else evaluates and returns defaultValue.",
                    Type = ad.ValueType,
                    Parameters = new List<INode> {
                        new DVariable(){
                            Name="key",
                            Type=ad.KeyType
                        },
                        new DVariable(){
                            Name="defaultValue",
                            Type=ad.ValueType,
                            Attributes=new List<DAttribute>{ new DAttribute(DTokens.Lazy)}
                        }
                    }
                });
            }

            foreach (var prop in ll)
                cdg.Add(prop);
        }
 //public TraitsExpression TraitsExpr;
 public TraitsExpressionCompletionProvider(ICompletionDataGenerator gen)
     : base(gen)
 {
 }
		public SelectiveImportCompletionProvider(ICompletionDataGenerator gen, ImportStatement.Import imp) : base(gen) {
			import = imp;
		}
 public StructInitializerCompletion(ICompletionDataGenerator gen, DVariable initializedVariable, StructInitializer init) : base(gen)
 {
     this.initedVar = initializedVariable;
     this.init      = init;
 }
 public CtrlSpaceCompletionProvider(ICompletionDataGenerator cdg) : base(cdg)
 {
 }
Esempio n. 56
0
        //public ScopeGuardStatement ScopeStmt;

        public ScopeAttributeCompletionProvider(ICompletionDataGenerator gen) : base(gen)
        {
        }
 public static void AddClassTypeProperties(ICompletionDataGenerator cdg, INode relatedNode = null)
 {
     CreateArtificialProperties(ClassTypeProps, cdg);
 }
        public static void AddFloatingTypeProperties(int TypeToken, ISemantic rr, ICompletionDataGenerator cdg, INode relatedNode = null, bool DontAddInitProperty = false)
        {
            var intType = new DTokenDeclaration(TypeToken);

            if (!DontAddInitProperty)
            {
                var prop_Init = new DVariable() {
                    Type = intType,
                    Initializer = new PostfixExpression_Access() {
                        PostfixForeExpression = new TokenExpression(TypeToken),
                        AccessExpression = new IdentifierExpression("nan")
                    }
                };

                if (relatedNode != null)
                    prop_Init.AssignFrom(relatedNode);

                // Override the initializer variable's name and description
                prop_Init.Name = "init";
                prop_Init.Description = "A type's or variable's static initializer expression";

                cdg.Add(prop_Init);
            }

            CreateArtificialProperties(FloatingTypeProps, cdg, intType);
        }
 public AttributeCompletionProvider(ICompletionDataGenerator gen)
     : base(gen)
 {
 }
		public MemberCompletionProvider(ICompletionDataGenerator cdg) : base(cdg) { }