Пример #1
0
        protected void showCodeCompletion(KDataCommand cmd)
        {
            if (completionWindow != null)
            {
                return;
            }
            if (dom == null)
            {
                Log.Debug("Use the codeCompletionInit() for work with Code Completion");
                return;
            }

            var data = dom.Find(_.TextArea.Document.Text, _.TextArea.Caret.Offset, cmd);

            if (data == null)
            {
                return;
            }

            completionWindow = new CompletionWindow(_.TextArea)
            {
                Width = 270
            };
            completionWindow.Closed += delegate {
                completionWindow = null;
            };

            foreach (INodeInfo item in data)
            {
                completionWindow.CompletionList.CompletionData.Add(new CompletionData(item));
            }
            completionWindow.Show();
        }
Пример #2
0
        /// <param name="data">Where to look.</param>
        /// <param name="offset">Position in data to start searching.</param>
        /// <param name="cmd">Specified command for this search.</param>
        /// <returns>Found items.</returns>
        public IEnumerable <INodeInfo> Find(string data, int offset, KDataCommand cmd)
        {
            if (cmd == KDataCommand.Default)
            {
                return(ListEmpty);
            }

            if (cmd == KDataCommand.MSBuildContainer)  // '$(' - root
            {
                return(ListMSBuildProperties(null));
            }

            if (cmd == KDataCommand.Container)  // '#[' - root
            {
                return(ListComponents(null));
            }

            data = Region(data, offset);

            // '$( '<--
            if (Regex.IsMatch(data, Pattern.EvMLeft))
            {
                return((cmd == KDataCommand.CtrlSpace)? ListMSBuildProperties() : ListNull);
            }

            // '#[ '<--
            Match root = Regex.Match(data, Pattern.SobaLeft, RegexOptions.IgnorePatternWhitespace);


            if (root.Success)
            {
                return((cmd == KDataCommand.CtrlSpace)? ListComponents(root.Groups["data"].Value) : ListNull);
            }

            // '#[...' -->
            Match m = Regex.Match(data, Pattern.SobaMiddle, RegexOptions.IgnorePatternWhitespace);

            if (!m.Success)
            {
                return(ListNull);
            }

            INodeInfo component = FindComponent(data);

            if (component == null)
            {
                // hidden components:
                //Match hc = Regex.Match(data, @"^\s*\#\[(\S+)");
                //if(hc.Groups[1].Success) {
                //    return list(new NodeIdent(hc.Groups[1].Value, null));
                //}
                return(ListNull);
            }

            return(Find(cmd, component, (m.Groups[2].Success)? m.Groups[2].Value : null));
        }
Пример #3
0
        /// <param name="cmd"></param>
        /// <param name="component">INodeInfo component for searching.</param>
        /// <param name="raw">Full raw string to search.</param>
        /// <returns></returns>
        protected IEnumerable <INodeInfo> Find(KDataCommand cmd, INodeInfo component, string raw)
        {
            if (raw == null)
            {
                if (cmd == KDataCommand.CtrlSpace || cmd == KDataCommand.Space)
                {
                    return(ListInfo(new NodeIdent(component.Name, null)));
                }
                return(ListNull);
            }

            if (cmd == KDataCommand.Space)
            {
                return(ListNull);
            }

            string ident = new StringHandler().ProtectMixedQuotes(raw.Trim());

            if (IsLatest('.', ident))
            {
                ident = ident.Substring(0, ident.Length - 1);
                if (cmd == KDataCommand.CtrlSpace)
                {
                    cmd = KDataCommand.LevelByDot;
                }
            }

            if (cmd == KDataCommand.CtrlSpace)
            {
                if (Regex.IsMatch(raw, Pattern.Finalization, RegexOptions.IgnorePatternWhitespace))
                {
                    return(ListNull);
                }
            }

            string[] parts = Regex.Replace
                             (
                ident,
                SobaScript.Pattern.RoundBracketsContent,
                "()",
                RegexOptions.IgnorePatternWhitespace
                             )
                             .Split('.');

            NodeIdent id = new NodeIdent(component.Name, null);

            for (int i = 0; i < parts.Length; ++i)
            {
                parts[i] = parts[i].Trim();

                if (cmd == KDataCommand.CtrlSpace && i == parts.Length - 1)
                {
                    return(ListInfo(id, parts[i]));
                }

                INodeInfo info = InfoBy(parts[i], id, (cmd == KDataCommand.LevelByDot));
                if (info == null)
                {
                    return(ListEmpty);
                }

                id = info.Link;
            }

            if (cmd == KDataCommand.LevelByDot)
            {
                return(ListInfo(id));
            }
            return(ListEmpty);
        }