Java 类com.intellij.psi.impl.beanProperties.BeanProperty 实例源码

项目:consulo-apache-velocity    文件:VtlReferenceExpression.java   
@Nullable
public PsiType getPsiType() {
    final PsiElement element = resolve();
    if (element instanceof VtlVariable) {
        return ((VtlVariable) element).getPsiType();
    }
    if (element instanceof PsiMethod) {
        PsiMethod method = (PsiMethod) element;
        return getSubstitutedType(method, method.getReturnType());
    }
    if (element instanceof BeanProperty) {
        final BeanProperty beanProperty = (BeanProperty) element;
        return getSubstitutedType(beanProperty.getMethod(), beanProperty.getPropertyType());
    }
    return null;
}
项目:consulo-java    文件:BeanPropertyRenameHandler.java   
public static void doRename(@NotNull final BeanProperty property, final String newName, final boolean searchInComments, boolean isPreview) {
  final PsiElement psiElement = property.getPsiElement();
  final RenameRefactoring rename = new JavaRenameRefactoringImpl(psiElement.getProject(), psiElement, newName, searchInComments, false);
  rename.setPreviewUsages(isPreview);

  final PsiMethod setter = property.getSetter();
  if (setter != null) {
    final String setterName = PropertyUtil.suggestSetterName(newName);
    rename.addElement(setter, setterName);
  }

  final PsiMethod getter = property.getGetter();
  if (getter != null) {
    final String getterName = PropertyUtil.suggestGetterName(newName, getter.getReturnType());
    rename.addElement(getter, getterName);
  }

  rename.run();
}
项目:intellij-ce-playground    文件:BeanPropertyRenameHandler.java   
public static void doRename(@NotNull final BeanProperty property, final String newName, final boolean searchInComments, boolean isPreview) {
  final PsiElement psiElement = property.getPsiElement();
  final RenameRefactoring rename = new JavaRenameRefactoringImpl(psiElement.getProject(), psiElement, newName, searchInComments, false);
  rename.setPreviewUsages(isPreview);

  final PsiMethod setter = property.getSetter();
  if (setter != null) {
    final String setterName = PropertyUtil.suggestSetterName(newName);
    rename.addElement(setter, setterName);

    final PsiParameter[] setterParameters = setter.getParameterList().getParameters();
    if (setterParameters.length == 1) {
      final JavaCodeStyleManager manager = JavaCodeStyleManager.getInstance(psiElement.getProject());
      final String suggestedParameterName = manager.propertyNameToVariableName(property.getName(), VariableKind.PARAMETER);
      if (suggestedParameterName.equals(setterParameters[0].getName())) {
        rename.addElement(setterParameters[0], manager.propertyNameToVariableName(newName, VariableKind.PARAMETER));
      }
    }
  }

  final PsiMethod getter = property.getGetter();
  if (getter != null) {
    final String getterName = PropertyUtil.suggestGetterName(newName, getter.getReturnType());
    rename.addElement(getter, getterName);
  }

  rename.run();
}
项目:tools-idea    文件:BeanPropertyRenameHandler.java   
public static void doRename(@NotNull final BeanProperty property, final String newName, final boolean searchInComments, boolean isPreview) {
  final PsiElement psiElement = property.getPsiElement();
  final RenameRefactoring rename = new JavaRenameRefactoringImpl(psiElement.getProject(), psiElement, newName, searchInComments, false);
  rename.setPreviewUsages(isPreview);

  final PsiMethod setter = property.getSetter();
  if (setter != null) {
    final String setterName = PropertyUtil.suggestSetterName(newName);
    rename.addElement(setter, setterName);

    final PsiParameter[] setterParameters = setter.getParameterList().getParameters();
    if (setterParameters.length == 1) {
      final JavaCodeStyleManager manager = JavaCodeStyleManager.getInstance(psiElement.getProject());
      final String suggestedParameterName = manager.propertyNameToVariableName(property.getName(), VariableKind.PARAMETER);
      if (suggestedParameterName.equals(setterParameters[0].getName())) {
        rename.addElement(setterParameters[0], manager.propertyNameToVariableName(newName, VariableKind.PARAMETER));
      }
    }
  }

  final PsiMethod getter = property.getGetter();
  if (getter != null) {
    final String getterName = PropertyUtil.suggestGetterName(newName, getter.getReturnType());
    rename.addElement(getter, getterName);
  }

  rename.run();
}
项目:consulo-apache-velocity    文件:VelocityStyleBeanProperty.java   
@Nullable
public static BeanProperty createVelocityStyleBeanProperty(@NotNull PsiMethod method, @Nullable String name) {
    if(name == null) {
        return null;
    }
    return VelocityNamingUtil.isPropertyAccessor(method) || VelocityNamingUtil.isGetByStringOrByObjectMethod(method)
            ? new VelocityStyleBeanProperty(method, name)
            : null;
}
项目:intellij-ce-playground    文件:BeanPropertyRenameHandler.java   
@Nullable
protected abstract BeanProperty getProperty(DataContext context);
项目:intellij-ce-playground    文件:BeanPropertyRenameHandler.java   
protected PropertyRenameDialog(BeanProperty property, final Editor editor) {
  super(property.getMethod().getProject(), property.getPsiElement(), null, editor);
  myProperty = property;
}
项目:tools-idea    文件:BeanPropertyRenameHandler.java   
private void performInvoke(@Nullable Editor editor, DataContext dataContext) {
  final BeanProperty property = getProperty(dataContext);
  new PropertyRenameDialog(property, editor).show();
}
项目:tools-idea    文件:BeanPropertyRenameHandler.java   
@Nullable
protected abstract BeanProperty getProperty(DataContext context);
项目:tools-idea    文件:BeanPropertyRenameHandler.java   
protected PropertyRenameDialog(BeanProperty property, final Editor editor) {
  super(property.getMethod().getProject(), property.getPsiElement(), null, editor);
  myProperty = property;
}
项目:consulo-java    文件:BeanPropertyRenameHandler.java   
private void performInvoke(@Nullable Editor editor, DataContext dataContext) {
  final BeanProperty property = getProperty(dataContext);
  new PropertyRenameDialog(property, editor).show();
}
项目:consulo-java    文件:BeanPropertyRenameHandler.java   
@Nullable
protected abstract BeanProperty getProperty(DataContext context);
项目:consulo-java    文件:BeanPropertyRenameHandler.java   
protected PropertyRenameDialog(BeanProperty property, final Editor editor) {
  super(property.getMethod().getProject(), property.getPsiElement(), null, editor);
  myProperty = property;
}