Esempio n. 1
0
        public bool GoToDefinition()
        {
            var step = GetCurrentStep();
            if (step == null)
                return false;

            var bindingMatchService = GetBindingMatchService();
            if (bindingMatchService == null)
                return false;

            if (!bindingMatchService.Ready)
            {
                MessageBox.Show("Step bindings are still being analyzed. Please wait.", "Go to binding");
                return true;
            }

            IEnumerable<StepBindingNew> candidatingBindings;
            var binding = bindingMatchService.GetBestMatchingBinding(step, out candidatingBindings);

            if (binding == null)
            {
                if (candidatingBindings.Any())
                {
                    string bindingsText = string.Join(Environment.NewLine, candidatingBindings.Select(b => b.Method.ShortDisplayText));
                    MessageBox.Show("Multiple matching bindings found. Navigating to the first match..."
                        + Environment.NewLine + Environment.NewLine + bindingsText, "Go to binding");
                    binding = candidatingBindings.First();
                }
                else
                {
                    string skeleton = languageService.ProjectScope.StepDefinitionSkeletonProvider.GetStepDefinitionSkeleton(step);

                    var result = MessageBox.Show("No matching step binding found for this step! Do you want to copy the step binding skeleton to the clipboard?"
                         + Environment.NewLine + Environment.NewLine + skeleton, "Go to binding", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (result == DialogResult.Yes)
                    {
                        Clipboard.SetText(skeleton);
                    }
                    return true;
                }
            }

            var method = binding.Method;
            var codeFunction = new VsStepSuggestionBindingCollector().FindCodeFunction(((VsProjectScope) languageService.ProjectScope), method);

            if (codeFunction != null)
            {
                if (!codeFunction.ProjectItem.IsOpen)
                {
                    codeFunction.ProjectItem.Open();
                }
                var navigatePoint = codeFunction.GetStartPoint(vsCMPart.vsCMPartHeader);
                navigatePoint.TryToShow();
                navigatePoint.Parent.Selection.MoveToPoint(navigatePoint);
            }

            return true;
        }
Esempio n. 2
0
 public BindingFilesTracker(VsProjectScope vsProjectScope) : base(vsProjectScope)
 {
     stepSuggestionBindingCollector = new VsStepSuggestionBindingCollector();
 }