Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java42
1 files changed, 22 insertions, 20 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java
index 67b2bb831..1bc135f12 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/sourcelookup/SourceLookupUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * Copyright (c) 2003, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,7 +12,6 @@ package org.eclipse.debug.internal.core.sourcelookup;
import java.io.IOException;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.zip.ZipFile;
import org.eclipse.core.resources.IResourceChangeEvent;
@@ -31,19 +30,19 @@ import org.eclipse.debug.core.ILaunchesListener2;
* @since 3.0
*/
public class SourceLookupUtils {
-
+
/**
* Cache of shared zip files. Zip files are closed
* when this class's plug-in is shutdown, when a project
* is about to be closed or deleted, when a launch is
- * removed, and when a debug target or process terminates.
+ * removed, and when a debug target or process terminates.
*/
- private static HashMap fgZipFileCache = new HashMap(5);
+ private static HashMap<String, ZipFile> fgZipFileCache = new HashMap<String, ZipFile>(5);
private static ArchiveCleaner fgCleaner = null;
-
+
/**
* Returns a zip file with the given name
- *
+ *
* @param name zip file name
* @return The zip file with the given name
* @exception IOException if unable to create the specified zip
@@ -56,7 +55,7 @@ public class SourceLookupUtils {
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(fgCleaner);
ResourcesPlugin.getWorkspace().addResourceChangeListener(fgCleaner, IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.PRE_CLOSE);
}
- ZipFile zip = (ZipFile)fgZipFileCache.get(name);
+ ZipFile zip = fgZipFileCache.get(name);
if (zip == null) {
zip = new ZipFile(name);
fgZipFileCache.put(name, zip);
@@ -64,7 +63,7 @@ public class SourceLookupUtils {
return zip;
}
}
-
+
/**
* Closes all zip files that have been opened,
* and removes them from the zip file cache.
@@ -73,9 +72,7 @@ public class SourceLookupUtils {
*/
public static void closeArchives() {
synchronized (fgZipFileCache) {
- Iterator iter = fgZipFileCache.values().iterator();
- while (iter.hasNext()) {
- ZipFile file = (ZipFile)iter.next();
+ for (ZipFile file : fgZipFileCache.values()) {
synchronized (file) {
try {
file.close();
@@ -86,8 +83,8 @@ public class SourceLookupUtils {
}
fgZipFileCache.clear();
}
- }
-
+ }
+
/**
* Called when the debug plug-in shuts down.
*/
@@ -95,10 +92,10 @@ public class SourceLookupUtils {
closeArchives();
if (fgCleaner != null) {
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(fgCleaner);
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(fgCleaner);
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(fgCleaner);
}
}
-
+
/**
* Clears the cache of open zip files when a launch terminates,
* is removed, or when a project is about to be deleted or closed.
@@ -108,10 +105,11 @@ public class SourceLookupUtils {
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.debug.core.ILaunch[])
*/
+ @Override
public void launchesRemoved(ILaunch[] launches) {
for (int i = 0; i < launches.length; i++) {
ILaunch launch = launches[i];
- if (!launch.isTerminated()) {
+ if (!launch.isTerminated()) {
SourceLookupUtils.closeArchives();
return;
}
@@ -121,18 +119,21 @@ public class SourceLookupUtils {
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug.core.ILaunch[])
*/
- public void launchesAdded(ILaunch[] launches) {
+ @Override
+ public void launchesAdded(ILaunch[] launches) {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch[])
*/
+ @Override
public void launchesChanged(ILaunch[] launches) {
}
/* (non-Javadoc)
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
*/
+ @Override
public void resourceChanged(IResourceChangeEvent event) {
SourceLookupUtils.closeArchives();
}
@@ -140,9 +141,10 @@ public class SourceLookupUtils {
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener2#launchesTerminated(org.eclipse.debug.core.ILaunch[])
*/
+ @Override
public void launchesTerminated(ILaunch[] launches) {
SourceLookupUtils.closeArchives();
}
-
- }
+
+ }
}

Back to the top