Exemplo n.º 1
0
        private IEnumerable <CodeCompletion> SearchWithoutType(Group search, int offset)
        {
            var lowerSearch = search.Value.ToLower();
            var variables   = from i in RexHelper.Variables
                              let lowerItem = i.Key.ToLower()
                                              where lowerItem.Contains(lowerSearch)
                                              select new
            {
                SearchName        = lowerItem,
                IsNested          = false,
                ReplacementString = i.Key,
                Details           = new MemberDetails(i.Value.VarValue,
                                                      RexUtils.GetCSharpRepresentation(i.Value.VarType, false).Concat(new[] {
                    Syntax.Space, Syntax.Name(i.Key),
                    Syntax.Space, Syntax.EqualsOp,
                    Syntax.Space
                }).Concat(RexReflectionUtils.GetSyntaxForValue(i.Value.VarValue))),
                isInScope = true
            };

            var types = from type in RexUtils.AllVisibleTypes
                        let lowerItem = type.Name.ToLower()
                                        where lowerItem.Contains(lowerSearch) && !RexReflectionUtils.IsCompilerGenerated(type)
                                        let isInScope = RexCompileEngine.Instance.NamespaceInfos.Any(i => i.Name == type.Namespace && i.Selected)
                                                        select new
            {
                SearchName = lowerItem,
                type.IsNested,
                ReplacementString = GetNestedName(type),
                Details           = RexUtils.GetCSharpRepresentation(type),
                isInScope
            };

            return(from i in types.Concat(variables)
                   orderby i.SearchName.IndexOf(lowerSearch), i.SearchName.Length, i.isInScope, i.IsNested
                   select new CodeCompletion
            {
                Details = i.Details,
                Start = offset,
                End = offset + search.Length - 1,
                ReplaceString = i.ReplacementString,                           //.Details.Name.String,
                Search = search.Value,
                IsInScope = i.isInScope
            });
        }
        /// <summary>
        /// Displays a single variable, returns true if the varible was deleted else false.
        /// </summary>
        /// <param name="VarName">Name of the var. (key of the <see cref="RexHelper.Variables"/>)</param>
        /// <param name="var">The varible to display. (Value of the <see cref="RexHelper.Variables"/>)</param>
        private bool DisplayVariable(string VarName, RexHelper.Variable var)
        {
            string highlightedString;

            var type = RexUtils.GetCSharpRepresentation(var.VarType);

            // Format the code for syntax highlighting using richtext.
            highlightedString = RexUIUtils.SyntaxHighlingting(type.Concat(new[] {
                Syntax.Space, Syntax.Name(VarName), Syntax.Space, Syntax.EqualsOp, Syntax.Space
            }).Concat(RexReflectionUtils.GetSyntaxForValue(var.VarValue)));

            var shouldDelete = GUILayout.Button(_texts.GetText("remove_variable", tooltipFormat: VarName), GUILayout.Width(20));

            // Draw the button as a label.
            if (GUILayout.Button(_texts.GetText("inspect_variable", highlightedString, VarName), varLabelStyle, GUILayout.ExpandWidth(true)))
            {
                var ouput = new OutputEntry();
                ouput.LoadObject(var.VarValue);
                RexHelper.AddOutput(ouput);
            }

            return(shouldDelete);
        }