Remove SparseHtmlFile dependency from PatchScript
My hosting environment builds its own custom Gerrit, without using Maven. In that build process we need to break the dependency between PatchScript in the server CLASSPATH and SafeHtml, which isn't available in the server CLASSPATH as its supposed to only be used in the GWT JavaScript world. Move the factory that builds the SparseHtmlFile off PatchScript and into the real client code that needs it, AbstractPatchContentTable and its two subclasses. Change-Id: I7375e0962ef53ff83aee2c6abf53bae5eba25286
This commit is contained in:
@@ -14,15 +14,12 @@
|
||||
|
||||
package com.google.gerrit.common.data;
|
||||
|
||||
import com.google.gerrit.prettify.client.ClientSideFormatter;
|
||||
import com.google.gerrit.prettify.common.EditList;
|
||||
import com.google.gerrit.prettify.common.PrettyFormatter;
|
||||
import com.google.gerrit.prettify.common.SparseFileContent;
|
||||
import com.google.gerrit.prettify.common.SparseHtmlFile;
|
||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace;
|
||||
import com.google.gerrit.reviewdb.client.Patch.ChangeType;
|
||||
|
||||
import org.eclipse.jgit.diff.Edit;
|
||||
@@ -167,36 +164,6 @@ public class PatchScript {
|
||||
return b;
|
||||
}
|
||||
|
||||
public SparseHtmlFile getSparseHtmlFileA() {
|
||||
AccountDiffPreference dp = new AccountDiffPreference(diffPrefs);
|
||||
dp.setShowWhitespaceErrors(false);
|
||||
|
||||
PrettyFormatter f = ClientSideFormatter.FACTORY.get();
|
||||
f.setDiffPrefs(dp);
|
||||
f.setFileName(a.getPath());
|
||||
f.setEditFilter(PrettyFormatter.A);
|
||||
f.setEditList(edits);
|
||||
f.format(a);
|
||||
return f;
|
||||
}
|
||||
|
||||
public SparseHtmlFile getSparseHtmlFileB() {
|
||||
AccountDiffPreference dp = new AccountDiffPreference(diffPrefs);
|
||||
|
||||
PrettyFormatter f = ClientSideFormatter.FACTORY.get();
|
||||
f.setDiffPrefs(dp);
|
||||
f.setFileName(b.getPath());
|
||||
f.setEditFilter(PrettyFormatter.B);
|
||||
f.setEditList(edits);
|
||||
|
||||
if (dp.isSyntaxHighlighting() && a.isWholeFile() && !b.isWholeFile()) {
|
||||
f.format(b.apply(a, edits));
|
||||
} else {
|
||||
f.format(b);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
public List<Edit> getEdits() {
|
||||
return edits;
|
||||
}
|
||||
|
@@ -26,7 +26,11 @@ import com.google.gerrit.common.data.AccountInfo;
|
||||
import com.google.gerrit.common.data.AccountInfoCache;
|
||||
import com.google.gerrit.common.data.CommentDetail;
|
||||
import com.google.gerrit.common.data.PatchScript;
|
||||
import com.google.gerrit.prettify.client.ClientSideFormatter;
|
||||
import com.google.gerrit.prettify.common.PrettyFormatter;
|
||||
import com.google.gerrit.prettify.common.SparseFileContent;
|
||||
import com.google.gerrit.prettify.common.SparseHtmlFile;
|
||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
@@ -171,6 +175,36 @@ public abstract class AbstractPatchContentTable extends NavigationTable<Object>
|
||||
render(s);
|
||||
}
|
||||
|
||||
protected SparseHtmlFile getSparseHtmlFileA(PatchScript s) {
|
||||
AccountDiffPreference dp = new AccountDiffPreference(s.getDiffPrefs());
|
||||
dp.setShowWhitespaceErrors(false);
|
||||
|
||||
PrettyFormatter f = ClientSideFormatter.FACTORY.get();
|
||||
f.setDiffPrefs(dp);
|
||||
f.setFileName(s.getA().getPath());
|
||||
f.setEditFilter(PrettyFormatter.A);
|
||||
f.setEditList(s.getEdits());
|
||||
f.format(s.getA());
|
||||
return f;
|
||||
}
|
||||
|
||||
protected SparseHtmlFile getSparseHtmlFileB(PatchScript s) {
|
||||
AccountDiffPreference dp = new AccountDiffPreference(s.getDiffPrefs());
|
||||
|
||||
PrettyFormatter f = ClientSideFormatter.FACTORY.get();
|
||||
f.setDiffPrefs(dp);
|
||||
f.setFileName(s.getB().getPath());
|
||||
f.setEditFilter(PrettyFormatter.B);
|
||||
f.setEditList(s.getEdits());
|
||||
|
||||
if (dp.isSyntaxHighlighting() && s.getA().isWholeFile() && !s.getB().isWholeFile()) {
|
||||
f.format(s.getB().apply(s.getA(), s.getEdits()));
|
||||
} else {
|
||||
f.format(s.getB());
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
protected abstract void render(PatchScript script);
|
||||
|
||||
protected abstract void onInsertComment(PatchLine pl);
|
||||
|
@@ -89,8 +89,8 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
||||
|
||||
@Override
|
||||
protected void render(final PatchScript script) {
|
||||
a = script.getSparseHtmlFileA();
|
||||
b = script.getSparseHtmlFileB();
|
||||
a = getSparseHtmlFileA(script);
|
||||
b = getSparseHtmlFileB(script);
|
||||
final ArrayList<Object> lines = new ArrayList<Object>();
|
||||
final SafeHtmlBuilder nc = new SafeHtmlBuilder();
|
||||
final boolean intraline =
|
||||
|
@@ -95,8 +95,8 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
|
||||
|
||||
@Override
|
||||
protected void render(final PatchScript script) {
|
||||
final SparseHtmlFile a = script.getSparseHtmlFileA();
|
||||
final SparseHtmlFile b = script.getSparseHtmlFileB();
|
||||
final SparseHtmlFile a = getSparseHtmlFileA(script);
|
||||
final SparseHtmlFile b = getSparseHtmlFileB(script);
|
||||
final SafeHtmlBuilder nc = new SafeHtmlBuilder();
|
||||
|
||||
// Display the patch header
|
||||
|
Reference in New Issue
Block a user