@Override protected ImmutableList<String> getLockExpressions(MethodTree tree) { UnlockMethod unlockMethod = ASTHelpers.getAnnotation(tree, UnlockMethod.class); return unlockMethod == null ? ImmutableList.<String>of() : ImmutableList.copyOf(unlockMethod.value()); }
/** Checks {@link UnlockMethod}-annotated methods. */ private void handleUnlockAnnotatedMethods(MethodInvocationTree tree) { UnlockMethod annotation = ASTHelpers.getAnnotation(tree, UnlockMethod.class); if (annotation == null) { return; } for (String lockString : annotation.value()) { Optional<GuardedByExpression> guard = GuardedByBinder.bindString(lockString, GuardedBySymbolResolver.from(tree, state)); // TODO(cushon): http://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#ifPresent if (guard.isPresent()) { Optional<GuardedByExpression> lock = ExpectedLockCalculator.from((JCExpression) tree, guard.get(), state); if (lock.isPresent()) { locks.add(lock.get()); } } } } }
@Override protected ImmutableList<String> getLockExpressions(MethodTree tree) { UnlockMethod unlockMethod = ASTHelpers.getAnnotation(tree, UnlockMethod.class); return unlockMethod == null ? ImmutableList.<String>of() : ImmutableList.copyOf(unlockMethod.value()); }
/** Checks {@link UnlockMethod}-annotated methods. */ private void handleUnlockAnnotatedMethods(MethodInvocationTree tree) { UnlockMethod annotation = ASTHelpers.getAnnotation(tree, UnlockMethod.class); if (annotation == null) { return; } for (String lockString : annotation.value()) { Optional<GuardedByExpression> guard = GuardedByBinder.bindString(lockString, GuardedBySymbolResolver.from(tree, state)); // TODO(cushon): http://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#ifPresent if (guard.isPresent()) { Optional<GuardedByExpression> lock = ExpectedLockCalculator.from((JCExpression) tree, guard.get(), state); if (lock.isPresent()) { locks.add(lock.get()); } } } } }