I have a Rider plugin that gets the local path of the opened file in Rider. It is a context menu button. It is now only able to get the path of certain project files such as C# files.
It is not able to get the path of other file types such as txt.
Below is my code
public void Execute(IDataContext context, DelegateExecute nextExecute)
{
var solution = context.GetData(JetBrains.ProjectModel.DataContext.ProjectModelDataConstants.SOLUTION);
if (solution == null)
return;
var textControl = context.GetData(TextControlDataConstants.TEXT_CONTROL);
if (textControl == null)
return;
var document = textControl.Document;
var Offset = textControl.Caret.Offset();
var lineNumber = document.GetCoordsByOffset(Offset).Line.Plus1();
var sourceFile = document.GetPsiSourceFile(solution);
if (sourceFile == null)
return;
var fullPath = $"{sourceFile.GetLocation().FullPath}?line={lineNumber}";
var file = solution.SolutionDirectory / "file.txt";
}
how to make it able to get the path of all file(s) types?
Please help and thanks in advance.