if (maybeDecl.isVarDeclaration()) {
   Preconditions.checkState(!maybeDecl.isInitializingDeclaration());
   Reference maybeInit = references.get(index);
   if (maybeInit.isSimpleAssignmentToName()) {
     return true;
   }
 }
Exemplo n.º 2
0
 /** @return Whether the variable is never assigned a value. */
 boolean isNeverAssigned() {
   int size = references.size();
   for (int i = 0; i < size; i++) {
     Reference ref = references.get(i);
     if (ref.isLvalue() || ref.isInitializingDeclaration()) {
       return false;
     }
   }
   return true;
 }
Exemplo n.º 3
0
 /**
  * @param index The index into the references array to look for an assigning declaration.
  *     <p>This is either the declaration if a value is assigned (such as "var a = 2", "function
  *     a()...", "... catch (a)...").
  */
 private boolean isInitializingDeclarationAt(int index) {
   Reference maybeInit = references.get(index);
   if (maybeInit.isInitializingDeclaration()) {
     // This is a declaration that represents the initial value.
     // Specifically, var declarations without assignments such as "var a;"
     // are not.
     return true;
   }
   return false;
 }
Exemplo n.º 4
0
 /**
  * @param index The index into the references array to look for an initialized assignment
  *     reference. That is, an assignment immediately follow a variable declaration that itself
  *     does not initialize the variable.
  */
 private boolean isInitializingAssignmentAt(int index) {
   if (index < references.size() && index > 0) {
     Reference maybeDecl = references.get(index - 1);
     if (maybeDecl.isVarDeclaration()) {
       Preconditions.checkState(!maybeDecl.isInitializingDeclaration());
       Reference maybeInit = references.get(index);
       if (maybeInit.isSimpleAssignmentToName()) {
         return true;
       }
     }
   }
   return false;
 }
Exemplo n.º 5
0
 /** @return The one and only assignment. Returns if there are 0 or 2+ assignments. */
 private Reference getOneAndOnlyAssignment() {
   Reference assignment = null;
   int size = references.size();
   for (int i = 0; i < size; i++) {
     Reference ref = references.get(i);
     if (ref.isLvalue() || ref.isInitializingDeclaration()) {
       if (assignment == null) {
         assignment = ref;
       } else {
         return null;
       }
     }
   }
   return assignment;
 }