当前位置: 首页>>代码示例>>Java>>正文


Java PropertyUtil.findPropertySetter方法代码示例

本文整理汇总了Java中com.intellij.psi.util.PropertyUtil.findPropertySetter方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyUtil.findPropertySetter方法的具体用法?Java PropertyUtil.findPropertySetter怎么用?Java PropertyUtil.findPropertySetter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.util.PropertyUtil的用法示例。


在下文中一共展示了PropertyUtil.findPropertySetter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromString

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public PsiMember fromString(final String s, final ConvertContext context) {
  if (s == null) return null;
  final PsiClass psiClass = getTargetClass(context);
  if (psiClass == null) return null;
  for (PropertyMemberType type : getMemberTypes(context)) {
    switch (type) {
      case FIELD:
        final PsiField field = psiClass.findFieldByName(s, isLookDeep());
        if (field != null) return field;
        break;
      case GETTER:
        final PsiMethod getter = PropertyUtil.findPropertyGetter(psiClass, getPropertyName(s, context), false, isLookDeep());
        if (getter != null) return getter;
        break;
      case SETTER:
        final PsiMethod setter = PropertyUtil.findPropertySetter(psiClass, getPropertyName(s, context), false, isLookDeep());
        if (setter != null) return setter;
        break;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AbstractMemberResolveConverter.java

示例2: isAvailable

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
  if (!myField.isValid()) return false;

  final PsiClass aClass = myField.getContainingClass();
  if (aClass == null) {
    return false;
  }

  if (myCreateGetter){
    if (isStaticFinal(myField) || PropertyUtil.findPropertyGetter(aClass, myPropertyName, isStatic(myField), false) != null){
      return false;
    }
  }

  if (myCreateSetter){
    if(isFinal(myField) || PropertyUtil.findPropertySetter(aClass, myPropertyName, isStatic(myField), false) != null){
      return false;
    }
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CreateGetterOrSetterFix.java

示例3: isSetterNonNls

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private static boolean isSetterNonNls(final Project project, final GlobalSearchScope searchScope,
                                      final String componentClassName, final String propertyName) {
  PsiClass componentClass = JavaPsiFacade.getInstance(project).findClass(componentClassName, searchScope);
  if (componentClass == null) {
    return false;
  }
  PsiMethod setter = PropertyUtil.findPropertySetter(componentClass, propertyName, false, true);
  if (setter != null) {
    PsiParameter[] parameters = setter.getParameterList().getParameters();
    if (parameters.length == 1 &&
        "java.lang.String".equals(parameters[0].getType().getCanonicalText()) &&
        AnnotationUtil.isAnnotated(parameters [0], AnnotationUtil.NON_NLS, false, true)) {
      return true;
    }
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:I18nFormInspection.java

示例4: visitField

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitField(@NotNull PsiField field) {
  final Project project = field.getProject();
  final String propertyName = PropertyUtil.suggestPropertyName(project, field);
  final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
  final PsiClass containingClass = field.getContainingClass();
  final PsiMethod setter = PropertyUtil.findPropertySetter(containingClass, propertyName, isStatic, false);
  if (setter == null) {
    return;
  }
  final PsiMethod getter = PropertyUtil.findPropertyGetter(containingClass, propertyName, isStatic, false);
  if (getter != null) {
    return;
  }
  registerFieldError(field);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:FieldHasSetterButNoGetterInspection.java

示例5: process

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
protected void process(List<ClassMember> classMembers) {
  for (ClassMember classMember : classMembers) {
    final PsiElementClassMember elementClassMember = (PsiElementClassMember) classMember;

    PsiField psiField = (PsiField) elementClassMember.getPsiElement();
    PsiMethod psiMethod = PropertyUtil.findPropertySetter(psiField.getContainingClass(), psiField.getName(), false, false);
    if (null != psiMethod) {
      PsiModifierList modifierList = psiField.getModifierList();
      if (null != modifierList) {
        PsiAnnotation psiAnnotation = modifierList.addAnnotation(Setter.class.getName());

        psiMethod.delete();
      }
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:18,代码来源:RefactorSetterHandler.java

示例6: isSetter

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private static boolean isSetter(PsiAssignmentExpression expression)
{
	final PsiExpression lExpression = expression.getLExpression();
	if(lExpression instanceof PsiReferenceExpression)
	{
		final PsiElement resolved = ((PsiReferenceExpression) lExpression).resolve();
		if(resolved instanceof PsiField)
		{
			PsiField field = (PsiField) resolved;
			final NavigatablePsiElement containingMethod = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, PsiLambdaExpression.class);
			if(containingMethod instanceof PsiMethod)
			{
				final PsiMethod setter = PropertyUtil.findPropertySetter(field.getContainingClass(), field.getName(), field.hasModifierProperty(PsiModifier.STATIC), false);
				if(containingMethod.isEquivalentTo(setter))
				{
					return true;
				}
			}
		}
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:TypeMigrationStatementProcessor.java

示例7: findSettablePsiField

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@NotNull
public static Optional<PsiField> findSettablePsiField(@NotNull PsiClass clazz,
    @Nullable String propertyName) {
  PsiMethod propertySetter = PropertyUtil.findPropertySetter(clazz, propertyName, false, true);
  return null == propertySetter ?
      Optional.empty() :
      Optional.ofNullable(PropertyUtil.findPropertyFieldByMember(propertySetter));
}
 
开发者ID:1tontech,项目名称:intellij-spring-assistant,代码行数:9,代码来源:PsiUtil.java

示例8: getSetter

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Nullable
public PsiMethod getSetter() {
  if (PropertyUtil.isSimplePropertySetter(myMethod)) {
    return myMethod;
  }
  return PropertyUtil.findPropertySetter(myMethod.getContainingClass(), getName(), false, true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:BeanProperty.java

示例9: getAdditionalElementsToDelete

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public Collection<PsiElement> getAdditionalElementsToDelete(@NotNull final PsiElement element,
                                                            @NotNull final Collection<PsiElement> allElementsToDelete,
                                                            final boolean askUser) {
  if (element instanceof PsiField) {
    PsiField field = (PsiField)element;
    final Project project = element.getProject();
    String propertyName = JavaCodeStyleManager.getInstance(project).variableNameToPropertyName(field.getName(), VariableKind.FIELD);

    PsiClass aClass = field.getContainingClass();
    if (aClass != null) {
      boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
      PsiMethod[] getters = GetterSetterPrototypeProvider.findGetters(aClass, propertyName, isStatic);
      if (getters != null) {
        final List<PsiMethod> validGetters = new ArrayList<PsiMethod>(1);
        for (PsiMethod getter : getters) {
          if (!allElementsToDelete.contains(getter) && (getter != null && getter.isPhysical())) {
            validGetters.add(getter);
          }
        }
        getters = validGetters.isEmpty() ? null : validGetters.toArray(new PsiMethod[validGetters.size()]);
      }

      PsiMethod setter = PropertyUtil.findPropertySetter(aClass, propertyName, isStatic, false);
      if (allElementsToDelete.contains(setter) || setter != null && !setter.isPhysical()) setter = null;
      if (askUser && (getters != null || setter != null)) {
        final String message =
          RefactoringMessageUtil.getGetterSetterMessage(field.getName(), RefactoringBundle.message("delete.title"), getters != null ? getters[0] : null, setter);
        if (!ApplicationManager.getApplication().isUnitTestMode() && Messages.showYesNoDialog(project, message, RefactoringBundle.message("safe.delete.title"), Messages.getQuestionIcon()) != Messages.YES) {
          getters = null;
          setter = null;
        }
      }
      List<PsiElement> elements = new ArrayList<PsiElement>();
      if (setter != null) elements.add(setter);
      if (getters != null) Collections.addAll(elements, getters);
      return elements;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:JavaSafeDeleteProcessor.java

示例10: getData

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public Object getData(final String dataId) {
  if(getClass().getName().equals(dataId)){
    return this;
  }
  else if(CommonDataKeys.PSI_ELEMENT.is(dataId)){
    final IntrospectedProperty introspectedProperty = getSelectedIntrospectedProperty();
    if(introspectedProperty == null){
      return null;
    }
    final PsiClass aClass = getComponentClass();
    if(aClass == null){
      return null;
    }

    final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, introspectedProperty.getName(), false, true);
    if(getter != null){
      return getter;
    }

    return PropertyUtil.findPropertySetter(aClass, introspectedProperty.getName(), false, true);
  }
  else if (CommonDataKeys.PSI_FILE.is(dataId) && myEditor != null) {
    return PsiManager.getInstance(myEditor.getProject()).findFile(myEditor.getFile());
  }
  else if (GuiEditor.DATA_KEY.is(dataId)) {
    return myEditor;
  }
  else if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
    GuiEditor designer = DesignerToolWindowManager.getInstance(myProject).getActiveFormEditor();
    return designer == null ? null : designer.getEditor();
  }
  else if (PlatformDataKeys.HELP_ID.is(dataId)) {
    return ourHelpID;
  }
  else {
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:PropertyInspectorTable.java

示例11: visitField

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitField(@NotNull PsiField field) {
  final String propertyName = PropertyUtil.suggestPropertyName(field);
  final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
  final PsiClass containingClass = field.getContainingClass();
  final PsiMethod setter = PropertyUtil.findPropertySetter(containingClass, propertyName, isStatic, false);
  if (setter == null) {
    return;
  }
  final PsiMethod getter = PropertyUtil.findPropertyGetter(containingClass, propertyName, isStatic, false);
  if (getter != null) {
    return;
  }
  registerFieldError(field);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:FieldHasSetterButNoGetterInspection.java

示例12: multiResolve

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
  final GrArgumentLabel context = getElement();
  final GrNamedArgument namedArgument = (GrNamedArgument) context.getParent();
  final GrExpression map = (GrExpression)namedArgument.getParent();
  final PsiClassType classType = LiteralConstructorReference.getTargetConversionType(map);
  if (classType != null) {
    final PsiClass psiClass = classType.resolve();
    if (psiClass != null) {
      final GrExpression value = namedArgument.getExpression();

      final List<ResolveResult> applicable = addMethodCandidates(classType, value);

      final String memberName = getValue();
      if (value == null || applicable.isEmpty()) {
        final PsiMethod setter = PropertyUtil.findPropertySetter(psiClass, memberName, false, true);
        if (setter != null) {
          applicable.add(new PsiElementResolveResult(setter));
        } else {
          final PsiField field = PropertyUtil.findPropertyField(psiClass, memberName, false);
          if (field != null) {
            applicable.add(new PsiElementResolveResult(field));
          }
        }
      }

      return applicable.toArray(new ResolveResult[applicable.size()]);
    }
  }

  return ResolveResult.EMPTY_ARRAY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:GppReferenceContributor.java

示例13: findExistingNameConflicts

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void findExistingNameConflicts(PsiElement element, String newName, MultiMap<PsiElement, String> conflicts) {
  super.findExistingNameConflicts(element, newName, conflicts);

  GrField field = (GrField)element;
  final PsiClass containingClass = field.getContainingClass();
  if (containingClass == null) return;

  final PsiMethod getter = GroovyPropertyUtils.findGetterForField(field);
  if (getter instanceof GrAccessorMethod) {
    final PsiMethod newGetter =
      PropertyUtil.findPropertyGetter(containingClass, newName, field.hasModifierProperty(PsiModifier.STATIC), true);
    if (newGetter != null && !(newGetter instanceof GrAccessorMethod)) {
      conflicts.putValue(newGetter, GroovyRefactoringBundle
        .message("implicit.getter.will.by.overriden.by.method", field.getName(), newGetter.getName()));
    }
  }
  final PsiMethod setter = GroovyPropertyUtils.findSetterForField(field);
  if (setter instanceof GrAccessorMethod) {
    final PsiMethod newSetter =
      PropertyUtil.findPropertySetter(containingClass, newName, field.hasModifierProperty(PsiModifier.STATIC), true);
    if (newSetter != null && !(newSetter instanceof GrAccessorMethod)) {
      conflicts.putValue(newSetter, GroovyRefactoringBundle
        .message("implicit.setter.will.by.overriden.by.method", field.getName(), newSetter.getName()));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:RenameGrFieldProcessor.java

示例14: getAdditionalElementsToDelete

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public Collection<PsiElement> getAdditionalElementsToDelete(final PsiElement element,
                                                            final Collection<PsiElement> allElementsToDelete,
                                                            final boolean askUser) {
  if (element instanceof PsiField) {
    PsiField field = (PsiField)element;
    final Project project = element.getProject();
    String propertyName = JavaCodeStyleManager.getInstance(project).variableNameToPropertyName(field.getName(), VariableKind.FIELD);

    PsiClass aClass = field.getContainingClass();
    if (aClass != null) {
      boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
      PsiMethod[] getters = GetterSetterPrototypeProvider.findGetters(aClass, propertyName, isStatic);
      if (getters != null) {
        final List<PsiMethod> validGetters = new ArrayList<PsiMethod>(1);
        for (PsiMethod getter : getters) {
          if (!allElementsToDelete.contains(getter) && (getter != null && getter.isPhysical())) {
            validGetters.add(getter);
          }
        }
        getters = validGetters.isEmpty() ? null : validGetters.toArray(new PsiMethod[validGetters.size()]);
      }

      PsiMethod setter = PropertyUtil.findPropertySetter(aClass, propertyName, isStatic, false);
      if (allElementsToDelete.contains(setter) || setter != null && !setter.isPhysical()) setter = null;
      if (askUser && (getters != null || setter != null)) {
        final String message =
          RefactoringMessageUtil.getGetterSetterMessage(field.getName(), RefactoringBundle.message("delete.title"), getters != null ? getters[0] : null, setter);
        if (!ApplicationManager.getApplication().isUnitTestMode() && Messages.showYesNoDialog(project, message, RefactoringBundle.message("safe.delete.title"), Messages.getQuestionIcon()) != 0) {
          getters = null;
          setter = null;
        }
      }
      List<PsiElement> elements = new ArrayList<PsiElement>();
      if (setter != null) elements.add(setter);
      if (getters != null) Collections.addAll(elements, getters);
      return elements;
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:41,代码来源:JavaSafeDeleteProcessor.java

示例15: getData

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public Object getData(final String dataId) {
  if(getClass().getName().equals(dataId)){
    return this;
  }
  else if(LangDataKeys.PSI_ELEMENT.is(dataId)){
    final IntrospectedProperty introspectedProperty = getSelectedIntrospectedProperty();
    if(introspectedProperty == null){
      return null;
    }
    final PsiClass aClass = getComponentClass();
    if(aClass == null){
      return null;
    }

    final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, introspectedProperty.getName(), false, true);
    if(getter != null){
      return getter;
    }

    return PropertyUtil.findPropertySetter(aClass, introspectedProperty.getName(), false, true);
  }
  else if (LangDataKeys.PSI_FILE.is(dataId) && myEditor != null) {
    return PsiManager.getInstance(myEditor.getProject()).findFile(myEditor.getFile());
  }
  else if (GuiEditor.DATA_KEY.is(dataId)) {
    return myEditor;
  }
  else if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
    return UIDesignerToolWindowManager.getInstance(myProject).getActiveFormFileEditor();
  }
  else if (PlatformDataKeys.HELP_ID.is(dataId)) {
    return ourHelpID;
  }
  else {
    return null;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:PropertyInspectorTable.java


注:本文中的com.intellij.psi.util.PropertyUtil.findPropertySetter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。