use of com.python.pydev.analysis.additionalinfo.builders.AnalysisBuilderVisitor in project Pydev by fabioz.
the class ForceCodeAnalysisOnTree method forceCodeAnalysisOnFiles.
public static void forceCodeAnalysisOnFiles(PythonNature nature, IProgressMonitor monitor, List<IFile> filesToVisit, Set<IFile> filesVisited, List<IExternalCodeAnalysisVisitor> externalVisitors) {
if (nature == null) {
return;
}
AnalysisBuilderVisitor visitor = new AnalysisBuilderVisitor();
visitor.visitingWillStart(new NullProgressMonitor(), false, null);
FastStringBuffer buf = new FastStringBuffer();
for (IFile f : filesToVisit) {
if (monitor.isCanceled()) {
break;
}
if (filesVisited.contains(f)) {
continue;
}
filesVisited.add(f);
monitor.setTaskName(buf.clear().append("Scheduling: ").append(f.getName()).toString());
IDocument doc = FileUtilsFileBuffer.getDocFromResource(f);
visitor.memo = new VisitorMemo();
visitor.memo.put(PyDevBuilderVisitor.IS_FULL_BUILD, false);
long documentTime = System.currentTimeMillis();
visitor.memo.put(PyDevBuilderVisitor.DOCUMENT_TIME, documentTime);
String moduleName;
try {
moduleName = nature.resolveModule(f);
} catch (MisconfigurationException e) {
Log.log(e);
continue;
}
if (moduleName == null) {
continue;
}
AnalysisBuilderVisitor.setModuleNameInCache(visitor.memo, f, moduleName);
if (!PythonPathHelper.isValidSourceFile(f)) {
AnalysisRunner.deleteMarkers(f, true);
continue;
}
IModule module = nature.getAstManager().getModule(moduleName, nature, true, new BaseModuleRequest(false));
if (module == null) {
Log.log(IStatus.WARNING, "Unable to get module: " + moduleName + " for resource: " + f, null);
continue;
}
visitor.doVisitChangedResource(nature, f, doc, null, module, new NullProgressMonitor(), true, AnalysisBuilderRunnable.ANALYSIS_CAUSE_PARSER, documentTime, false, externalVisitors);
}
visitor.visitingEnded(new NullProgressMonitor());
}
use of com.python.pydev.analysis.additionalinfo.builders.AnalysisBuilderVisitor in project Pydev by fabioz.
the class AnalysisParserObserver method analyze.
private static void analyze(ChangedParserInfoForObservers info, SimpleNode root, IFile fileAdapter, boolean force, IPythonNature nature, boolean forceAnalyzeInThisThread) {
if (!nature.startRequests()) {
return;
}
IModule module;
try {
// we visit external because we must index them
String moduleName = nature.resolveModuleOnlyInProjectSources(fileAdapter, true);
if (moduleName == null) {
AnalysisRunner.deleteMarkers(fileAdapter);
// we only analyze resources that are in the pythonpath
return;
}
IPath location = fileAdapter.getLocation();
if (location == null) {
return;
}
String file = location.toOSString();
module = AbstractModule.createModule(root, new File(file), moduleName, nature);
} catch (Exception e) {
// Not much we can do about it.
Log.log(e);
return;
} finally {
nature.endRequests();
}
// visit it
AnalysisBuilderVisitor visitor = new AnalysisBuilderVisitor();
visitor.memo = new VisitorMemo();
visitor.memo.put(PyDevBuilderVisitor.IS_FULL_BUILD, false);
visitor.memo.put(PyDevBuilderVisitor.DOCUMENT_TIME, info.documentMillisTime);
visitor.visitingWillStart(new NullProgressMonitor(), false, null);
try {
visitor.doVisitChangedResource(nature, fileAdapter, info.doc, null, module, new NullProgressMonitor(), force, AnalysisBuilderRunnable.ANALYSIS_CAUSE_PARSER, info.documentMillisTime, forceAnalyzeInThisThread);
} finally {
visitor.visitingEnded(new NullProgressMonitor());
}
}
Aggregations