code: static String enclosing(String identifier) {
      int hash = identifier.lastIndexOf('#');
      if (hash != -1) return identifier.substring(0, hash);
  
      int from = identifier.endsWith(".*") ? identifier.length() - 3 : identifier.length() - 1;
      int dot = identifier.lastIndexOf('.', from);
      if (dot != -1) return identifier.substring(0, dot) + ".*";
  
      return !identifier.equals("*") ? "*" : null;
    }
docs: Returns the identifier or wildcard that encloses {@code identifier}, or null if it is not
  enclosed.
  
  <ul>
  <li>If {@code identifier} is a member this returns the enclosing type.
  <li>If it is a type it returns the enclosing package with a wildcard, like {@code
  squareup.dinosaurs.*}.
  <li>If it is a package with a wildcard, it returns the parent package with a wildcard, like
  {@code squareup.*}. The root wildcard is a lone asterisk, {@code *}.
  </ul>