gt:                 "for x in []:   \n" +
context: /**
   * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
   * Licensed under the terms of the Eclipse Public License (EPL).
   * Please see the license.txt included with this distribution for details.
   * Any modifications to this file must keep this entire header intact.
   */
  /*
   * Created on Mar 8, 2005
   *
   * @author Fabio Zadrozny
   */
  package org.python.pydev.editor.codecompletion;
  
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import org.eclipse.core.runtime.CoreException;
  import org.eclipse.jface.text.BadLocationException;
  import org.eclipse.jface.text.Document;
  import org.eclipse.jface.text.contentassist.ICompletionProposal;
  import org.python.pydev.core.ExtensionHelper;
  import org.python.pydev.core.ICompletionState;
  import org.python.pydev.core.ILocalScope;
  import org.python.pydev.core.IModule;
  import org.python.pydev.core.IPythonNature;
  import org.python.pydev.core.IToken;
  import org.python.pydev.core.MisconfigurationException;
  import org.python.pydev.core.TestDependent;
  import org.python.pydev.core.docutils.ImportsSelection;
  import org.python.pydev.core.docutils.PySelection;
  import org.python.pydev.core.docutils.PySelection.ActivationTokenAndQual;
  import org.python.pydev.core.docutils.StringUtils;
  import org.python.pydev.core.log.Log;
  import org.python.pydev.core.structure.CompletionRecursionException;
  import org.python.pydev.editor.codecompletion.revisited.CodeCompletionTestsBase;
  import org.python.pydev.editor.codecompletion.revisited.CompletionCache;
  import org.python.pydev.editor.codecompletion.revisited.modules.CompiledModule;
  import org.python.pydev.editor.codecompletion.revisited.modules.SourceToken;
  
  import com.aptana.shared_core.callbacks.ICallback;
  import com.aptana.shared_core.io.FileUtils;
  
  /**
   * This tests the 'whole' code completion, passing through all modules.
   * 
   * @author Fabio Zadrozny
   */
  public class PythonCompletionWithoutBuiltinsTest extends CodeCompletionTestsBase {
  
      public static void main(String[] args) {
  
          try {
              //DEBUG_TESTS_BASE = true;
              PythonCompletionWithoutBuiltinsTest test = new PythonCompletionWithoutBuiltinsTest();
              test.setUp();
              test.testGrammar2AbsoluteAndRelativeImports();
              test.tearDown();
              System.out.println("Finished");
  
              junit.textui.TestRunner.run(PythonCompletionWithoutBuiltinsTest.class);
          } catch (Throwable e) {
              e.printStackTrace();
          }
      }
  
      private static final class ParticipantWithBarToken implements IPyDevCompletionParticipant {
          public Collection<Object> getStringGlobalCompletions(CompletionRequest request, ICompletionState state)
                  throws MisconfigurationException {
              throw new RuntimeException("Not implemented");
          }
  
          public Collection<Object> getGlobalCompletions(CompletionRequest request, ICompletionState state)
                  throws MisconfigurationException {
              throw new RuntimeException("Not implemented");
          }
  
          public Collection<IToken> getCompletionsForMethodParameter(ICompletionState state, ILocalScope localScope,
                  Collection<IToken> interfaceForLocal) {
              throw new RuntimeException("Not implemented");
          }
  
          public Collection<IToken> getCompletionsForTokenWithUndefinedType(ICompletionState state,
                  ILocalScope localScope, Collection<IToken> interfaceForLocal) {
              ArrayList<IToken> ret = new ArrayList<IToken>();
              ret.add(new SourceToken(null, "bar", null, null, null, IToken.TYPE_ATTR));
              return ret;
          }
  
          public Collection<Object> getArgsCompletion(ICompletionState state, ILocalScope localScope,
                  Collection<IToken> interfaceForLocal) {
              throw new RuntimeException("Not implemented");
          }
      }
  
      /*
       * @see TestCase#setUp()
       */
      public void setUp() throws Exception {
          super.setUp();
          CompiledModule.COMPILED_MODULES_ENABLED = false;
          this.restorePythonPath(TestDependent.GetCompletePythonLib(true) +
                  "|" + TestDependent.PYTHON_PIL_PACKAGES +
                  "|"
                  + TestDependent.TEST_PYSRC_LOC +
                  "configobj-4.6.0-py2.6.egg", false);
  
          this.restorePythonPath(false);
          codeCompletion = new PyCodeCompletion();
          PyCodeCompletion.onCompletionRecursionException = new ICallback<Object, CompletionRecursionException>() {
  
              public Object call(CompletionRecursionException e) {
                  throw new RuntimeException("Recursion error:" + Log.getExceptionStr(e));
              }
  
          };
      }
  
      /*
       * @see TestCase#tearDown()
       */
      public void tearDown() throws Exception {
          CompiledModule.COMPILED_MODULES_ENABLED = true;
          super.tearDown();
          PyCodeCompletion.onCompletionRecursionException = null;
      }
  
      public void testCompleteImportCompletion() throws Exception {
          String[] testLibAndSubmodules = new String[] { "testlib",
                  //                "testlib.unittest",
                  //                "testlib.unittest.anothertest",
                  //                "testlib.unittest.guitestcase",
                  //                "testlib.unittest.relative",
                  //                "testlib.unittest.relative.testrelative",
                  //                "testlib.unittest.relative.toimport",
                  //                "testlib.unittest.testcase",
          };
  
          requestCompl("import zipf", new String[] { "zipfile" });
          requestCompl("from testl", testLibAndSubmodules);
          requestCompl("import testl", testLibAndSubmodules);
          requestCompl("from testlib import ", new String[] { "__file__", "__name__", "__init__", "unittest", "__path__",
                  "__dict__" });
          requestCompl("from testlib import unittest, __in", new String[] { "__init__" });
          requestCompl("from testlib import unittest,__in", new String[] { "__init__" });
          requestCompl("from testlib import unittest ,__in", new String[] { "__init__" });
          requestCompl("from testlib import unittest , __in", new String[] { "__init__" });
          requestCompl("from testlib import unittest , ", new String[] { "__file__", "__name__", "__init__", "unittest",
                  "__path__", "__dict__" });
  
          requestCompl("from testlib.unittest import  ", getTestLibUnittestTokens());
  
          requestCompl("from testlib.unittest.testcase.TestCase import  assertImagesNotE",
                  new String[] { "assertImagesNotEqual" });
          requestCompl("from testlib.unittest.testcase.TestCase import  assertBM", new String[] { "assertBMPsNotEqual",
                  "assertBMPsEqual" });
      }
  
      public void testFullModulesOnFromImport() throws Exception {
          requestCompl("from ", -1, new String[] { "testlib" });
          //        requestCompl("from ", -1, new String[]{"testlib", "testlib.unittest"}); -- feature removed.
      }
  
      /**
       * This test checks the code-completion for adaptation and factory methods, provided that the 
       * class expected is passed as one of the parameters.
       * 
       * This is done in AssignAnalysis
       */
      public void testProtocolsAdaptation() throws Exception {
          String s = "import protocols\n" +
                  "class InterfM1(protocols.Interface):\n" +
                  "    def m1(self):\n"
                  +
                  "        pass\n" +
                  " \n" +
                  "class Bar(object):\n"
                  +
                  "    protocols.advise(instancesProvide=[InterfM1])\n" +
                  "if __name__ == '__main__':\n"
                  +
                  "    a = protocols.adapt(Bar(), InterfM1)\n" +
                  "    a.";
  
          requestCompl(s, s.length(), -1, new String[] { "m1()" });
      }
  
      /**
       * Check if some assert for an instance is enough to get the type of some variable. This should
       * be configurable so that the user can do something as assert IsInterfaceDeclared(obj, Class) or 
       * AssertImplements(obj, Class), with the assert or not, providing some way for the user to configure that.
       * 
       * This is done in ILocalScope#getPossibleClassesForActivationToken
       */
      public void testAssertDeterminesClass() throws Exception {
          String s = "def m1(a):\n" +
                  "    import xmllib\n" +
                  "    assert isinstance(a, xmllib.XMLParser)\n" +
                  "    a.";
  
          requestCompl(s, s.length(), -1, new String[] { "handle_data(data)" });
  
      }
  
      public void testAssertDeterminesClass2() throws Exception {
          String s = "def m1(a):\n" +
                  "    import xmllib\n" +
                  "    assert isinstance(a.bar, xmllib.XMLParser)\n"
                  +
                  "    a.bar.";
  
          requestCompl(s, s.length(), -1, new String[] { "handle_data(data)" });
  
      }
  
      public void testAssertDeterminesClass3() throws Exception {
          String s = "class InterfM1:\n" +
                  "    def m1(self):\n" +
                  "        pass\n" +
                  "\n" +
                  "" +
                  "def m1(a):\n"
                  +
                  "    assert isinstance(a, InterfM1)\n" +
                  "    a.";
  
          requestCompl(s, s.length(), -1, new String[] { "m1()" });
  
      }
  
      public void testAssertDeterminesClass4() throws Exception {
          String s = "class InterfM1:\n" +
                  "    def m1(self):\n" +
                  "        pass\n" +
                  "\n" +
                  "class InterfM2:\n"
                  +
                  "    def m2(self):\n" +
                  "        pass\n" +
                  "\n" +
                  "" +
                  "def m1(a):\n"
                  +
                  "    assert isinstance(a, (InterfM1, InterfM2))\n" +
                  "    a.";
  
          requestCompl(s, s.length(), -1, new String[] { "m1()", "m2()" });
  
      }
  
      public void testAssertDeterminesClass5() throws Exception {
          String s = "class InterfM1:\n" +
                  "    def m1(self):\n" +
                  "        pass\n" +
                  "\n" +
                  "" +
                  "def m1(a):\n"
                  +
                  "    assert InterfM1.implementedBy(a)\n" +
                  "    a.";
  
          requestCompl(s, s.length(), -1, new String[] { "m1()" });
  
      }
  
      public void testAssertDeterminesClass6() throws Exception {
          String s = "class InterfM1:\n" +
                  "    def m1(self):\n" +
                  "        pass\n" +
                  "\n" +
                  "" +
                  "def m1(a):\n"
                  +
                  "    assert InterfM1.implementedBy()\n" + //should give no error
                  "    a.";
  
          requestCompl(s, s.length(), -1, new String[] {});
  
      }
  
      public void testMultilineImportCompletion() throws Exception {
          String s = "from testlib import (\n";
  
          requestCompl(s, new String[] { "__file__", "__name__", "__init__", "unittest", "__path__", "__dict__" });
  
      }
  
      /**
       * @return
       */
      public String[] getTestLibUnittestTokens() {
          return new String[] { "__file__", "__init__", "__name__", "__dict__", "__path__", "anothertest", "AnotherTest",
                  "GUITest", "guitestcase", "main", "relative", "t", "TestCase", "testcase", "TestCaseAlias" };
      }
  
      public void testSelfReference() throws Exception {
          String s;
          s = "class C:            \n" +
                  "    def met1(self): \n" +
                  "        pass        \n" +
                  "                    \n"
                  +
                  "class B:            \n" +
                  "    def met2(self): \n" +
                  "        self.c = C()\n"
                  +
                  "                    \n" +
                  "    def met3(self): \n" +
                  "        self.c.";
          requestCompl(s, s.length(), -1, new String[] { "met1()" });
      }
  
      public void testProj2() throws Exception {
          String s;
          s = "" +
                  "import proj2root\n" +
                  "print proj2root.";
          requestCompl(s, s.length(), -1, new String[] { "Proj2Root" }, nature2);
      }
  
      public void testProj2Global() throws Exception {
          String s;
          s = "" +
                  "import ";
          requestCompl(s, s.length(), -1, new String[] { "proj2root", "testlib" }, nature2);
      }
  
      public void testPIL() throws Exception {
          if (TestDependent.PYTHON_PIL_PACKAGES != null) {
              String s;
              s = "" +
                      "import Image\n" +
                      "Image." +
                      "";
              requestCompl(s, s.length(), -1, new String[] { "RASTERIZE" });
          }
      }
  
      public void testClassAttrs() throws Exception {
          String s;
          s = "" +
                  "class A:\n" +
                  "    aa, bb, cc = range(3)\n" + //the heuristic to find the attrs (class HeuristicFindAttrs) was not getting this
                  "    dd = 1\n" +
                  "    def m1(self):\n" +
                  "        self.";
          requestCompl(s, s.length(), -1, new String[] { "aa", "bb", "cc", "dd" });
      }
  
      public void testFromImport() throws Exception {
          //TODO: see AbstractASTManager.resolveImport
          String s;
          s = "" +
                  "from testOtherImports.f3 import test\n" +
                  "tes";
          ICompletionProposal[] p = requestCompl(s, s.length(), -1, new String[] { "test(a, b, c)" }, nature);
          assertEquals("def test(a, b, c):    \"\"\"This is a docstring\"\"\"",
                  StringUtils.removeNewLineChars(p[0].getAdditionalProposalInfo()));
      }
  
      public void testFromImportAs() throws Exception {
          String s;
          s = "" +
                  "from testOtherImports.f3 import test as AnotherTest\n" +
                  "t = AnotherTes";
          ICompletionProposal[] p = requestCompl(s, s.length(), -1, new String[] { "AnotherTest(a, b, c)" }, nature);
          assertEquals("def test(a, b, c):    \"\"\"This is a docstring\"\"\"",
                  StringUtils.removeNewLineChars(p[0].getAdditionalProposalInfo()));
      }
  
      public void testFromImportAs2() throws Exception {
          String s;
          s = "" +
                  "from testOtherImports.f3 import Foo\n" +
                  "t = Fo";
          ICompletionProposal[] p = requestCompl(s, s.length(), -1, new String[] { "Foo" }, nature);
          assertEquals("class SomeOtherTest(object):    '''SomeOtherTest'''    def __init__(self, a, b):        pass",
                  StringUtils.removeNewLineChars(p[0].getAdditionalProposalInfo()));
      }
  
      public void testInnerImport() throws Exception {
          String s;
          s = "" +
                  "def m1():\n" +
                  "    from testlib import unittest\n" +
                  "    unittest.";
          requestCompl(s, s.length(), -1, new String[] { "AnotherTest", "GUITest",
                  "main(module, defaultTest, argv, testRunner, testLoader)", "TestCase", "testcase", "TestCaseAlias"
  
                  //gotten because unittest is actually an __init__, so, gather others that are in the same level
                  , "anothertest", "guitestcase", "testcase" });
      }
  
      public void testSelfReferenceWithTabs() throws Exception {
          String s;
          s = "class C:\n" +
                  "    def met1(self):\n" +
                  "        pass\n" +
                  "        \n" +
                  "class B:\n"
                  +
                  "    def met2(self):\n" +
                  "        self.c = C()\n" +
                  "        \n" +
                  "    def met3(self):\n"
                  +
                  "        self.c.";
          s = s.replaceAll("\\ \\ \\ \\ ", "\t");
          requestCompl(s, s.length(), -1, new String[] { "met1()" });
      }
  
      public void testClassCompl() throws Exception {
          String s;
          s = "" +
                  "class Test:\n" +
                  "    classVar = 1\n" +
                  "    def findIt(self):\n" +
                  "        self.";
          requestCompl(s, s.length(), -1, new String[] { "classVar" });
      }
  
      public void testInnerCtxt() throws Exception {
          String s;
          s = "" +
                  "class Test:\n" +
                  "    def findIt(self):\n" +
                  "        pass\n" +
                  "    \n" +
                  "def m1():\n"
                  +
                  "    s = Test()\n" +
                  "    s.";
          requestCompl(s, s.length(), -1, new String[] { "findIt()" });
      }
  
      public void testDeepNested() throws Exception {
          String s;
          s = "" +
                  "from extendable.nested2 import hub\n" +
                  "hub.c1.a.";
          requestCompl(s, s.length(), -1, new String[] { "fun()" });
      }
  
      public void testDeepNested2() throws Exception {
          String s;
          s = "" +
                  "from extendable.nested2 import hub\n" +
                  "hub.c1.b.";
          requestCompl(s, s.length(), -1, new String[] { "another()" });
      }
  
      public void testDeepNested3() throws Exception {
          String s;
          s = "" +
                  "from extendable.nested2 import hub\n" +
                  "hub.c1.c.";
          requestCompl(s, s.length(), -1, new String[] { "another()" });
      }
  
      public void testDeepNested4() throws Exception {
          String s;
          s = "" +
                  "from extendable.nested2 import hub\n" +
                  "hub.c1.d.";
          requestCompl(s, s.length(), -1, new String[] { "AnotherTest" });
      }
  
      public void testDeepNested5() throws Exception {
          String s;
          s = "" +
                  "from extendable.nested2 import hub\n" +
                  "hub.c1.e.";
          requestCompl(s, s.length(), -1, new String[] { "assertBMPsNotEqual(f1, f2)" });
      }
  
      public void testDeepNested6() throws Exception {
          String s;
          s = "" +
                  "from extendable.nested2 import mod2\n" +
                  "mod2.c1.a.";
          requestCompl(s, s.length(), -1, new String[] { "fun()" });
      }
  
      public void testSelfReferenceWithTabs2() throws Exception {
          String s;
          s = "" +
                  "class C:\n" +
                  "    def met3(self):\n" +
                  "        self.COMPLETE_HERE\n" +
                  "                    \n"
                  +
                  "    def met1(self): \n" +
                  "        pass        \n" +
                  "";
          s = s.replaceAll("\\ \\ \\ \\ ", "\t");
          int iComp = s.indexOf("COMPLETE_HERE");
          s = s.replaceAll("COMPLETE_HERE", "");
          requestCompl(s, iComp, -1, new String[] { "met1()" });
      }
  
      public void testRelativeImport() throws FileNotFoundException, Exception {
          String file = TestDependent.TEST_PYSRC_LOC +
                  "testlib/unittest/relative/testrelative.py";
          String strDoc = "from toimport import ";
          requestCompl(new File(file), strDoc, strDoc.length(), -1, new String[] { "Test1", "Test2" });
      }
  
      public void testRelativeImport2() throws FileNotFoundException, Exception {
          String file = TestDependent.TEST_PYSRC_LOC +
                  "extendable/relative_absolute_import/__init__.py";
          String strDoc = "from .foo import bar as buzz\nbuzz.";
          requestCompl(new File(file), strDoc, strDoc.length(), -1, new String[] { "jazz()" });
      }
  
      public void testInModuleWithoutExtension() throws FileNotFoundException, Exception {
          String file = TestDependent.TEST_PYSRC_LOC +
                  "mod_without_extension";
          String strDoc = FileUtils.getFileContents(new File(file));
          requestCompl(new File(file), strDoc, strDoc.length(), -1, new String[] { "ClassInModWithoutExtension" });
      }
  
      public void testRelativeImportWithSubclass() throws FileNotFoundException, Exception {
          String file = TestDependent.TEST_PYSRC_LOC +
                  "extendable/relative_with_sub/bb.py";
          String strDoc = FileUtils.getFileContents(new File(file));
          requestCompl(new File(file), strDoc, strDoc.length(), -1, new String[] { "yyy()" });
      }
  
      public void testWildImportRecursive() throws BadLocationException, IOException, Exception {
          String s;
          s = "from testrecwild import *\n" +
                  "";
          requestCompl(s, -1, -1, new String[] { "Class1" });
      }
  
      public void testWildImportRecursive2() throws BadLocationException, IOException, Exception {
          String s;
          s = "from testrecwild2 import *\n" +
                  "";
          requestCompl(s, -1, -1, new String[] { "Class2" });
      }
  
      public void testWildImportRecursive3() throws BadLocationException, IOException, Exception {
          String s;
          s = "from testrec2 import *\n" +
                  "";
          requestCompl(s, -1, -1, new String[] { "Leaf" });
      }
  
      public void testProperties() throws BadLocationException, IOException, Exception {
          String s;
          s = "class C:\n" +
                  "    \n" +
                  "    properties.create(test = 0)\n" +
                  "    \n" +
                  "c = C.";
          requestCompl(s, -1, -1, new String[] { "test" });
      }
  
      public void testImportMultipleFromImport() throws BadLocationException, IOException, Exception {
          String s;
          s = "import testlib.unittest.relative\n" +
                  "";
          requestCompl(s, -1, -1, new String[] { "testlib", "testlib.unittest", "testlib.unittest.relative" });
      }
  
      public void testImportMultipleFromImport2() throws BadLocationException, IOException, Exception {
          String s;
          s = "import testlib.unittest.relative\n" +
                  "testlib.";
          requestCompl(s, -1, -1, new String[] { "__path__" });
      }
  
      public void testNestedImports() throws BadLocationException, IOException, Exception {
          String s;
          s = "from extendable import nested\n" +
                  "print nested.NestedClass.";
          requestCompl(s, -1, 1, new String[] { "nestedMethod(self)" });
      }
  
      public void testSameName() throws BadLocationException, IOException, Exception {
          String s;
          s = "from extendable.namecheck import samename\n" +
                  "print samename.";
          requestCompl(s, -1, 1, new String[] { "method1(self)" });
      }
  
      public void testSameName2() throws BadLocationException, IOException, Exception {
          String s;
          s = "from extendable import namecheck\n" +
                  "print namecheck.samename.";
          requestCompl(s, -1, 1, new String[] { "method1(self)" });
      }
  
      public void testCompositeImport() throws BadLocationException, IOException, Exception {
          String s;
          s = "import xml.sax\n" +
                  "print xml.sax.";
          requestCompl(s, -1, -1, new String[] { "default_parser_list" });
      }
  
      public void testIsInGlobalTokens() throws BadLocationException, IOException, Exception {
          IModule module = nature.getAstManager().getModule("testAssist.__init__", nature, true);
          assertTrue(module.isInGlobalTokens("assist.ExistingClass.existingMethod", nature, new CompletionCache()));
      }
  
      public void testGetActTok() {
          String strs[];
  
          strs = PySelection.getActivationTokenAndQual(new Document(""), 0, false);
          assertEquals("", strs[0]);
          assertEquals("", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(
                  new Document("self.assertEquals( DECAY_COEF, t.item(0, C).text())"), 42, false);
          assertEquals("", strs[0]);
          assertEquals("C", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(
                  new Document("self.assertEquals( DECAY_COEF, t.item(0,C).text())"), 41, false);
          assertEquals("", strs[0]);
          assertEquals("C", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("m = met(self.c, self.b)"), 14, false);
          assertEquals("self.", strs[0]);
          assertEquals("c", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("[a,b].ap"), 8, false);
          assertEquals("list.", strs[0]);
          assertEquals("ap", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("{a:1,b:2}.ap"), 12, false);
          assertEquals("dict.", strs[0]);
          assertEquals("ap", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("''.ap"), 5, false);
          assertEquals("str.", strs[0]);
          assertEquals("ap", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("\"\".ap"), 5, false);
          assertEquals("str.", strs[0]);
          assertEquals("ap", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("ClassA.someMethod.ap"), 20, false);
          assertEquals("ClassA.someMethod.", strs[0]);
          assertEquals("ap", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("ClassA.someMethod().ap"), 22, false);
          assertEquals("ClassA.someMethod().", strs[0]);
          assertEquals("ap", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("ClassA.someMethod( a, b ).ap"), 28, false);
          assertEquals("ClassA.someMethod().", strs[0]);
          assertEquals("ap", strs[1]);
  
          String s = "Foo().";
          strs = PySelection.getActivationTokenAndQual(new Document(s), s.length(), false);
          assertEquals("Foo().", strs[0]);
          assertEquals("", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("foo.bar"), 2, false);
          assertEquals("", strs[0]);
          assertEquals("fo", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("foo.bar"), 2, false);
          assertEquals("", strs[0]);
          assertEquals("fo", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("foo.bar"), 2, true);
          assertEquals("", strs[0]);
          assertEquals("foo", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("foo.bar   "), 2, true);
          assertEquals("", strs[0]);
          assertEquals("foo", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("foo.bar   "), 5, true); //get the full qualifier
          assertEquals("foo.", strs[0]);
          assertEquals("bar", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("foo.bar   "), 5, false); //get just a part of it
          assertEquals("foo.", strs[0]);
          assertEquals("b", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("foo.bar   "), 100, true); //out of the league
          assertEquals("", strs[0]);
          assertEquals("", strs[1]);
  
          String importsTipperStr = ImportsSelection.getImportsTipperStr(new Document("from coilib.decorators import "),
                  30).importsTipperStr;
          assertEquals("coilib.decorators", importsTipperStr);
  
          strs = PySelection.getActivationTokenAndQual(new Document("foo.bar.xxx   "), 9, true);
          assertEquals("foo.bar.", strs[0]);
          assertEquals("xxx", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("foo.bar.xxx   "), 9, false);
          assertEquals("foo.bar.", strs[0]);
          assertEquals("x", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document("m1(a.b)"), 4, false);
          assertEquals("", strs[0]);
          assertEquals("a", strs[1]);
  
          //Ok, now, the tests for getting the activation token and qualifier for the calltips.
          //We should 'know' that we're just after a parenthesis and get the contents before it
          //This means: get the char before the offset (excluding spaces and tabs) and see
          //if it is a ',' or '(' and if it is, go to that offset and do the rest of the process
          //as if we were on that position
          ActivationTokenAndQual act = PySelection.getActivationTokenAndQual(new Document("m1()"), 3, false, true);
          assertEquals("", act.activationToken);
          assertEquals("m1", act.qualifier);
          assertTrue(act.changedForCalltip);
          assertFalse(act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document("m1.m2()"), 6, false, true);
          assertEquals("m1.", act.activationToken);
          assertEquals("m2", act.qualifier);
          assertTrue(act.changedForCalltip);
          assertFalse(act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document("m1.m2(  \t)"), 9, false, true);
          assertEquals("m1.", act.activationToken);
          assertEquals("m2", act.qualifier);
          assertTrue(act.changedForCalltip);
          assertFalse(act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document("m1(a  , \t)"), 9, false, true);
          assertEquals("", act.activationToken);
          assertEquals("m1", act.qualifier);
          assertTrue(act.changedForCalltip);
          assertTrue(act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document("m1(a)"), 4, false, true);
          assertEquals("", act.activationToken);
          assertEquals("a", act.qualifier);
          assertTrue(!act.changedForCalltip);
          assertTrue(!act.alreadyHasParams);
          assertTrue(act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document("m1(a.)"), 5, false, true);
          assertEquals("a.", act.activationToken);
          assertEquals("", act.qualifier);
          assertTrue(!act.changedForCalltip);
          assertTrue(!act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document("m1(a, b)"), 7, false, true);
          assertEquals("", act.activationToken);
          assertEquals("b", act.qualifier);
          assertTrue(!act.changedForCalltip);
          assertTrue(!act.alreadyHasParams);
          assertTrue(act.isInMethodKeywordParam);
      }
  
      /**
       * Add tests that demonstrate behaviour when doc starts with a . 
       */
      public void testGetAckTok2() {
          String strs[];
          strs = PySelection.getActivationTokenAndQual(new Document("."), 1, false);
          assertEquals("", strs[0]);
          assertEquals("", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document(".a"), 1, false);
          assertEquals("", strs[0]);
          assertEquals("", strs[1]);
  
          strs = PySelection.getActivationTokenAndQual(new Document(".a"), 2, false);
          assertEquals("", strs[0]);
          assertEquals("a", strs[1]);
  
          ActivationTokenAndQual act = PySelection.getActivationTokenAndQual(new Document("."), 1, false, true);
          assertEquals("", act.activationToken);
          assertEquals("", act.qualifier);
          assertTrue(!act.changedForCalltip);
          assertTrue(!act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document(".a"), 1, false, true);
          assertEquals("", act.activationToken);
          assertEquals("", act.qualifier);
          assertTrue(!act.changedForCalltip);
          assertTrue(!act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document(".a"), 2, false, true);
          assertEquals("", act.activationToken);
          assertEquals("a", act.qualifier);
          assertTrue(!act.changedForCalltip);
          assertTrue(!act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document(".abc"), 1, true, true);
          assertEquals("", act.activationToken);
          assertEquals("abc", act.qualifier);
          assertTrue(!act.changedForCalltip);
          assertTrue(!act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
  
          act = PySelection.getActivationTokenAndQual(new Document(".abc"), 2, true, true);
          assertEquals("", act.activationToken);
          assertEquals("abc", act.qualifier);
          assertTrue(!act.changedForCalltip);
          assertTrue(!act.alreadyHasParams);
          assertTrue(!act.isInMethodKeywordParam);
      }
  
      /**
       * @throws BadLocationException
       * @throws CoreException
       */
      public void testFor() throws Exception {
          String s;
          s = "" +
                  "for event in a:   \n" +
                  "    print event   \n" +
                  "                  \n" +
                  "print event.xx\n"
                  +
                  "print event." +
                  "";
          requestCompl(s, s.length(), -1, new String[] { "xx" });
      }
  
      public void testForWithExtensions() throws Exception {
          String s;
          s = "" +
                  "for event in a:   \n" +
                  "    print event   \n" +
                  "                  \n" +
                  "print event.xx\n"
                  +
                  "print event." +
                  "";
          checkParticipantAndXXInterface(s);
      }
  
      public void testForWithExtensions2() throws Exception {
          String s;
          s = "" +
  