Java 类com.intellij.psi.util.PropertyMemberType 实例源码

项目:intellij-ce-playground    文件:AbstractMemberResolveConverter.java   
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;
}
项目:intellij-ce-playground    文件:GenerateFieldOrPropertyHandler.java   
@Nullable
public PsiMember findExistingMember(@NotNull PsiClass aClass, @NotNull PropertyMemberType memberType) {
  if (memberType == PropertyMemberType.FIELD) {
    return aClass.findFieldByName(getFieldName(aClass), false);
  }
  else if (memberType == PropertyMemberType.GETTER) {
    try {
      PsiElementFactory psiElementFactory = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory();
      PsiField field = psiElementFactory.createField(myAttributeName, myType);
      PsiMethod[] templates = GetterSetterPrototypeProvider.generateGetterSetters(field, myMemberType == PropertyMemberType.GETTER);
      for (PsiMethod template : templates) {
        PsiMethod existingMethod = aClass.findMethodBySignature(template, true);
        if (existingMethod != null) return existingMethod;
      }
    }
    catch (IncorrectOperationException e) {
      assert false : e;
    }
  }
  return null;
}
项目:tools-idea    文件:AbstractMemberResolveConverter.java   
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;
}
项目:tools-idea    文件:GenerateFieldOrPropertyHandler.java   
@Nullable
public PsiMember findExistingMember(@NotNull PsiClass aClass, @NotNull PropertyMemberType memberType) {
  if (memberType == PropertyMemberType.FIELD) {
    return aClass.findFieldByName(getFieldName(aClass), false);
  }
  else if (memberType == PropertyMemberType.GETTER) {
    try {
      PsiElementFactory psiElementFactory = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory();
      PsiField field = psiElementFactory.createField(myAttributeName, myType);
      PsiMethod[] templates = GetterSetterPrototypeProvider.generateGetterSetters(field, myMemberType == PropertyMemberType.GETTER);
      for (PsiMethod template : templates) {
        PsiMethod existingMethod = aClass.findMethodBySignature(template, true);
        if (existingMethod != null) return existingMethod;
      }
    }
    catch (IncorrectOperationException e) {
      assert false : e;
    }
  }
  return null;
}
项目:consulo-java    文件:AbstractMemberResolveConverter.java   
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;
}
项目:intellij-ce-playground    文件:AbstractMemberResolveConverter.java   
public LocalQuickFix[] getQuickFixes(final ConvertContext context) {
  final String targetName = ((GenericValue)context.getInvocationElement()).getStringValue();
  if (!PsiNameHelper.getInstance(context.getProject()).isIdentifier(targetName)) return super.getQuickFixes(context);
  final PsiClass targetClass = getTargetClass(context);
  if (targetClass == null) return super.getQuickFixes(context);
  final PropertyMemberType memberType = getMemberTypes(context)[0];

  final PsiType psiType = getPsiType(context);
  final IntentionAction fix = QuickFixFactory.getInstance().createCreateFieldOrPropertyFix(targetClass, targetName, psiType, memberType);
  return fix instanceof LocalQuickFix? new LocalQuickFix[] {(LocalQuickFix)fix} : super.getQuickFixes(context);
}
项目:intellij-ce-playground    文件:GenerateFieldOrPropertyHandler.java   
public GenerateFieldOrPropertyHandler(String attributeName, PsiType type, final PropertyMemberType memberType, final PsiAnnotation... annotations) {
  super("");
  myAttributeName = attributeName;
  myType = type;
  myMemberType = memberType;
  myAnnotations = annotations;
}
项目:intellij-ce-playground    文件:CreateFieldOrPropertyFix.java   
public CreateFieldOrPropertyFix(final PsiClass aClass,
                                final String name,
                                final PsiType type,
                                @NotNull PropertyMemberType memberType,
                                final PsiAnnotation[] annotations) {
  myClass = aClass;
  myName = name;
  myType = type;
  myMemberType = memberType;
  myAnnotations = annotations;
}
项目:tools-idea    文件:AbstractMemberResolveConverter.java   
public LocalQuickFix[] getQuickFixes(final ConvertContext context) {
  final String targetName = ((GenericValue)context.getInvocationElement()).getStringValue();
  if (!JavaPsiFacade.getInstance(context.getProject()).getNameHelper().isIdentifier(targetName)) return super.getQuickFixes(context);
  final PsiClass targetClass = getTargetClass(context);
  if (targetClass == null) return super.getQuickFixes(context);
  final PropertyMemberType memberType = getMemberTypes(context)[0];

  final PsiType psiType = getPsiType(context);
  final IntentionAction fix = QuickFixFactory.getInstance().createCreateFieldOrPropertyFix(targetClass, targetName, psiType, memberType);
  return fix instanceof LocalQuickFix? new LocalQuickFix[] {(LocalQuickFix)fix} : super.getQuickFixes(context);
}
项目:tools-idea    文件:GenerateFieldOrPropertyHandler.java   
public GenerateFieldOrPropertyHandler(String attributeName, PsiType type, final PropertyMemberType memberType, final PsiAnnotation... annotations) {
  super("");
  myAttributeName = attributeName;
  myType = type;
  myMemberType = memberType;
  myAnnotations = annotations;
}
项目:tools-idea    文件:CreateFieldOrPropertyFix.java   
public CreateFieldOrPropertyFix(final PsiClass aClass, final String name, final PsiType type, final PropertyMemberType memberType, final PsiAnnotation[] annotations) {
  myClass = aClass;
  myName = name;
  myType = type;
  myMemberType = memberType;
  myAnnotations = annotations;
}
项目:consulo-java    文件:GenerateFieldOrPropertyHandler.java   
public GenerateFieldOrPropertyHandler(String attributeName, PsiType type, final PropertyMemberType memberType, final PsiAnnotation... annotations)
{
    super("");
    myAttributeName = attributeName;
    myType = type;
    myMemberType = memberType;
    myAnnotations = annotations;
}
项目:consulo-java    文件:GenerateFieldOrPropertyHandler.java   
@Nullable
public PsiMember findExistingMember(@NotNull PsiClass aClass, @NotNull PropertyMemberType memberType)
{
    if(memberType == PropertyMemberType.FIELD)
    {
        return aClass.findFieldByName(getFieldName(aClass), false);
    }
    else if(memberType == PropertyMemberType.GETTER)
    {
        try
        {
            PsiElementFactory psiElementFactory = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory();
            PsiField field = psiElementFactory.createField(myAttributeName, myType);
            PsiMethod[] templates = GetterSetterPrototypeProvider.generateGetterSetters(field, myMemberType == PropertyMemberType.GETTER);
            for(PsiMethod template : templates)
            {
                PsiMethod existingMethod = aClass.findMethodBySignature(template, true);
                if(existingMethod != null)
                {
                    return existingMethod;
                }
            }
        }
        catch(IncorrectOperationException e)
        {
            assert false : e;
        }
    }
    return null;
}
项目:consulo-java    文件:CreateFieldOrPropertyFix.java   
public CreateFieldOrPropertyFix(final PsiClass aClass, final String name, final PsiType type, final PropertyMemberType memberType, final PsiAnnotation[] annotations) {
  myClass = aClass;
  myName = name;
  myType = type;
  myMemberType = memberType;
  myAnnotations = annotations;
}
项目:consulo-java    文件:QuickFixFactoryImpl.java   
@NotNull
@Override
public IntentionAction createCreateFieldOrPropertyFix(@NotNull final PsiClass aClass,
        @NotNull final String name,
        @NotNull final PsiType type,
        @NotNull final PropertyMemberType targetMember,
        @NotNull final PsiAnnotation... annotations)
{
    return new CreateFieldOrPropertyFix(aClass, name, type, targetMember, annotations);
}
项目:consulo-java    文件:AbstractMemberResolveConverter.java   
public LocalQuickFix[] getQuickFixes(final ConvertContext context) {
  final String targetName = ((GenericValue)context.getInvocationElement()).getStringValue();
  if (!PsiNameHelper.getInstance(context.getProject()).isIdentifier(targetName)) return super.getQuickFixes(context);
  final PsiClass targetClass = getTargetClass(context);
  if (targetClass == null) return super.getQuickFixes(context);
  final PropertyMemberType memberType = getMemberTypes(context)[0];

  final PsiType psiType = getPsiType(context);
  final IntentionAction fix = QuickFixFactory.getInstance().createCreateFieldOrPropertyFix(targetClass, targetName, psiType, memberType);
  return fix instanceof LocalQuickFix? new LocalQuickFix[] {(LocalQuickFix)fix} : super.getQuickFixes(context);
}
项目:intellij-ce-playground    文件:AbstractMemberResolveConverter.java   
@NotNull
protected abstract PropertyMemberType[] getMemberTypes(final ConvertContext context);
项目:intellij-ce-playground    文件:EmptyQuickFixFactory.java   
@NotNull
@Override
public IntentionAction createCreateFieldOrPropertyFix(@NotNull PsiClass psiClass, @NotNull String s, @NotNull PsiType psiType, @NotNull PropertyMemberType propertyMemberType, @NotNull PsiAnnotation... psiAnnotations) {
  return QuickFixes.EMPTY_FIX;
}
项目:intellij-ce-playground    文件:GenerateFieldOrPropertyHandler.java   
private String getFieldName(PsiClass aClass) {
  return myMemberType == PropertyMemberType.FIELD? myAttributeName : JavaCodeStyleManager
    .getInstance(aClass.getProject()).propertyNameToVariableName(myAttributeName, VariableKind.FIELD);
}
项目:intellij-ce-playground    文件:CreateFieldOrPropertyFix.java   
@Override
@NotNull
public String getText() {
  return QuickFixBundle.message(myMemberType == PropertyMemberType.FIELD ? "create.field.text":"create.property.text", myName);
}
项目:intellij-ce-playground    文件:QuickFixFactoryImpl.java   
@NotNull
@Override
public IntentionAction createCreateFieldOrPropertyFix(@NotNull final PsiClass aClass, @NotNull final String name, @NotNull final PsiType type, @NotNull final PropertyMemberType targetMember, @NotNull final PsiAnnotation... annotations) {
  return new CreateFieldOrPropertyFix(aClass, name, type, targetMember, annotations);
}
项目:intellij-ce-playground    文件:QuickFixFactory.java   
@NotNull
public abstract IntentionAction createCreateFieldOrPropertyFix(@NotNull PsiClass aClass, @NotNull String name, @NotNull PsiType type, @NotNull PropertyMemberType targetMember, @NotNull PsiAnnotation... annotations);
项目:tools-idea    文件:AbstractMemberResolveConverter.java   
@NotNull
protected abstract PropertyMemberType[] getMemberTypes(final ConvertContext context);
项目:tools-idea    文件:GenerateFieldOrPropertyHandler.java   
private String getFieldName(PsiClass aClass) {
  return myMemberType == PropertyMemberType.FIELD? myAttributeName : JavaCodeStyleManager
    .getInstance(aClass.getProject()).propertyNameToVariableName(myAttributeName, VariableKind.FIELD);
}
项目:tools-idea    文件:CreateFieldOrPropertyFix.java   
@Override
@NotNull
public String getText() {
  return QuickFixBundle.message(myMemberType == PropertyMemberType.FIELD ? "create.field.text":"create.property.text", myName);
}
项目:tools-idea    文件:QuickFixFactoryImpl.java   
@Override
public IntentionAction createCreateFieldOrPropertyFix(final PsiClass aClass, final String name, final PsiType type, final PropertyMemberType targetMember, final PsiAnnotation... annotations) {
  return new CreateFieldOrPropertyFix(aClass, name, type, targetMember, annotations);
}
项目:consulo-javaee    文件:EjbInjectionTargetConverter.java   
@NotNull
protected PropertyMemberType[] getMemberTypes(final ConvertContext context) {
  return new PropertyMemberType[] { PropertyMemberType.SETTER, PropertyMemberType.FIELD};
}
项目:consulo-java    文件:GenerateFieldOrPropertyHandler.java   
private String getFieldName(PsiClass aClass)
{
    return myMemberType == PropertyMemberType.FIELD ? myAttributeName : JavaCodeStyleManager.getInstance(aClass.getProject()).propertyNameToVariableName(myAttributeName, VariableKind.FIELD);
}
项目:consulo-java    文件:CreateFieldOrPropertyFix.java   
@Override
@NotNull
public String getText() {
  return JavaQuickFixBundle.message(myMemberType == PropertyMemberType.FIELD ? "create.field.text":"create.property.text", myName);
}
项目:consulo-java    文件:AbstractMemberResolveConverter.java   
@NotNull
protected abstract PropertyMemberType[] getMemberTypes(final ConvertContext context);
项目:consulo-java    文件:QuickFixFactory.java   
@NotNull
public abstract IntentionAction createCreateFieldOrPropertyFix(@NotNull PsiClass aClass,
        @NotNull String name,
        @NotNull PsiType type,
        @NotNull PropertyMemberType targetMember,
        @NotNull PsiAnnotation... annotations);
项目:tools-idea    文件:QuickFixFactory.java   
public abstract IntentionAction createCreateFieldOrPropertyFix(final PsiClass aClass, final String name, final PsiType type, final PropertyMemberType targetMember, final PsiAnnotation... annotations);