public RegisteredComponentsSearchRequest GetRegisteredComponentsRequest(IDataContext dataContext)
{
ISolution solution = dataContext.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);
if (solution == null)
{
throw new InvalidOperationException("Unable to get the solution");
}
var invokedNode = dataContext.GetSelectedTreeNode<IExpression>();
IDocument document = dataContext.GetData(JetBrains.IDE.DataConstants.DOCUMENT);
if (document == null)
return null;
IPsiSourceFile psiSourceFile = document.GetPsiSourceFile(solution);
if (psiSourceFile == null)
{
return null;
}
var registration = solution.GetComponent<IPatternManager>().GetRegistrationsForFile(psiSourceFile)
.FirstOrDefault(r => r.Registration.RegistrationElement.Children().Contains(invokedNode));
if (registration == null)
{
return null;
}
return new RegisteredComponentsSearchRequest(solution, locks, registration.Registration);
}