Hey,
I’m experimenting on the Python Language demo and I’m trying to get the declaration (path + line number + column offset) of a function from the current selection.
I got the path but I couldn’t retrieve the rest of the information – is it possible?
var context = new PythonContextFactory().CreateContext(codeEditor.ActiveView.Selection.EndSnapshotOffset, PythonContextKind.Self);
if (context == null)
{
return;
}
if ((context.Location != null) && ((context.Location == PythonContextLocations.Comment) || (context.Location == PythonContextLocations.LiteralString)))
{
return;
}
IResolverResultSet set = context.Resolve();
if (((set == null) || (set.Results == null)) || (set.Results.Count == 0))
{
return;
}
IFunctionResolverResult result = set.Results[0] as IFunctionResolverResult;
if ((result == null) || (result.Function == null))
{
return;
}
bool isBuiltin = result.Function.DeclaringModule.IsBuiltin;
string path = result.Function.DeclaringModule.Path;
(I'm looking into implementing a GoToDefinition functionality)
Thanks,
Tal