Examples of PsiType


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 PsiType booleanType = PsiPrimitiveTypeFactory.getInstance().getBooleanType();
      final boolean isBoolean = booleanType.equals(psiField.getType());
      final Collection<String> methodNames = LombokUtils.toAllGetterNames(psiField.getName(), isBoolean);
      final PsiMethod[] classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass);

      for (String methodName : methodNames) {
        for (PsiMethod classMethod : classMethods) {
View Full Code Here

Examples of com.intellij.psi.PsiType

  @NotNull
  public Collection<PsiMethod> createFieldGetters(@NotNull PsiClass psiClass, @NotNull String methodModifier) {
    Collection<PsiMethod> result = new ArrayList<PsiMethod>();
    final PsiMethod[] classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass);

    final PsiType booleanType = PsiPrimitiveTypeFactory.getInstance().getBooleanType();
    for (PsiField psiField : psiClass.getFields()) {
      boolean createGetter = true;
      PsiModifierList modifierList = psiField.getModifierList();
      if (null != modifierList) {
        //Skip static fields.
        createGetter = !modifierList.hasModifierProperty(PsiModifier.STATIC);
        //Skip fields having Getter annotation already
        createGetter &= !hasFieldProcessorAnnotation(modifierList);
        //Skip fields that start with $
        createGetter &= !psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER);
        //Skip fields if a method with same name already exists
        final Collection<String> methodNames = LombokUtils.toAllGetterNames(psiField.getName(), booleanType.equals(psiField.getType()));
        createGetter &= !PsiMethodUtil.hasMethodByName(classMethods, methodNames);
      }
      if (createGetter) {
        result.add(fieldProcessor.createGetterMethod(psiField, methodModifier));
      }
View Full Code Here

Examples of com.intellij.psi.PsiType

  }

  @NotNull
  public PsiMethod createGetterMethod(@NotNull PsiField psiField, @NotNull String methodModifier) {
    final String fieldName = psiField.getName();
    final PsiType psiReturnType = psiField.getType();
    final PsiType booleanType = PsiPrimitiveTypeFactory.getInstance().getBooleanType();
    String methodName = LombokUtils.toGetterName(fieldName, booleanType.equals(psiReturnType));

    PsiClass psiClass = psiField.getContainingClass();
    assert psiClass != null;

    UserMapKeys.addReadUsageFor(psiField);
View Full Code Here

Examples of com.intellij.psi.PsiType

    return result;
  }

  protected <Psi extends PsiElement> void processIntern(@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation, @NotNull List<Psi> target) {
    final String fieldName = psiField.getName();
    final PsiType psiFieldType = psiField.getType();

    final String methodName = getFindByName(psiField);

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

Examples of com.intellij.psi.PsiType

  protected void processIntern(@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target) {
    Project project = psiClass.getProject();
    PsiManager manager = psiClass.getContainingFile().getManager();

    final PsiElementFactory psiElementFactory = JavaPsiFacade.getElementFactory(project);
    PsiType psiLoggerType = psiElementFactory.createTypeFromText(loggerType, psiClass);
    LombokLightFieldBuilder loggerField = LombokPsiElementFactory.getInstance().createLightField(manager, loggerName, psiLoggerType)
        .withContainingClass(psiClass)
        .withModifier(PsiModifier.FINAL).withModifier(PsiModifier.STATIC).withModifier(PsiModifier.PRIVATE)
        .withNavigationElement(psiAnnotation);
View Full Code Here

Examples of com.intellij.psi.PsiType

  private PsiMethod rebuildMethodFromString() {
    final StringBuilder builder = StringBuilderSpinAllocator.alloc();
    try {
      builder.append(getAllModifierProperties((LightModifierList) getModifierList()));
      PsiType returnType = getReturnType();
      if (null != returnType) {
        builder.append(returnType.getCanonicalText()).append(' ');
      }
      builder.append(getName());
      builder.append('(');
      if (getParameterList().getParametersCount() > 0) {
        for (PsiParameter parameter : getParameterList().getParameters()) {
View Full Code Here

Examples of com.intellij.psi.PsiType

  private PsiMethod createSetterMethod(PsiField psiField, String methodVisibility, PsiClass psiClass, PsiManager manager, PsiElementFactory elementFactory) {
    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 (builder.length() > 0) {
        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 = collectAnnotationsToCopy(psiField);
      final String annotationsString = buildAnnotationsString(annotationsToCopy);

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

      PsiMethod setterMethod = elementFactory.createMethodFromText(builder.toString(), psiClass);
      return prepareMethod(manager, setterMethod, psiClass, psiField);
View Full Code Here

Examples of com.intellij.psi.PsiType

    }

    final Project project = psiField.getProject();
    final PsiManager manager = psiField.getContainingFile().getManager();

    final PsiType psiType = psiField.getType();
    if (psiType instanceof PsiClassType) {
      final PsiClassType objectType = PsiType.getJavaLangObject(manager, GlobalSearchScope.allScope(project));
      final PsiClass objectClass = objectType.resolve();

      PsiClassType psiClassType = (PsiClassType) psiType;
View Full Code Here

Examples of com.intellij.psi.PsiType

  private LightMethod generateDelegateMethod(@NotNull PsiClass psiClass, @NotNull PsiManager manager, @NotNull PsiElementFactory elementFactory, @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

  private PsiMethod createGetterMethod(PsiField psiField, String methodVisibility, PsiClass psiClass, PsiManager manager, PsiElementFactory elementFactory) {
    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 = collectAnnotationsToCopy(psiField);
      final String annotationsString = buildAnnotationsString(annotationsToCopy);

      builder.append(methodVisibility);
      if (builder.length() > 0) {
        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
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.