code: @Override
    @GwtIncompatible // TODO(tdeegan): Remove use of Matcher#group to make this fully GWT compatible.
    public String getPackageName(StaticSourceFile source) {
      String name = source.getName();
      Matcher genfilesMatcher = GENFILES_DIR.matcher(name);
      if (genfilesMatcher.find()) {
        name = genfilesMatcher.group(2);
      }
  
      Matcher m = PACKAGE_WITH_TEST_DIR.matcher(name);
      if (m.find()) {
        return m.group(1);
      } else {
        int lastSlash = name.lastIndexOf('/');
        return lastSlash == -1 ? "" : name.substring(0, lastSlash);
      }
    }
docs: {@inheritDoc}
  
  <p>In Google code, the package name of a source file is its file path.
  Exceptions: if a source file's parent directory is "test", "tests", or
  "testing", that directory is stripped from the package name.
  If a file is generated, strip the "genfiles" prefix to try
  to match the package of the generating file.