/** save the information contained for the given manager */ public static void saveAdditionalSystemInfo(IInterpreterManager manager, String interpreter) { AbstractAdditionalInterpreterInfo info; try { info = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(manager, interpreter); info.save(); } catch (MisconfigurationException e) { PydevPlugin.log(e); return; } }
private void fillNatureCompletionsForConsole( IScriptConsoleViewer viewer, int requestOffset, List<ICompletionProposal> completions, String qual, boolean addAutoImport, int qlen, String lowerQual, IPythonNature nature, boolean getSystem) { AbstractAdditionalInterpreterInfo additionalInfoForProject; if (getSystem) { try { additionalInfoForProject = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo( PydevPlugin.getInterpreterManager(nature), nature.getProjectInterpreter().getExecutableOrJar()); } catch (Exception e) { PydevPlugin.log(e); return; } } else { try { additionalInfoForProject = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature); } catch (Exception e) { PydevPlugin.log(e); return; } } List<IInfo> tokensStartingWith = additionalInfoForProject.getTokensStartingWith( qual, AbstractAdditionalInterpreterInfo.TOP_LEVEL); FastStringBuffer realImportRep = new FastStringBuffer(); FastStringBuffer displayString = new FastStringBuffer(); FastStringBuffer tempBuf = new FastStringBuffer(); for (IInfo info : tokensStartingWith) { // there always must be a declaringModuleName String declaringModuleName = info.getDeclaringModuleName(); boolean hasInit = false; if (declaringModuleName.endsWith(".__init__")) { declaringModuleName = declaringModuleName.substring( 0, declaringModuleName.length() - 9); // remove the .__init__ hasInit = true; } String rep = info.getName(); String lowerRep = rep.toLowerCase(); if (!lowerRep.startsWith(lowerQual)) { continue; } if (addAutoImport) { realImportRep.clear(); realImportRep.append("from "); realImportRep.append( AutoImportsPreferencesPage.removeImportsStartingWithUnderIfNeeded( declaringModuleName, tempBuf)); realImportRep.append(" import "); realImportRep.append(rep); } displayString.clear(); displayString.append(rep); displayString.append(" - "); displayString.append(declaringModuleName); if (hasInit) { displayString.append(".__init__"); } PyConsoleCompletion proposal = new PyConsoleCompletion( rep, requestOffset - qlen, qlen, realImportRep.length(), AnalysisPlugin.getImageForAutoImportTypeInfo(info), displayString.toString(), (IContextInformation) null, "", lowerRep.equals(lowerQual) ? IPyCompletionProposal.PRIORITY_LOCALS_1 : IPyCompletionProposal.PRIORITY_GLOBALS, realImportRep.toString(), viewer); completions.add(proposal); } }