Esempio n. 1
0
    @Nullable
    @Override
    protected ClassData getClassData(@NotNull ClassId classId) {
      InputStream stream =
          getStreamNullable(BuiltInsSerializationUtil.getClassMetadataPath(classId));
      if (stream == null) {
        return null;
      }

      try {
        ProtoBuf.Class classProto = ProtoBuf.Class.parseFrom(stream);

        Name expectedShortName = classId.getRelativeClassName().shortName();
        Name actualShortName =
            nameResolver.getClassId(classProto.getFqName()).getRelativeClassName().shortName();
        if (!actualShortName.isSpecial() && !actualShortName.equals(expectedShortName)) {
          // Workaround for case-insensitive file systems,
          // otherwise we'd find "Collection" for "collection" etc
          return null;
        }

        return new ClassData(nameResolver, classProto);
      } catch (IOException e) {
        throw new IllegalStateException(e);
      }
    }
Esempio n. 2
0
 @NotNull
 private ProtoBuf.Package loadPackage() {
   String packageFilePath = BuiltInsSerializationUtil.getPackageFilePath(getFqName());
   InputStream stream = getStream(packageFilePath);
   try {
     return ProtoBuf.Package.parseFrom(stream);
   } catch (IOException e) {
     throw new IllegalStateException(e);
   }
 }
Esempio n. 3
0
  public BuiltinsPackageFragment(
      @NotNull StorageManager storageManager, @NotNull ModuleDescriptor module) {
    super(module, KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME);
    nameResolver =
        NameSerializationUtil.deserializeNameResolver(
            getStream(BuiltInsSerializationUtil.getNameTableFilePath(getFqName())));

    packageFragmentProvider = new BuiltinsPackageFragmentProvider();

    // TODO: support annotations
    members =
        new DeserializedPackageMemberScope(
            storageManager,
            this,
            Deserializers.UNSUPPORTED,
            MemberFilter.ALWAYS_TRUE,
            new BuiltInsDescriptorFinder(storageManager),
            loadPackage(),
            nameResolver);
  }