本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}