[Pydev-cvs] org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited AS
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:21
|
Update of /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/tests_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: ASTManagerTest.java PythonPathHelperTest.java CodeCompletionTestsBase.java SourceModuleProposalTest.java ProjectStub.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: SourceModuleProposalTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/SourceModuleProposalTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SourceModuleProposalTest.java 21 Aug 2008 20:56:28 -0000 1.4 --- SourceModuleProposalTest.java 28 Sep 2008 12:45:43 -0000 1.5 *************** *** 90,98 **** // s.doc = doc; // if(tokDef != null) ! // try { ! // s.definition = mod.findGlobalTokDef(CompletionStateFactory.getEmptyCompletionState(tokDef, null, new CompletionCache()), null); ! // } catch (Exception e) { ! // throw new RuntimeException(e); ! // } // s.addTo = addTo; // IRegion region = doc.getLineInformation(line); --- 90,98 ---- // s.doc = doc; // if(tokDef != null) ! // try { ! // s.definition = mod.findGlobalTokDef(CompletionStateFactory.getEmptyCompletionState(tokDef, null, new CompletionCache()), null); ! // } catch (Exception e) { ! // throw new RuntimeException(e); ! // } // s.addTo = addTo; // IRegion region = doc.getLineInformation(line); Index: ASTManagerTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/ASTManagerTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ASTManagerTest.java 5 Feb 2008 13:07:14 -0000 1.3 --- ASTManagerTest.java 28 Sep 2008 12:45:43 -0000 1.4 *************** *** 65,77 **** col = 11; sDoc = ""+ ! "class C: \n" + ! " \n" + ! " def makeit(self):\n" + ! " pass \n" + ! " \n" + ! "class D(C.: \n" + ! " \n" + ! " def a(self): \n" + ! " pass \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 65,77 ---- col = 11; sDoc = ""+ ! "class C: \n" + ! " \n" + ! " def makeit(self):\n" + ! " pass \n" + ! " \n" + ! "class D(C.: \n" + ! " \n" + ! " def a(self): \n" + ! " pass \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 81,99 **** ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 81,99 ---- ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 103,124 **** assertIsIn("Test", comps); ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n" + ! " \n" + ! "def meth1(): \n" + ! " pass \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 103,124 ---- assertIsIn("Test", comps); ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n" + ! " \n" + ! "def meth1(): \n" + ! " pass \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 129,150 **** assertIsIn("meth1", comps); ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n" + ! " \n" + ! " def meth1(): \n" + ! " pass \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 129,150 ---- assertIsIn("meth1", comps); ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n" + ! " \n" + ! " def meth1(): \n" + ! " pass \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 154,170 **** assertIsIn("Test", comps); ! sDoc = ""+ ! "class Classe1: \n" + ! " \n" + ! " def foo(self): \n" + ! " ignoreThis=0 \n" + ! " self.a = 1 \n" + ! " self. \n" + ! " \n"; ! ! line = 6; ! col = 13; ! token = "Classe1"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 154,170 ---- assertIsIn("Test", comps); ! sDoc = ""+ ! "class Classe1: \n" + ! " \n" + ! " def foo(self): \n" + ! " ignoreThis=0 \n" + ! " self.a = 1 \n" + ! " self. \n" + ! " \n"; ! ! line = 6; ! col = 13; ! token = "Classe1"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 173,190 **** assertIsIn("foo", comps); ! sDoc = ""+ ! "class Classe1: \n" + ! " \n" + ! " def foo(self): \n" + ! " self.a = 2 \n" + ! " \n" + ! " test = foo \n" + ! " \n" + ! "Classe1. \n"; ! ! line = 8; ! col = 9; ! token = "Classe1"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 173,190 ---- assertIsIn("foo", comps); ! sDoc = ""+ ! "class Classe1: \n" + ! " \n" + ! " def foo(self): \n" + ! " self.a = 2 \n" + ! " \n" + ! " test = foo \n" + ! " \n" + ! "Classe1. \n"; ! ! line = 8; ! col = 9; ! token = "Classe1"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 196,215 **** ! sDoc = ""+ ! "class LinkedList: \n"+ ! " def __init__(self,content='Null'): \n" + ! " if not content: \n"+ ! " self.first=content \n"+ ! " self.last=content \n"+ ! " else: \n"+ ! " self.first='Null' \n"+ ! " self.last='Null' \n"+ ! " self.content=content \n"+ ! " self. \n"; ! ! line = 9; ! col = 9; ! token = "LinkedList"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 196,215 ---- ! sDoc = ""+ ! "class LinkedList: \n"+ ! " def __init__(self,content='Null'): \n" + ! " if not content: \n"+ ! " self.first=content \n"+ ! " self.last=content \n"+ ! " else: \n"+ ! " self.first='Null' \n"+ ! " self.last='Null' \n"+ ! " self.content=content \n"+ ! " self. \n"; ! ! line = 9; ! col = 9; ! token = "LinkedList"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 220,230 **** } ! private IToken[] getComps() { ! try { ! return getManager().getCompletionsForToken(doc, state); ! } catch (CompletionRecursionException e) { ! throw new RuntimeException(e); ! } ! } public void testRecursion(){ --- 220,230 ---- } ! private IToken[] getComps() { ! try { ! return getManager().getCompletionsForToken(doc, state); ! } catch (CompletionRecursionException e) { ! throw new RuntimeException(e); ! } ! } public void testRecursion(){ *************** *** 233,238 **** col = 0; sDoc = ""+ ! "class A(B):pass \n" + ! "class B(A):pass \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 233,238 ---- col = 0; sDoc = ""+ ! "class A(B):pass \n" + ! "class B(A):pass \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 248,253 **** col = 0; sDoc = ""+ ! "from testlib.unittest.relative import Test1 \n" + ! "\n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 248,253 ---- col = 0; sDoc = ""+ ! "from testlib.unittest.relative import Test1 \n" + ! "\n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 277,282 **** col = 10; sDoc = ""+ ! "def met(par1, par2): \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 277,282 ---- col = 10; sDoc = ""+ ! "def met(par1, par2): \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 292,298 **** col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 292,298 ---- col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 309,316 **** col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " loc1 = 10 \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 309,316 ---- col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " loc1 = 10 \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 328,336 **** col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " loc1 = 10 \n" + ! " print \n" + ! " ignoreLineAfter = 5 \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 328,336 ---- col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " loc1 = 10 \n" + ! " print \n" + ! " ignoreLineAfter = 5 \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 350,362 **** */ public static void assertIsIn(String string, IToken[] comps) { ! StringBuffer buffer = new StringBuffer("Available: \n"); boolean found = false; for (int i = 0; i < comps.length; i++) { String rep = comps[i].getRepresentation(); ! if(string.equals(rep)){ found = true; } ! buffer.append(rep); ! buffer.append("\n"); } --- 350,362 ---- */ public static void assertIsIn(String string, IToken[] comps) { ! StringBuffer buffer = new StringBuffer("Available: \n"); boolean found = false; for (int i = 0; i < comps.length; i++) { String rep = comps[i].getRepresentation(); ! if(string.equals(rep)){ found = true; } ! buffer.append(rep); ! buffer.append("\n"); } Index: ProjectStub.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/ProjectStub.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ProjectStub.java 31 Jul 2008 01:47:36 -0000 1.4 --- ProjectStub.java 28 Sep 2008 12:45:43 -0000 1.5 *************** *** 35,47 **** String name; ! public IProject[] referencedProjects; ! public IProject[] referencingProjects; ! private PythonNature nature; ! private String path; public ProjectStub(String name, String path2, IProject[] referencedProjects, IProject[] referencingProjects) { ! this.path = path2; ! this.name = name; ! this.referencedProjects = referencedProjects; this.referencingProjects = referencingProjects; } --- 35,47 ---- String name; ! public IProject[] referencedProjects; ! public IProject[] referencingProjects; ! private PythonNature nature; ! private String path; public ProjectStub(String name, String path2, IProject[] referencedProjects, IProject[] referencingProjects) { ! this.path = path2; ! this.name = name; ! this.referencedProjects = referencedProjects; this.referencingProjects = referencingProjects; } *************** *** 91,98 **** public IProjectNature getNature(String natureId) throws CoreException { ! if(nature == null){ ! throw new RuntimeException("not expected"); ! } ! return nature; } --- 91,98 ---- public IProjectNature getNature(String natureId) throws CoreException { ! if(nature == null){ ! throw new RuntimeException("not expected"); ! } ! return nature; } *************** *** 115,121 **** public boolean hasNature(String natureId) throws CoreException { ! if(PythonNature.PYTHON_NATURE_ID.equals(natureId)){ ! return true; ! } throw new RuntimeException("not expected"); } --- 115,121 ---- public boolean hasNature(String natureId) throws CoreException { ! if(PythonNature.PYTHON_NATURE_ID.equals(natureId)){ ! return true; ! } throw new RuntimeException("not expected"); } *************** *** 434,456 **** } ! public void setNature(PythonNature nature) { ! this.nature = nature; ! } ! public IResourceProxy createProxy() { ! return null; ! } ! public URI getLocationURI() { ! return null; ! } ! public URI getRawLocationURI() { ! return null; ! } ! public boolean isLinked(int options) { ! return false; ! } public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth) throws CoreException { --- 434,456 ---- } ! public void setNature(PythonNature nature) { ! this.nature = nature; ! } ! public IResourceProxy createProxy() { ! return null; ! } ! public URI getLocationURI() { ! return null; ! } ! public URI getRawLocationURI() { ! return null; ! } ! public boolean isLinked(int options) { ! return false; ! } public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth) throws CoreException { *************** *** 458,491 **** } ! public void create(IProjectDescription description, int updateFlags, ! IProgressMonitor monitor) throws CoreException { ! // TODO Auto-generated method stub ! ! } ! public Map getPersistentProperties() throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } ! public Map getSessionProperties() throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } ! public boolean isDerived(int options) { ! // TODO Auto-generated method stub ! return false; ! } ! public boolean isHidden() { ! // TODO Auto-generated method stub ! return false; ! } ! public void setHidden(boolean isHidden) throws CoreException { ! // TODO Auto-generated method stub ! ! } } --- 458,491 ---- } ! public void create(IProjectDescription description, int updateFlags, ! IProgressMonitor monitor) throws CoreException { ! // TODO Auto-generated method stub ! ! } ! public Map getPersistentProperties() throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } ! public Map getSessionProperties() throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } ! public boolean isDerived(int options) { ! // TODO Auto-generated method stub ! return false; ! } ! public boolean isHidden() { ! // TODO Auto-generated method stub ! return false; ! } ! public void setHidden(boolean isHidden) throws CoreException { ! // TODO Auto-generated method stub ! ! } } Index: PythonPathHelperTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/PythonPathHelperTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PythonPathHelperTest.java 2 May 2008 13:42:01 -0000 1.5 --- PythonPathHelperTest.java 28 Sep 2008 12:45:43 -0000 1.6 *************** *** 43,51 **** ! public String qual = ""; ! public String token = ""; ! public int line; ! public int col; ! public String sDoc = ""; --- 43,51 ---- ! public String qual = ""; ! public String token = ""; ! public int line; ! public int col; ! public String sDoc = ""; *************** *** 72,76 **** PythonPathHelper helper = new PythonPathHelper(); String path = TestDependent.GetCompletePythonLib(true)+"|"+TestDependent.TEST_PYSRC_LOC; ! helper.setPythonPath(path); assertEquals("unittest",helper.resolveModule(TestDependent.PYTHON_LIB+"unittest.py")); --- 72,76 ---- PythonPathHelper helper = new PythonPathHelper(); String path = TestDependent.GetCompletePythonLib(true)+"|"+TestDependent.TEST_PYSRC_LOC; ! helper.setPythonPath(path); assertEquals("unittest",helper.resolveModule(TestDependent.PYTHON_LIB+"unittest.py")); *************** *** 96,104 **** col = 9; ! sDoc = ""+ ! "from testlib import unittest \n"+ ! " \n"+ ! "unittest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); --- 96,104 ---- col = 9; ! sDoc = ""+ ! "from testlib import unittest \n"+ ! " \n"+ ! "unittest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); *************** *** 119,129 **** } ! private IToken[] getComps(Document doc, ICompletionState state) { ! try { ! return ((ICodeCompletionASTManager)nature.getAstManager()).getCompletionsForToken(doc, state); ! } catch (CompletionRecursionException e) { ! throw new RuntimeException(e); ! } ! } public void testRecursionModuleCompletion() throws CompletionRecursionException{ --- 119,129 ---- } ! private IToken[] getComps(Document doc, ICompletionState state) { ! try { ! return ((ICodeCompletionASTManager)nature.getAstManager()).getCompletionsForToken(doc, state); ! } catch (CompletionRecursionException e) { ! throw new RuntimeException(e); ! } ! } public void testRecursionModuleCompletion() throws CompletionRecursionException{ *************** *** 132,139 **** col = 0; ! sDoc = ""+ ! "from testrec.imp1 import * \n"+ ! " \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); --- 132,139 ---- col = 0; ! sDoc = ""+ ! "from testrec.imp1 import * \n"+ ! " \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); *************** *** 150,158 **** col = 2; ! sDoc = ""+ ! "from testrec.imp3 import MethodReturn1 \n"+ ! "i = MethodReturn1() \n" + ! "i."; ! IToken[] comps = null; Document doc = new Document(sDoc); --- 150,158 ---- col = 2; ! sDoc = ""+ ! "from testrec.imp3 import MethodReturn1 \n"+ ! "i = MethodReturn1() \n" + ! "i."; ! IToken[] comps = null; Document doc = new Document(sDoc); *************** *** 167,184 **** public void testClassHierarchyCompletion(){ ! token = "TestCase"; ! line = 3; ! col = 9; ! sDoc = ""+ ! "from testlib.unittest.testcase import TestCase \n"+ ! " \n"+ ! "TestCase. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); --- 167,184 ---- public void testClassHierarchyCompletion(){ ! token = "TestCase"; ! line = 3; ! col = 9; ! sDoc = ""+ ! "from testlib.unittest.testcase import TestCase \n"+ ! " \n"+ ! "TestCase. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); *************** *** 188,205 **** public void testClassHierarchyCompletion2(){ ! token = "GUITest"; ! line = 3; ! col = 8; ! sDoc = ""+ ! "from testlib.unittest import GUITest \n"+ ! " \n"+ ! "GUITest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! ASTManagerTest.assertIsIn("SetWidget", comps); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); --- 188,205 ---- public void testClassHierarchyCompletion2(){ ! token = "GUITest"; ! line = 3; ! col = 8; ! sDoc = ""+ ! "from testlib.unittest import GUITest \n"+ ! " \n"+ ! "GUITest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! ASTManagerTest.assertIsIn("SetWidget", comps); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); *************** *** 210,227 **** public void testClassHierarchyCompletion3(){ ! token = "AnotherTest"; ! line = 3; ! col = 12; ! sDoc = ""+ ! "from testlib.unittest import AnotherTest \n"+ ! " \n"+ ! "AnotherTest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); --- 210,227 ---- public void testClassHierarchyCompletion3(){ ! token = "AnotherTest"; ! line = 3; ! col = 12; ! sDoc = ""+ ! "from testlib.unittest import AnotherTest \n"+ ! " \n"+ ! "AnotherTest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); *************** *** 235,243 **** col = 2; ! sDoc = ""+ ! "from testlib import unittest as t \n"+ ! " \n"+ ! "t. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); --- 235,243 ---- col = 2; ! sDoc = ""+ ! "from testlib import unittest as t \n"+ ! " \n"+ ! "t. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); *************** *** 259,276 **** public void testImportAs2(){ ! token = "t"; ! line = 3; ! col = 2; ! sDoc = ""+ ! "from testlib.unittest import AnotherTest as t \n"+ ! " \n"+ ! "t. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); --- 259,276 ---- public void testImportAs2(){ ! token = "t"; ! line = 3; ! col = 2; ! sDoc = ""+ ! "from testlib.unittest import AnotherTest as t \n"+ ! " \n"+ ! "t. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); *************** *** 281,300 **** public void testRelativeImport(){ ! token = "Derived"; ! line = 3; ! col = 8; ! sDoc = ""+ ! "from testlib.unittest.relative.testrelative import Derived \n"+ ! " \n"+ ! "Derived. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ASTManagerTest.assertIsIn("test1", comps); ASTManagerTest.assertIsIn("test2", comps); ! assertEquals(2, comps.length); --- 281,300 ---- public void testRelativeImport(){ ! token = "Derived"; ! line = 3; ! col = 8; ! sDoc = ""+ ! "from testlib.unittest.relative.testrelative import Derived \n"+ ! " \n"+ ! "Derived. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ASTManagerTest.assertIsIn("test1", comps); ASTManagerTest.assertIsIn("test2", comps); ! assertEquals(2, comps.length); Index: CodeCompletionTestsBase.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/CodeCompletionTestsBase.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** CodeCompletionTestsBase.java 31 Jul 2008 01:47:36 -0000 1.12 --- CodeCompletionTestsBase.java 28 Sep 2008 12:45:43 -0000 1.13 *************** *** 58,70 **** * Check the restorePythonPath function. */ ! public static PythonNature nature; ! ! /** ! * Nature for the second project. * * This nature has the other nature as a dependency. ! */ ! public static PythonNature nature2; ! /** * A map with the name of the project pointing to the last class that restored the --- 58,70 ---- * Check the restorePythonPath function. */ ! public static PythonNature nature; ! ! /** ! * Nature for the second project. * * This nature has the other nature as a dependency. ! */ ! public static PythonNature nature2; ! /** * A map with the name of the project pointing to the last class that restored the *************** *** 72,93 **** * all the time among tests from the same test case. */ ! public static Map<String, Class> restoredClass = new HashMap<String, Class>(); ! /** * Serves the same purpose that the restoredClass serves, but for the system * python nature. */ ! public static Class restoredSystem; ! private Preferences preferences; ! public Preferences getPreferences(){ ! if(this.preferences == null){ ! this.preferences = new Preferences(); ! } ! return this.preferences; ! } ! ! protected boolean ADD_MX_TO_FORCED_BUILTINS = true; ! protected boolean ADD_NUMPY_TO_FORCED_BUILTINS = true; /** --- 72,93 ---- * all the time among tests from the same test case. */ ! public static Map<String, Class> restoredClass = new HashMap<String, Class>(); ! /** * Serves the same purpose that the restoredClass serves, but for the system * python nature. */ ! public static Class restoredSystem; ! private Preferences preferences; ! public Preferences getPreferences(){ ! if(this.preferences == null){ ! this.preferences = new Preferences(); ! } ! return this.preferences; ! } ! ! protected boolean ADD_MX_TO_FORCED_BUILTINS = true; ! protected boolean ADD_NUMPY_TO_FORCED_BUILTINS = true; /** *************** *** 96,100 **** protected static boolean DEBUG_TESTS_BASE = false; ! /* * @see TestCase#setUp() */ --- 96,100 ---- protected static boolean DEBUG_TESTS_BASE = false; ! /* * @see TestCase#setUp() */ *************** *** 162,168 **** PythonNature n = checkNewNature(name, force); if(n != null){ ! nature2 = n; ! ProjectStub projectFromNature1 = (ProjectStub) nature.getProject(); //create a new project referencing the first one ProjectStub projectFromNature2 = new ProjectStub(name, path, new IProject[]{projectFromNature1}, new IProject[0]); --- 162,168 ---- PythonNature n = checkNewNature(name, force); if(n != null){ ! nature2 = n; ! ProjectStub projectFromNature1 = (ProjectStub) nature.getProject(); //create a new project referencing the first one ProjectStub projectFromNature2 = new ProjectStub(name, path, new IProject[]{projectFromNature1}, new IProject[0]); *************** *** 171,178 **** projectFromNature1.referencingProjects = new IProject[]{projectFromNature2}; ! setAstManager(path, projectFromNature2, nature2); ! return true; ! } ! return false; } --- 171,178 ---- projectFromNature1.referencingProjects = new IProject[]{projectFromNature2}; ! setAstManager(path, projectFromNature2, nature2); ! return true; ! } ! return false; } *************** *** 258,262 **** info.restoreCompiledLibs(getProgressMonitor()); if(ADD_MX_TO_FORCED_BUILTINS){ ! info.addForcedLib("mx"); } if(ADD_NUMPY_TO_FORCED_BUILTINS){ --- 258,262 ---- info.restoreCompiledLibs(getProgressMonitor()); if(ADD_MX_TO_FORCED_BUILTINS){ ! info.addForcedLib("mx"); } if(ADD_NUMPY_TO_FORCED_BUILTINS){ *************** *** 377,385 **** int size = ((ASTManager)nature.getAstManager()).getSize(); assertTrue("Interpreter size:"+info.getModulesManager().getSize(true)+" should be smaller than project size:"+size+" " + ! "(because it contains system+project info)" , info.getModulesManager().getSize(true) < size ); size = ((ASTManager)nature2.getAstManager()).getSize(); assertTrue("Interpreter size:"+info.getModulesManager().getSize(true)+" should be smaller than project size:"+size+" " + ! "(because it contains system+project info)" , info.getModulesManager().getSize(true) < size ); } --- 377,385 ---- int size = ((ASTManager)nature.getAstManager()).getSize(); assertTrue("Interpreter size:"+info.getModulesManager().getSize(true)+" should be smaller than project size:"+size+" " + ! "(because it contains system+project info)" , info.getModulesManager().getSize(true) < size ); size = ((ASTManager)nature2.getAstManager()).getSize(); assertTrue("Interpreter size:"+info.getModulesManager().getSize(true)+" should be smaller than project size:"+size+" " + ! "(because it contains system+project info)" , info.getModulesManager().getSize(true) < size ); } *************** *** 403,410 **** public ICompletionProposal[] requestCompl(String strDoc, int documentOffset, int returned, String []retCompl) throws CoreException, BadLocationException{ ! return requestCompl(strDoc, documentOffset, returned, retCompl, nature); } public ICompletionProposal[] requestCompl(String strDoc, int documentOffset, int returned, String []retCompl, PythonNature nature) throws CoreException, BadLocationException{ ! return requestCompl(null, strDoc, documentOffset, returned, retCompl, nature); } --- 403,410 ---- public ICompletionProposal[] requestCompl(String strDoc, int documentOffset, int returned, String []retCompl) throws CoreException, BadLocationException{ ! return requestCompl(strDoc, documentOffset, returned, retCompl, nature); } public ICompletionProposal[] requestCompl(String strDoc, int documentOffset, int returned, String []retCompl, PythonNature nature) throws CoreException, BadLocationException{ ! return requestCompl(null, strDoc, documentOffset, returned, retCompl, nature); } *************** *** 415,419 **** public ICompletionProposal[] requestCompl(File file, String strDoc, int documentOffset, int returned, String []retCompl) throws CoreException, BadLocationException{ ! return requestCompl(file, strDoc, documentOffset, returned, retCompl, nature); } --- 415,419 ---- public ICompletionProposal[] requestCompl(File file, String strDoc, int documentOffset, int returned, String []retCompl) throws CoreException, BadLocationException{ ! return requestCompl(file, strDoc, documentOffset, returned, retCompl, nature); } *************** *** 481,490 **** */ protected void assertNotContains(String string, ICompletionProposal[] codeCompletionProposals) { ! for (int i = 0; i < codeCompletionProposals.length; i++) { ! ICompletionProposal completionProposal = codeCompletionProposals[i]; ! if(checkIfEquals(string, completionProposal)){ ! fail("The string >>"+string+"<< was found in the returned completions (was not expected to be found)."); ! } ! } } --- 481,490 ---- */ protected void assertNotContains(String string, ICompletionProposal[] codeCompletionProposals) { ! for (int i = 0; i < codeCompletionProposals.length; i++) { ! ICompletionProposal completionProposal = codeCompletionProposals[i]; ! if(checkIfEquals(string, completionProposal)){ ! fail("The string >>"+string+"<< was found in the returned completions (was not expected to be found)."); ! } ! } } |