Search in sources :

Example 1 with CtxParticipant

use of com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant in project Pydev by fabioz.

the class ParameterCompletionTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    CompiledModule.COMPILED_MODULES_ENABLED = false;
    useOriginalRequestCompl = true;
    participant = new CtxParticipant();
    ExtensionHelper.testingParticipants = new HashMap<String, List<Object>>();
    ArrayList<Object> participants = new ArrayList<Object>();
    /*IPyDevCompletionParticipant*/
    participants.add(participant);
    ExtensionHelper.testingParticipants.put(ExtensionHelper.PYDEV_COMPLETION, participants);
    codeCompletion = new PyCodeCompletion();
    this.restorePythonPath(false);
    final IEclipsePreferences prefs = new InMemoryEclipsePreferences();
    PyCodeCompletionPreferences.getPreferencesForTests = () -> prefs;
    prefs.putBoolean(PyCodeCompletionPreferences.MATCH_BY_SUBSTRING_IN_CODE_COMPLETION, false);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) PyCodeCompletion(org.python.pydev.ast.codecompletion.PyCodeCompletion) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CtxParticipant(com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant) InMemoryEclipsePreferences(org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences)

Example 2 with CtxParticipant

use of com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant in project Pydev by fabioz.

the class CompletionParticipantTest method testImportCompletion2.

public void testImportCompletion2() throws Exception {
    participant = new CtxParticipant();
    ICompletionProposalHandle[] proposals = requestCompl("xml", -1, -1, new String[] {});
    assertNotContains("xml - xmlrpclib", proposals);
    requestCompl(new File(TestDependent.TEST_PYSRC_TESTING_LOC + "/testlib/unittest/guitestcase.py"), "guite", -1, 0, new String[] {});
    // the behavior changes for tokens on modules
    AnalysisPreferences.TESTS_DO_IGNORE_IMPORT_STARTING_WITH_UNDER = true;
    try {
        proposals = requestCompl("Priv3", new String[] { "Priv3 - relative.rel1._priv1._priv2._priv3" });
        Document document = new Document("Priv3");
        ((CtxInsensitiveImportComplProposal) proposals[0]).indentString = "    ";
        ((CtxInsensitiveImportComplProposal) proposals[0]).apply(document, ' ', 0, 5);
        PySelectionTest.checkStrEquals("from relative.rel1 import Priv3\r\nPriv3", document.get());
    } finally {
        AnalysisPreferences.TESTS_DO_IGNORE_IMPORT_STARTING_WITH_UNDER = false;
    }
}
Also used : CtxInsensitiveImportComplProposal(org.python.pydev.editor.codecompletion.proposals.CtxInsensitiveImportComplProposal) ICompletionProposalHandle(org.python.pydev.shared_core.code_completion.ICompletionProposalHandle) CtxParticipant(com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant) Document(org.eclipse.jface.text.Document) File(java.io.File)

Example 3 with CtxParticipant

use of com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant in project Pydev by fabioz.

the class CompletionParticipantBuiltinsTest method testImportCompletion2.

// public void testCompletionBuiltins() throws Exception {
// //        wx.Frame.CaptureMouse()
// //        wx.Frame.CacheBestSize()
// //        wx.Frame.AcceptsFocus()
// //        wx.Frame.AcceptsFocusFromKeyboard()
// useOriginalRequestCompl = true;
// String s = "" +
// "def m1(a):\n" +
// "    a.Accepts";
// requestCompl(s, -1, -1, new String[]{"AcceptsFocus()", "AcceptsFocusFromKeyboard()"});
// 
// 
// }
public void testImportCompletion2() throws Exception {
    if (SharedCorePlugin.skipKnownFailures()) {
        return;
    }
    if (TestDependent.PYTHON2_WXPYTHON_PACKAGES != null) {
        CompiledModule module = new CompiledModule("wx", this.getManager().getModulesManager(), this.getManager().getNature());
        participant = new CtxParticipant();
        ICompletionProposalHandle[] proposals = requestCompl("Frame", -1, -1, new String[] {});
        // Expected to fail. See: org.python.pydev.ast.analysis.additionalinfo.builders.AdditionalInfoModulesObserver.notifyCompiledModuleCreated(CompiledModule, IModulesManager)
        assertContains("Frame - wx", proposals);
    }
}
Also used : ICompletionProposalHandle(org.python.pydev.shared_core.code_completion.ICompletionProposalHandle) CtxParticipant(com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant) CompiledModule(org.python.pydev.ast.codecompletion.revisited.modules.CompiledModule)

Example 4 with CtxParticipant

use of com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant in project Pydev by fabioz.

the class CompletionParticipantBuiltinsTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    CompiledModule.COMPILED_MODULES_ENABLED = true;
    participant = new CtxParticipant();
    ExtensionHelper.testingParticipants = new HashMap<String, List<Object>>();
    ArrayList<Object> participants = new ArrayList<Object>();
    /*IPyDevCompletionParticipant*/
    participants.add(participant);
    ExtensionHelper.testingParticipants.put(ExtensionHelper.PYDEV_COMPLETION, participants);
    codeCompletion = new PyCodeCompletion();
    this.restorePythonPath(false);
}
Also used : PyCodeCompletion(org.python.pydev.ast.codecompletion.PyCodeCompletion) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) CtxParticipant(com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant)

Example 5 with CtxParticipant

use of com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant in project Pydev by fabioz.

the class CompletionParticipantTest method testImportCompletionFromZip.

public void testImportCompletionFromZip() throws Exception {
    participant = new CtxParticipant();
    ICompletionProposalHandle[] proposals = requestCompl("myzipc", -1, -1, new String[] {});
    assertContains("MyZipClass - myzipmodule.myzipfile", proposals);
    proposals = requestCompl("myegg", -1, -1, new String[] {});
    assertContains("MyEggClass - myeggmodule.myeggfile", proposals);
}
Also used : ICompletionProposalHandle(org.python.pydev.shared_core.code_completion.ICompletionProposalHandle) CtxParticipant(com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant)

Aggregations

CtxParticipant (com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant)5 ICompletionProposalHandle (org.python.pydev.shared_core.code_completion.ICompletionProposalHandle)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 PyCodeCompletion (org.python.pydev.ast.codecompletion.PyCodeCompletion)2 File (java.io.File)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 Document (org.eclipse.jface.text.Document)1 CompiledModule (org.python.pydev.ast.codecompletion.revisited.modules.CompiledModule)1 CtxInsensitiveImportComplProposal (org.python.pydev.editor.codecompletion.proposals.CtxInsensitiveImportComplProposal)1 InMemoryEclipsePreferences (org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences)1