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


Java PropertyUtil.isSimplePropertyGetter方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:DfaExpressionFactory.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:JavaFoldingBuilderBase.java

示例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;
}
 
开发者ID:srichard,项目名称:mfgen,代码行数:18,代码来源:InspectingMetaFields.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:DfaExpressionFactory.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:RecursionWeigher.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:JavaFoldingBuilderBase.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:RecursionWeigher.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:JavaArrangementVisitor.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: 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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:RecursionWeigher.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:JavaCompletionSorting.java

示例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);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:36,代码来源:JavaArrangementVisitor.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:79,代码来源:PreferByKindWeigher.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:49,代码来源:JavaFoldingBuilderBase.java

示例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);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:45,代码来源:JavaArrangementVisitor.java


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