use of org.python.pydev.editor.codecompletion.proposals.PyLinkedModeCompletionProposal in project Pydev by fabioz.
the class PythonCompletionWithoutBuiltinsTest method testReturn5.
public void testReturn5() throws Exception {
String s = "import unittest\n" + "\n" + "\n" + "class Test(unittest.TestCase):\n" + " \n" + " def Compute(self):\n" + " return Test()\n" + "\n" + " def BB(self):\n" + " self.Compute()." + "";
ICompletionProposalHandle[] requestCompl = requestCompl(s, s.length(), -1, new String[] { "BB()", "assertEquals(first, second, msg)" });
boolean found = false;
for (ICompletionProposalHandle p : requestCompl) {
if (p.getDisplayString().equals("assertEquals(first, second, msg)")) {
IToken element = ((PyLinkedModeCompletionProposal) p).getElement();
assertEquals(element.getType(), IToken.TYPE_FUNCTION);
found = true;
}
}
assertTrue(found);
}
use of org.python.pydev.editor.codecompletion.proposals.PyLinkedModeCompletionProposal in project Pydev by fabioz.
the class PythonCompletionCalltipsTest method testCalltips8a.
public void testCalltips8a() throws Exception {
String s0 = "class TestCase(object):\n" + " def __init__(self, param1, param2):\n" + " pass\n" + " \n" + "TestCase(param1=10, para%s=20)";
String s = StringUtils.format(s0, "m3");
ICompletionProposalHandle[] proposals = requestCompl(s, s.length() - 7, -1, new String[] {});
assertEquals(2, proposals.length);
PyLinkedModeCompletionProposal paramProposal = (PyLinkedModeCompletionProposal) assertContains("param1=", proposals);
paramProposal = (PyLinkedModeCompletionProposal) assertContains("param2=", proposals);
Document document = new Document(s);
// only the 'm3'
paramProposal.setLen(2);
paramProposal.applyOnDoc(paramProposal.getReplacementOffset() + 4, true, document, 4, '\0');
assertEquals(StringUtils.format(s0, "m2"), document.get());
}
use of org.python.pydev.editor.codecompletion.proposals.PyLinkedModeCompletionProposal in project Pydev by fabioz.
the class PythonApplyCompletionsTest method testApply3.
public void testApply3() throws Exception {
String s = "class XX:\n" + " def method1(self, a, b):\n" + " return 1\n" + " def foo(self):\n" + " self.metho";
int offset = s.length() - 1;
ICompletionProposalHandle[] proposals = requestCompl(s, offset, -1, new String[] {});
assertEquals(1, proposals.length);
PyLinkedModeCompletionProposal p = (PyLinkedModeCompletionProposal) proposals[0];
p.fLen = 1;
Document d = new Document(s);
p.applyOnDoc(offset, true, d, "meth".length(), '\n');
// System.out.println(d.get());
assertEquals(s + "d1", d.get());
assertEquals(new Point(d.getLength(), 0), p.getSelection(d));
}
use of org.python.pydev.editor.codecompletion.proposals.PyLinkedModeCompletionProposal in project Pydev by fabioz.
the class PythonApplyCompletionsTest method testApply6.
public void testApply6() throws Exception {
String s = "class XX:\n" + " def method1(self, a, b):\n" + " return 1\n" + " def foo(self):\n" + " self.meth";
int offset = s.length();
ICompletionProposalHandle[] proposals = requestCompl(s, offset, -1, new String[] {});
assertEquals(1, proposals.length);
PyLinkedModeCompletionProposal p = (PyLinkedModeCompletionProposal) proposals[0];
Document d = new Document(s);
p.applyOnDoc(offset, false, d, 4, ')');
// System.out.println(d.get());
assertEquals(s + "od1(a, b)", d.get());
assertEquals(new Point(d.getLength() - "a, b)".length(), 0), p.getSelection(d));
}
use of org.python.pydev.editor.codecompletion.proposals.PyLinkedModeCompletionProposal in project Pydev by fabioz.
the class PythonApplyCompletionsTest method testApply5.
public void testApply5() throws Exception {
String s = "class XX:\n" + " def method1(self, a, b):\n" + " return 1\n" + " def foo(self):\n" + " self.meth";
int offset = s.length();
ICompletionProposalHandle[] proposals = requestCompl(s, offset, -1, new String[] {});
assertEquals(1, proposals.length);
PyLinkedModeCompletionProposal p = (PyLinkedModeCompletionProposal) proposals[0];
Document d = new Document(s);
p.applyOnDoc(offset, false, d, 4, '(');
// System.out.println(d.get());
assertEquals(s + "od1()", d.get());
assertEquals(new Point(d.getLength() - 1, 0), p.getSelection(d));
}
Aggregations