Вопрос

I want to write a ReSharper Action that just calls a ContextAction. Is this possible? A ContextAction takes a Solution as a parameter, and an Action gets a DataContext on construction. So the question really becomes:

Can you get the current Solution from an instance of DataContext?

EDIT: Oops! I asked the wrong thing. The above is true, but not the real problem. Like Dmitri below says, you can get indeed the solution like so:

var solution = 
  dataContext.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);

The tricky bit is getting the _psiModule, which can be gotten from the ICSharpContextDataProvider which is passed in when the ContextAction is constructed, via provider.PsiModule. Can you get an ICSharpContextDataProvider or the correct PsiModule from the DataContext?

Это было полезно?

Решение

  var document = context.GetData(DocumentModel.DataConstants.DOCUMENT);
  var solution = context.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION);
  var psiModule = document.GetPsiSourceFile(solution).GetPsiModule();

Другие советы

You can try getting the solution like so:

var solution =
  dataContext.GetData(JetBrains.ProjectModel.DataContext.DataConstants.SOLUTION)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top