return "None";
}
//Only mark it as found if we were able to get the python nature (otherwise, this could change later
//if requesting during a setup)
if (nature.startRequests()) { //start requests, as we'll ask for resolve and get module.
SourceModule sourceModule = null;
try {
String modName = nature.resolveModule(fileStr);
if (modName != null) {
//when all is set up, this is the most likely path we're going to use
//so, we shouldn't have delays when the module is changed, as it's already
//ok for use.
IModule module = astManager.getModule(modName, nature, true);
if (module instanceof SourceModule) {
sourceModule = (SourceModule) module;
}
}
} finally {
nature.endRequests();
}
lastModifiedTimeCached = file.lastModified();
if (sourceModule == null) {
//the text for the breakpoint requires the function name, and it may be requested before
//the ast manager is actually restored (so, modName is None, and we have little alternative
//but making a parse to get the function name)
IDocument doc = getDocument();
sourceModule = (SourceModule) AbstractModule.createModuleFromDoc("", null, doc, nature, true);
}
int lineToUse = getLineNumber() - 1;
if (sourceModule == null || sourceModule.getAst() == null || lineToUse < 0) {
functionName = "None";
return functionName;
}
SimpleNode ast = sourceModule.getAst();
functionName = NodeUtils.getContextName(lineToUse, ast);
if (functionName == null) {
functionName = ""; //global context
}