Ejemplo n.º 1
0
        internal IIntellisenseResult Suggest(string expression, FormulaType parameterType, int cursorPosition)
        {
            var formula = new Formula(expression);

            formula.EnsureParsed(TexlParser.Flags.None);

            var binding = TexlBinding.Run(
                new Glue2DocumentBinderGlue(),
                formula.ParseTree,
                new SimpleResolver(EnumStore.EnumSymbols),
                ruleScope: parameterType._type,
                useThisRecordForRuleScope: false
                );

            var context      = new IntellisenseContext(expression, cursorPosition);
            var intellisense = IntellisenseProvider.GetIntellisense();
            var suggestions  = intellisense.Suggest(context, binding, formula);

            if (suggestions.Exception != null)
            {
                throw suggestions.Exception;
            }

            return(suggestions);
        }
        /// <summary>
        /// if downkey is pressed and intellisence is being displayed: enters intelliselect
        /// otherwise executes if Return is pressed.
        /// </summary>
        public static void Update_Typing()
        {
            if (IsKeyDown(KeyCode.DownArrow) && IntelliSenceHelp.Any())
            {
                Enter_IntelliSelect();
            }
            else if (IsKeyDown(KeyCode.Tab) && IntelliSenceHelp.Count > 0)
            {
                SelectedHelp = 0;
                UseIntelliSelection();
                return;
            }
            else if (IsKeyDown(KeyCode.Return) || IsKeyDown(KeyCode.KeypadEnter))
            {
                // Replace code with selected history element.
                Exit_Typing();
                Execute();
                return;
            }
            else if (IsKeyDown(KeyCode.Escape))
            {
                DisplayHelp = false;
            }

            var parseResult = Parser.ParseAssignment(Code);

            if (IntelliSenceLastCode != parseResult.ExpressionString)
            {
                DisplayHelp          = true;
                IntelliSenceLastCode = parseResult.ExpressionString;
                IntelliSenceHelp     = IntellisenseProvider.Intellisense(Code).ToList();
                SelectedHelp         = -1;
                Repaint();
            }
        }
Ejemplo n.º 3
0
        public ItemTemplate(Plugin plugin)
        {
            Name         = "";
            ID           = Guid.Empty;
            Intellisense = new Intellisense();

            AutoCompletionProvider = new IntellisenseProvider(Intellisense);
            Plugin = plugin;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get intellisense from the formula.
        /// </summary>
        public IIntellisenseResult Suggest(string expression, FormulaType parameterType, int cursorPosition)
        {
            var result  = this.CheckInternal(expression, parameterType, intellisense: true);
            var binding = result._binding;
            var formula = result._formula;

            var context      = new IntellisenseContext(expression, cursorPosition);
            var intellisense = IntellisenseProvider.GetIntellisense();
            var suggestions  = intellisense.Suggest(context, binding, formula);

            return(suggestions);
        }
Ejemplo n.º 5
0
        private void TextArea_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            var pos2 = Mouse.GetPosition(this);
            // get line at position
            var mousePos = new Point(e.CursorLeft, e.CursorTop);
            var pos      = this.GetPositionFromPoint(pos2);

            if (pos == null)
            {
                ContextMenuWord = string.Empty;
            }
            else
            {
                var word = IntellisenseProvider.GetCurrentWord((TextViewPosition)pos);
                ContextMenuWord = word;
            }

            // get word
            // set contextMenuWord
        }
Ejemplo n.º 6
0
        public static View Select(ItemTemplate it, byte[] data, File file, IntellisenseProvider intellisenseOProvider, DockWindow window = null)
        {
            if (it.View != null)
            {
                it.View.Window = window;

                it.View.Create(data);

                return(it.View);
            }
            else
            {
                var v = new EditorView(it, file);
                v.Window = window;
                v.IntellisenseProvider = intellisenseOProvider;

                v.Create(data);

                return(v);
            }
        }
Ejemplo n.º 7
0
 void textEditor_TextArea_TextEntering(object sender, TextCompositionEventArgs e)
 {
     IntellisenseProvider.ProcessTextEntering(sender, e, ref completionWindow);
 }
Ejemplo n.º 8
0
 void TextArea_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     IntellisenseProvider.ProcessKeyDown(sender, e);
 }