use of com.python.pydev.analysis.additionalinfo.AbstractAdditionalTokensInfo in project Pydev by fabioz.
the class CtxParticipant method computeConsoleCompletions.
// Console completions ---------------------------------------------------------------------------------------------
/**
* IPyDevCompletionParticipant2
*/
@Override
public Collection<ICompletionProposalHandle> computeConsoleCompletions(ActivationTokenAndQualifier tokenAndQual, Set<IPythonNature> naturesUsed, IScriptConsoleViewer viewer, int requestOffset) {
List<ICompletionProposalHandle> completions = new ArrayList<ICompletionProposalHandle>();
if (tokenAndQual.activationToken != null && tokenAndQual.activationToken.length() > 0) {
// we only want
return completions;
}
String qual = tokenAndQual.qualifier;
if (qual.length() >= PyCodeCompletionPreferences.getCharsForContextInsensitiveGlobalTokensCompletion() && naturesUsed != null && naturesUsed.size() > 0) {
// at least n characters required...
boolean addAutoImport = AnalysisPreferences.doAutoImport(null);
int qlen = qual.length();
boolean useSubstringMatchInCodeCompletion = PyCodeCompletionPreferences.getUseSubstringMatchInCodeCompletion();
IFilter nameFilter = PyCodeCompletionUtils.getNameFilter(useSubstringMatchInCodeCompletion, qual);
for (IPythonNature nature : naturesUsed) {
AbstractAdditionalTokensInfo additionalInfo;
try {
if (nature instanceof SystemPythonNature) {
SystemPythonNature systemPythonNature = (SystemPythonNature) nature;
additionalInfo = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(systemPythonNature.getRelatedInterpreterManager(), systemPythonNature.getProjectInterpreter().getExecutableOrJar());
fillNatureCompletionsForConsole(viewer, requestOffset, completions, qual, addAutoImport, qlen, nameFilter, nature, additionalInfo, useSubstringMatchInCodeCompletion);
} else {
additionalInfo = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);
fillNatureCompletionsForConsole(viewer, requestOffset, completions, qual, addAutoImport, qlen, nameFilter, nature, additionalInfo, useSubstringMatchInCodeCompletion);
}
} catch (MisconfigurationException e) {
Log.log(e);
}
}
}
return completions;
}
use of com.python.pydev.analysis.additionalinfo.AbstractAdditionalTokensInfo in project Pydev by fabioz.
the class GlobalsDialogFactory method create.
/**
* Creates the dialog according to the Eclipse version we have (on 3.2, the old API is used)
* @param pythonNatures
*/
public static SelectionDialog create(Shell shell, List<AbstractAdditionalTokensInfo> additionalInfo, String selectedText) {
boolean expectedError = true;
try {
GlobalsTwoPanelElementSelector2 newDialog = new GlobalsTwoPanelElementSelector2(shell, true, selectedText);
// If we were able to instance it, the error is no longer expected!
expectedError = false;
newDialog.setElements(additionalInfo);
return newDialog;
} catch (Throwable e) {
// That's OK: it's only available for Eclipse 3.3 onwards.
if (expectedError) {
Log.log(e);
}
}
// If it got here, we were unable to create the new dialog (show the old -- compatible with 3.2)
GlobalsTwoPaneElementSelector dialog;
dialog = new GlobalsTwoPaneElementSelector(shell);
dialog.setMessage("Filter");
if (selectedText != null && selectedText.length() > 0) {
dialog.setFilter(selectedText);
}
List<IInfo> lst = new ArrayList<IInfo>();
for (AbstractAdditionalTokensInfo info : additionalInfo) {
lst.addAll(info.getAllTokens());
}
dialog.setElements(lst.toArray());
return dialog;
}
use of com.python.pydev.analysis.additionalinfo.AbstractAdditionalTokensInfo in project Pydev by fabioz.
the class AnalysisRequestsTestWorkbench method testRefreshAnalyzesFiles.
public void testRefreshAnalyzesFiles() throws Exception {
editor.close(false);
// just to have any parse events consumed
goToIdleLoopUntilCondition(getInitialParsesCondition(), getParsesDone(), false);
// give it a bit more time...
goToManual(TIME_FOR_ANALYSIS);
PythonNature nature = PythonNature.getPythonNature(mod1);
AbstractAdditionalTokensInfo info = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);
// all modules are empty
assertEquals(new HashSet<String>(), info.getAllModulesWithTokens());
ICallback<Object, IResource> analysisCallback = getAnalysisCallback();
AnalysisBuilderRunnable.analysisBuilderListeners.add(analysisCallback);
try {
checkSetInvalidContents();
checkSetValidContents(info);
checkSetValidContentsWithFooToken(info);
checkRename(info);
checkSetValidContents(info);
// can analyze when editor is opened
resourcesAnalyzed.clear();
print("-------- Opening editor ----------");
editor = (PyEdit) PyOpenEditor.doOpenEditor(mod1);
goToIdleLoopUntilCondition(get1ResourceAnalyzed(), getResourcesAnalyzed());
assertEquals(1, resourcesAnalyzed.size());
// wait for it to complete (if it's too close it may consider it being the same analysis request even with a different time)
goToManual(TIME_FOR_ANALYSIS);
// analyze when forced
resourcesAnalyzed.clear();
AnalyzeOnRequestAction analyzeOnRequestAction = new AnalyzeOnRequestSetter.AnalyzeOnRequestAction(editor);
analyzeOnRequestAction.run();
// in 1 seconds, 1 analysis should happen
goToManual(TIME_FOR_ANALYSIS);
assertEquals(1, resourcesAnalyzed.size());
} finally {
AnalysisBuilderRunnable.analysisBuilderListeners.remove(analysisCallback);
}
CheckRefreshAnalyzesFilesOnlyOnActiveEditor();
}
Aggregations