本文整理汇总了Java中com.intellij.psi.util.PropertyUtil.isSimplePropertyGetter方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyUtil.isSimplePropertyGetter方法的具体用法?Java PropertyUtil.isSimplePropertyGetter怎么用?Java PropertyUtil.isSimplePropertyGetter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PropertyUtil
的用法示例。
在下文中一共展示了PropertyUtil.isSimplePropertyGetter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAccessedVariableOrGetter
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Nullable
private static PsiModifierListOwner getAccessedVariableOrGetter(final PsiElement target) {
if (target instanceof PsiVariable) {
return (PsiVariable)target;
}
if (target instanceof PsiMethod) {
PsiMethod method = (PsiMethod)target;
if (PropertyUtil.isSimplePropertyGetter(method) && !(method.getReturnType() instanceof PsiPrimitiveType)) {
String qName = PsiUtil.getMemberQualifiedName(method);
if (qName == null || !FALSE_GETTERS.value(qName)) {
return method;
}
}
}
return null;
}
示例2: isSimplePropertyAccessor
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private static boolean isSimplePropertyAccessor(PsiMethod method) {
PsiCodeBlock body = method.getBody();
if (body == null) return false;
PsiStatement[] statements = body.getStatements();
if (statements.length == 0) return false;
PsiStatement statement = statements[0];
if (PropertyUtil.isSimplePropertyGetter(method)) {
if (statement instanceof PsiReturnStatement) {
return ((PsiReturnStatement)statement).getReturnValue() instanceof PsiReferenceExpression;
}
}
else if (PropertyUtil.isSimplePropertySetter(method)) {
if (statements.length > 1 && !(statements[1] instanceof PsiReturnStatement)) return false;
if (statement instanceof PsiExpressionStatement) {
PsiExpression expr = ((PsiExpressionStatement)statement).getExpression();
if (expr instanceof PsiAssignmentExpression) {
PsiExpression lhs = ((PsiAssignmentExpression)expr).getLExpression();
PsiExpression rhs = ((PsiAssignmentExpression)expr).getRExpression();
return lhs instanceof PsiReferenceExpression && rhs instanceof PsiReferenceExpression && !((PsiReferenceExpression)rhs).isQualified();
}
}
}
return false;
}
示例3: generateAcceptedMetaFieldNames
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private Set<String> generateAcceptedMetaFieldNames(PsiClass psiClass) {
Set<String> acceptedMetaFields = Sets.newHashSet();
for (PsiField field : psiClass.getAllFields()) {
if (!field.hasModifierProperty(PsiModifier.STATIC)) {
acceptedMetaFields.add(MetaFieldUtil.generateMetaFieldName(field.getName()));
}
}
for (PsiMethod method : psiClass.getAllMethods()) {
if (!method.hasModifierProperty(PsiModifier.STATIC) && PropertyUtil.isSimplePropertyGetter(method)) {
String propertyName = PropertyUtil.getPropertyNameByGetter(method);
acceptedMetaFields.add(MetaFieldUtil.generateMetaFieldName(propertyName));
}
}
return acceptedMetaFields;
}
示例4: getAccessedVariableOrGetter
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Nullable
private static PsiModifierListOwner getAccessedVariableOrGetter(final PsiElement target)
{
if(target instanceof PsiVariable)
{
return (PsiVariable) target;
}
if(target instanceof PsiMethod)
{
if(PropertyUtil.isSimplePropertyGetter((PsiMethod) target))
{
String qName = PsiUtil.getMemberQualifiedName((PsiMethod) target);
if(qName == null || !FALSE_GETTERS.value(qName))
{
return (PsiMethod) target;
}
}
}
return null;
}
示例5: isGetterSetterAssignment
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private boolean isGetterSetterAssignment(Object lookupObject, @Nullable PsiMethod calledMethod)
{
String prop = getSetterPropertyName(calledMethod);
if(prop == null)
{
return false;
}
if(lookupObject instanceof PsiField && prop.equals(PropertyUtil.suggestPropertyName((PsiField) lookupObject)))
{
return true;
}
if(lookupObject instanceof PsiMethod && PropertyUtil.isSimplePropertyGetter((PsiMethod) lookupObject) && prop.equals(PropertyUtil.getPropertyName((PsiMethod) lookupObject)))
{
return true;
}
return false;
}
示例6: isSimplePropertyAccessor
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private static boolean isSimplePropertyAccessor(PsiMethod method) {
if (DumbService.isDumb(method.getProject())) return false;
PsiCodeBlock body = method.getBody();
if (body == null || body.getLBrace() == null || body.getRBrace() == null) return false;
PsiStatement[] statements = body.getStatements();
if (statements.length == 0) return false;
PsiStatement statement = statements[0];
if (PropertyUtil.isSimplePropertyGetter(method)) {
if (statement instanceof PsiReturnStatement) {
return ((PsiReturnStatement)statement).getReturnValue() instanceof PsiReferenceExpression;
}
return false;
}
// builder-style setter?
if (statements.length > 1 && !(statements[1] instanceof PsiReturnStatement)) return false;
// any setter?
if (statement instanceof PsiExpressionStatement) {
PsiExpression expr = ((PsiExpressionStatement)statement).getExpression();
if (expr instanceof PsiAssignmentExpression) {
PsiExpression lhs = ((PsiAssignmentExpression)expr).getLExpression();
PsiExpression rhs = ((PsiAssignmentExpression)expr).getRExpression();
return lhs instanceof PsiReferenceExpression &&
rhs instanceof PsiReferenceExpression &&
!((PsiReferenceExpression)rhs).isQualified() &&
PropertyUtil.isSimplePropertySetter(method); // last check because it can perform long return type resolve
}
}
return false;
}
示例7: isGetterSetterAssignment
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private boolean isGetterSetterAssignment(Object lookupObject, @Nullable PsiMethod calledMethod) {
String prop = getSetterPropertyName(calledMethod);
if (prop == null) return false;
if (lookupObject instanceof PsiField &&
prop.equals(PropertyUtil.suggestPropertyName((PsiField)lookupObject))) {
return true;
}
if (lookupObject instanceof PsiMethod &&
PropertyUtil.isSimplePropertyGetter((PsiMethod)lookupObject) &&
prop.equals(PropertyUtil.getPropertyName((PsiMethod)lookupObject))) {
return true;
}
return false;
}
示例8: parseProperties
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private void parseProperties(PsiMethod method, JavaElementArrangementEntry entry) {
String propertyName = null;
boolean getter = true;
if (PropertyUtil.isSimplePropertyGetter(method)) {
entry.addModifier(GETTER);
propertyName = PropertyUtil.getPropertyNameByGetter(method);
}
else if (PropertyUtil.isSimplePropertySetter(method)) {
entry.addModifier(SETTER);
propertyName = PropertyUtil.getPropertyNameBySetter(method);
getter = false;
}
if (!myGroupingRules.contains(StdArrangementTokens.Grouping.GETTERS_AND_SETTERS) || propertyName == null) {
return;
}
PsiClass containingClass = method.getContainingClass();
String className = null;
if (containingClass != null) {
className = containingClass.getQualifiedName();
}
if (className == null) {
className = NULL_CONTENT;
}
if (getter) {
myInfo.registerGetter(propertyName, className, entry);
}
else {
myInfo.registerSetter(propertyName, className, entry);
}
}
示例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);
}
示例10: isGetterSetterAssignment
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private static boolean isGetterSetterAssignment(Object lookupObject, String prop) {
if (lookupObject instanceof PsiField &&
prop.equals(PropertyUtil.suggestPropertyName((PsiField)lookupObject))) {
return true;
}
if (lookupObject instanceof PsiMethod &&
PropertyUtil.isSimplePropertyGetter((PsiMethod)lookupObject) &&
prop.equals(PropertyUtil.getPropertyName((PsiMethod)lookupObject))) {
return true;
}
return false;
}
示例11: weigh
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@NotNull
@Override
public Comparable weigh(@NotNull LookupElement element) {
final Object object = element.getObject();
if (object instanceof PsiField) return -2;
if (object instanceof PsiMethod && PropertyUtil.isSimplePropertyGetter((PsiMethod)object)) return -1;
return 0;
}
示例12: parseProperties
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private void parseProperties(PsiMethod method, JavaElementArrangementEntry entry) {
if (!myGroupingRules.contains(StdArrangementTokens.Grouping.GETTERS_AND_SETTERS)) {
return;
}
String propertyName = null;
boolean getter = true;
if (PropertyUtil.isSimplePropertyGetter(method)) {
propertyName = PropertyUtil.getPropertyNameByGetter(method);
}
else if (PropertyUtil.isSimplePropertySetter(method)) {
propertyName = PropertyUtil.getPropertyNameBySetter(method);
getter = false;
}
if (propertyName == null) {
return;
}
PsiClass containingClass = method.getContainingClass();
String className = null;
if (containingClass != null) {
className = containingClass.getQualifiedName();
}
if (className == null) {
className = NULL_CONTENT;
}
if (getter) {
myInfo.registerGetter(propertyName, className, entry);
}
else {
myInfo.registerSetter(propertyName, className, entry);
}
}
示例13: weigh
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@NotNull
@Override
public MyResult weigh(@NotNull LookupElement item) {
final Object object = item.getObject();
if (object instanceof PsiKeyword) {
String keyword = ((PsiKeyword)object).getText();
if (PsiKeyword.RETURN.equals(keyword) && isLastStatement(PsiTreeUtil.getParentOfType(myPosition, PsiStatement.class))) {
return MyResult.probableKeyword;
}
if (PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) {
return MyResult.probableKeyword;
}
}
if (myCompletionType == CompletionType.SMART) {
if (object instanceof PsiLocalVariable || object instanceof PsiParameter || object instanceof PsiThisExpression) {
return MyResult.localOrParameter;
}
}
if (object instanceof String && item.getUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS) == Boolean.TRUE) {
return MyResult.superMethodParameters;
}
if (myCompletionType == CompletionType.SMART) {
if (item.getUserData(CollectionsUtilityMethodsProvider.COLLECTION_FACTORY) != null) {
return MyResult.collectionFactory;
}
if (Boolean.TRUE.equals(item.getUserData(MembersGetter.EXPECTED_TYPE_INHERITOR_MEMBER))) {
return MyResult.expectedTypeMember;
}
final JavaChainLookupElement chain = item.as(JavaChainLookupElement.CLASS_CONDITION_KEY);
if (chain != null) {
Object qualifier = chain.getQualifier().getObject();
if (qualifier instanceof PsiLocalVariable || qualifier instanceof PsiParameter) {
return MyResult.localOrParameter;
}
if (qualifier instanceof PsiField) {
return MyResult.qualifiedWithField;
}
if (qualifier instanceof PsiMethod && PropertyUtil.isSimplePropertyGetter((PsiMethod)qualifier)) {
return MyResult.qualifiedWithGetter;
}
}
return MyResult.normal;
}
if (myCompletionType == CompletionType.BASIC) {
StaticallyImportable callElement = item.as(StaticallyImportable.CLASS_CONDITION_KEY);
if (callElement != null && callElement.canBeImported() && !callElement.willBeImported()) {
return MyResult.classNameOrGlobalStatic;
}
if (object instanceof PsiKeyword && PsiKeyword.CLASS.equals(item.getLookupString())) {
return MyResult.classLiteral;
}
if (object instanceof PsiMethod && PsiUtil.isAnnotationMethod((PsiElement)object)) {
return MyResult.annoMethod;
}
if (object instanceof PsiClass) {
if (myRequiredSuper.value((PsiClass)object)) {
return MyResult.suitableClass;
}
return MyResult.classNameOrGlobalStatic;
}
if (object instanceof PsiField && myNonInitializedFields.contains(object)) {
return MyResult.nonInitialized;
}
}
return MyResult.normal;
}
示例14: isSimplePropertyAccessor
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private static boolean isSimplePropertyAccessor(@NotNull PsiMethod method)
{
if(DumbService.isDumb(method.getProject()))
{
return false;
}
PsiCodeBlock body = method.getBody();
if(body == null || body.getLBrace() == null || body.getRBrace() == null)
{
return false;
}
PsiStatement[] statements = body.getStatements();
if(statements.length == 0)
{
return false;
}
PsiStatement statement = statements[0];
if(PropertyUtil.isSimplePropertyGetter(method))
{
if(statement instanceof PsiReturnStatement)
{
return ((PsiReturnStatement) statement).getReturnValue() instanceof PsiReferenceExpression;
}
return false;
}
// builder-style setter?
if(statements.length > 1 && !(statements[1] instanceof PsiReturnStatement))
{
return false;
}
// any setter?
if(statement instanceof PsiExpressionStatement)
{
PsiExpression expr = ((PsiExpressionStatement) statement).getExpression();
if(expr instanceof PsiAssignmentExpression)
{
PsiExpression lhs = ((PsiAssignmentExpression) expr).getLExpression();
PsiExpression rhs = ((PsiAssignmentExpression) expr).getRExpression();
return lhs instanceof PsiReferenceExpression && rhs instanceof PsiReferenceExpression && !((PsiReferenceExpression) rhs).isQualified() && PropertyUtil.isSimplePropertySetter(method);
// last check because it can perform long return type resolve
}
}
return false;
}
示例15: parseProperties
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private void parseProperties(PsiMethod method, JavaElementArrangementEntry entry)
{
if(!myGroupingRules.contains(StdArrangementTokens.Grouping.GETTERS_AND_SETTERS))
{
return;
}
String propertyName = null;
boolean getter = true;
if(PropertyUtil.isSimplePropertyGetter(method))
{
propertyName = PropertyUtil.getPropertyNameByGetter(method);
}
else if(PropertyUtil.isSimplePropertySetter(method))
{
propertyName = PropertyUtil.getPropertyNameBySetter(method);
getter = false;
}
if(propertyName == null)
{
return;
}
PsiClass containingClass = method.getContainingClass();
String className = null;
if(containingClass != null)
{
className = containingClass.getQualifiedName();
}
if(className == null)
{
className = NULL_CONTENT;
}
if(getter)
{
myInfo.registerGetter(propertyName, className, entry);
}
else
{
myInfo.registerSetter(propertyName, className, entry);
}
}