本文整理汇总了Java中com.intellij.psi.util.PropertyUtil.isSimpleGetter方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyUtil.isSimpleGetter方法的具体用法?Java PropertyUtil.isSimpleGetter怎么用?Java PropertyUtil.isSimpleGetter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PropertyUtil
的用法示例。
在下文中一共展示了PropertyUtil.isSimpleGetter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inferPurity
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public static boolean inferPurity(@NotNull final PsiMethod method) {
if (!InferenceFromSourceUtil.shouldInferFromSource(method) ||
method.getReturnType() == PsiType.VOID ||
method.getBody() == null ||
method.isConstructor() ||
PropertyUtil.isSimpleGetter(method)) {
return false;
}
return CachedValuesManager.getCachedValue(method, new CachedValueProvider<Boolean>() {
@Nullable
@Override
public Result<Boolean> compute() {
boolean pure = RecursionManager.doPreventingRecursion(method, true, new Computable<Boolean>() {
@Override
public Boolean compute() {
return doInferPurity(method);
}
}) == Boolean.TRUE;
return Result.create(pure, method);
}
});
}
示例2: visitMethod
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
//no drilldown
if (method.getNameIdentifier() == null) {
return;
}
if (!method.hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
final PsiCodeBlock body = method.getBody();
if (body == null) {
return;
}
if (method.isConstructor()) {
return;
}
if (PropertyUtil.isSimpleGetter(method) || PropertyUtil.isSimpleSetter(method)) {
return;
}
if (containsLoggingCall(body)) {
return;
}
registerMethodError(method);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PublicMethodWithoutLoggingInspectionBase.java
示例3: calculateTotalMethodCount
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private int calculateTotalMethodCount(PsiClass aClass) {
final PsiMethod[] methods = aClass.getMethods();
int totalCount = 0;
for (final PsiMethod method : methods) {
if (method.isConstructor()) {
continue;
}
if (ignoreGettersAndSetters) {
if (PropertyUtil.isSimpleGetter(method) || PropertyUtil.isSimpleSetter(method)) {
continue;
}
}
if (ignoreOverridingMethods) {
if (MethodUtils.hasSuper(method)) {
continue;
}
}
totalCount++;
}
return totalCount;
}
示例4: calculateTotalMethodCount
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
private int calculateTotalMethodCount(PsiClass aClass) {
final PsiMethod[] methods = aClass.getMethods();
int totalCount = 0;
for (final PsiMethod method : methods) {
if (method.isConstructor()) {
continue;
}
if (ignoreGettersAndSetters) {
if (PropertyUtil.isSimpleGetter(method) ||
PropertyUtil.isSimpleSetter(method)) {
continue;
}
}
totalCount++;
}
return totalCount;
}
示例5: visitMethodCallExpression
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression expression) {
if (sideEffect != null) {
return;
}
super.visitMethodCallExpression(expression);
final PsiMethod method = expression.resolveMethod();
if (method != null && (PropertyUtil.isSimpleGetter(method) || ControlFlowAnalyzer.isPure(method))) {
return;
}
sideEffect = expression;
}
示例6: checkSideEffects
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public static boolean checkSideEffects(PsiElement element, PsiVariable variable, List<PsiElement> sideEffects) {
if (sideEffects == null || element == null) return false;
if (element instanceof PsiMethodCallExpression) {
final PsiMethod psiMethod = ((PsiMethodCallExpression)element).resolveMethod();
if (psiMethod == null || !PropertyUtil.isSimpleGetter(psiMethod) && !PropertyUtil.isSimpleSetter(psiMethod)) {
sideEffects.add(element);
return true;
}
}
if (element instanceof PsiNewExpression) {
PsiNewExpression newExpression = (PsiNewExpression)element;
if (newExpression.getArrayDimensions().length == 0
&& newExpression.getArrayInitializer() == null
&& !isSideEffectFreeConstructor(newExpression)) {
sideEffects.add(element);
return true;
}
}
if (element instanceof PsiAssignmentExpression
&& !(((PsiAssignmentExpression)element).getLExpression() instanceof PsiReferenceExpression
&& ((PsiReferenceExpression)((PsiAssignmentExpression)element).getLExpression()).resolve() == variable)) {
sideEffects.add(element);
return true;
}
PsiElement[] children = element.getChildren();
for (PsiElement child : children) {
checkSideEffects(child, variable, sideEffects);
}
return !sideEffects.isEmpty();
}
示例7: isPure
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
protected boolean isPure(PsiMethod method)
{
if(method == null)
{
return false;
}
if(PropertyUtil.isSimpleGetter(method))
{
return true;
}
return ControlFlowAnalyzer.isPure(method) && !mayHaveExceptionalSideEffect(method);
}
示例8: checkSideEffects
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
public static boolean checkSideEffects(PsiElement element, PsiVariable variable, List<PsiElement> sideEffects) {
if (sideEffects == null || element == null) return false;
if (element instanceof PsiMethodCallExpression) {
final PsiMethod psiMethod = ((PsiMethodCallExpression)element).resolveMethod();
if (psiMethod == null || !PropertyUtil.isSimpleGetter(psiMethod) && !PropertyUtil.isSimpleSetter(psiMethod)) {
sideEffects.add(element);
return true;
}
}
if (element instanceof PsiNewExpression) {
PsiNewExpression newExpression = (PsiNewExpression)element;
if (newExpression.getArrayDimensions().length == 0
&& newExpression.getArrayInitializer() == null
&& !isSideEffectFreeConstructor(newExpression)) {
sideEffects.add(element);
return true;
}
}
if (element instanceof PsiAssignmentExpression
&& !(((PsiAssignmentExpression)element).getLExpression() instanceof PsiReferenceExpression
&& ((PsiReferenceExpression)((PsiAssignmentExpression)element).getLExpression()).resolve() == variable)) {
sideEffects.add(element);
return true;
}
PsiElement[] children = element.getChildren();
for (PsiElement child : children) {
checkSideEffects(child, variable, sideEffects);
}
return !sideEffects.isEmpty();
}
示例9: visitMethodCallExpression
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
super.visitMethodCallExpression(call);
final PsiClass containingClass = ClassUtils.getContainingClass(call);
if (containingClass == null) {
return;
}
final PsiMethod method = call.resolveMethod();
if (method == null) {
return;
}
if (!containingClass.equals(method.getContainingClass())) {
return;
}
final PsiReferenceExpression methodExpression = call.getMethodExpression();
final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (qualifier != null && !(qualifier instanceof PsiThisExpression)) {
if (ignoreGetterCallsOnOtherObjects) {
return;
}
final PsiType type = qualifier.getType();
if (!(type instanceof PsiClassType)) {
return;
}
final PsiClassType classType = (PsiClassType)type;
final PsiClass qualifierClass = classType.resolve();
if (!containingClass.equals(qualifierClass)) {
return;
}
}
if (!PropertyUtil.isSimpleGetter(method)) {
return;
}
if (onlyReportPrivateGetter && !method.hasModifierProperty(PsiModifier.PRIVATE)) {
return;
}
final Query<PsiMethod> query = OverridingMethodsSearch.search(method, true);
final PsiMethod overridingMethod = query.findFirst();
if (overridingMethod != null) {
return;
}
registerMethodCallError(call);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:CallToSimpleGetterInClassInspectionBase.java
示例10: visitMethodCallExpression
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
PsiElement parent = expression.getParent();
while (parent instanceof PsiParenthesizedExpression || parent instanceof PsiTypeCastExpression) {
parent = parent.getParent();
}
if (canBeThrown(parent)) {
return;
}
if (!TypeUtils.expressionHasTypeOrSubtype(expression, CommonClassNames.JAVA_LANG_THROWABLE)) {
return;
}
final PsiMethod method = expression.resolveMethod();
if (method == null || PropertyUtil.isSimpleGetter(method)) {
return;
}
if (!method.hasModifierProperty(PsiModifier.STATIC)) {
final PsiClass containingClass = method.getContainingClass();
if (InheritanceUtil.isInheritor(containingClass, CommonClassNames.JAVA_LANG_THROWABLE)) {
return;
}
}
if ("propagate".equals(method.getName())
&& method.getContainingClass() != null
&& "com.google.common.base.Throwables".equals(method.getContainingClass().getQualifiedName())) {
return;
}
final PsiElement var = getVariable(parent, expression);
if (var == null) {
return;
}
if (var instanceof PsiLocalVariable) {
final Query<PsiReference> query = ReferencesSearch.search(var, var.getUseScope());
for (PsiReference reference : query) {
final PsiElement usage = reference.getElement();
PsiElement usageParent = usage.getParent();
while (usageParent instanceof PsiParenthesizedExpression) {
usageParent = usageParent.getParent();
}
if (canBeThrown(usageParent)) {
return;
}
}
}
registerMethodCallError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:51,代码来源:ThrowableResultOfMethodCallIgnoredInspection.java
示例11: visitMethodCallExpression
import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
PsiExpression outerExpression = expression;
while (outerExpression != null && outerExpression.getParent() instanceof PsiExpression) {
outerExpression = (PsiExpression)outerExpression.getParent();
}
if (outerExpression == null) {
return;
}
final PsiElement parent = outerExpression.getParent();
if (!(parent instanceof PsiExpressionList)) {
return;
}
final PsiElement grandParent = parent.getParent();
if (!(grandParent instanceof PsiCallExpression)) {
return;
}
if (ExpressionUtils.isConstructorInvocation(grandParent)) {
//ignore nested method calls at the start of a constructor,
//where they can't be extracted
return;
}
if (m_ignoreFieldInitializations) {
final PsiElement field = PsiTreeUtil.getParentOfType(expression, PsiField.class);
if (field != null) {
return;
}
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return;
}
if (ignoreStaticMethods || ignoreGetterCalls) {
if (ignoreStaticMethods && method.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
if (ignoreGetterCalls && PropertyUtil.isSimpleGetter(method)) {
return;
}
}
registerMethodCallError(expression);
}