Examples of PsiType


Examples of com.intellij.psi.PsiType

  @NotNull
  public PsiMethod createSetterMethod(@NotNull PsiField psiField, @NotNull String methodVisibility) {
    final StringBuilder builder = StringBuilderSpinAllocator.alloc();
    try {
      final String fieldName = psiField.getName();
      final PsiType psiFieldType = psiField.getType();
      final String methodName = TransformationsUtil.toSetterName(fieldName, PsiType.BOOLEAN.equals(psiFieldType));

      builder.append(methodVisibility);
      if (StringUtil.isNotEmpty(methodVisibility)) {
        builder.append(' ');
      }
      if (psiField.hasModifierProperty(PsiModifier.STATIC)) {
        builder.append(PsiModifier.STATIC).append(' ');
      }
      builder.append(PsiType.VOID.getCanonicalText());
      builder.append(' ');
      builder.append(methodName);

      final Collection<String> annotationsToCopy = PsiAnnotationUtil.collectAnnotationsToCopy(psiField);
      final String annotationsString = PsiAnnotationUtil.buildAnnotationsString(annotationsToCopy);

      builder.append("(").append(annotationsString).append(psiFieldType.getCanonicalText()).append(' ').append(fieldName).append(')');
      builder.append("{ this.").append(fieldName).append(" = ").append(fieldName).append("; }");

      PsiClass psiClass = psiField.getContainingClass();
      assert psiClass != null;
View Full Code Here

Examples of com.intellij.psi.PsiType

  }

  private Collection<PsiType> collectDelegateTypes(PsiAnnotation psiAnnotation, PsiField psiField) {
    Collection<PsiType> types = PsiAnnotationUtil.getAnnotationValues(psiAnnotation, "types", PsiType.class);
    if (types.isEmpty()) {
      final PsiType psiType = psiField.getType();
      types = Collections.singletonList(psiType);
    }
    return types;
  }
View Full Code Here

Examples of com.intellij.psi.PsiType

  private PsiMethod generateDelegateMethod(@NotNull PsiClass psiClass, @NotNull PsiMethod psiMethod, @Nullable PsiSubstitutor psiSubstitutor) {
    final StringBuilder builder = StringBuilderSpinAllocator.alloc();
    try {
      builder.append(PsiModifier.PUBLIC);
      builder.append(' ');
      final PsiType returnType = null == psiSubstitutor ? psiMethod.getReturnType() : psiSubstitutor.substitute(psiMethod.getReturnType());
      builder.append(null == returnType ? "" : returnType.getCanonicalText());
      builder.append(' ');
      builder.append(psiMethod.getName());
      builder.append('(');

      PsiParameterList parameterList = psiMethod.getParameterList();
      if (parameterList.getParametersCount() > 0) {
        for (PsiParameter psiParameter : parameterList.getParameters()) {
          final PsiType psiParameterType = null == psiSubstitutor ? psiParameter.getType() : psiSubstitutor.substitute(psiParameter.getType());
          builder.append(psiParameterType.getCanonicalText()).append(' ').append(psiParameter.getName()).append(',');
        }
        builder.deleteCharAt(builder.length() - 1);
      }
      builder.append(')');
      builder.append("{ }");
View Full Code Here

Examples of com.intellij.psi.PsiType

    if (parameterTypes != null) {
      final PsiParameterList parameterList = method.getParameterList();
      if (parameterList.getParametersCount() != parameterTypes.size()) {
        return false;
      }
      final PsiType nullType = PsiPrimitiveTypeFactory.getInstance().getNullType();
      final PsiParameter[] parameters = parameterList.getParameters();
      for (int i = 0; i < parameters.length; i++) {
        final PsiParameter parameter = parameters[i];
        final PsiType type = parameter.getType();
        final PsiType parameterType = parameterTypes.get(i);
        if (nullType.equals(parameterType)) {
          continue;
        }
        if (parameterType != null &&
            !typesAreEquivalent(type,
                parameterType)) {
          return false;
        }
      }
    }
    if (returnType != null) {
      final PsiType methodReturnType = method.getReturnType();
      if (!typesAreEquivalent(returnType,
          methodReturnType)) {
        return false;
      }
    }
View Full Code Here

Examples of com.intellij.psi.PsiType

      if (methodParameterList.getParametersCount() != parameterList.getParametersCount()) {
        return false;
      }
      final PsiParameter[] methodParameters = methodParameterList.getParameters();
      final PsiParameter[] otherParameters = parameterList.getParameters();
      final PsiType nullType = PsiPrimitiveTypeFactory.getInstance().getNullType();
      for (int i = 0; i < methodParameters.length; i++) {
        final PsiType type = methodParameters[i].getType();
        final PsiType parameterType = otherParameters[i].getType();
        if (nullType.equals(parameterType)) {
          continue;
        }
        if (!typesAreEquivalent(type,
            parameterType)) {
          return false;
        }
      }
    }
    if (returnType != null) {
      final PsiType methodReturnType = method.getReturnType();
      if (!typesAreEquivalent(returnType,
          methodReturnType)) {
        return false;
      }
    }
View Full Code Here

Examples of com.intellij.psi.PsiType

    PsiParameter[] firstMethodParameterListParameters = firstMethodParameterList.getParameters();
    PsiParameter[] secondMethodParameterListParameters = secondMethodParameterList.getParameters();
    PsiSubstitutor firstSubstitutor = firstPair.getSecond();
    PsiSubstitutor secondSubstitutor = secondPair.getSecond();
    final PsiType nullType = PsiPrimitiveTypeFactory.getInstance().getNullType();
    for (int i = 0; i < firstMethodParameterListParameters.length; i++) {
      PsiType firstMethodParameterListParameterType = firstSubstitutor.substitute(firstMethodParameterListParameters[i].getType());
      PsiType secondMethodParameterListParameterType = secondSubstitutor.substitute(secondMethodParameterListParameters[i].getType());
      if (nullType.equals(firstMethodParameterListParameterType)) {
        continue;
      }
      if (!typesAreEquivalent(firstMethodParameterListParameterType, secondMethodParameterListParameterType)) {
        return false;
View Full Code Here

Examples of com.intellij.psi.PsiType

  @NotNull
  public PsiMethod createGetterMethod(@NotNull PsiField psiField, @NotNull String methodVisibility) {
    final StringBuilder builder = StringBuilderSpinAllocator.alloc();
    try {
      final String fieldName = psiField.getName();
      final PsiType psiReturnType = psiField.getType();
      String methodName = TransformationsUtil.toGetterName(fieldName, PsiType.BOOLEAN.equals(psiReturnType));

      final Collection<String> annotationsToCopy = PsiAnnotationUtil.collectAnnotationsToCopy(psiField);
      final String annotationsString = PsiAnnotationUtil.buildAnnotationsString(annotationsToCopy);

      builder.append(methodVisibility);
      if (StringUtil.isNotEmpty(methodVisibility)) {
        builder.append(' ');
      }
      if (psiField.hasModifierProperty(PsiModifier.STATIC)) {
        builder.append(PsiModifier.STATIC).append(' ');
      }
      builder.append(annotationsString);
      builder.append(psiReturnType.getCanonicalText());
      builder.append(' ');
      builder.append(methodName);
      builder.append("()");
      builder.append("{ return this.").append(fieldName).append("; }");
View Full Code Here

Examples of com.intellij.psi.PsiType

    return result;
  }

  private void validateCleanUpMethodExists(@NotNull PsiLocalVariable psiVariable, @NotNull String cleanupName, @NotNull ProblemNewBuilder problemNewBuilder) {
    final PsiType psiType = psiVariable.getType();
    if (psiType instanceof PsiClassType) {
      final PsiClassType psiClassType = (PsiClassType) psiType;
      final PsiClass psiClassOfField = psiClassType.resolve();
      final PsiMethod[] methods;
View Full Code Here

Examples of com.intellij.psi.PsiType

    return result;
  }

  private void validateCleanUpMethodExists(@NotNull PsiLocalVariable psiVariable, @NotNull String cleanupName, @NotNull ProblemNewBuilder problemNewBuilder) {
    final PsiType psiType = psiVariable.getType();
    if (psiType instanceof PsiClassType) {
      final PsiClassType psiClassType = (PsiClassType) psiType;
      final PsiClass psiClassOfField = psiClassType.resolve();
      final PsiMethod[] methods;
View Full Code Here

Examples of com.intellij.psi.PsiType

  protected boolean validateExistingMethods(@NotNull PsiField psiField, @NotNull ProblemBuilder builder) {
    boolean result = true;
    final PsiClass psiClass = psiField.getContainingClass();
    if (null != psiClass) {
      final PsiMethod[] classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass);
      final PsiType booleanType = PsiPrimitiveTypeFactory.getInstance().getBooleanType();
      final boolean isBoolean = booleanType.equals(psiField.getType());
      final Collection<String> methodNames = getAllSetterNames(psiField, isBoolean);

      for (String methodName : methodNames) {
        if (PsiMethodUtil.hasMethodByName(classMethods, methodName)) {
          final String setterMethodName = getSetterName(psiField, isBoolean);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.