Adapt to changes in gerrit core

Change I78c15e01 migrated PrologEnvironment off of PatchListCache.
find-owners used to reference this field which is no longer valid, hence
fixing with this change. This field was redundant in find-owners anyway,
so we are just removing it.

While we are at it, cleanup some unused code in find-owners as well.

Change-Id: I31d938875d857775263dc17e8e1f8b5b47f0f41d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java
index 8da0290..5d6f7c6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/Action.java
@@ -34,7 +34,6 @@
 import com.google.gerrit.server.change.RevisionResource;
 import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.gerrit.server.git.GitRepositoryManager;
-import com.google.gerrit.server.patch.PatchListCache;
 import com.google.gerrit.server.permissions.PermissionBackend;
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.gerrit.server.project.ProjectState;
@@ -77,7 +76,6 @@
       Provider<CurrentUser> userProvider,
       ChangeData.Factory changeDataFactory,
       AccountCache accountCache,
-      PatchListCache patchListCache,
       Emails emails,
       GitRepositoryManager repoManager,
       ProjectCache projectCache) {
@@ -88,7 +86,7 @@
     this.emails = emails;
     this.repoManager = repoManager;
     this.projectCache = projectCache;
-    this.config = new Config(configFactory, null, accountCache, patchListCache, emails);
+    this.config = new Config(configFactory, null);
   }
 
   private String getUserName() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/Checker.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/Checker.java
index 1fbc37f..e21c79d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/Checker.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/Checker.java
@@ -22,10 +22,8 @@
 import com.google.gerrit.server.account.Emails;
 import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.gerrit.server.git.GitRepositoryManager;
-import com.google.gerrit.server.patch.PatchListCache;
 import com.google.gerrit.server.project.ProjectState;
 import com.google.gerrit.server.query.change.ChangeData;
-import com.google.gerrit.server.rules.PrologEnvironment;
 import com.google.gerrit.server.rules.StoredValues;
 import com.googlecode.prolog_cafe.lang.Prolog;
 import java.util.HashMap;
@@ -51,7 +49,6 @@
 
   Checker(
       AccountCache accountCache,
-      PatchListCache patchListCache,
       GitRepositoryManager repoManager,
       Emails emails,
       PluginConfigFactory configFactory,
@@ -63,7 +60,7 @@
     this.emails = emails;
     this.projectState = projectState;
     this.changeData = changeData;
-    this.config = new Config(configFactory, null, accountCache, patchListCache, emails);
+    this.config = new Config(configFactory, null);
     minVoteLevel = v;
   }
 
@@ -135,11 +132,9 @@
     ChangeData changeData = null;
     try {
       changeData = StoredValues.CHANGE_DATA.get(engine);
-      PrologEnvironment env = (PrologEnvironment) engine.control;
       Checker checker =
           new Checker(
               StoredValues.ACCOUNT_CACHE.get(engine),
-              env.getArgs().getPatchListCache(),
               StoredValues.REPO_MANAGER.get(engine),
               StoredValues.EMAILS.get(engine),
               StoredValues.PLUGIN_CONFIG_FACTORY.get(engine),
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/Config.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/Config.java
index e3fab58..a3ee8a3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/Config.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/Config.java
@@ -14,14 +14,10 @@
 
 package com.googlesource.gerrit.plugins.findowners;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.flogger.FluentLogger;
 import com.google.gerrit.entities.Project;
-import com.google.gerrit.server.account.AccountCache;
-import com.google.gerrit.server.account.Emails;
 import com.google.gerrit.server.config.PluginConfig;
 import com.google.gerrit.server.config.PluginConfigFactory;
-import com.google.gerrit.server.patch.PatchListCache;
 import com.google.gerrit.server.project.NoSuchProjectException;
 import com.google.gerrit.server.project.ProjectState;
 import com.google.gerrit.server.query.change.ChangeData;
@@ -63,23 +59,13 @@
   private int maxCacheSize = 1000;
   private boolean reportSyntaxError = false;
 
-  // Gerrit server objects to set up JS initcode for JSEConfig.
-  private final AccountCache accountCache;
-  private final PatchListCache patchListCache;
-  private final Emails emails;
-
   private static final FluentLogger logger = FluentLogger.forEnclosingClass();
 
   Config(
       PluginConfigFactory configFactory, // null when called from unit tests
-      PluginConfig config, // null when called by Action and Checker
-      AccountCache accountCache,
-      PatchListCache patchListCache,
-      Emails emails) {
+      PluginConfig config // null when called by Action and Checker
+      ) {
     this.configFactory = configFactory;
-    this.accountCache = accountCache;
-    this.patchListCache = patchListCache;
-    this.emails = emails;
     projectConfigMap = new ConcurrentHashMap<>();
     if (configFactory == null && config == null) { // When called from integration tests.
       gerritConfig = null;
@@ -99,18 +85,6 @@
     reportSyntaxError = gerritConfig.getBoolean(REPORT_SYNTAX_ERROR, false);
   }
 
-  AccountCache accountCache() {
-    return accountCache;
-  }
-
-  Emails emails() {
-    return emails;
-  }
-
-  PatchListCache patchListCache() {
-    return patchListCache;
-  }
-
   private static BaseConfig newConfig(
       String name, PluginConfig cfg, Project project, ProjectState state, ChangeData changeData) {
     // This function is called
@@ -184,12 +158,6 @@
     return reportSyntaxError;
   }
 
-  static String getProjectName(ProjectState state, Project project) {
-    return state != null
-        ? state.getProject().getName()
-        : (project != null ? project.getName() : "(unknown project)");
-  }
-
   static String getChangeId(ChangeData data) {
     return data == null ? "(unknown change)" : ("c/" + data.getId().get());
   }
@@ -269,11 +237,6 @@
     }
   }
 
-  @VisibleForTesting
-  void setReportSyntaxError(boolean value) {
-    reportSyntaxError = value;
-  }
-
   int getMinOwnerVoteLevel(ProjectState projectState, ChangeData c) {
     if (projectState == null) {
       logger.atSevere().log("Null projectState for change %s", getChangeId(c));
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java
index 411ce02..d5faaff 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/GetOwners.java
@@ -24,7 +24,6 @@
 import com.google.gerrit.server.change.ChangeResource;
 import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.gerrit.server.git.GitRepositoryManager;
-import com.google.gerrit.server.patch.PatchListCache;
 import com.google.gerrit.server.permissions.PermissionBackend;
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.gerrit.server.query.change.ChangeData;
@@ -58,7 +57,6 @@
       Provider<CurrentUser> userProvider,
       ChangeData.Factory dataFactory,
       AccountCache accountCache,
-      PatchListCache patchListCache,
       Emails emails,
       GitRepositoryManager repoManager,
       ProjectCache projectCache) {
@@ -69,7 +67,6 @@
             userProvider,
             dataFactory,
             accountCache,
-            patchListCache,
             emails,
             repoManager,
             projectCache);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/findowners/OwnersValidator.java b/src/main/java/com/googlesource/gerrit/plugins/findowners/OwnersValidator.java
index 331dab8..dcea400 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/findowners/OwnersValidator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/findowners/OwnersValidator.java
@@ -35,7 +35,6 @@
 import com.google.gerrit.server.git.validators.CommitValidationException;
 import com.google.gerrit.server.git.validators.CommitValidationListener;
 import com.google.gerrit.server.git.validators.CommitValidationMessage;
-import com.google.gerrit.server.patch.PatchListCache;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import java.io.BufferedReader;
@@ -96,30 +95,27 @@
   OwnersValidator(
       PluginConfigFactory cfgFactory,
       AccountCache accountCache,
-      PatchListCache patchListCache,
       GitRepositoryManager repoManager,
       Emails emails) {
-    this(cfgFactory, null, accountCache, patchListCache, repoManager, emails);
+    this(cfgFactory, null, accountCache, repoManager, emails);
   }
 
   @VisibleForTesting
   OwnersValidator(
       PluginConfig config,
       AccountCache accountCache,
-      PatchListCache patchListCache,
       GitRepositoryManager repoManager,
       Emails emails) {
-    this(null, config, accountCache, patchListCache, repoManager, emails);
+    this(null, config, accountCache, repoManager, emails);
   }
 
   private OwnersValidator(
       PluginConfigFactory cfgFactory,
       PluginConfig config,
       AccountCache accountCache,
-      PatchListCache patchListCache,
       GitRepositoryManager repoManager,
       Emails emails) {
-    this.config = new Config(cfgFactory, config, accountCache, patchListCache, emails);
+    this.config = new Config(cfgFactory, config);
     this.repoManager = repoManager;
     this.emails = emails;
   }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/ApiIT.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/ApiIT.java
index 283faaf..1abdfd9 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/ApiIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/ApiIT.java
@@ -117,7 +117,6 @@
             null,
             changeDataFactory,
             accountCache,
-            patchListCache,
             emails,
             repoManager,
             projectCache);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/FindOwners.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/FindOwners.java
index cf1cf9f..b47276d 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/FindOwners.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/FindOwners.java
@@ -35,7 +35,6 @@
 import com.google.gerrit.extensions.common.ChangeInfo;
 import com.google.gerrit.extensions.common.ChangeInput;
 import com.google.gerrit.server.account.Emails;
-import com.google.gerrit.server.patch.PatchListCache;
 import com.google.gerrit.server.permissions.PermissionBackend;
 import com.google.inject.Inject;
 import org.eclipse.jgit.lib.ObjectLoader;
@@ -53,14 +52,13 @@
   @Inject protected Emails emails;
   @Inject protected PermissionBackend permissionBackend;
   @Inject protected ProjectOperations projectOperations;
-  @Inject protected PatchListCache patchListCache;
 
   protected static final String PLUGIN_NAME = "find-owners";
   protected Config config;
 
   @Before
   public void setConfig() {
-    config = new Config(pluginConfig, null, null, null, null);
+    config = new Config(pluginConfig, null);
   }
 
   protected String oneOwnerList(String email) {
@@ -183,15 +181,7 @@
             r.getChange(),
             1);
     Checker c =
-        new Checker(
-            accountCache,
-            patchListCache,
-            repoManager,
-            emails,
-            pluginConfig,
-            null,
-            r.getChange(),
-            1);
+        new Checker(accountCache, repoManager, emails, pluginConfig, null, r.getChange(), 1);
     return c.findApproval(db);
   }
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/findowners/OwnersValidatorIT.java b/src/test/java/com/googlesource/gerrit/plugins/findowners/OwnersValidatorIT.java
index 2f11570..eb66504 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/findowners/OwnersValidatorIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/findowners/OwnersValidatorIT.java
@@ -129,7 +129,7 @@
   private static final PluginConfig DISABLED_CONFIG = createDisabledConfig();
 
   private OwnersValidator newOwnersValidator(PluginConfig cfg) {
-    return new OwnersValidator(cfg, accountCache, patchListCache, repoManager, new MockedEmails());
+    return new OwnersValidator(cfg, accountCache, repoManager, new MockedEmails());
   }
 
   @Test