本文整理汇总了Java中com.siyeh.ig.psiutils.SynchronizationUtil类的典型用法代码示例。如果您正苦于以下问题:Java SynchronizationUtil类的具体用法?Java SynchronizationUtil怎么用?Java SynchronizationUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SynchronizationUtil类属于com.siyeh.ig.psiutils包,在下文中一共展示了SynchronizationUtil类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例6: visitAssertStatement
import com.siyeh.ig.psiutils.SynchronizationUtil; //导入依赖的package包/类
@Override
public void visitAssertStatement(PsiAssertStatement statement) {
final PsiExpression condition = statement.getAssertCondition();
if (SynchronizationUtil.isCallToHoldsLock(condition)) {
m_inSynchronizedContextCount++;
PsiElement codeBlock = statement.getParent();
if (codeBlock != null) {
codeBlock.putUserData(CODE_BLOCK_CONTAINS_HOLDS_LOCK_CALL, true);
}
}
super.visitAssertStatement(statement);
}