Skip to content

Commit

Permalink
Merge pull request #522 from eclipse-mylyn/305-remove-guava-typetoken
Browse files Browse the repository at this point in the history
Remove guava TypeToken #305
  • Loading branch information
gnl42 committed May 11, 2024
2 parents 7d5ae7b + cc8314f commit 42b23c7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
Expand Up @@ -29,7 +29,6 @@ Export-Package: org.eclipse.mylyn.internal.gerrit.core;x-friends:="org.eclipse.m
org.eclipse.mylyn.internal.gerrit.core.remote;x-friends:="org.eclipse.mylyn.gerrit.ui"
Bundle-Vendor: Eclipse Mylyn
Import-Package: com.github.benmanes.caffeine.cache;version="3.1.8",
com.google.common.reflect;version="31.1.0",
com.google.gerrit.common.auth;version="2.1.5",
com.google.gerrit.common.auth.openid;version="2.1.5",
com.google.gerrit.common.auth.userpass;version="2.1.5",
Expand Down
Expand Up @@ -80,6 +80,7 @@
import com.google.gerrit.reviewdb.RefRight.RefPattern;
import com.google.gerrit.reviewdb.RevId;
import com.google.gerrit.reviewdb.UserIdentity;
import com.google.gson.reflect.TypeToken;

public class GerritClient212 extends GerritClient29 {

Expand Down Expand Up @@ -197,31 +198,33 @@ protected PatchScriptX getPatchScript(final Patch.Key key, final PatchSet.Id lef
patchScriptX.setChangeId(new Change.Key(rightId.getParentKey().toString()));
patchScriptX.setDiffPrefs(diffPrefs);
patchScriptX.setComments(commentDetail);
patchScriptX.setHeader(diffInfo.getDiff_header());
patchScriptX.setChangeType(diffInfo.getChange_type());
patchScriptX.setHistory(adaptRestPatches(rightId, monitor));
patchScriptX.setDisplayMethodA(DisplayMethod.DIFF); // hardcoded to diff.
patchScriptX.setDisplayMethodB(DisplayMethod.DIFF);

if (diffInfo.getContent() != null) {
patchScriptX.setEdits(adaptDiffContent(diffInfo, patchScriptX, monitor));
}
if (diffInfo != null) {
patchScriptX.setChangeType(diffInfo.getChange_type());
patchScriptX.setHeader(diffInfo.getDiff_header());
if (diffInfo.getContent() != null) {
patchScriptX.setEdits(adaptDiffContent(diffInfo, patchScriptX, monitor));
}

if (diffInfo.getMeta_a() != null) {
patchScriptX.setA(adaptSparseFileContent_A(diffInfo, monitor));
} else {
patchScriptX.setA(new SparseFileContent());
}
if (diffInfo.getMeta_b() != null) {
patchScriptX.setB(adaptSparseFileContent_B(diffInfo, monitor));
} else {
patchScriptX.setB(new SparseFileContent());
}
if (diffInfo.getMeta_a() != null) {
patchScriptX.setA(adaptSparseFileContent_A(diffInfo, monitor));
} else {
patchScriptX.setA(new SparseFileContent());
}
if (diffInfo.getMeta_b() != null) {
patchScriptX.setB(adaptSparseFileContent_B(diffInfo, monitor));
} else {
patchScriptX.setB(new SparseFileContent());
}

if (diffInfo.getDiff_header() != null) {
if (patchScriptX.isBinary()) {
fetchLeftBinaryContent(patchScriptX, key, leftId, monitor);
fetchRightBinaryContent(patchScriptX, key, rightId, monitor);
if (diffInfo.getDiff_header() != null) {
if (patchScriptX.isBinary()) {
fetchLeftBinaryContent(patchScriptX, key, leftId, monitor);
fetchRightBinaryContent(patchScriptX, key, rightId, monitor);
}
}
}
return patchScriptX;
Expand Down Expand Up @@ -297,7 +300,7 @@ private AccountDiffPreference adaptAccountDiffPref(AccountInfo accInfo, DiffPref
accDiffPref.setContext(diffPrefInfo.getContext());
accDiffPref.setIgnoreWhitespace(diffPrefInfo.getIgnoreWhitespace() != null
? diffPrefInfo.getIgnoreWhitespace()
: Whitespace.IGNORE_NONE);
: Whitespace.IGNORE_NONE);
accDiffPref.setIntralineDifference(diffPrefInfo.isIntralineDifference());
accDiffPref.setLineLength(diffPrefInfo.getLineLength());
accDiffPref.setShowTabs(diffPrefInfo.isShowTabs());
Expand Down Expand Up @@ -539,8 +542,7 @@ private CommitInfo retrieveCommitInfo(PatchSet.Id id, IProgressMonitor monitor)

private Map<String, FileInfo> retrieveFileInfos(PatchSet.Id id, IProgressMonitor monitor) throws GerritException {
String commitQuery = String.format("/changes/%s/revisions/%s/files", id.getParentKey().get(), id.get()); //$NON-NLS-1$
@SuppressWarnings("serial")
Type mapTypeToken = new com.google.common.reflect.TypeToken<Map<String, FileInfo>>() {
Type mapTypeToken = new TypeToken<Map<String, FileInfo>>() {
}.getType();
return getRestClient().executeGetRestRequest(commitQuery, mapTypeToken, monitor);
}
Expand All @@ -567,8 +569,7 @@ private DiffInfo retrieveDiffInfoAgainstBase(PatchSet.Id targetId, String fileNa
private Map<String, List<CommentInfo>> retrieveRevisionComments(PatchSet.Id id, IProgressMonitor monitor)
throws GerritException {
String query = String.format("/changes/%s/revisions/%s/comments/", id.getParentKey().get(), id.get()); //$NON-NLS-1$
@SuppressWarnings("serial")
Type mapTypeToken = new com.google.common.reflect.TypeToken<Map<String, List<CommentInfo>>>() {
Type mapTypeToken = new TypeToken<Map<String, List<CommentInfo>>>() {
}.getType();
return getRestClient().executeGetRestRequest(query, mapTypeToken, monitor);
}
Expand All @@ -580,8 +581,7 @@ private ConfigInfo retrieveProjectConfigs(String projectName, IProgressMonitor m

private Map<String, ProjectInfo> listProjects(IProgressMonitor monitor) throws GerritException {
String query = String.format("/projects/?n=25"); //$NON-NLS-1$
@SuppressWarnings("serial")
Type mapTypeToken = new com.google.common.reflect.TypeToken<Map<String, ProjectInfo>>() {
Type mapTypeToken = new TypeToken<Map<String, ProjectInfo>>() {
}.getType();
return getRestClient().executeGetRestRequest(query, mapTypeToken, monitor);
}
Expand Down

0 comments on commit 42b23c7

Please sign in to comment.