private static boolean canAddFinal(IBinding binding, ASTNode declNode) {
    if (!(binding instanceof IVariableBinding)) return false;

    IVariableBinding varbinding = (IVariableBinding) binding;
    int modifiers = varbinding.getModifiers();
    if (Modifier.isFinal(modifiers)
        || Modifier.isVolatile(modifiers)
        || Modifier.isTransient(modifiers)) return false;

    ASTNode parent = ASTNodes.getParent(declNode, VariableDeclarationExpression.class);
    if (parent != null && ((VariableDeclarationExpression) parent).fragments().size() > 1)
      return false;

    if (varbinding.isField() && !Modifier.isPrivate(modifiers)) return false;

    if (varbinding.isParameter()) {
      ASTNode varDecl = declNode.getParent();
      if (varDecl instanceof MethodDeclaration) {
        MethodDeclaration declaration = (MethodDeclaration) varDecl;
        if (declaration.getBody() == null) return false;
      }
    }

    return true;
  }
 public static String getSetterName(
     IVariableBinding variableType,
     IJavaProject project,
     String[] excludedNames,
     boolean isBoolean) {
   return getSetterName(
       project, variableType.getName(), variableType.getModifiers(), isBoolean, excludedNames);
 }
 public static String getGetterName(
     IVariableBinding variableType,
     IJavaProject project,
     String[] excludedNames,
     boolean isBoolean) {
   boolean useIs = StubUtility.useIsForBooleanGetters(project) && isBoolean;
   return getGetterName(
       project, variableType.getName(), variableType.getModifiers(), useIs, excludedNames);
 }
 private boolean testModifier(IVariableBinding curr) {
   int modifiers = curr.getModifiers();
   int staticFinal = Modifier.STATIC | Modifier.FINAL;
   if ((modifiers & staticFinal) == staticFinal) {
     return false;
   }
   if (Modifier.isStatic(modifiers) && !Modifier.isStatic(fMethodDecl.getModifiers())) {
     return false;
   }
   return true;
 }
Beispiel #5
0
 public static boolean isVolatile(IVariableBinding binding) {
   return Modifier.isVolatile(binding.getModifiers());
 }