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


Java PropertyUtil.findGetterForField方法代码示例

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


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

示例1: newFieldElement

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
/**
 * Create a new {@link FieldElement} object.
 *
 * @param field   the {@link com.intellij.psi.PsiField} to get the information from.
 * @return a new {@link FieldElement} object.
 */
public static FieldElement newFieldElement(PsiField field, boolean useAccessor) {
  FieldElement fe = new FieldElement();
  fe.setName(field.getName());
  final PsiMethod getterForField = useAccessor ? PropertyUtil.findGetterForField(field) : null;
  fe.setAccessor(getterForField != null ? getterForField.getName() + "()" : field.getName());

  if (PsiAdapter.isConstantField(field)) fe.setConstant(true);
  if (PsiAdapter.isEnumField(field)) fe.setEnum(true);
  PsiModifierList modifiers = field.getModifierList();
  if (modifiers != null) {
    if (modifiers.hasModifierProperty(PsiModifier.TRANSIENT)) fe.setModifierTransient(true);
    if (modifiers.hasModifierProperty(PsiModifier.VOLATILE)) fe.setModifierVolatile(true);
  }

  PsiElementFactory factory = JavaPsiFacade.getInstance(field.getProject()).getElementFactory();
  PsiType type = field.getType();
  setElementInfo(fe, factory, type, modifiers);

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

示例2: getAnnotationForField

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Nullable
private static PsiAnnotation getAnnotationForField(PsiField field) {
  PsiAnnotation annotation = getAnnotation(field);
  if (annotation == null) {
    // Fields are usually not annotated (because they are private, not part of the API).
    // However, if a field has a getter, there is a good chance that the getter has been
    // annotated!
    PsiMethod getter = PropertyUtil.findGetterForField(field);
    if (getter != null) {
      return getAnnotation(getter);
    }
  }
  return annotation;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:AndroidResolveHelper.java

示例3: getAnnotationValue

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public static String getAnnotationValue(PsiField psiField, Class annotationClass) {
  final PsiConstantEvaluationHelper evalHelper = JavaPsiFacade.getInstance(psiField.getProject()).getConstantEvaluationHelper();
  final PsiMethod getter = PropertyUtil.findGetterForField(psiField);
  final PsiMethod setter = PropertyUtil.findSetterForField(psiField);
  final PsiAnnotation attrAnno = ExtensionDomExtender.findAnnotation(annotationClass, psiField, getter, setter);
  if (attrAnno != null) {
    return ExtensionDomExtender.getStringAttribute(attrAnno, "value", evalHelper);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PluginFieldNameConverter.java

示例4: newFieldElement

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
/**
 * Create a new {@link FieldElement} object.
 *
 * @param field the {@link com.intellij.psi.PsiField} to get the information from.
 * @return a new {@link FieldElement} object.
 */
public static FieldElement newFieldElement(PsiField field, boolean useAccessor)
{
	FieldElement fe = new FieldElement();
	fe.setName(field.getName());
	final PsiMethod getterForField = useAccessor ? PropertyUtil.findGetterForField(field) : null;
	fe.setAccessor(getterForField != null ? getterForField.getName() + "()" : field.getName());

	if(PsiAdapter.isConstantField(field))
	{
		fe.setConstant(true);
	}
	if(PsiAdapter.isEnumField(field))
	{
		fe.setEnum(true);
	}
	PsiModifierList modifiers = field.getModifierList();
	if(modifiers != null)
	{
		if(modifiers.hasModifierProperty(PsiModifier.TRANSIENT))
		{
			fe.setModifierTransient(true);
		}
		if(modifiers.hasModifierProperty(PsiModifier.VOLATILE))
		{
			fe.setModifierVolatile(true);
		}
	}

	PsiElementFactory factory = JavaPsiFacade.getInstance(field.getProject()).getElementFactory();
	PsiType type = field.getType();
	setElementInfo(fe, factory, type, modifiers);

	return fe;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:41,代码来源:ElementFactory.java


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