Search in sources :

Example 1 with GlobalFeedbackReporter

use of org.python.pydev.shared_core.global_feedback.GlobalFeedback.GlobalFeedbackReporter in project Pydev by fabioz.

the class AdditionalProjectInterpreterInfo method recreateAllInfo.

public static void recreateAllInfo(IPythonNature nature, IProgressMonitor monitor) {
    try (GlobalFeedbackReporter r = GlobalFeedback.start("Full projects reindex...")) {
        synchronized (additionalNatureInfoLock) {
            // Note: at this point we're 100% certain that the ast manager is there.
            ICodeCompletionASTManager astManager = nature.getAstManager();
            if (astManager == null) {
                return;
            }
            IModulesManager m = astManager.getModulesManager();
            if (m == null) {
                return;
            }
            IProject project = nature.getProject();
            AbstractAdditionalDependencyInfo currInfo = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);
            if (currInfo != null) {
                currInfo.clearAllInfo();
                currInfo.dispose();
            }
            String feedback = "(project:" + project.getName() + ")";
            synchronized (m) {
                AbstractAdditionalDependencyInfo info = (AbstractAdditionalDependencyInfo) restoreInfoForModuleManager(monitor, m, feedback, new AdditionalProjectInterpreterInfo(project), nature, nature.getGrammarVersion());
                if (info != null) {
                    // ok, set it and save it
                    additionalNatureInfo.put(FileUtilsFileBuffer.getValidProjectName(project), info);
                    info.save();
                }
            }
        }
    } catch (Exception e) {
        Log.log(e);
        throw new RuntimeException(e);
    }
}
Also used : ICodeCompletionASTManager(org.python.pydev.core.ICodeCompletionASTManager) IModulesManager(org.python.pydev.core.IModulesManager) GlobalFeedbackReporter(org.python.pydev.shared_core.global_feedback.GlobalFeedback.GlobalFeedbackReporter) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PythonNatureWithoutProjectException(org.python.pydev.core.PythonNatureWithoutProjectException) MisconfigurationException(org.python.pydev.core.MisconfigurationException)

Example 2 with GlobalFeedbackReporter

use of org.python.pydev.shared_core.global_feedback.GlobalFeedback.GlobalFeedbackReporter in project Pydev by fabioz.

the class AdditionalSystemInterpreterInfo method recreateAllInfo.

public static void recreateAllInfo(IInterpreterManager manager, String interpreter, IProgressMonitor monitor) {
    synchronized (additionalSystemInfoLock) {
        try (GlobalFeedbackReporter r = GlobalFeedback.start("Full system reindex...")) {
            final IInterpreterInfo interpreterInfo = manager.getInterpreterInfo(interpreter, monitor);
            int grammarVersion = interpreterInfo.getGrammarVersion();
            AbstractAdditionalTokensInfo currInfo = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(manager, interpreter);
            if (currInfo != null) {
                currInfo.clearAllInfo();
            }
            InterpreterInfo defaultInterpreterInfo = (InterpreterInfo) manager.getInterpreterInfo(interpreter, monitor);
            ISystemModulesManager m = defaultInterpreterInfo.getModulesManager();
            AbstractAdditionalTokensInfo info = restoreInfoForModuleManager(monitor, m, "(system: " + manager.getManagerRelatedName() + " - " + interpreter + ")", new AdditionalSystemInterpreterInfo(manager, interpreter), null, grammarVersion);
            if (info != null) {
                // ok, set it and save it
                additionalSystemInfo.put(new Tuple<String, String>(manager.getManagerRelatedName(), interpreter), info);
                info.save();
            }
        } catch (Throwable e) {
            Log.log(e);
        }
    }
}
Also used : ISystemModulesManager(org.python.pydev.core.ISystemModulesManager) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) InterpreterInfo(org.python.pydev.ast.interpreter_managers.InterpreterInfo) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) GlobalFeedbackReporter(org.python.pydev.shared_core.global_feedback.GlobalFeedback.GlobalFeedbackReporter)

Example 3 with GlobalFeedbackReporter

use of org.python.pydev.shared_core.global_feedback.GlobalFeedback.GlobalFeedbackReporter in project Pydev by fabioz.

the class AdditionalProjectInterpreterInfo method getAdditionalInfoForProject.

/**
 * @param project the project we want to get info on
 * @return the additional info for a given project (gotten from the cache with its name)
 * @throws MisconfigurationException
 */
public static AbstractAdditionalDependencyInfo getAdditionalInfoForProject(final IPythonNature nature) throws MisconfigurationException {
    if (nature == null) {
        return null;
    }
    IProject project = nature.getProject();
    if (project == null) {
        return null;
    }
    String name = FileUtilsFileBuffer.getValidProjectName(project);
    synchronized (additionalNatureInfoLock) {
        AbstractAdditionalDependencyInfo info = additionalNatureInfo.get(name);
        if (info == null) {
            info = new AdditionalProjectInterpreterInfo(project);
            additionalNatureInfo.put(name, info);
            if (!info.load()) {
                recreateAllInfo(nature, new NullProgressMonitor());
            } else {
                final AbstractAdditionalDependencyInfo temp = info;
                temp.setWaitForIntegrityCheck(true);
                // Ok, after it's loaded the first time, check the index integrity!
                Job j = new Job("Check index integrity for: " + project.getName()) {

                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                        try (GlobalFeedbackReporter r = GlobalFeedback.start("Check index integrity...")) {
                            new InterpreterInfoBuilder().syncInfoToPythonPath(monitor, nature);
                        } catch (Exception e) {
                            Log.log(e);
                        } finally {
                            temp.setWaitForIntegrityCheck(false);
                        }
                        return Status.OK_STATUS;
                    }
                };
                j.setPriority(Job.INTERACTIVE);
                j.setSystem(true);
                j.schedule();
            }
        }
        return info;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Job(org.eclipse.core.runtime.jobs.Job) IProject(org.eclipse.core.resources.IProject) GlobalFeedbackReporter(org.python.pydev.shared_core.global_feedback.GlobalFeedback.GlobalFeedbackReporter) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PythonNatureWithoutProjectException(org.python.pydev.core.PythonNatureWithoutProjectException) MisconfigurationException(org.python.pydev.core.MisconfigurationException) InterpreterInfoBuilder(com.python.pydev.analysis.system_info_builder.InterpreterInfoBuilder)

Aggregations

GlobalFeedbackReporter (org.python.pydev.shared_core.global_feedback.GlobalFeedback.GlobalFeedbackReporter)3 IProject (org.eclipse.core.resources.IProject)2 CoreException (org.eclipse.core.runtime.CoreException)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 MisconfigurationException (org.python.pydev.core.MisconfigurationException)2 PythonNatureWithoutProjectException (org.python.pydev.core.PythonNatureWithoutProjectException)2 InterpreterInfoBuilder (com.python.pydev.analysis.system_info_builder.InterpreterInfoBuilder)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 InterpreterInfo (org.python.pydev.ast.interpreter_managers.InterpreterInfo)1 ICodeCompletionASTManager (org.python.pydev.core.ICodeCompletionASTManager)1 IInterpreterInfo (org.python.pydev.core.IInterpreterInfo)1 IModulesManager (org.python.pydev.core.IModulesManager)1 ISystemModulesManager (org.python.pydev.core.ISystemModulesManager)1