Skip to contentSkip to conversation

Cleanups and javadocs

PATCH In review Robin Rosenberg 3 participants 13 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Cleanups and javadocs

Here is a number of small enhancements that reduce the number of warnings displayed and raises the standard on comments. We now get javadoc comments on all public and protected methods which hopefully will make it slighly easier to get on the train for those interested in helping out with Egit/Jgit.

Disabling the else-warning is probably fairly uncontroversial. Disabling some warning about boxing/unboxing of integers might be as might be requiring javadoc comments.

-- robin

#1 lore raw

PATCH 1/6 Comment some empty blocks that should be empty

---
 .../src/org/spearce/egit/core/test/Activator.java  |    1 +
 .../internal/actions/AbstractOperationAction.java  |    1 +
 .../egit/ui/internal/dialogs/CommitDialog.java     |    3 +++
 .../ui/internal/preferences/GitPreferencePage.java |    1 +
 .../spearce/jgit/lib/AbstractIndexTreeVisitor.java |    4 ++++
 .../org/spearce/jgit/lib/TopologicalSorter.java    |    1 +
 6 files changed, 11 insertions(+), 0 deletions(-)
org.spearce.egit.core.test/src/org/spearce/egit/core/test/Activator.java +1 -0
index 9807c84..10d7d94 100644
@@ -18,6 +18,7 @@ public class Activator extends Plugin {
 	 * The constructor
 	 */
 	public Activator() {
+		// Empty
 	}
 
 	/*
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/AbstractOperationAction.java +1 -0
index c3f347e..0e96323 100644
@@ -73,6 +73,7 @@ public abstract class AbstractOperationAction implements IObjectActionDelegate {
 	 * A method to invoke when the operation is finished.
 	 */
 	protected void postOperation() {
+		// Empty
 	}
 
 	public void run(final IAction act) {
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java +3 -0
index 3778b94..064a2dc 100644
@@ -212,6 +212,7 @@ public class CommitDialog extends Dialog {
 			}
 		
 			public void widgetDefaultSelected(SelectionEvent arg0) {
+				// Empty
 			}
 		});
 		
@@ -242,9 +243,11 @@ public class CommitDialog extends Dialog {
 
 			public void inputChanged(Viewer viewer, Object oldInput,
 					Object newInput) {
+				// Empty
 			}
 
 			public void dispose() {
+				// Empty
 			}
 
 			public Object[] getElements(Object inputElement) {
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/preferences/GitPreferencePage.java +1 -0
index 780375b..8e6d3f3 100644
@@ -36,5 +36,6 @@ public class GitPreferencePage extends PreferencePage implements
 	}
 
 	public void init(final IWorkbench workbench) {
+		// Empty
 	}
 }
org.spearce.jgit/src/org/spearce/jgit/lib/AbstractIndexTreeVisitor.java +4 -0
index 40b42dd..6f5ede4 100644
@@ -31,17 +31,21 @@ import org.spearce.jgit.lib.GitIndex.Entry;
 public class AbstractIndexTreeVisitor implements IndexTreeVisitor {
 	public void finishVisitTree(Tree tree, Tree auxTree, int i, String curDir)
 			throws IOException {
+		// Empty
 	}
 
 	public void finishVisitTree(Tree tree, int i, String curDir)
 			throws IOException {
+		// Empty
 	}
 
 	public void visitEntry(TreeEntry treeEntry, Entry indexEntry, File file)
 			throws IOException {
+		// Empty
 	}
 
 	public void visitEntry(TreeEntry treeEntry, TreeEntry auxEntry,
 			Entry indexEntry, File file) throws IOException {
+		// Empty
 	}
 }
org.spearce.jgit/src/org/spearce/jgit/lib/TopologicalSorter.java +1 -0
index 7b59490..c33334e 100644
@@ -292,6 +292,7 @@ public class TopologicalSorter<T> {
 		private int number = -1;
 
 		Lane() {
+			// Empty
 		}
 
 		@Override
Signature · 1 line
1.5.4.rc4.25.g81cc
#2 lore raw

PATCH 2/6 Cleanup unboxing/boxing

These operation are relatively expensive in general so it is good to make them visible, but when they are needed a lot we just want to do without explicit conversion so we ignore the warning there.

---
 .../src/org/spearce/egit/ui/GitHistoryPage.java    |    1 +
 .../internal/decorators/GitResourceDecorator.java  |   10 +++++-----
 .../tst/org/spearce/jgit/lib/LaneTest.java         |    1 +
 .../tst/org/spearce/jgit/lib/SuperListTest.java    |    1 +
 .../src/org/spearce/jgit/lib/PersonIdent.java      |    2 +-
 5 files changed, 9 insertions(+), 6 deletions(-)
org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java +1 -0
index 812747d..2fc7afa 100644
@@ -864,6 +864,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
 //				SWT.COLOR_WHITE,
 				SWT.COLOR_YELLOW
 			};
+			@SuppressWarnings("boxing")
 			public void handleEvent(Event event) {
 				TableItem item = (TableItem) event.item;
 				if (event.index == 0) {
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java +5 -5
index c13c38a..7eb008b 100644
@@ -207,7 +207,7 @@ public class GitResourceDecorator extends LabelProvider implements
 					return Boolean.FALSE;
 				}
 
-				return mapped.isResourceChanged(rsrc);
+				return new Boolean(mapped.isResourceChanged(rsrc));
 			}
 			return null; // not mapped
 		} catch (CoreException e) {
@@ -244,8 +244,8 @@ public class GitResourceDecorator extends LabelProvider implements
 						if (rsrc instanceof IContainer) {
 							Integer df = (Integer) rsrc
 									.getSessionProperty(GITFOLDERDIRTYSTATEPROPERTY);
-							Boolean f = df == null ? isDirty(rsrc) : df
-									.intValue() == CHANGED;
+							Boolean f = df == null ? isDirty(rsrc)
+									: new Boolean(df.intValue() == CHANGED);
 							if (f != null) {
 								if (f.booleanValue()) {
 									decoration.addPrefix(">"); // Have not
@@ -358,7 +358,7 @@ public class GitResourceDecorator extends LabelProvider implements
 		try {
 			Integer dirty = (Integer) rsrc.getSessionProperty(GITFOLDERDIRTYSTATEPROPERTY);
 			if (dirty == null) {
-				rsrc.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, flag);
+				rsrc.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, new Integer(flag));
 				Activator.trace("SETTING:"+rsrc.getFullPath().toOSString()+" => "+flag);
 				orState(rsrc.getParent(), flag);
 				Display.getDefault().asyncExec(new Runnable() {
@@ -375,7 +375,7 @@ public class GitResourceDecorator extends LabelProvider implements
 				});
 			} else {
 				if ((dirty.intValue() | flag) != dirty.intValue()) {
-					dirty = dirty | flag;
+					dirty = new Integer(dirty.intValue() | flag);
 					rsrc.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, dirty);
 					Activator.trace("SETTING:"+rsrc.getFullPath().toOSString()+" => "+dirty);
 					orState(rsrc.getParent(), dirty.intValue());
org.spearce.jgit.test/tst/org/spearce/jgit/lib/LaneTest.java +1 -0
index 0f57075..707fb86 100644
@@ -498,6 +498,7 @@ public class LaneTest extends TestCase {
 				, road);
 	}
 
+	@SuppressWarnings("boxing")
 	private String drawAsAscii(TopologicalSorter<Data> counter) {
 		StringWriter w = new StringWriter();
 		List<Data> entries = counter.getEntries();
org.spearce.jgit.test/tst/org/spearce/jgit/lib/SuperListTest.java +1 -0
index 121bf9c..79f4da6 100644
@@ -28,6 +28,7 @@ public class SuperListTest extends TestCase {
 		assertEquals(0, l.size());
 	}
 
+	@SuppressWarnings("boxing")
 	public void testNonEmpty() {
 		List<Integer> l = new SuperList<Integer>();
 		List<Integer> sl1 = Arrays.asList(new Integer[] { 3,4 });
org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java +1 -1
index 5857cb7..6879eb7 100644
@@ -62,7 +62,7 @@ public class PersonIdent {
 
 		name = username;
 		emailAddress = email;
-		when = Calendar.getInstance().getTimeInMillis();
+		when = new Long(Calendar.getInstance().getTimeInMillis());
 		tzOffset = TimeZone.getDefault().getOffset(when.longValue())
 				/ (60 * 1000);
 	}
Signature · 1 line
1.5.4.rc4.25.g81cc
#3 lore raw

PATCH 3/6 Do not require javadoc in egit.core test project

---
 .../.settings/org.eclipse.jdt.core.prefs           |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
org.spearce.egit.core.test/.settings/org.eclipse.jdt.core.prefs +2 -2
index fb1bc6e..fb77da2 100644
@@ -1,4 +1,4 @@
-#Wed May 16 23:05:36 EDT 2007
+#Sun Feb 03 03:52:00 CET 2008
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
@@ -34,7 +34,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
 org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
 org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
 org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
 org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
Signature · 1 line
1.5.4.rc4.25.g81cc
#4 lore raw

PATCH 4/6 Javadoc update for Egit

Also includes reduced visibility for a few methods.

---
 .../src/org/spearce/egit/core/Activator.java       |   31 +++++++
 .../src/org/spearce/egit/core/CoreText.java        |   29 +++++++
 .../spearce/egit/core/GitIndexFileRevision.java    |    8 ++
 .../src/org/spearce/egit/core/GitProvider.java     |    7 ++
 .../src/org/spearce/egit/core/GitStorage.java      |   10 ++
 .../src/org/spearce/egit/core/GitTag.java          |    7 ++
 .../egit/core/GitWorkspaceFileRevision.java        |   13 +++
 .../org/spearce/egit/core/internal/UpdateJob.java  |   10 ++
 .../internal/mapping/GitCommitFileRevision.java    |   19 ++++
 .../egit/core/internal/mapping/GitFileHistory.java |   22 +++++
 .../internal/mapping/GitFileHistoryProvider.java   |   22 +++++-
 .../core/internal/mapping/GitFileRevision.java     |   34 ++++++++
 .../org/spearce/egit/core/op/BranchOperation.java  |    9 ++
 .../org/spearce/egit/core/op/ResetOperation.java   |   22 +++++
 .../spearce/egit/core/project/CheckpointJob.java   |    9 ++
 .../spearce/egit/core/project/GitProjectData.java  |   60 +++++++++++++-
 .../egit/core/project/RepositoryMapping.java       |   87 ++++++++++++++++----
 17 files changed, 379 insertions(+), 20 deletions(-)
org.spearce.egit.core/src/org/spearce/egit/core/Activator.java +31 -0
index e3dc3a5..214de61 100644
@@ -24,22 +24,45 @@ import org.eclipse.core.runtime.Status;
 import org.osgi.framework.BundleContext;
 import org.spearce.egit.core.project.GitProjectData;
 
+/**
+ * The plugin class for the org.spearce.egit.core plugin. This
+ * is a singleton class.
+ */
 public class Activator extends Plugin {
 	private static Activator plugin;
 
+	/**
+	 * @return the singleton {@link Activator}
+	 */
 	public static Activator getDefault() {
 		return plugin;
 	}
 
+	/**
+	 * @return the name of this plugin
+	 */
 	public static String getPluginId() {
 		return getDefault().getBundle().getSymbolicName();
 	}
 
+	/**
+	 * Utility method to help throwing errors in the Egit plugin. This method
+	 * does not actually throw the exception, but just creates an instance.
+	 *
+	 * @param message User comprehensible message
+	 * @param thr cause
+	 * @return an Initialized {@link CoreException}
+	 */
 	public static CoreException error(final String message, final Throwable thr) {
 		return new CoreException(new Status(IStatus.ERROR, getPluginId(), 0,
 				message, thr));
 	}
 
+	/**
+	 * Utility method to log errors in the Egit plugin.
+	 * @param message User comprehensible message
+	 * @param thr The exception through which we noticed the error
+	 */
 	public static void logError(final String message, final Throwable thr) {
 		getDefault().getLog().log(
 				new Status(IStatus.ERROR, getPluginId(), 0, message, thr));
@@ -51,6 +74,11 @@ public class Activator extends Plugin {
 		return value != null && value.equals("true");
 	}
 
+	/**
+	 * Utility method for debug logging.
+	 *
+	 * @param what
+	 */
 	public static void trace(final String what) {
 		if (getDefault().traceVerbose) {
 			System.out.println("[" + getPluginId() + "] " + what);
@@ -59,6 +87,9 @@ public class Activator extends Plugin {
 
 	private boolean traceVerbose;
 
+	/**
+	 * Construct the {@link Activator} singleton instance
+	 */
 	public Activator() {
 		plugin = this;
 	}
org.spearce.egit.core/src/org/spearce/egit/core/CoreText.java +29 -0
index 7281c90..e1e1cb3 100644
@@ -18,57 +18,86 @@ package org.spearce.egit.core;
 
 import org.eclipse.osgi.util.NLS;
 
+/**
+ * Possibly Translated strings for the Egit plugin.
+ */
 public class CoreText extends NLS {
+	/** */
 	public static String AssumeUnchangedOperation_failed;
 
+	/** */
 	public static String AssumeUnchangedOperation_adding;
 
+	/** */
 	public static String UpdateOperation_updating;
 
+	/** */
 	public static String UpdateOperation_failed;
 
+	/** */
 	public static String ConnectProviderOperation_connecting;
 
+	/** */
 	public static String ConnectProviderOperation_creating;
 
+	/** */
 	public static String ConnectProviderOperation_recordingMapping;
 
+	/** */
 	public static String ConnectProviderOperation_updatingCache;
 
+	/** */
 	public static String DisconnectProviderOperation_disconnecting;
 
+	/** */
 	public static String AddOperation_adding;
 
+	/** */
 	public static String AddOperation_failed;
 
+	/** */
 	public static String UntrackOperation_adding;
 
+	/** */
 	public static String UntrackOperation_failed;
 
+	/** */
 	public static String GitProjectData_lazyResolveFailed;
 
+	/** */
 	public static String GitProjectData_mappedResourceGone;
 
+	/** */
 	public static String GitProjectData_cannotReadHEAD;
 
+	/** */
 	public static String GitProjectData_missing;
 
+	/** */
 	public static String GitProjectData_saveFailed;
 
+	/** */
 	public static String GitProjectData_notifyChangedFailed;
 
+	/** */
 	public static String RepositoryFinder_finding;
 
+	/** */
 	public static String MoveDeleteHook_cannotModifyFolder;
 
+	/** */
 	public static String MoveDeleteHook_operationError;
 
+	/** */
 	public static String Error_CanonicalFile;
 
+	/** */
 	public static String CheckpointJob_writing;
 
+	/** */
 	public static String CheckpointJob_name;
 
+	/** */
 	public static String CheckpointJob_failed;
 
 	static {
org.spearce.egit.core/src/org/spearce/egit/core/GitIndexFileRevision.java +8 -0
index 9ef272c..daae33b 100644
@@ -24,9 +24,17 @@ import org.eclipse.team.core.history.IFileRevision;
 import org.spearce.egit.core.internal.mapping.GitFileRevision;
 import org.spearce.jgit.lib.ObjectId;
 
+/**
+ * An {@link IFileRevision} for the version in the Git index.
+ */
 public class GitIndexFileRevision extends GitFileRevision implements
 		IFileRevision {
 
+	/**
+	 * Construct a GitIndexFileRevision matching a certain resource.
+	 * @param resource The corresponding workspace resource
+	 * @param count index into the full list of results
+	 */
 	public GitIndexFileRevision(IResource resource, int count) {
 		super(resource, count);
 	}
org.spearce.egit.core/src/org/spearce/egit/core/GitProvider.java +7 -0
index f31eec5..e42f6fa 100644
@@ -23,6 +23,9 @@ import org.eclipse.team.core.history.IFileHistoryProvider;
 import org.spearce.egit.core.internal.mapping.GitFileHistoryProvider;
 import org.spearce.egit.core.project.GitProjectData;
 
+/**
+ * The Team provider class for a Git repository.
+ */
 public class GitProvider extends RepositoryProvider {
 	private GitProjectData data;
 
@@ -53,6 +56,10 @@ public class GitProvider extends RepositoryProvider {
 		return hook;
 	}
 
+	/**
+	 * @return information about the mapping of an Eclipse project
+	 * to a Git repository.
+	 */
 	public synchronized GitProjectData getData() {
 		if (data == null) {
 			data = GitProjectData.get(getProject());
org.spearce.egit.core/src/org/spearce/egit/core/GitStorage.java +10 -0
index f791e31..86943ed 100644
@@ -36,6 +36,9 @@ import org.spearce.jgit.lib.Tree;
 import org.spearce.jgit.lib.TreeEntry;
 import org.spearce.jgit.lib.GitIndex.Entry;
 
+/**
+ * Implements access to a Git managed version of a resource.
+ */
 public class GitStorage implements IStorage {
 
 	private final IResource resource;
@@ -44,6 +47,13 @@ public class GitStorage implements IStorage {
 
 	private ObjectId treeId;
 
+	/**
+	 * Construct an GitStorage instance corresponding to
+	 * a certain workspace resource.
+	 *
+	 * @param treeId
+	 * @param resource
+	 */
 	public GitStorage(ObjectId treeId, IResource resource) {
 		this.treeId = treeId;
 		this.resource = resource;
org.spearce.egit.core/src/org/spearce/egit/core/GitTag.java +7 -0
index b8d7c11..86b908c 100644
@@ -18,10 +18,17 @@ package org.spearce.egit.core;
 
 import org.eclipse.team.core.history.ITag;
 
+/**
+ * A representation of a Git tag in Eclipse.
+ */
 public class GitTag implements ITag {
 
 	private String name;
 
+	/**
+	 * Construct a GitTag object with a give name.
+	 * @param name the Git tag name
+	 */
 	public GitTag(String name) {
 		this.name = name;
 	}
org.spearce.egit.core/src/org/spearce/egit/core/GitWorkspaceFileRevision.java +13 -0
index aad79b4..7142671 100644
@@ -23,9 +23,22 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.team.core.history.IFileRevision;
 import org.spearce.egit.core.internal.mapping.GitFileRevision;
 
+/**
+ * An {@link IFileRevision} for the version in workspace.
+ */
 public class GitWorkspaceFileRevision extends GitFileRevision implements
 		IFileRevision {
 
+	/**
+	 * Construct a GitWorkspaceFileRevision matching a certain resource. This is
+	 * the same as the resource, which the possible distinction that this is the
+	 * version on disk when unsaved.
+	 *
+	 * @param resource
+	 *            The corresponding workspace resource
+	 * @param count
+	 *            index into the full list of results
+	 */
 	public GitWorkspaceFileRevision(IResource resource, int count) {
 		super(resource, count);
 	}
org.spearce.egit.core/src/org/spearce/egit/core/internal/UpdateJob.java +10 -0
index 72b4190..a1476bf 100644
@@ -40,10 +40,20 @@ import org.spearce.jgit.errors.NotSupportedException;
 import org.spearce.jgit.lib.GitIndex;
 import org.spearce.jgit.lib.GitIndex.Entry;
 
+/**
+ * This job updates the index with the content of all specified
+ * and tracked resources. If a project is selected all tracked
+ * resources withing that container are updated.
+ */
 public class UpdateJob extends Job {
 
 	private final Collection rsrcList;
 
+	/**
+	 * Construct an UpdateJob for the specified resources.
+	 *
+	 * @param rsrcList
+	 */
 	public UpdateJob(Collection rsrcList) {
 		super("Update index");
 		this.rsrcList = rsrcList;
org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitCommitFileRevision.java +19 -0
index 6d6f7ea..0ed5a92 100644
@@ -38,10 +38,21 @@ import org.spearce.jgit.lib.Repository;
 import org.spearce.jgit.lib.Tree;
 import org.spearce.jgit.lib.TreeEntry;
 
+/**
+ * An {@link IFileRevision} for a version of a specified resource in the
+ * specified commit (revision).
+ */
 public class GitCommitFileRevision extends GitFileRevision {
 
 	private final ObjectId commitId;
 
+	/**
+	 * Construct a {@link GitCommitFileRevision} for a resource in a specified commit.
+	 *
+	 * @param commitId
+	 * @param resource
+	 * @param count index to full list of commits.
+	 */
 	public GitCommitFileRevision(ObjectId commitId, IResource resource, int count) {
 		super(resource, count);
 		this.commitId = commitId;
@@ -109,6 +120,11 @@ public class GitCommitFileRevision extends GitFileRevision {
 		return (ITag[]) ret.toArray(new ITag[ret.size()]);
 	}
 
+	/**
+	 * Maps the commit id of this object and
+	 *
+	 * @return the {@link Commit} object this {@link IFileRevision} refers to
+	 */
 	public Commit getCommit() {
 		try {
 			return RepositoryMapping.getMapping(getResource()).getRepository().mapCommit(commitId);
@@ -121,6 +137,9 @@ public class GitCommitFileRevision extends GitFileRevision {
 		return commitId;
 	}
 
+	/**
+	 * @return the {@link TreeEntry} this {@link IFileRevision} refers to.
+	 */
 	public TreeEntry getTreeEntry() {
 		RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(getResource());
 		Tree tree;
org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java +22 -0
index 2d06405..d1e5733 100644
@@ -48,6 +48,11 @@ import org.spearce.jgit.lib.Tree;
 import org.spearce.jgit.lib.TreeEntry;
 import org.spearce.jgit.lib.GitIndex.Entry;
 
+/**
+ * A list of revisions for a specific resource according to some
+ * filtering criterion. Though git really does not do file tracking,
+ * this corresponds to listing all files with the same path.
+ */
 public class GitFileHistory extends FileHistory implements IAdaptable {
 
 	private final IResource resource;
@@ -60,6 +65,20 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 
 	private final boolean returnAll;
 
+	/**
+	 * Construct a {@link GitFileHistory} object for a given resource (path)
+	 * with some filtering applied. The filter could reduces the number of
+	 * commitgs returned or just mark some versions as interesting.
+	 *
+	 * @param resource
+	 * @param flags
+	 *            See {@link IFileHistoryProvider}
+	 * @param monitor
+	 *            progress reporting facility
+	 * @param returnAll
+	 *            true if all versions should be collected even if the filter
+	 *            does not match.
+	 */
 	public GitFileHistory(IResource resource, int flags, IProgressMonitor monitor, boolean returnAll) {
 		this.resource = resource;
 		this.flags = flags;
@@ -160,6 +179,9 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
 		return revisions.toArray(new IFileRevision[revisions.size()]);
 	}
 
+	/**
+	 * @return the list of revisions. The list may be lazy-evaluated.
+	 */
 	public List<IFileRevision> getFileRevisionsList() {
 		return revisions;
 	}
org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistoryProvider.java +20 -2
index 298009f..eb7961b 100644
@@ -25,13 +25,16 @@ import org.eclipse.team.core.history.IFileRevision;
 import org.eclipse.team.core.history.provider.FileHistoryProvider;
 import org.spearce.egit.core.GitWorkspaceFileRevision;
 
+/**
+ * A {@link FileHistoryProvider} for Git. This class has methods for
+ * retrieving specific versions of a tracked resource.
+ */
 public class GitFileHistoryProvider extends FileHistoryProvider implements
 		IFileHistoryProvider {
 
 	public IFileHistory getFileHistoryFor(IResource resource, int flags,
 			IProgressMonitor monitor) {
-		// TODO: implement flags
-		return new GitFileHistory(resource, flags, monitor, false); // TODO: implement flags
+		return new GitFileHistory(resource, flags, monitor, false);
 	}
 
 	public IFileRevision getWorkspaceFileRevision(IResource resource) {
@@ -44,6 +47,21 @@ public class GitFileHistoryProvider extends FileHistoryProvider implements
 		return null;
 	}
 
+	/**
+	 * Get the history for a given resource as viewed using the specified
+	 * filtering flags.
+	 *
+	 * @param resource
+	 * @param flags
+	 *            See {@link IFileHistoryProvider}
+	 * @param monitor
+	 *            progress monitor
+	 * @param returnAll
+	 *            true if all revisions are returned and interesting revisiosn.
+	 *
+	 * @return a {@link GitFileHistory} object.
+	 *
+	 */
 	public GitFileHistory getHistoryFor(IResource resource, int flags, IProgressMonitor monitor, boolean returnAll) {
 		return new GitFileHistory(resource, flags, monitor, returnAll); // TODO: implement flags
 	}
org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileRevision.java +34 -0
index e11a24c..c309b9d 100644
@@ -26,6 +26,11 @@ import org.eclipse.team.core.history.provider.FileRevision;
 import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.lib.TopologicalSorter;
 
+/**
+ * A Git related {@link IFileRevision}. It references a version
+ * and a resource, i.e. the version we think corresponds to the
+ * resource in specific version.
+ */
 public abstract class GitFileRevision extends FileRevision {
 
 	private final IResource resource;
@@ -34,6 +39,12 @@ public abstract class GitFileRevision extends FileRevision {
 
 	private TopologicalSorter<ObjectId>.Lane lane;
 
+	/**
+	 * Construct a {@link GitFileRevision}
+	 *
+	 * @param resource
+	 * @param count index into the full list of commits
+	 */
 	public GitFileRevision(IResource resource, int count) {
 		this.count = count;
 		this.resource = resource;
@@ -56,20 +67,43 @@ public abstract class GitFileRevision extends FileRevision {
 		return resource.getLocationURI();
 	}
 
+	/**
+	 * @return the {@link IResource} the {@link IFileRevision} refers to.
+	 */
 	public IResource getResource() {
 		return resource;
 	}
 
+	/**
+	 * @deprecated
+	 * @return index into full list of versions
+	 */
 	public int getCount() {
 		return count;
 	}
 
+	/**
+	 * @return the swim lane assigned by the graph layout
+	 */
 	public TopologicalSorter<ObjectId>.Lane getLane() {
 		return lane;
 	}
 
+	/**
+	 * Set the swim where this revision is found. Invoked by the
+	 * graph layout.
+	 *
+	 * @param lane
+	 */
 	public void setLane(TopologicalSorter<ObjectId>.Lane lane) {
 		this.lane = lane;
 	}
 
+	/**
+	 * @return the ObjectId this IFileRevision refers to.
+	 */
+	public ObjectId getCommitId() {
+		return null;
+	}
+
 }
org.spearce.egit.core/src/org/spearce/egit/core/op/BranchOperation.java +9 -0
index f3a0ccb..f1d6cf7 100644
@@ -34,12 +34,21 @@ import org.spearce.jgit.lib.Repository;
 import org.spearce.jgit.lib.Tree;
 import org.spearce.jgit.lib.WorkDirCheckout;
 
+/**
+ * This class implements checkouts of a specific revision. A check
+ * is made that this can be done without data loss.
+ */
 public class BranchOperation implements IWorkspaceRunnable {
 
 	private final Repository repository;
 
 	private final String refName;
 
+	/**
+	 * Construct a {@link BranchOperation} object.
+	 * @param repository
+	 * @param refName Name of git ref to checkout
+	 */
 	public BranchOperation(Repository repository, String refName) {
 		this.repository = repository;
 		this.refName = refName;
org.spearce.egit.core/src/org/spearce/egit/core/op/ResetOperation.java +22 -0
index 3c5b9bb..9fd5db1 100644
@@ -36,10 +36,25 @@ import org.spearce.jgit.lib.Tag;
 import org.spearce.jgit.lib.Tree;
 import org.spearce.jgit.lib.WorkDirCheckout;
 
+/**
+ * An class for changing a ref and possibly index and workdir too.
+ */
 public class ResetOperation implements IWorkspaceRunnable {
+	/**
+	 * Kind of reset
+	 */
 	public enum ResetType {
+		/**
+		 * Just change the ref. The index and workdir are not changed.
+		 */
 		SOFT,
+		/**
+		 * Change the ref and the index. The workdir is not changed.
+		 */
 		MIXED,
+		/**
+		 * Change the ref, the index and the workdir
+		 */
 		HARD
 	}
 	
@@ -52,6 +67,13 @@ public class ResetOperation implements IWorkspaceRunnable {
 	private Tree newTree;
 	private GitIndex index;
 
+	/**
+	 * Construct a {@link ResetOperation}
+	 *
+	 * @param repository
+	 * @param refName
+	 * @param type
+	 */
 	public ResetOperation(Repository repository, String refName, ResetType type) {
 		this.repository = repository;
 		this.refName = refName;
org.spearce.egit.core/src/org/spearce/egit/core/project/CheckpointJob.java +9 -0
index acc8f1f..bc8e8ed 100644
@@ -31,10 +31,19 @@ import org.spearce.egit.core.CoreText;
 import org.spearce.jgit.lib.GitIndex;
 import org.spearce.jgit.lib.GitIndex.Entry;
 
+/**
+ * This class updates the index with the content of all resources tracked by git
+ * in the index.
+ */
 public class CheckpointJob extends Job {
 
 	private final RepositoryMapping rm;
 
+	/**
+	 * Construct a {@link CheckpointJob} for the specified resource maping
+	 *
+	 * @param m
+	 */
 	public CheckpointJob(final RepositoryMapping m) {
 		super(NLS.bind(CoreText.CheckpointJob_name, m.getContainer()
 				.getFullPath()));
org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java +58 -2

138 lines not on this page · raw message

org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryMapping.java +71 -16

175 lines not on this page · raw message

Signature · 1 line
1.5.4.rc4.25.g81cc
#5 lore raw

PATCH 5/6 Drop unused GitBlobStorage class

---
 .../src/org/spearce/egit/core/GitBlobStorage.java  |   99 --------------------
 1 files changed, 0 insertions(+), 99 deletions(-)
 delete mode 100644 org.spearce.egit.core/src/org/spearce/egit/core/GitBlobStorage.java
org.spearce.egit.core/src/org/spearce/egit/core/GitBlobStorage.java deleted +0 -99
deleted file mode 100644
index f7a062c..0000000
@@ -1,99 +0,0 @@
-/*
- *  Copyright (C) 2006  Robin Rosenberg
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License, version 2.1, as published by the Free Software Foundation.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
- */
-package org.spearce.egit.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.internal.resources.ResourceException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.spearce.egit.core.project.RepositoryMapping;
-import org.spearce.jgit.lib.ObjectId;
-import org.spearce.jgit.lib.ObjectLoader;
-import org.spearce.jgit.lib.Tree;
-import org.spearce.jgit.lib.TreeEntry;
-
-public class GitBlobStorage implements IStorage {
-
-	private final IResource resource;
-
-	private TreeEntry entry;
-
-	public GitBlobStorage(ObjectId treeId, IResource resource, String relativeResourceName) {
-		this.resource = resource;
-		if (treeId == null)
-			return;
-
-		RepositoryMapping repositoryMapping = RepositoryMapping.getMapping(resource);
-		Tree tree;
-		try {
-			tree = repositoryMapping.getRepository().mapTree(treeId);
-			String name = repositoryMapping.getRepoRelativePath(resource);
-			entry = tree.findBlobMember(name);
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-
-	public InputStream getContents() throws CoreException {
-		try {
-			if (entry == null) {
-				return ((IFile) resource).getContents();
-			} else {
-				ObjectId id = entry.getId();
-				ObjectLoader reader = entry.getRepository().openBlob(id);
-				byte[] bytes = reader.getBytes();
-				return new ByteArrayInputStream(bytes);
-			}
-		} catch (FileNotFoundException e) {
-			throw new ResourceException(IResourceStatus.FAILED_READ_LOCAL,
-					resource.getFullPath(), "Could not read file", e);
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-			throw new ResourceException(33, resource.getFullPath(), e
-					.getMessage(), e);
-		}
-	}
-
-	public IPath getFullPath() {
-		return resource.getFullPath();
-	}
-
-	public String getName() {
-		return resource.getName();
-	}
-
-	public boolean isReadOnly() {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	public Object getAdapter(Class adapter) {
-		System.out.println("GitStorage("+adapter.getName()+")");
-		return null;
-	}
-
-}
Signature · 1 line
1.5.4.rc4.25.g81cc
#6 lore raw

PATCH 6/6 Tighten requirements on javadoc.

All public and protected methods and members must be documented.

---
 .../.settings/org.eclipse.jdt.core.prefs           |    4 ++--
 .../.settings/org.eclipse.jdt.core.prefs           |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
org.spearce.egit.core/.settings/org.eclipse.jdt.core.prefs +2 -2
index 322fe98..f94f9a8 100644
@@ -1,4 +1,4 @@
-#Wed May 16 23:05:48 EDT 2007
+#Sun Feb 03 18:48:30 CET 2008
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
@@ -34,7 +34,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
 org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
 org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
 org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
-org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=error
 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
 org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
org.spearce.jgit.test/.settings/org.eclipse.jdt.core.prefs +2 -2
index 15190a0..8bfa5f1 100644
@@ -1,4 +1,4 @@
-#Thu Dec 20 01:31:35 CET 2007
+#Tue Feb 05 00:01:29 CET 2008
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
@@ -37,7 +37,7 @@ org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
 org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
 org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
-org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
 org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
 org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
Signature · 1 line
1.5.4.rc4.25.g81cc
#7 lore raw

Re: [EGIT PATCH 2/6] Cleanup unboxing/boxing

In reply to Robin Rosenberg

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java public class GitResourceDecorator extends LabelProvider implements · line 213

Quoted 12 lines · Robin Rosenberg

These operation are relatively expensive in general so it is good to make them visible, but when they are needed a lot we just want to do without explicit conversion so we ignore the warning there.

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java +1 -1
@@ -207,7 +207,7 @@ public class GitResourceDecorator extends LabelProvider implements
 					return Boolean.FALSE;
 				}
 
-				return mapped.isResourceChanged(rsrc);
+				return new Boolean(mapped.isResourceChanged(rsrc));
 			}
 			return null; // not mapped
 		} catch (CoreException e) {

Oooooooow. That hurts.

Use Boolean.valueOf(boolean) instead of new Boolean. It recycles the cached Boolean.TRUE and Boolean.FALSE and thus avoids creating garbage that the GC needs to reclaim later.

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java public class GitResourceDecorator extends LabelProvider implements · line 364

Quoted 9 lines
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java +1 -1
@@ -358,7 +358,7 @@ public class GitResourceDecorator extends LabelProvider implements
 		try {
 			Integer dirty = (Integer) rsrc.getSessionProperty(GITFOLDERDIRTYSTATEPROPERTY);
 			if (dirty == null) {
-				rsrc.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, flag);
+				rsrc.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, new Integer(flag));
 				Activator.trace("SETTING:"+rsrc.getFullPath().toOSString()+" => "+flag);
 				orState(rsrc.getParent(), flag);
 				Display.getDefault().asyncExec(new Runnable() {

Use Integer.valueOf(int). Post Java 5 implementations of the J2SE are required to cache values between -128 and 127 (inclusive).

Actually, when the Java compiler autoboxes values it does so through these static valueOf methods, which were mostly introduced as part of the Java 5 API updates. For small common values its cached and will thus avoid garbage generation, for less common values it goes back to allocating the object.

Signature · 1 line
Shawn.
#8 lore raw

PATCH 1/2 Use Boolean.valueOf instead of new Boolean

onsdagen den 6 februari 2008 skrev Shawn O. Pearce:

Quoted 8 lines
Quoted 7 lines · Robin Rosenberg

These operation are relatively expensive in general so it is good to make them visible, but when they are needed a lot we just want to do without explicit conversion so we ignore the warning there.

(quoted diff) +0 -0
@@ -207,7 +207,7 @@ public class GitResourceDecorator extends LabelProvider implements
 					return Boolean.FALSE;
 				}
 
Quoted 7 lines

Review public class GitResourceDecorator extends LabelProvider implements · line 213

Quoted 5 lines
(quoted diff) +1 -1
-				return mapped.isResourceChanged(rsrc);
+				return new Boolean(mapped.isResourceChanged(rsrc));
 			}
 			return null; // not mapped
 		} catch (CoreException e) {

Oooooooow. That hurts.

Sorry :/

I reuse Date and String, and Integer object elsewhere all the time, but the obvious solution is too simple :)

Thanks Shawn.

-- robin

Quoted 1 line

From 4fbd3de89c53956abfbc1a4bb08113c6a9f83ab3 Mon Sep 17 00:00:00 2001

From: Robin Rosenberg <[email protected]>
Date: Wed, 6 Feb 2008 18:40:25 +0100
Subject: [EGIT PATCH 1/2] Use Boolean.valueOf instead of new Boolean

This use two singleton Booleans instead of allocating new objects.

---
 .../internal/decorators/GitResourceDecorator.java  |    4 ++--
 .../src/org/spearce/jgit/lib/GitIndex.java         |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java index 7eb008b..9592817 100644

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java +2 -2
@@ -207,7 +207,7 @@ public class GitResourceDecorator extends LabelProvider implements
 					return Boolean.FALSE;
 				}
 
-				return new Boolean(mapped.isResourceChanged(rsrc));
+				return Boolean.valueOf(mapped.isResourceChanged(rsrc));
 			}
 			return null; // not mapped
 		} catch (CoreException e) {
@@ -245,7 +245,7 @@ public class GitResourceDecorator extends LabelProvider implements
 							Integer df = (Integer) rsrc
 									.getSessionProperty(GITFOLDERDIRTYSTATEPROPERTY);
 							Boolean f = df == null ? isDirty(rsrc)
-									: new Boolean(df.intValue() == CHANGED);
+									: Boolean.valueOf(df.intValue() == CHANGED);
 							if (f != null) {
 								if (f.booleanValue()) {
 									decoration.addPrefix(">"); // Have not
org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java +1 -1
index 69ed270..3cd9de9 100644
@@ -290,7 +290,7 @@ public class GitIndex {
 		if (setExecute != null) {
 			try {
 				return ((Boolean) setExecute.invoke(f,
-						new Object[] { new Boolean(value) })).booleanValue();
+						new Object[] { Boolean.valueOf(value) })).booleanValue();
 			} catch (IllegalArgumentException e) {
 				throw new Error(e);
 			} catch (IllegalAccessException e) {
Signature · 1 line
1.5.4.rc4.25.g81cc
#9 lore raw

PATCH 2/2 Use Integer.valueOf instead of new Integer

In reply to Shawn O. Pearce

onsdagen den 6 februari 2008 skrev Shawn O. Pearce:

Quoted 8 lines

Use Integer.valueOf(int). Post Java 5 implementations of the J2SE are required to cache values between -128 and 127 (inclusive).

Actually, when the Java compiler autoboxes values it does so through these static valueOf methods, which were mostly introduced as part of the Java 5 API updates. For small common values its cached and will thus avoid garbage generation, for less common values it goes back to allocating the object.

Thank you for this information.

-- robin

Quoted 1 line

From 2f2248fc01c169d85e88d42d10693e4ec59a0c1d Mon Sep 17 00:00:00 2001

From: Robin Rosenberg <[email protected]>
Date: Wed, 6 Feb 2008 21:06:08 +0100
Subject: [EGIT PATCH 2/2] Use Integer.valueOf instead of new Integer

Java 1.5+ has a cache for small numbers.

---
 .../src/org/spearce/egit/ui/FindResults.java       |   10 +++++-----
 .../internal/decorators/GitResourceDecorator.java  |    4 ++--
 .../tst/org/spearce/jgit/lib/MappedListTest.java   |    8 ++++----
 .../tst/org/spearce/jgit/lib/SuperListTest.java    |   12 ++++++------
 .../src/org/spearce/jgit/lib/SuperList.java        |    2 +-
 .../org/spearce/jgit/lib/TopologicalSorter.java    |    8 ++++----
 6 files changed, 22 insertions(+), 22 deletions(-)

Thanks to Shawn

-- robin

org.spearce.egit.ui/src/org/spearce/egit/ui/FindResults.java +5 -5
index 9484503..2b49597 100644
@@ -45,7 +45,7 @@ public class FindResults {
 	 *         <code>false</code> otherwise
 	 */
 	public synchronized boolean isFoundAt(int index) {
-		return matchesMap.containsKey(new Integer(index));
+		return matchesMap.containsKey(Integer.valueOf(index));
 	}
 
 	/**
@@ -59,7 +59,7 @@ public class FindResults {
 	 */
 	public synchronized int getIndexAfter(int index) {
 		Integer[] matches = getkeysArray();
-		int sres = Arrays.binarySearch(matches, new Integer(index));
+		int sres = Arrays.binarySearch(matches, Integer.valueOf(index));
 		if (sres >= 0 && sres != matches.length - 1) {
 			return matches[sres + 1].intValue();
 		} else if (sres < 0) {
@@ -83,7 +83,7 @@ public class FindResults {
 	 */
 	public synchronized int getIndexBefore(int index) {
 		Integer[] matches = getkeysArray();
-		int sres = Arrays.binarySearch(matches, new Integer(index));
+		int sres = Arrays.binarySearch(matches, Integer.valueOf(index));
 		if (sres >= 0 && sres != 0) {
 			return matches[sres - 1].intValue();
 		} else if (sres < -1) {
@@ -136,7 +136,7 @@ public class FindResults {
 	 *         list. Returns -1 if <code>index</code> doesn't contain a match
 	 */
 	public synchronized int getMatchNumberFor(int index) {
-		Integer ix = matchesMap.get(new Integer(index));
+		Integer ix = matchesMap.get(Integer.valueOf(index));
 		if (ix != null) {
 			return ix.intValue();
 		}
@@ -168,7 +168,7 @@ public class FindResults {
 	 *            the history table item index that matches a find pattern.
 	 */
 	public synchronized void add(int matchIx) {
-		matchesMap.put(new Integer(matchIx), new Integer(++matchesCount));
+		matchesMap.put(Integer.valueOf(matchIx), Integer.valueOf(++matchesCount));
 		keysArray = null;
 	}
 
(quoted diff) +0 -0

b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java index 9592817..df2f569 100644

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/decorators/GitResourceDecorator.java +2 -2
@@ -358,7 +358,7 @@ public class GitResourceDecorator extends LabelProvider implements
 		try {
 			Integer dirty = (Integer) rsrc.getSessionProperty(GITFOLDERDIRTYSTATEPROPERTY);
 			if (dirty == null) {
-				rsrc.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, new Integer(flag));
+				rsrc.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, Integer.valueOf(flag));
 				Activator.trace("SETTING:"+rsrc.getFullPath().toOSString()+" => "+flag);
 				orState(rsrc.getParent(), flag);
 				Display.getDefault().asyncExec(new Runnable() {
@@ -375,7 +375,7 @@ public class GitResourceDecorator extends LabelProvider implements
 				});
 			} else {
 				if ((dirty.intValue() | flag) != dirty.intValue()) {
-					dirty = new Integer(dirty.intValue() | flag);
+					dirty = Integer.valueOf(dirty.intValue() | flag);
 					rsrc.setSessionProperty(GITFOLDERDIRTYSTATEPROPERTY, dirty);
 					Activator.trace("SETTING:"+rsrc.getFullPath().toOSString()+" => "+dirty);
 					orState(rsrc.getParent(), dirty.intValue());
org.spearce.jgit.test/tst/org/spearce/jgit/lib/MappedListTest.java +4 -4
index ccc13a0..6513d99 100644
@@ -29,13 +29,13 @@ public class MappedListTest extends TestCase {
 						new Float(3.14f) })) {
 			@Override
 			protected Integer map(Float from) {
-				return new Integer((int) from.floatValue() * 2);
+				return Integer.valueOf((int) from.floatValue() * 2);
 			}
 		};
 
 		assertEquals(3, x.toArray().length);
-		assertEquals(new Integer(2), x.toArray()[0]);
-		assertEquals(new Integer(4), x.toArray()[1]);
-		assertEquals(new Integer(6), x.toArray()[2]);
+		assertEquals(Integer.valueOf(2), x.toArray()[0]);
+		assertEquals(Integer.valueOf(4), x.toArray()[1]);
+		assertEquals(Integer.valueOf(6), x.toArray()[2]);
 	}
 }
org.spearce.jgit.test/tst/org/spearce/jgit/lib/SuperListTest.java +6 -6
index 79f4da6..be38b95 100644
@@ -38,14 +38,14 @@ public class SuperListTest extends TestCase {
 		l.addAll(sl1);
 		l.addAll(sl2);
 		l.addAll(sl3);
-		l.add(new Integer(7));
+		l.add(Integer.valueOf(7));
 
 		assertEquals(5, l.size());
-		assertEquals(new Integer(3), l.toArray()[0]);
-		assertEquals(new Integer(4), l.toArray()[1]);
-		assertEquals(new Integer(5), l.toArray()[2]);
-		assertEquals(new Integer(6), l.toArray()[3]);
-		assertEquals(new Integer(7), l.toArray()[4]);
+		assertEquals(Integer.valueOf(3), l.toArray()[0]);
+		assertEquals(Integer.valueOf(4), l.toArray()[1]);
+		assertEquals(Integer.valueOf(5), l.toArray()[2]);
+		assertEquals(Integer.valueOf(6), l.toArray()[3]);
+		assertEquals(Integer.valueOf(7), l.toArray()[4]);
 
 		assertEquals(5, l.toArray().length);
 	}
org.spearce.jgit/src/org/spearce/jgit/lib/SuperList.java +1 -1
index 4a50794..04c9958 100644
@@ -48,7 +48,7 @@ public class SuperList<T> extends AbstractList<T> {
 	 */
 	public boolean addAll(List<T> subList) {
 		int lastEnd = subLists.size() > 0 ? subListEnd.get(subListEnd.size()-1).intValue() : 0;
-		subListEnd.add(new Integer(lastEnd + subList.size()));
+		subListEnd.add(Integer.valueOf(lastEnd + subList.size()));
 		subLists.add(subList);
 		return true;
 	}
org.spearce.jgit/src/org/spearce/jgit/lib/TopologicalSorter.java +4 -4
index c33334e..d5c2430 100644
@@ -205,9 +205,9 @@ public class TopologicalSorter<T> {
 		allNodes.add(edge.to);
 		Integer n = inCount.get(edge.to);
 		if (n == null)
-			inCount.put(edge.to, new Integer(1));
+			inCount.put(edge.to, Integer.valueOf(1));
 		else
-			inCount.put(edge.to, new Integer(n.intValue() + 1));
+			inCount.put(edge.to, Integer.valueOf(n.intValue() + 1));
 	}
 
 	/**
@@ -255,7 +255,7 @@ public class TopologicalSorter<T> {
 					zeroIn.add(e.to);
 					inCount.remove(e.to);
 				} else {
-					inCount.put(e.to, new Integer(c.intValue() - 1));
+					inCount.put(e.to, Integer.valueOf(c.intValue() - 1));
 				}
 			}
 //			allEdges.remove(from);
@@ -356,7 +356,7 @@ public class TopologicalSorter<T> {
 		}
 		Iterator<T> i = zeroIn.iterator();
 		ret = i.next();
-		internalOrder.put(ret, new Integer(internalOrder.size()));
+		internalOrder.put(ret, Integer.valueOf(internalOrder.size()));
 		i.remove();
 		removeallfrom(ret);
 		return ret;
Signature · 1 line
1.5.4.rc4.25.g81cc
#10 lore raw

Re: [EGIT PATCH 2/2] Use Integer.valueOf instead of new Integer

Robin Rosenberg escreveu:

Quoted 12 lines

onsdagen den 6 februari 2008 skrev Shawn O. Pearce:

Quoted 9 lines

Use Integer.valueOf(int). Post Java 5 implementations of the J2SE are required to cache values between -128 and 127 (inclusive).

Actually, when the Java compiler autoboxes values it does so through these static valueOf methods, which were mostly introduced as part of the Java 5 API updates. For small common values its cached and will thus avoid garbage generation, for less common values it goes back to allocating the object.

Quoted 3 lines

Thank you for this information.

-- robin

Yep, this is very good to know. Thanks from me too :) This patches series looks fine to me.

[]s,
Roger.

#11 lore raw
In reply to Robin Rosenberg

Robin Rosenberg escreveu:

Quoted 10 lines

Here is a number of small enhancements that reduce the number of warnings displayed and raises the standard on comments. We now get javadoc comments on all public and protected methods which hopefully will make it slighly easier to get on the train for those interested in helping out with Egit/Jgit.

Disabling the else-warning is probably fairly uncontroversial. Disabling some warning about boxing/unboxing of integers might be as might be requiring javadoc comments.

Hi Robin,

[2, 3, 5 and 6] - looks fine to me.

[1] - What about something like "nothing to be done here" and/or "implementing interface method"?

[4] - Some typos:

+     * Construct an GitStorage instance corresponding to
+     * Construct a GitTag object with a give name.
+     * with some filtering applied. The filter could reduces the number of
+     * commitgs returned or just mark some versions as interesting.
+     *            true if all revisions are returned and interesting revisiosn.

+ * An class for changing a ref and possibly index and workdir too.
+ * Construct a {@link CheckpointJob} for the specified resource maping
+ * Drop the Eclipse project from our assocation of projects/repositories

And
+ /**

+     * Maps the commit id of this object and
+     *
+     * @return the {@link Commit} object this {@link IFileRevision} refers to
+     */

and what?

[]s,
Roger.

#12 lore raw

tisdagen den 5 februari 2008 skrev Roger C. Soares:

Quoted 7 lines

Robin Rosenberg escreveu:

Quoted 5 lines

Here is a number of small enhancements that reduce the number of warnings displayed and raises the standard on comments. We now get javadoc comments on all public and protected methods which hopefully will make it slighly easier to get on the train for those interested in helping out with Egit/Jgit.

Quoted 8 lines
Quoted 5 lines

Disabling the else-warning is probably fairly uncontroversial. Disabling some warning about boxing/unboxing of integers might be as might be requiring javadoc comments.

Hi Robin,

[2, 3, 5 and 6] - looks fine to me.

Thanks for looking.

Quoted 2 lines

[1] - What about something like "nothing to be done here" and/or "implementing interface method"?

"Empty" is a marker that the block is *intentionally* empty, which is the point here.

Quoted 1 line

[4] - Some typos:

Thanks

-- robin