コード例 #1
0
  public PackageViewDescriptorImpl(
      @NotNull ModuleDescriptor module,
      @NotNull FqName fqName,
      @NotNull List<PackageFragmentDescriptor> fragments) {
    super(Collections.<AnnotationDescriptor>emptyList(), fqName.shortNameOrSpecial());
    this.module = module;
    this.fqName = fqName;

    List<JetScope> scopes = Lists.newArrayList();
    assert !fragments.isEmpty() : fqName + " in " + module;
    for (PackageFragmentDescriptor fragment : fragments) {
      scopes.add(fragment.getMemberScope());
    }
    scopes.add(new SubpackagesScope());

    memberScope =
        new ChainedScope(
            this,
            "package view scope for " + fqName + " in " + module.getName(),
            scopes.toArray(new JetScope[scopes.size()]));
  }
コード例 #2
0
  @NotNull
  private static ClassDescriptor createClass(
      @NotNull PackageFragmentDescriptor packageFragment,
      @NotNull String name,
      @NotNull String... typeParameters) {
    MutableClassDescriptor descriptor =
        new MutableClassDescriptor(
            packageFragment,
            packageFragment.getMemberScope(),
            ClassKind.CLASS,
            false,
            Name.identifier(name));
    List<TypeParameterDescriptor> typeParameterDescriptors =
        new ArrayList<TypeParameterDescriptor>(typeParameters.length);
    for (int i = 0; i < typeParameters.length; i++) {
      String[] s = typeParameters[i].split(" ");
      Variance variance = Variance.valueOf(s[0].toUpperCase() + "_VARIANCE");
      String typeParameterName = s[1];
      TypeParameterDescriptorImpl typeParameter =
          TypeParameterDescriptorImpl.createForFurtherModification(
              descriptor,
              Annotations.EMPTY,
              false,
              variance,
              Name.identifier(typeParameterName),
              i);
      typeParameter.setInitialized();
      typeParameterDescriptors.add(typeParameter);
    }

    descriptor.setModality(Modality.FINAL);
    descriptor.setVisibility(Visibilities.PUBLIC);
    descriptor.setTypeParameterDescriptors(typeParameterDescriptors);
    descriptor.createTypeConstructor();

    return descriptor;
  }