本文整理汇总了Java中com.siyeh.ig.psiutils.SynchronizationUtil.isInSynchronizedContext方法的典型用法代码示例。如果您正苦于以下问题:Java SynchronizationUtil.isInSynchronizedContext方法的具体用法?Java SynchronizationUtil.isInSynchronizedContext怎么用?Java SynchronizationUtil.isInSynchronizedContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.siyeh.ig.psiutils.SynchronizationUtil
的用法示例。
在下文中一共展示了SynchronizationUtil.isInSynchronizedContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findNonSynchronizedVolatileField
import com.siyeh.ig.psiutils.SynchronizationUtil; //导入方法依赖的package包/类
@Nullable
private static PsiField findNonSynchronizedVolatileField(
PsiExpression expression) {
if (!(expression instanceof PsiReferenceExpression)) {
return null;
}
final PsiReferenceExpression reference =
(PsiReferenceExpression)expression;
final PsiElement referent = reference.resolve();
if (!(referent instanceof PsiField)) {
return null;
}
final PsiField field = (PsiField)referent;
if (!field.hasModifierProperty(PsiModifier.VOLATILE)) {
return null;
}
if (SynchronizationUtil.isInSynchronizedContext(reference)) {
return null;
}
return field;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:NonAtomicOperationOnVolatileFieldInspection.java
示例2: visitMethodCallExpression
import com.siyeh.ig.psiutils.SynchronizationUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression expression) {
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return;
}
if (!method.hasModifierProperty(PsiModifier.NATIVE)) {
return;
}
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null) {
return;
}
final String className = containingClass.getQualifiedName();
if (CommonClassNames.JAVA_LANG_OBJECT.equals(className)) {
return;
}
if (!SynchronizationUtil.isInSynchronizedContext(expression)) {
return;
}
registerMethodCallError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CallToNativeMethodWhileLockedInspection.java
示例3: visitReferenceExpression
import com.siyeh.ig.psiutils.SynchronizationUtil; //导入方法依赖的package包/类
@Override
public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) {
final PsiExpression qualifier = expression.getQualifierExpression();
if (qualifier != null && !(qualifier instanceof PsiThisExpression) && !(qualifier instanceof PsiSuperExpression)) {
return;
}
final PsiElement element = expression.resolve();
if (!(element instanceof PsiField)) {
return;
}
final PsiField field = (PsiField)element;
if (field.hasModifierProperty(PsiModifier.PRIVATE) || field.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
if (!SynchronizationUtil.isInSynchronizedContext(expression)) {
return;
}
final PsiClass containingClass = field.getContainingClass();
if (containingClass == null || containingClass.hasModifierProperty(PsiModifier.PRIVATE)) {
return;
}
registerError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PublicFieldAccessedInSynchronizedContextInspection.java
示例4: visitMethodCallExpression
import com.siyeh.ig.psiutils.SynchronizationUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
if (!HardcodedMethodConstants.NOTIFY.equals(methodName) &&
!HardcodedMethodConstants.NOTIFY_ALL.equals(methodName)) {
return;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return;
}
final PsiParameterList parameterList = method.getParameterList();
if (parameterList.getParametersCount() != 0) {
return;
}
if (SynchronizationUtil.isInSynchronizedContext(expression)) {
return;
}
registerMethodCallError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:NotifyNotInSynchronizedContextInspection.java
示例5: findNonSynchronizedVolatileField
import com.siyeh.ig.psiutils.SynchronizationUtil; //导入方法依赖的package包/类
@Nullable
private static PsiField findNonSynchronizedVolatileField(
PsiExpression expression) {
if (!(expression instanceof PsiReferenceExpression)) {
return null;
}
final PsiReferenceExpression reference =
(PsiReferenceExpression)expression;
if (SynchronizationUtil.isInSynchronizedContext(reference)) {
return null;
}
final PsiElement referent = reference.resolve();
if (!(referent instanceof PsiField)) {
return null;
}
final PsiField field = (PsiField)referent;
if (!field.hasModifierProperty(PsiModifier.VOLATILE)) {
return null;
}
return field;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:NonAtomicOperationOnVolatileFieldInspection.java