Exemple #1
0
        /// <summary>
        /// 定位方法
        /// </summary>
        /// <returns></returns>
        private bool ToFunc(Window win)
        {
            // 匹配方法定义代码
            string pattern = @"\w_ \.\<\>\[\]\t\n";

            switch (_funcInfo.ParamNum)
            {
            // -1不匹配参数个数
            case -1:
                pattern = $@"public\svirtual\s[a-zA-Z]+\s{_funcInfo.Func}\([^\)]*\)";
                break;

            case 0:
                pattern = $@"public\svirtual\s[a-zA-Z]+\s{_funcInfo.Func}\(\)";
                break;

            case 1:
                pattern = $@"public\svirtual\s[a-zA-Z]+\s{_funcInfo.Func}\([{pattern}]+\)";
                break;

            default:
                pattern =
                    $@"public\svirtual\s[a-zA-Z]+\s{_funcInfo.Func}\(([{pattern}]+,){{{_funcInfo.ParamNum - 1}}}[{pattern}]+\)";
                break;
            }

            return(ExtUtil.ToCode(win, pattern));
        }
Exemple #2
0
        /// <summary>
        /// 转到定义
        /// </summary>
        public override void Run()
        {
            // 解析
            string selection = ExtUtil.GetSelection(Dte);

            if (string.IsNullOrWhiteSpace(selection))
            {
                return;
            }
            AnalyzeInfo(selection);

            // 校验
            if (string.IsNullOrEmpty(_funcInfo.FullName))
            {
                MessageBox.Show("该方法缺少引用,请检查require!");
                return;
            }

            // 查找
            string path = GetFullPath();

            if (string.IsNullOrEmpty(path))
            {
                MessageBox.Show("未找到对应的后端文件!");
                return;
            }

            Window win = Dte.ItemOperations.OpenFile(path);

            if (!ExtUtil.ToCode(win, _funcInfo))
            {
                if (_funcInfo.ParamNum > -1)
                {
                    // 如果带参数匹配不到,那么仅匹配方法名
                    _funcInfo.ParamNum = -1;

                    if (ToFunc(win))
                    {
                        MessageBox.Show("未找到匹配的方法,已定位到同名方法!");
                        return;
                    }
                }

                MessageBox.Show("未找到匹配的方法!");
                return;
            }
        }
Exemple #3
0
        /// <summary>
        /// 定位SQL
        /// </summary>
        /// <param name="win"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        private bool ToSQL(Window win, string sql)
        {
            string pattern = $@"\b{sql}\b";

            return(ExtUtil.ToCode(win, pattern));
        }