Skip to contentSkip to conversation

Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.

PATCH In review Vasyl' Vavrychuk 3 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fixed trivial warnings. Mainly parametrized raw types, added serialVersionUID, removed unnecessery throws.

Also fixed:
1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
2. Possible NullPointerException warning.
3. Unnecessery function parameter warning.

---
 org.spearce.egit.core.test/META-INF/MANIFEST.MF    |    2 +-
 org.spearce.egit.core/META-INF/MANIFEST.MF         |    2 +-
 .../egit/core/internal/storage/GitFileHistory.java |    4 +-
 .../spearce/egit/core/project/GitProjectData.java  |   18 +++----
 .../egit/core/project/RepositoryFinder.java        |    5 +-
 org.spearce.egit.ui/META-INF/MANIFEST.MF           |    2 +-
 .../egit/ui/internal/actions/RepositoryAction.java |    2 +-
 .../tst/org/spearce/jgit/lib/T0002_Tree.java       |    4 +-
 org.spearce.jgit/META-INF/MANIFEST.MF              |    2 +-
 .../jgit/errors/InvalidPatternException.java       |    2 +
 .../jgit/errors/NoClosingBracketException.java     |    1 +
 .../jgit/errors/RevisionSyntaxException.java       |    1 +
 .../src/org/spearce/jgit/lib/AnyObjectId.java      |    6 +--
 .../src/org/spearce/jgit/lib/GitIndex.java         |   29 +++++------
 .../src/org/spearce/jgit/lib/ObjectIdMap.java      |    1 -
 .../src/org/spearce/jgit/lib/ObjectWriter.java     |    1 -
 .../src/org/spearce/jgit/lib/TreeIterator.java     |    2 +-
 .../jgit/lib/TreeVisitorWithCurrentDirectory.java  |    5 +-
 .../src/org/spearce/jgit/revwalk/RevWalk.java      |    3 +-
 .../jgit/transport/DefaultSshSessionFactory.java   |    2 +-
 .../spearce/jgit/treewalk/CanonicalTreeParser.java |    5 +-
 .../src/org/spearce/jgit/util/Base64.java          |   52 ++++++++++++--------
 22 files changed, 76 insertions(+), 75 deletions(-)
org.spearce.egit.core.test/META-INF/MANIFEST.MF +1 -1
index ee5f277..e8bcc79 100644
@@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.spearce.egit.ui,
  org.spearce.jgit,
  org.eclipse.core.filesystem
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
 Import-Package: org.eclipse.core.resources,
  org.eclipse.jdt.core,
  org.eclipse.jdt.junit,
org.spearce.egit.core/META-INF/MANIFEST.MF +1 -1
index 6c95084..43fc566 100644
@@ -16,5 +16,5 @@ Export-Package: org.spearce.egit.core.internal.storage;x-friends:="org.spearce.e
  org.spearce.egit.core,
  org.spearce.egit.core.op,
  org.spearce.egit.core.project
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +2 -2
index c01c1c3..61c32ce 100644
@@ -50,11 +50,11 @@
 	GitFileHistory(final IResource rsrc, final int flags,
 			final IProgressMonitor monitor) {
 		resource = rsrc;
-		walk = buildWalk(flags);
+		walk = buildWalk(/*flags*/);
 		revisions = buildRevisions(monitor, flags);
 	}
 
-	private KidWalk buildWalk(final int flags) {
+	private KidWalk buildWalk(/*final int flags*/) {
 		final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
 		if (rm == null) {
 			Activator.logError("Git not attached to project "
org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java +8 -10
index 04130db..db5f20b 100644
@@ -48,9 +48,9 @@
  * a Git repository.
  */
 public class GitProjectData {
-	private static final Map projectDataCache = new HashMap();
+	private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
 
-	private static final Map repositoryCache = new HashMap();
+	private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();
 
 	private static RepositoryChangeListener[] repositoryChangeListeners = {};
 
@@ -193,7 +193,7 @@ private synchronized static void uncache(final IProject p) {
 	}
 
 	private synchronized static GitProjectData lookup(final IProject p) {
-		return (GitProjectData) projectDataCache.get(p);
+		return projectDataCache.get(p);
 	}
 
 	private synchronized static Repository lookupRepository(final File gitDir)
@@ -206,11 +206,11 @@ private synchronized static Repository lookupRepository(final File gitDir)
 			}
 		}
 
-		final Reference r = (Reference) repositoryCache.get(gitDir);
+		final Reference r = repositoryCache.get(gitDir);
 		Repository d = r != null ? (Repository) r.get() : null;
 		if (d == null) {
 			d = new Repository(gitDir);
-			repositoryCache.put(gitDir, new WeakReference(d));
+			repositoryCache.put(gitDir, new WeakReference<Repository>(d));
 		}
 		return d;
 	}
@@ -229,9 +229,9 @@ public static void reconfigureWindowCache() {
 
 	private final IProject project;
 
-	private final Collection mappings;
+	private final Collection<RepositoryMapping> mappings = new ArrayList<RepositoryMapping>();
 
-	private final Set protectedResources;
+	private final Set<IResource> protectedResources = new HashSet<IResource>();
 
 	/**
 	 * Construct a {@link GitProjectData} for the mapping
@@ -241,8 +241,6 @@ public static void reconfigureWindowCache() {
 	 */
 	public GitProjectData(final IProject p) {
 		project = p;
-		mappings = new ArrayList();
-		protectedResources = new HashSet();
 	}
 
 	/**
@@ -257,7 +255,7 @@ public IProject getProject() {
 	 *
 	 * @param newMappings
 	 */
-	public void setRepositoryMappings(final Collection newMappings) {
+	public void setRepositoryMappings(final Collection<RepositoryMapping> newMappings) {
 		mappings.clear();
 		mappings.addAll(newMappings);
 		remapAll();
org.spearce.egit.core/src/org/spearce/egit/core/project/RepositoryFinder.java +2 -3
index c33f3a0..2b4b16f 100644
@@ -47,7 +47,7 @@
 public class RepositoryFinder {
 	private final IProject proj;
 
-	private final Collection results;
+	private final Collection<RepositoryMapping> results = new ArrayList<RepositoryMapping>();
 
 	/**
 	 * Create a new finder to locate Git repositories for a project.
@@ -58,7 +58,6 @@
 	 */
 	public RepositoryFinder(final IProject p) {
 		proj = p;
-		results = new ArrayList();
 	}
 
 	/**
@@ -72,7 +71,7 @@ public RepositoryFinder(final IProject p) {
 	 *             Eclipse was unable to access its workspace, and threw up on
 	 *             us. We're throwing it back at the caller.
 	 */
-	public Collection find(IProgressMonitor m) throws CoreException {
+	public Collection<RepositoryMapping> find(IProgressMonitor m) throws CoreException {
 		if (m == null) {
 			m = new NullProgressMonitor();
 		}
org.spearce.egit.ui/META-INF/MANIFEST.MF +1 -1
index ec1df4d..019ef6e 100644
@@ -20,7 +20,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.spearce.jgit,
  org.spearce.egit.core,
  org.eclipse.jsch.ui;bundle-version="1.1.100"
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Import-Package: org.eclipse.jsch.core,
  org.eclipse.jsch.internal.core
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/RepositoryAction.java +1 -1
index 8c250ca..362437e 100644
@@ -100,7 +100,7 @@ protected Repository getRepository(boolean warn) {
 				mapping = repositoryMapping;
 			if (repositoryMapping == null)
 				return null;
-			if (repositoryMapping != null && mapping.getRepository() != repositoryMapping.getRepository()) {
+			if (mapping.getRepository() != repositoryMapping.getRepository()) {
 				if (warn)
 					MessageDialog.openError(getShell(), "Multiple Repositories Selection", "Cannot perform reset on multiple repositories simultaneously.\n\nPlease select items from only one repository.");
 				return null;
org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0002_Tree.java +2 -2
index fcb4d96..97f299c 100644
@@ -236,7 +236,7 @@ public void test006_addDeepTree() throws IOException {
 
 	public void test007_manyFileLookup() throws IOException {
 		final Tree t = new Tree(db);
-		final List files = new ArrayList(26 * 26);
+		final List<FileTreeEntry> files = new ArrayList<FileTreeEntry>(26 * 26);
 		for (char level1 = 'a'; level1 <= 'z'; level1++) {
 			for (char level2 = 'a'; level2 <= 'z'; level2++) {
 				final String n = "." + level1 + level2 + "9";
@@ -251,7 +251,7 @@ public void test007_manyFileLookup() throws IOException {
 		assertNotNull(ents);
 		assertEquals(files.size(), ents.length);
 		for (int k = 0; k < ents.length; k++) {
-			assertTrue("File " + ((FileTreeEntry) files.get(k)).getName()
+			assertTrue("File " + files.get(k).getName()
 					+ " is at " + k + ".", files.get(k) == ents[k]);
 		}
 	}
org.spearce.jgit/META-INF/MANIFEST.MF +1 -1
index 36f92f2..459e8f3 100644
@@ -16,7 +16,7 @@ Export-Package: org.spearce.jgit.dircache,
  org.spearce.jgit.treewalk,
  org.spearce.jgit.treewalk.filter,
  org.spearce.jgit.util
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ClassPath: .
 Require-Bundle: com.jcraft.jsch;visibility:=reexport
org.spearce.jgit/src/org/spearce/jgit/errors/InvalidPatternException.java +2 -0
index 15d159b..e7be0d6 100644
@@ -42,6 +42,8 @@
  *
  */
 public class InvalidPatternException extends Exception {
+	private static final long serialVersionUID = 1L;
+
 	private final String pattern;
 
 	/**
org.spearce.jgit/src/org/spearce/jgit/errors/NoClosingBracketException.java +1 -0
index 1a93906..8fe9ab1 100644
@@ -42,6 +42,7 @@
  * side or a character class which is open to the right side.
  */
 public class NoClosingBracketException extends InvalidPatternException {
+	private static final long serialVersionUID = 1L;
 
 	/**
 	 * @param indexOfOpeningBracket
org.spearce.jgit/src/org/spearce/jgit/errors/RevisionSyntaxException.java +1 -0
index ac425bb..f943879 100644
@@ -45,6 +45,7 @@
  * properly formatted.
  */
 public class RevisionSyntaxException extends IOException {
+	private static final long serialVersionUID = 1L;
 
 	private final String revstr;
 
org.spearce.jgit/src/org/spearce/jgit/lib/AnyObjectId.java +1 -5
index a534202..f3e4534 100644
@@ -52,7 +52,7 @@
  * with this instance can alter at any time, if this instance is modified to
  * represent a different object name.
  */
-public abstract class AnyObjectId implements Comparable {
+public abstract class AnyObjectId implements Comparable<ObjectId> {
 	static final int RAW_LEN = Constants.OBJECT_ID_LENGTH;
 
 	static final int STR_LEN = RAW_LEN * 2;
@@ -178,10 +178,6 @@ public int compareTo(final ObjectId other) {
 		return NB.compareUInt32(w5, other.w5);
 	}
 
-	public int compareTo(final Object other) {
-		return compareTo(((ObjectId) other));
-	}
-
 	int compareTo(final byte[] bs, final int p) {
 		int cmp;
 
org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java +13 -16
index bafddef..7c3f1b4 100644
@@ -107,18 +107,16 @@
 
 	private final Repository db;
 
-	private Map entries = new TreeMap(new Comparator() {
-		public int compare(Object arg0, Object arg1) {
-			byte[] a = (byte[]) arg0;
-			byte[] b = (byte[]) arg1;
-			for (int i = 0; i < a.length && i < b.length; ++i) {
-				int c = a[i] - b[i];
+	private Map<byte[], Entry> entries = new TreeMap<byte[], Entry>(new Comparator<byte[]>() {
+		public int compare(byte[] o1, byte[] o2) {
+			for (int i = 0; i < o1.length && i < o2.length; ++i) {
+				int c = o1[i] - o2[i];
 				if (c != 0)
 					return c;
 			}
-			if (a.length < b.length)
+			if (o1.length < o2.length)
 				return -1;
-			else if (a.length > b.length)
+			else if (o1.length > o2.length)
 				return 1;
 			return 0;
 		}
@@ -161,7 +159,7 @@ public void rereadIfNecessary() throws IOException {
 	 */
 	public Entry add(File wd, File f) throws IOException {
 		byte[] key = makeKey(wd, f);
-		Entry e = (Entry) entries.get(key);
+		Entry e = entries.get(key);
 		if (e == null) {
 			e = new Entry(key, f, 0);
 			entries.put(key, e);
@@ -302,7 +300,7 @@ static boolean File_hasExecute() {
 		return FS.INSTANCE.supportsExecute();
 	}
 
-	static byte[] makeKey(File wd, File f) throws IOException {
+	static byte[] makeKey(File wd, File f) {
 		if (!f.getPath().startsWith(wd.getPath()))
 			throw new Error("Path is not in working dir");
 		String relName = Repository.stripWorkDir(wd, f);
@@ -362,8 +360,7 @@ Entry(byte[] key, File f, int stage)
 			flags = (short) ((stage << 12) | name.length); // TODO: fix flags
 		}
 
-		Entry(TreeEntry f, int stage)
-				throws UnsupportedEncodingException {
+		Entry(TreeEntry f, int stage) {
 			ctime = -1; // hmm
 			mtime = -1;
 			dev = -1;
@@ -810,7 +807,7 @@ public ObjectId writeTree() throws IOException {
 		checkWriteOk();
 		ObjectWriter writer = new ObjectWriter(db);
 		Tree current = new Tree(db);
-		Stack trees = new Stack();
+		Stack<Tree> trees = new Stack<Tree>();
 		trees.push(current);
 		String[] prevName = new String[0];
 		for (Iterator i = entries.values().iterator(); i.hasNext();) {
@@ -844,7 +841,7 @@ public ObjectId writeTree() throws IOException {
 			current.setId(writer.writeTree(current));
 			trees.pop();
 			if (!trees.isEmpty())
-				current = (Tree) trees.peek();
+				current = trees.peek();
 		}
 		return current.getTreeId();
 	}
@@ -886,7 +883,7 @@ int longestCommonPath(String[] a, String[] b) {
 	 * @return The index entries sorted
 	 */
 	public Entry[] getMembers() {
-		return (Entry[]) entries.values().toArray(new Entry[entries.size()]);
+		return entries.values().toArray(new Entry[entries.size()]);
 	}
 
 	/**
@@ -897,7 +894,7 @@ int longestCommonPath(String[] a, String[] b) {
 	 * @throws UnsupportedEncodingException
 	 */
 	public Entry getEntry(String path) throws UnsupportedEncodingException {
-		return (Entry) entries.get(Repository.gitInternalSlash(Constants.encode(path)));
+		return entries.get(Repository.gitInternalSlash(Constants.encode(path)));
 	}
 
 	/**
org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java +0 -1
index 600d0f4..d3c7f1d 100644
@@ -178,7 +178,6 @@ public boolean isEmpty() {
 		return true;
 	}
 
-	@SuppressWarnings("unchecked")
 	public V put(ObjectId key, V value) {
 		return submap(key).put(key, value);
 	}
org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java +0 -1
index 6c2cd4f..e84798a 100644
@@ -289,7 +289,6 @@ public ObjectId computeBlobSha1(final long len, final InputStream is)
 		return writeObject(Constants.OBJ_BLOB, len, is, false);
 	}
 
-	@SuppressWarnings("null")
 	ObjectId writeObject(final int type, long len, final InputStream is,
 			boolean store) throws IOException {
 		final File t;
org.spearce.jgit/src/org/spearce/jgit/lib/TreeIterator.java +1 -1
index 2344a3c..ec52078 100644
@@ -76,7 +76,7 @@
 		 * Visit leaves first, then node
 		 */
 		POSTORDER
-	};
+	}
 
 	/**
 	 * Construct a {@link TreeIterator} for visiting all non-tree nodes.
org.spearce.jgit/src/org/spearce/jgit/lib/TreeVisitorWithCurrentDirectory.java +2 -3
index 55854b2..e227adb 100644
@@ -46,12 +46,11 @@
  * Abstract TreeVisitor for visiting all files known by a Tree.
  */
 public abstract class TreeVisitorWithCurrentDirectory implements TreeVisitor {
-	private final ArrayList stack;
+	private final ArrayList<File> stack = new ArrayList<File>(16);
 
 	private File currentDirectory;
 
 	protected TreeVisitorWithCurrentDirectory(final File rootDirectory) {
-		stack = new ArrayList(16);
 		currentDirectory = rootDirectory;
 	}
 
@@ -67,6 +66,6 @@ public void startVisitTree(final Tree t) throws IOException {
 	}
 
 	public void endVisitTree(final Tree t) throws IOException {
-		currentDirectory = (File) stack.remove(stack.size() - 1);
+		currentDirectory = stack.remove(stack.size() - 1);
 	}
 }
org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java +1 -2
index d7e4c58..8d25125 100644
@@ -1014,8 +1014,7 @@ protected RevCommit createCommit(final AnyObjectId id) {
 		return new RevCommit(id);
 	}
 
-	void carryFlagsImpl(final RevCommit c) throws MissingObjectException,
-			IncorrectObjectTypeException, IOException {
+	void carryFlagsImpl(final RevCommit c) {
 		final int carry = c.flags & carryFlags;
 		if (carry != 0)
 			RevCommit.carryFlags(c, carry);
org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java +1 -1
index 89beab7..0d522df 100644
@@ -153,7 +153,7 @@ private void knownHosts(final JSch sch) throws JSchException {
 		}
 	}
 
-	private void identities() throws JSchException {
+	private void identities() {
 		final File home = FS.userHome();
 		if (home == null)
 			return;
org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java +3 -2
index dcc53cd..4700510 100644
@@ -175,8 +175,9 @@ public void back(int delta) {
 			// space so this prunes our search more quickly.
 			//
 			ptr -= Constants.OBJECT_ID_LENGTH;
-			while (raw[--ptr] != ' ')
-				/* nothing */;
+			while (raw[--ptr] != ' ') {
+				/* nothing */
+			}
 			if (--ptr < Constants.OBJECT_ID_LENGTH) {
 				if (delta != 0)
 					throw new ArrayIndexOutOfBoundsException(delta);
org.spearce.jgit/src/org/spearce/jgit/util/Base64.java +31 -21

121 lines not on this page · raw message

Signature · 1 line
1.5.6.1.1071.g76fb
#1 lore raw

söndag 04 januari 2009 23:20:19 skrev Vasyl' Vavrychuk:

Quoted 4 lines

Also fixed:
1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
2. Possible NullPointerException warning.
3. Unnecessery function parameter warning.

Thanks for your interest in the projects. Most changes from a 30 seconds review look reasonable. However we don't apply changes this way. From your comments it seems we'd require about five patches since the changes are of very different types.

-- robin

org.spearce.egit.core.test/META-INF/MANIFEST.MF Require-Bundle: org.eclipse.core.runtime, · line 14

Quoted 10 lines
org.spearce.egit.core.test/META-INF/MANIFEST.MF +1 -1
index ee5f277..e8bcc79 100644
@@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.spearce.egit.ui,
  org.spearce.jgit,
  org.eclipse.core.filesystem
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy

Any pointers on this? (so I can learn)

Quoted 5 lines
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +0 -0
index c01c1c3..61c32ce 100644

org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java line 56

Quoted 9 lines
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +2 -2
@@ -50,11 +50,11 @@
 	GitFileHistory(final IResource rsrc, final int flags,
 			final IProgressMonitor monitor) {
 		resource = rsrc;
-		walk = buildWalk(flags);
+		walk = buildWalk(/*flags*/);
 		revisions = buildRevisions(monitor, flags);
 	}
-	private KidWalk buildWalk(final int flags) {
+	private KidWalk buildWalk(/*final int flags*/) {

Can't we just drop the parameter completely and wipe every trace of it?

Quoted 8 lines
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +0 -0
 		final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
 		if (rm == null) {
 			Activator.logError("Git not attached to project "
org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java +0 -0
index 04130db..db5f20b 100644

org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java line 53

Quoted 8 lines
org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java +2 -2
@@ -48,9 +48,9 @@
  * a Git repository.
  */
 public class GitProjectData {
-	private static final Map projectDataCache = new HashMap();
+	private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
 
-	private static final Map repositoryCache = new HashMap();
+	private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();

Been thinking about doing this myself but always found something more interesting to do. Good.

org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java public void back(int delta) { · line 180

Quoted 13 lines
org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java +3 -2
index dcc53cd..4700510 100644
@@ -175,8 +175,9 @@ public void back(int delta) {
 			// space so this prunes our search more quickly.
 			//
 			ptr -= Constants.OBJECT_ID_LENGTH;
-			while (raw[--ptr] != ' ')
-				/* nothing */;
+			while (raw[--ptr] != ' ') {
+				/* nothing */
+			}

Not sure if this buys us anything. I wouldn't react if original code was either way, but changing it seems unnecessary.

-- robin

#2 lore raw
Quoted 10 lines · Robin Rosenberg

söndag 04 januari 2009 23:20:19 skrev Vasyl' Vavrychuk:

Quoted 4 lines

Also fixed:
1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
2. Possible NullPointerException warning.
3. Unnecessery function parameter warning.

Thanks for your interest in the projects.
Most changes from a 30 seconds review look reasonable.
However we don't apply changes this way. From your comments it seems we'd require about five patches since the changes are of very different types.

I thought that commit is trivial. But maybe series of patches will be better because of an ability to revert what we want.

Quoted 15 lines

-- robin

org.spearce.egit.core.test/META-INF/MANIFEST.MF Require-Bundle: org.eclipse.core.runtime, · line 14

Quoted 10 lines
org.spearce.egit.core.test/META-INF/MANIFEST.MF +1 -1
index ee5f277..e8bcc79 100644
@@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.spearce.egit.ui,
  org.spearce.jgit,
  org.eclipse.core.filesystem
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy

Any pointers on this? (so I can learn)

http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/bundle_manifest.html
The Eclipse-AutoStart and Eclipse-LazyStart headers have been deprecated in Eclipse 3.4

Quoted 16 lines
Quoted 6 lines
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +0 -0
index c01c1c3..61c32ce 100644

org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java line 56

Quoted 9 lines
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +2 -2
@@ -50,11 +50,11 @@
 	GitFileHistory(final IResource rsrc, final int flags,
 			final IProgressMonitor monitor) {
 		resource = rsrc;
-		walk = buildWalk(flags);
+		walk = buildWalk(/*flags*/);
 		revisions = buildRevisions(monitor, flags);
 	}
-	private KidWalk buildWalk(final int flags) {
+	private KidWalk buildWalk(/*final int flags*/) {

Can't we just drop the parameter completely and wipe every trace of it?

OK

Quoted 14 lines
Quoted 14 lines
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +0 -0
 		final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
 		if (rm == null) {
 			Activator.logError("Git not attached to project "
org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java +1 -1
index 04130db..db5f20b 100644
@@ -48,9 +48,9 @@
  * a Git repository.
  */
 public class GitProjectData {
-	private static final Map projectDataCache = new HashMap();
+	private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
 
Quoted 3 lines

org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java line 53

Quoted 2 lines
org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java +1 -1
-	private static final Map repositoryCache = new HashMap();
+	private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();

Been thinking about doing this myself but always found something more interesting to do. Good.

Hope that we will have a generic version of SWT/JFace sometime. Because now I do not know how to handle an inter operation between generic collections and SWT, use SuppressWarning there maybe?

Quoted 7 lines
Quoted 7 lines
org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java +0 -0
index dcc53cd..4700510 100644
@@ -175,8 +175,9 @@ public void back(int delta) {
 			// space so this prunes our search more quickly.
 			//
Quoted 8 lines

org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java public void back(int delta) { · line 180

Quoted 6 lines
org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java +3 -2
 			ptr -= Constants.OBJECT_ID_LENGTH;
-			while (raw[--ptr] != ' ')
-				/* nothing */;
+			while (raw[--ptr] != ' ') {
+				/* nothing */
+			}

Not sure if this buys us anything. I wouldn't react if original code was either way, but changing it seems unnecessary.

With an old version I get "Empty control-flow statement" warning, I've checked org.eclipse.jdt.core.prefs file, there is:
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning

#3 lore raw
In reply to Robin Rosenberg
Quoted 10 lines · Robin Rosenberg

söndag 04 januari 2009 23:20:19 skrev Vasyl' Vavrychuk:

Quoted 4 lines

Also fixed:
1. "The 'Eclipse-LazyStart' header is deprecated, use 'Bundle-ActivationPolicy'" warning.
2. Possible NullPointerException warning.
3. Unnecessery function parameter warning.

Thanks for your interest in the projects.
Most changes from a 30 seconds review look reasonable.
However we don't apply changes this way. From your comments it seems we'd require about five patches since the changes are of very different types.

I thought that commit is trivial. But maybe series of patches will be better because of an ability to revert what we want.

Quoted 15 lines

-- robin

org.spearce.egit.core.test/META-INF/MANIFEST.MF Require-Bundle: org.eclipse.core.runtime, · line 14

Quoted 10 lines
org.spearce.egit.core.test/META-INF/MANIFEST.MF +1 -1
index ee5f277..e8bcc79 100644
@@ -11,7 +11,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.spearce.egit.ui,
  org.spearce.jgit,
  org.eclipse.core.filesystem
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy

Any pointers on this? (so I can learn)

http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/bundle_manifest.html
The Eclipse-AutoStart and Eclipse-LazyStart headers have been deprecated in Eclipse 3.4

Quoted 16 lines
Quoted 6 lines
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +0 -0
index c01c1c3..61c32ce 100644

org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java line 56

Quoted 9 lines
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +2 -2
@@ -50,11 +50,11 @@
 	GitFileHistory(final IResource rsrc, final int flags,
 			final IProgressMonitor monitor) {
 		resource = rsrc;
-		walk = buildWalk(flags);
+		walk = buildWalk(/*flags*/);
 		revisions = buildRevisions(monitor, flags);
 	}
-	private KidWalk buildWalk(final int flags) {
+	private KidWalk buildWalk(/*final int flags*/) {

Can't we just drop the parameter completely and wipe every trace of it?

OK

Quoted 14 lines
Quoted 14 lines
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/GitFileHistory.java +0 -0
 		final RepositoryMapping rm = RepositoryMapping.getMapping(resource);
 		if (rm == null) {
 			Activator.logError("Git not attached to project "
org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java +1 -1
index 04130db..db5f20b 100644
@@ -48,9 +48,9 @@
  * a Git repository.
  */
 public class GitProjectData {
-	private static final Map projectDataCache = new HashMap();
+	private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
 
Quoted 3 lines

org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java line 53

Quoted 2 lines
org.spearce.egit.core/src/org/spearce/egit/core/project/GitProjectData.java +1 -1
-	private static final Map repositoryCache = new HashMap();
+	private static final Map<File, WeakReference> repositoryCache = new HashMap<File, WeakReference>();

Been thinking about doing this myself but always found something more interesting to do. Good.

Hope that we will have a generic version of SWT/JFace sometime. Because now I do not know how to handle an inter operation between generic collections and SWT, use SuppressWarning there maybe?

Quoted 7 lines
Quoted 7 lines
org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java +0 -0
index dcc53cd..4700510 100644
@@ -175,8 +175,9 @@ public void back(int delta) {
 			// space so this prunes our search more quickly.
 			//
Quoted 8 lines

org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java public void back(int delta) { · line 180

Quoted 6 lines
org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java +3 -2
 			ptr -= Constants.OBJECT_ID_LENGTH;
-			while (raw[--ptr] != ' ')
-				/* nothing */;
+			while (raw[--ptr] != ' ') {
+				/* nothing */
+			}

Not sure if this buys us anything. I wouldn't react if original code was either way, but changing it seems unnecessary.

With an old version I get "Empty control-flow statement" warning, I've checked org.eclipse.jdt.core.prefs file, there is:
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning

#4 lore raw
In reply to Vasyl' Vavrychuk

Not sure what is right:
public abstract class AnyObjectId implements Comparable<ObjectId> { or
public abstract class AnyObjectId implements Comparable<AnyObjectId> {

IMHO second, but class AnyObjectId contains some compareTo(ObjectId).

Also not sure if this bunch of changes is complete enough. Maybe it's better to make more fixes in this direction and then commit.

#5 lore raw
Quoted 6 lines · Vasyl' Vavrychuk

Not sure what is right:
public abstract class AnyObjectId implements Comparable<ObjectId> { or
public abstract class AnyObjectId implements Comparable<AnyObjectId> {

IMHO second, but class AnyObjectId contains some compareTo(ObjectId).

Hmmph. That probably can be AnyObjectId. At one point we only had ObjectId, then AnyObjectId was introduced as a base so we can have the immutable AnyObjectId and the mutable MutableObjectId subclasses.

compareTo doesn't care about the mutable state of its argument, this is probably left-over code that didn't get converted when we added the AnyObjectId base class.

So it should be the second, and the compareTo method should be made to match that.

Signature · 1 line
Shawn.
#6 lore raw
In reply to Vasyl' Vavrychuk

måndag 05 januari 2009 00:26:02 skrev Vasyl' Vavrychuk:

Quoted 8 lines

Not sure what is right:
public abstract class AnyObjectId implements Comparable<ObjectId> { or
public abstract class AnyObjectId implements Comparable<AnyObjectId> {

IMHO second, but class AnyObjectId contains some compareTo(ObjectId).

Also not sure if this bunch of changes is complete enough. Maybe it's better to make more fixes in this direction and then commit.

I broke up the patch and applied it just to be nice, with the exception of this change.

-- robin