コード例 #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);
      }
    }
コード例 #2
0
 @Nullable
 private static JetTypeConstraint findTypeParameterConstraint(
     @NotNull JetFunction function, @NotNull Name typeParameterName, int index) {
   if (index != 0) {
     int currentIndex = 0;
     for (JetTypeConstraint constraint : function.getTypeConstraints()) {
       JetSimpleNameExpression parameterName = constraint.getSubjectTypeParameterName();
       assert parameterName != null;
       if (typeParameterName.equals(parameterName.getReferencedNameAsName())) {
         currentIndex++;
       }
       if (currentIndex == index) {
         return constraint;
       }
     }
   }
   return null;
 }