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


Java PropertyUtil.findPropertyGetter方法代码示例

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


在下文中一共展示了PropertyUtil.findPropertyGetter方法的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: checkComponentProperties

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector) {
  final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
  final PsiManager psiManager = PsiManager.getInstance(module.getProject());
  final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
  if (aClass == null) {
    return;
  }

  for(final IProperty prop: component.getModifiedProperties()) {
    final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
    if (getter == null) continue;
    final LanguageLevel languageLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module);
    if (Java15APIUsageInspection.isForbiddenApiUsage(getter, languageLevel)) {
      registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:Java15FormInspection.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.findPropertyGetter(psiField.getContainingClass(), psiField.getName(), false, false);

      if (null != psiMethod) {
        PsiModifierList modifierList = psiField.getModifierList();
        if (null != modifierList) {
          PsiAnnotation psiAnnotation = modifierList.addAnnotation(Getter.class.getName());
//          psiAnnotation.setDeclaredAttributeValue("value", )

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

示例6: checkComponentProperties

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector)
{
	final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
	final PsiManager psiManager = PsiManager.getInstance(module.getProject());
	final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
	if(aClass == null)
	{
		return;
	}

	for(final IProperty prop : component.getModifiedProperties())
	{
		final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
		if(getter == null)
		{
			continue;
		}
		final LanguageLevel languageLevel = EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module);
		if(Java15APIUsageInspection.isForbiddenApiUsage(getter, languageLevel))
		{
			registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-ui-designer,代码行数:26,代码来源:Java15FormInspection.java

示例7: findGetters

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public static PsiMethod[] findGetters(PsiClass aClass, String propertyName, boolean isStatic)
{
	if(!isStatic)
	{
		for(GetterSetterPrototypeProvider provider : Extensions.getExtensions(EP_NAME))
		{
			final PsiMethod[] getterSetter = provider.findGetters(aClass, propertyName);
			if(getterSetter != null)
			{
				return getterSetter;
			}
		}
	}
	final PsiMethod propertyGetterSetter = PropertyUtil.findPropertyGetter(aClass, propertyName, isStatic, false);
	if(propertyGetterSetter != null)
	{
		return new PsiMethod[]{propertyGetterSetter};
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:GetterSetterPrototypeProvider.java

示例8: findGetters

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public static PsiMethod[] findGetters(PsiClass aClass, String propertyName, boolean isStatic) {
  if (!isStatic) {
    for (GetterSetterPrototypeProvider provider : Extensions.getExtensions(EP_NAME)) {
      final PsiMethod[] getterSetter = provider.findGetters(aClass, propertyName);
      if (getterSetter != null) return getterSetter;
    }
  }
  final PsiMethod propertyGetterSetter = PropertyUtil.findPropertyGetter(aClass, propertyName, isStatic, false);
  if (propertyGetterSetter != null) {
    return new PsiMethod[] {propertyGetterSetter};
  }
  return null; 
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GetterSetterPrototypeProvider.java

示例9: getGetter

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

示例10: RemoveMiddlemanProcessor

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public RemoveMiddlemanProcessor(PsiField field, List<MemberInfo> memberInfos) {
  super(field.getProject());
  this.field = field;
  containingClass = field.getContainingClass();
  final String propertyName = PropertyUtil.suggestPropertyName(field);
  final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
  getter = PropertyUtil.findPropertyGetter(containingClass, propertyName, isStatic, false);
  myDelegateMethodInfos = memberInfos;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:RemoveMiddlemanProcessor.java

示例11: 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

示例12: 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

示例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: findGetters

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public PsiMethod[] findGetters(PsiClass psiClass, String propertyName) {
  final String getterName = suggestGetterName(propertyName);
  final PsiMethod specificGetter = psiClass
    .findMethodBySignature(JavaPsiFacade.getElementFactory(psiClass.getProject()).createMethod(getterName, PsiType.VOID), false);
  if (specificGetter != null) {
    final PsiMethod getter = PropertyUtil.findPropertyGetter(psiClass, propertyName, false, false);
    return getter == null ? new PsiMethod[] {specificGetter} : new PsiMethod[] {getter, specificGetter};
  }
  return super.findGetters(psiClass, propertyName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:JavaFxGetterSetterPrototypeProvider.java

示例15: RemoveMiddlemanProcessor

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public RemoveMiddlemanProcessor(PsiField field, List<MemberInfo> memberInfos) {
  super(field.getProject());
  this.field = field;
  containingClass = field.getContainingClass();
  final Project project = field.getProject();
  final String propertyName = PropertyUtil.suggestPropertyName(project, field);
  final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
  getter = PropertyUtil.findPropertyGetter(containingClass, propertyName, isStatic, false);
  myDelegateMethodInfos = memberInfos;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:RemoveMiddlemanProcessor.java


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