예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stack"></param>
        /// <returns></returns>
        private IStackData GetCurrentDropperLexemConfigPair(out ConfigStack stack)
        {
            // Gets current stack of complex lexems.
            // Example:
            // {                        <- first { in stack
            //   get
            //   { return null;
            //   }
            //   set
            //   {                      <- second { in stack
            //     CallMethod1( |<-cursor is here )
            //   }
            // When cursor is set as in example, stack will have such data:
            // 1) first lexem "{",its configuration and position
            // 2) complex lexem "set", its configuration and position
            // 3) second lexem "{",its configuration and position
            // 4) complex lexem "CallMethod1", its configuration and position
            // 5) complex lexem lexem "(",its configuration and position, ( is context prompt dropper( DropContextPrompt == true ).
            // Note: this example is not appliable to configuration in current sample.

            stack = editControl1.GetCurrentStack();

            if (stack != null && stack.Count > 0)
            {
                IStackData stackItem = stack.Pop();

                if (stackItem.Config.DropContextPrompt)
                {
                    return(stackItem);
                }
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Gets context tooltip.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editControl1_UpdateContextToolTip(object sender, Syncfusion.Windows.Forms.Edit.UpdateTooltipEventArgs e)
        {
            // If the text is already specified, than we should not change it. This is needed to display default tooltip for the collapsed region.
            if (e.Text != string.Empty)
            {
                return;
            }

            // Convert position of the mouse cursor to the position in text.
            Point virt = editControl1.PointToVirtualPosition(new Point(e.X, e.Y), true);

            // If there is no text in tat position, tan exit.
            if (virt.IsEmpty == true)
            {
                return;
            }

            ILexemLine line = editControl1.GetLine(virt.Y);

            if (line != null)
            {
                // Get lexem under cursor.
                ILexem lexem = line.FindLexemByColumn(virt.X);

                if (lexem != null)
                {
                    // Set text of the tooltip.
                    e.Text = GetLexemInfo(lexem) + "\n";

                    // Get stack of the lexem.
                    ConfigStack stack = line.GetStackByColumn(virt.X);

                    if (stack != null)
                    {
                        e.Text += "Stack before parsing lexem:\n";

                        while (stack.Count > 0)
                        {
                            IStackData stackItem =
                                ( IStackData )stack.Pop();

                            if (stackItem.Lexem != null)
                            {
                                e.Text += "-- " + GetLexemInfo(stackItem.Lexem) + "\n";
                            }
                        }

                        e.Text += "\n";
                    }

                    // Add description if present.
                    if (m_MethodComments.Contains(lexem.Config.ID))
                    {
                        e.Text += "Lexem contains description:\n";
                        e.Text += m_MethodComments[lexem.Config.ID];
                    }
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Return a configuration object composed of
 /// all sources except the primary source
 /// merged into one.
 /// </summary>
 /// <returns></returns>
 private T CreateBaseConfig()
 {
     return(ConfigStack
            .Select(c => c.Config)
            .Where(c => !ReferenceEquals(c, _primarySource.Config)).Merge());
 }