Пример #1
0
  /**
   * This test checks if {@link INameEnvironment#findType(char[], char[][])} is executed.
   * INameEnvironment has no option to avoid the search for secondary types, therefore the search
   * for secondary types is executed (when available).
   */
  public void test03() {
    NameEnvironmentDummy nameEnv = new NameEnvironmentDummy(false);

    LookupEnvironment lookupEnv = new LookupEnvironment(null, new CompilerOptions(), null, nameEnv);
    PackageBinding packageBinding =
        lookupEnv.createPackage(
            new char[][] {
              "org/eclipse/jdt".toCharArray(), "org/eclipse/jdt/internal".toCharArray()
            });
    assertNotNull(packageBinding);

    assertTrue(
        nameEnv
            .isTypeSearchExecuted); // the method findType(char[], char[][]) should got executed
                                    // (without an option to avoid the search for secondary types)
  }
Пример #2
0
  /**
   * This test checks if types are searched on creating a package, but without the search for
   * secondary types. It isn't necessary to search for secondary types when creating a package,
   * because a package name can not collide with a secondary type. The search for secondary types
   * should not get executed, because the search for secondary types is very expensive regarding
   * performance (all classes of a package have to get loaded, parsed and analyzed).
   */
  public void test04() {
    NameEnvironmentWithProgressDummy nameEnvWithProgress = new NameEnvironmentWithProgressDummy();

    LookupEnvironment lookupEnv =
        new LookupEnvironment(null, new CompilerOptions(), null, nameEnvWithProgress);
    PackageBinding packageBinding =
        lookupEnv.createPackage(
            new char[][] {
              "org/eclipse/jdt".toCharArray(), "org/eclipse/jdt/internal".toCharArray()
            });
    assertNotNull(packageBinding);

    assertTrue(
        nameEnvWithProgress
            .isTypeSearchExecutedWithSearchWithSecondaryTypes); // the method findType(char[],
                                                                // char[][], boolean) should got
                                                                // executed ...
    assertFalse(
        nameEnvWithProgress
            .isTypeSearchWithSearchWithSecondaryTypes); // ... but without the search for secondary
                                                        // types
  }