@Override
 public void invoke(@NotNull Project project, Editor editor, JetFile file)
     throws IncorrectOperationException {
   for (JetTypeReference typeReference : getElement().getTypeArgumentsAsTypes()) {
     if (typeReference != null) {
       typeReference.replace(JetPsiFactoryKt.JetPsiFactory(file).createStar());
     }
   }
 }
Пример #2
0
 // Temporary
 // Returns true if deprecated constructor is in use, like
 // ENTRY: Enum(arguments) instead of
 // ENTRY(arguments)
 public static boolean enumEntryUsesDeprecatedSuperConstructor(@NotNull JetEnumEntry enumEntry) {
   JetInitializerList initializerList = enumEntry.getInitializerList();
   if (initializerList == null || initializerList.getInitializers().isEmpty()) return false;
   JetTypeReference typeReference = initializerList.getInitializers().get(0).getTypeReference();
   if (typeReference == null) return false;
   JetUserType userType = (JetUserType) typeReference.getTypeElement();
   if (userType == null
       || userType.getReferenceExpression() instanceof JetEnumEntrySuperclassReferenceExpression)
     return false;
   return true;
 }
Пример #3
0
 @Nullable
 public static Name getShortName(@NotNull JetAnnotationEntry annotation) {
   JetTypeReference typeReference = annotation.getTypeReference();
   assert typeReference != null : "Annotation entry hasn't typeReference " + annotation.getText();
   JetTypeElement typeElement = typeReference.getTypeElement();
   if (typeElement instanceof JetUserType) {
     JetUserType userType = (JetUserType) typeElement;
     String shortName = userType.getReferencedName();
     if (shortName != null) {
       return Name.identifier(shortName);
     }
   }
   return null;
 }
Пример #4
0
  public static boolean isVoidType(@Nullable JetTypeReference typeReference) {
    if (typeReference == null) {
      return false;
    }

    return KotlinBuiltIns.getInstance()
        .getUnit()
        .getName()
        .asString()
        .equals(typeReference.getText());
  }
  private void computeTypeParameters(List<TypeParameterDescriptor> typeParameters) {
    if (typeParameters.size() != altFunDeclaration.getTypeParameters().size()) {
      throw new AlternativeSignatureMismatchException(
          "Method signature has %d type parameters, but alternative signature has %d",
          typeParameters.size(), altFunDeclaration.getTypeParameters().size());
    }

    altTypeParameters = new ArrayList<TypeParameterDescriptor>();

    for (int i = 0, size = typeParameters.size(); i < size; i++) {
      TypeParameterDescriptor originalTypeParamDescriptor = typeParameters.get(i);

      TypeParameterDescriptorImpl altParamDescriptor =
          originalToAltTypeParameters.get(originalTypeParamDescriptor);
      JetTypeParameter altTypeParameter = altFunDeclaration.getTypeParameters().get(i);

      int upperBoundIndex = 0;
      for (JetType upperBound : originalTypeParamDescriptor.getUpperBounds()) {
        JetTypeElement altTypeElement;

        if (upperBoundIndex == 0) {
          JetTypeReference extendsBound = altTypeParameter.getExtendsBound();
          if (extendsBound == null) { // default upper bound
            assert originalTypeParamDescriptor.getUpperBounds().size() == 1;
            altParamDescriptor.addDefaultUpperBound();
            break;
          } else {
            altTypeElement = extendsBound.getTypeElement();
          }
        } else {
          JetTypeConstraint constraint =
              findTypeParameterConstraint(
                  altFunDeclaration, originalTypeParamDescriptor.getName(), upperBoundIndex);
          if (constraint == null) {
            throw new AlternativeSignatureMismatchException(
                "Upper bound #%d for type parameter %s is missing",
                upperBoundIndex, originalTypeParamDescriptor.getName());
          }
          //noinspection ConstantConditions
          altTypeElement = constraint.getBoundTypeReference().getTypeElement();
        }

        assert (altTypeElement != null);

        altParamDescriptor.addUpperBound(
            TypeTransformingVisitor.computeType(
                altTypeElement, upperBound,
                originalToAltTypeParameters, UPPER_BOUND));
        upperBoundIndex++;
      }

      if (findTypeParameterConstraint(
              altFunDeclaration, originalTypeParamDescriptor.getName(), upperBoundIndex)
          != null) {
        throw new AlternativeSignatureMismatchException(
            "Extra upper bound #%d for type parameter %s",
            upperBoundIndex, originalTypeParamDescriptor.getName());
      }

      altParamDescriptor.setInitialized();
      altTypeParameters.add(altParamDescriptor);
    }
  }