Skip to content

Commit c4ec4fb

Browse files
author
rcartwright
committed
This revions contains some minor cleanup code like deleting print
statements inserted for debugging and converting instances of Vector to ArrayList. The following files were modified: M src/edu/rice/cs/drjava/model/BrowserHistoryManager.java M src/edu/rice/cs/drjava/model/debug/jpda/PendingRequestManager.java M src/edu/rice/cs/drjava/model/GlobalModel.java M src/edu/rice/cs/drjava/model/cache/DocumentCacheTest.java M src/edu/rice/cs/drjava/model/definitions/DefinitionsDocumentTest.java M src/edu/rice/cs/drjava/model/definitions/reducedmodel/ReducedModelControl.java M src/edu/rice/cs/drjava/model/RegionManager.java M src/edu/rice/cs/drjava/model/repl/History.java M src/edu/rice/cs/drjava/model/repl/newjvm/InterpreterJVM.java M src/edu/rice/cs/drjava/model/ConcreteRegionManager.java M src/edu/rice/cs/drjava/model/Query.java M src/edu/rice/cs/drjava/model/AbstractDJDocument.java M src/edu/rice/cs/drjava/model/DocumentRegion.java M src/edu/rice/cs/drjava/model/DummyGlobalModel.java M src/edu/rice/cs/drjava/model/AbstractGlobalModel.java M src/edu/rice/cs/drjava/model/DefaultLightWeightParsingControl.java M src/edu/rice/cs/drjava/model/GlobalModelOtherTest.java M src/edu/rice/cs/drjava/config/KeyStrokeOption.java M src/edu/rice/cs/drjava/config/OptionParser.java M src/edu/rice/cs/drjava/config/Option.java M src/edu/rice/cs/drjava/ui/MainFrame.java M src/edu/rice/cs/drjava/ui/InteractionsPane.java M src/edu/rice/cs/drjava/ui/RecentFileManager.java M src/edu/rice/cs/drjava/ui/KeyBindingManager.java M src/edu/rice/cs/drjava/ui/HTMLFrame.java M src/edu/rice/cs/drjava/ui/ErrorPanel.java M src/edu/rice/cs/drjava/ui/BrowserHistoryPanel.java M src/edu/rice/cs/drjava/ui/config/ConfigFrame.java M src/edu/rice/cs/drjava/ui/config/KeyStrokeOptionComponent.java M src/edu/rice/cs/drjava/ui/InsertVariableDialog.java M src/edu/rice/cs/drjava/ui/DefinitionsPaneTest.java M src/edu/rice/cs/drjava/ui/FindResultsPanel.java M src/edu/rice/cs/drjava/ui/InteractionsController.java M src/edu/rice/cs/drjava/ui/ReverseHighlighter.java M src/edu/rice/cs/drjava/ui/ProjectPropertiesFrame.java M src/edu/rice/cs/util/FileOps.java M src/edu/rice/cs/util/text/SwingDocument.java M src/edu/rice/cs/util/OrderedHashSet.java M src/edu/rice/cs/util/swing/HighlightManager.java M src/edu/rice/cs/util/NullFile.java M src/edu/rice/cs/util/sexp/Tokens.java git-svn-id: file:///tmp/test-svn/trunk@4620 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 2aadb81 commit c4ec4fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+273
-438
lines changed

drjava/src/edu/rice/cs/drjava/config/KeyStrokeOption.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
import javax.swing.KeyStroke;
4343
import java.awt.event.KeyEvent;
4444
import java.awt.Event;
45-
import java.util.Hashtable;
45+
import java.util.HashMap;
4646

4747
/** Class representing all configuration options with values of type KeyStroke. Only runs in the event thread, so no
4848
* synchronization is necessary (or advisable).*/
4949
public class KeyStrokeOption extends Option<KeyStroke> {
5050

5151
/** Storage for keystrokes.*/
52-
static Hashtable<Integer, String> keys = new Hashtable<Integer, String>();
52+
static HashMap<Integer, String> keys = new HashMap<Integer, String>();
5353
public static final KeyStroke NULL_KEYSTROKE = KeyStroke.getKeyStroke(0, 0);
5454
/** Standard constructor
5555
* @param key The name of this option.

drjava/src/edu/rice/cs/drjava/config/Option.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
import edu.rice.cs.util.swing.Utilities;
4040

41-
import java.util.Hashtable;
41+
import java.util.HashMap;
4242
import java.util.Vector;
4343
// TODO: Change the usage of these classes to Collections style.
4444
// TODO: Do these need to be synchronized?
@@ -64,8 +64,8 @@ public abstract class Option<T> extends OptionParser<T> implements FormatStrateg
6464
/** A hashtable that maps Configuration objects to a list of listeners for this particular option. Part of the magic
6565
* inner workings of this package.
6666
*/
67-
final Hashtable<Configuration,Vector<OptionListener<T>>> listeners =
68-
new Hashtable<Configuration,Vector<OptionListener<T>>>();
67+
final HashMap<Configuration,Vector<OptionListener<T>>> listeners =
68+
new HashMap<Configuration,Vector<OptionListener<T>>>();
6969

7070
/** Constructor that takes in a name and default value
7171
* @param name the name of this option (eg. "indent.level");

drjava/src/edu/rice/cs/drjava/config/OptionParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* END_COPYRIGHT_BLOCK*/
3636

3737
package edu.rice.cs.drjava.config;
38-
import java.util.Hashtable;
38+
import java.util.HashMap;
3939
/** The association of an OptionName with the ability to parse something to type T; the intended type
4040
* parameterization is covariant: if U extends T, then OptionParser<U> extends OptionParser<T>.
4141
*/
@@ -48,7 +48,7 @@ public abstract class OptionParser<T> implements ParseStrategy<T> {
4848
protected final T defaultValue;
4949

5050
/** An inner hashtable that maps DefaultOptionMaps to value T's. Part of the magic inner workings of this package. */
51-
final Hashtable<DefaultOptionMap,T> map = new Hashtable<DefaultOptionMap,T>();
51+
final HashMap<DefaultOptionMap,T> map = new HashMap<DefaultOptionMap,T>();
5252

5353
/** Constructor that takes in a name
5454
* @param name the name of this option (i.e. "indent.level");

drjava/src/edu/rice/cs/drjava/model/AbstractDJDocument.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
import java.util.Set;
7070
import java.util.StringTokenizer;
7171
import java.util.TreeMap;
72-
import java.util.Vector;
7372
import javax.swing.ProgressMonitor;
7473
import javax.swing.text.AbstractDocument;
7574
import javax.swing.text.AttributeSet;

drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
import java.util.Comparator;
6363
import java.util.Set;
6464
import java.util.LinkedHashSet;
65+
import java.util.HashMap;
6566
import java.util.HashSet;
66-
import java.util.Hashtable;
6767
import java.util.LinkedHashMap;
6868
import java.util.LinkedList;
6969
import java.util.List;
@@ -135,7 +135,6 @@
135135
import edu.rice.cs.plt.lambda.LambdaUtil;
136136
import edu.rice.cs.plt.lambda.Predicate;
137137

138-
139138
//import edu.rice.cs.util.CompletionMonitor;
140139
import edu.rice.cs.util.FileOpenSelector;
141140
import edu.rice.cs.util.FileOps;
@@ -268,7 +267,6 @@ public class AbstractGlobalModel implements SingleDisplayModel, OptionConstants,
268267

269268
/** @return new copy of list of find results managers for find result regions. */
270269
public List<RegionManager<MovingDocumentRegion>> getFindResultsManagers() {
271-
// System.err.println("getFindResultsManager called; returning " + _findResultsManagers + ")");
272270
return new LinkedList<RegionManager<MovingDocumentRegion>>(_findResultsManagers);
273271
}
274272

@@ -576,8 +574,8 @@ class ProjectFileGroupingState implements FileGroupingState {
576574
volatile File _workDir;
577575
volatile File _projectFile;
578576
final File[] _projectFiles;
579-
volatile Vector<File> _auxFiles; // distinct from _auxiliaryFiles in ProjectProfile
580-
private volatile Vector<File> _exclFiles; // distinct from _excludedFiles in ProjectProile and CompilerErrorPanel
577+
volatile ArrayList<File> _auxFiles; // distinct from _auxiliaryFiles in ProjectProfile
578+
private volatile ArrayList<File> _exclFiles; // distinct from _excludedFiles in ProjectProile and CompilerErrorPanel
581579
volatile Iterable<File> _projExtraClassPath;
582580
private boolean _isProjectChanged = false;
583581
volatile File _createJarFile;
@@ -599,9 +597,9 @@ class ProjectFileGroupingState implements FileGroupingState {
599597
_workDir = wd;
600598
_projectFile = project;
601599
_projectFiles = srcFiles;
602-
_auxFiles = new Vector<File>(auxFiles.length);
600+
_auxFiles = new ArrayList<File>(auxFiles.length);
603601
for(File f: auxFiles) { _auxFiles.add(f); }
604-
_exclFiles = new Vector<File>(excludedFiles.length);
602+
_exclFiles = new ArrayList<File>(excludedFiles.length);
605603
for(File f: excludedFiles) { _exclFiles.add(f); }
606604
_projExtraClassPath = cp;
607605

@@ -1494,7 +1492,7 @@ else if ( doc.isAuxiliaryFile()) {
14941492
* @param file where to save the project
14951493
* @param info
14961494
*/
1497-
public ProjectProfile _makeProjectProfile(File file, Hashtable<OpenDefinitionsDocument, DocumentInfoGetter> info)
1495+
public ProjectProfile _makeProjectProfile(File file, HashMap<OpenDefinitionsDocument, DocumentInfoGetter> info)
14981496
throws IOException {
14991497
ProjectProfile builder = new ProjectProfile(file);
15001498

@@ -1570,7 +1568,7 @@ else if (doc.isAuxiliaryFile()) {
15701568
/** Writes the project profile augmented by usage info to specified file. Assumes DrJava is in project mode.
15711569
* @param file where to save the project
15721570
*/
1573-
public void saveProject(File file, Hashtable<OpenDefinitionsDocument, DocumentInfoGetter> info) throws IOException {
1571+
public void saveProject(File file, HashMap<OpenDefinitionsDocument, DocumentInfoGetter> info) throws IOException {
15741572
// if file is read-only, ask if it should be made writable
15751573
if (file.exists() && !file.canWrite()) {
15761574
File[] res = _notifier.filesReadOnly(new File[] {file});
@@ -1600,7 +1598,7 @@ public void saveProject(File file, Hashtable<OpenDefinitionsDocument, DocumentIn
16001598
/** Writes the project profile in the old project format. Assumes DrJava is in project mode.
16011599
* @param file where to save the project
16021600
*/
1603-
public void exportOldProject(File file, Hashtable<OpenDefinitionsDocument, DocumentInfoGetter> info) throws IOException {
1601+
public void exportOldProject(File file, HashMap<OpenDefinitionsDocument, DocumentInfoGetter> info) throws IOException {
16041602
ProjectProfile builder = _makeProjectProfile(file, info);
16051603

16061604
// write to disk
@@ -1619,7 +1617,7 @@ public void exportOldProject(File file, Hashtable<OpenDefinitionsDocument, Docum
16191617
builder.getCreateJarFlags(), builder.getAutoRefreshStatus()));
16201618
}
16211619

1622-
public void reloadProject(File file, Hashtable<OpenDefinitionsDocument, DocumentInfoGetter> info) throws IOException {
1620+
public void reloadProject(File file, HashMap<OpenDefinitionsDocument, DocumentInfoGetter> info) throws IOException {
16231621
boolean projChanged = isProjectChanged();
16241622
ProjectProfile builder = _makeProjectProfile(file, info);
16251623
_loadProject(builder);

drjava/src/edu/rice/cs/drjava/model/BrowserHistoryManager.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ public class BrowserHistoryManager extends EventNotifier<RegionManagerListener<B
7575
*/
7676
// public boolean contains(DocumentRegion r) { return _regionSet.contains(r); }
7777

78-
private boolean equals(BrowserDocumentRegion r1, BrowserDocumentRegion r2) {
79-
return r1.getDocument() == r2.getDocument() && r1.getStartOffset() == r2.getStartOffset() &&
80-
r1.getEndOffset() == r2.getEndOffset();
81-
}
78+
// Not used
79+
// private boolean equals(BrowserDocumentRegion r1, BrowserDocumentRegion r2) {
80+
// return r1.getDocument() == r2.getDocument() && r1.getStartOffset() == r2.getStartOffset() &&
81+
// r1.getEndOffset() == r2.getEndOffset();
82+
// }
8283

8384
/** Add the supplied DocumentRegion r to the manager just above _current and set _current to refer to r. Only runs
8485
* in event thread after initialization. Notifies regionAdded listeners if _currentIndex is changed. Assumes

drjava/src/edu/rice/cs/drjava/model/ConcreteRegionManager.java

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@
4444
import java.util.LinkedHashSet;
4545
import java.util.HashMap;
4646
import java.util.HashSet;
47-
import java.util.Hashtable;
4847
import java.util.Iterator;
4948
import java.util.LinkedHashMap;
5049
import java.util.LinkedList;
5150
import java.util.List;
5251
import java.util.ListIterator;
5352
import java.util.SortedSet;
5453
import java.util.TreeSet;
55-
import java.util.Vector;
5654

5755
import javax.swing.SwingUtilities;
5856
//import javax.swing.tree.DefaultMutableTreeNode;
@@ -67,8 +65,8 @@ class ConcreteRegionManager<R extends OrderedDocumentRegion> extends EventNotifi
6765
RegionManager<R> {
6866

6967
/** Hashtable mapping documents to collections of regions. Primitive operations are thread safe. */
70-
private volatile Hashtable<OpenDefinitionsDocument, SortedSet<R>> _regions =
71-
new Hashtable<OpenDefinitionsDocument, SortedSet<R>>();
68+
private volatile HashMap<OpenDefinitionsDocument, SortedSet<R>> _regions =
69+
new HashMap<OpenDefinitionsDocument, SortedSet<R>>();
7270

7371
/** The domain of the _regions. This field can be extracted from _regions so it is provided to improve performance
7472
* Primitive operations are thread-safe.
@@ -93,10 +91,6 @@ private <T> T newDocumentRegion(OpenDefinitionsDocument odd, int start, int end)
9391
return (T) new DocumentRegion(odd, start, end);
9492
}
9593

96-
// public DefaultMutableTreeNode getTreeNode(OpenDefinitionsDocument doc) { return _treeNodes.get(doc); }
97-
//
98-
// public void setTreeNode(OpenDefinitionsDocument doc, DefaultMutableTreeNode node) { _treeNodes.put(doc, node); }
99-
10094
private SortedSet<R> getHeadSet(R r) {
10195
SortedSet<R> oddRegions = _regions.get(r.getDocument());
10296
if (oddRegions == null || oddRegions.isEmpty()) return emptySet();
@@ -187,26 +181,20 @@ public void addRegion(final R region) {
187181
SortedSet<R> docRegions = _regions.get(odd);
188182
if (docRegions == null) { // if necessary create a Hashtable entry for odd and insert it in the _documents set
189183
_documents.add(odd);
190-
docRegions = Collections.synchronizedSortedSet(new TreeSet<R>());
184+
docRegions = new TreeSet<R>();
191185
_regions.put(odd, docRegions);
192186
}
193187

194188
// Check for duplicate region
195-
final boolean alreadyContained = docRegions.contains(region);
196-
if (!alreadyContained) { // region does not already exist in manager
189+
final boolean alreadyPresent = docRegions.contains(region);
190+
if (! alreadyPresent) { // region does not already exist in manager
197191
docRegions.add(region); // modifies docRegions, which is part of _regions
198-
// Utilities.show("Region manager " + this + " added region " + region);
199-
// Utilities.show("docRegions for document " + odd + " = " + _regions.get(odd));
200192
}
201193

202-
// _current = region;
203-
// final int regionIndex = getIndexOf(region);
204-
// final String stackTrace = StringOps.getStackTrace();
205-
206194
assert _documents.contains(odd);
207195

208196
// only notify if the region was actually added
209-
if (! alreadyContained) {
197+
if (! alreadyPresent) {
210198
// notify. invokeLater unnecessary if it only runs in the event thread
211199
_lock.startRead();
212200
try { for (RegionManagerListener<R> l: _listeners) { l.regionAdded(region); } }
@@ -222,7 +210,6 @@ public void removeRegion(final R region) {
222210

223211
OpenDefinitionsDocument doc = region.getDocument();
224212
SortedSet<R> docRegions = _regions.get(doc);
225-
// System.err.println("ODD for region " + region + " = " + doc);
226213
// System.err.println("doc regions for " + doc + " = " + docRegions);
227214
if (docRegions == null) return; // since region is not stored in this region manager, exit!
228215
final boolean wasRemoved = docRegions.remove(region); // remove the region from the manager
@@ -250,32 +237,17 @@ public void removeRegions(final OpenDefinitionsDocument doc) {
250237
if (found) {
251238
// System.err.println("Removing document regions for " + doc + " in " + this);
252239
final SortedSet<R> regions = _regions.get(doc);
253-
// The following ugly line of code is dictated by the "fail fast" semantics of Java iterators and erasure generics
254-
for (Object r: regions.toArray()) { removeRegion((R) r); }
255-
// notify all listeners for all regions
256-
// _notifyRegionsRemoved(regions);
257-
// _regions.remove(doc); // done automatically when last region r in doc is removed
240+
// The following ugly line of code is dictated by the "fail fast" semantics of Java iterators
241+
while (! regions.isEmpty()) regions.remove(regions.first());
258242
}
259243
}
260-
261-
// private void _notifyRegionsRemoved(final Collection<R> regions) {
262-
// _lock.startRead();
263-
// try {
264-
// for (RegionManagerListener<R> l: _listeners) {
265-
// for (R r: regions) { l.regionRemoved(r); }
266-
// }
267-
// }
268-
// finally { _lock.endRead(); }
269-
// }
270244

271245
/** @return a Vector<R> containing the DocumentRegion objects for document odd in this mangager. */
272246
public SortedSet<R> getRegions(OpenDefinitionsDocument odd) { return _regions.get(odd); }
273247

274-
public Vector<R> getRegions() {
275-
Vector<R> regions = new Vector<R>();
248+
public ArrayList<R> getRegions() {
249+
ArrayList<R> regions = new ArrayList<R>();
276250
for (OpenDefinitionsDocument odd: _documents) regions.addAll(_regions.get(odd));
277-
// Utilities.show("in ConcreteRegionManager " + this + ",_documents = " + _documents);
278-
// Utilities.show("getRegions returning: " + regions);
279251
return regions;
280252
}
281253

@@ -288,7 +260,7 @@ public boolean contains(R region) {
288260

289261
/** Tells the manager to remove all regions. */
290262
public void clearRegions() {
291-
final Vector<R> regions = getRegions();
263+
final ArrayList<R> regions = getRegions();
292264
// Remove all regions in this manager
293265
_regions.clear();
294266
_documents.clear();

drjava/src/edu/rice/cs/drjava/model/DefaultLightWeightParsingControl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
import java.util.List;
4040
import java.util.LinkedList;
41-
import java.util.Hashtable;
41+
import java.util.HashMap;
4242
import javax.swing.text.*;
4343

4444
import edu.rice.cs.drjava.DrJava;
@@ -62,10 +62,10 @@ public final class DefaultLightWeightParsingControl implements LightWeightParsin
6262
private long _lastDelay = System.currentTimeMillis();
6363

6464
/** Last updates for the documents. */
65-
private Hashtable<OpenDefinitionsDocument, Long> _lastUpdates = new Hashtable<OpenDefinitionsDocument, Long>();
66-
65+
private HashMap<OpenDefinitionsDocument, Long> _lastUpdates = new HashMap<OpenDefinitionsDocument, Long>();
66+
6767
/** Enclosing class names for the documents. */
68-
private Hashtable<OpenDefinitionsDocument, String> _enclosingClassNames = new Hashtable<OpenDefinitionsDocument, String>();
68+
private HashMap<OpenDefinitionsDocument, String> _enclosingClassNames = new HashMap<OpenDefinitionsDocument, String>();
6969

7070
/** Flag to stop automatic updates. */
7171
private volatile boolean _running = false;

drjava/src/edu/rice/cs/drjava/model/DocumentRegion.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ private static Position createPosition(OpenDefinitionsDocument doc, int i) {
9191
// return o1.equals(o2);
9292
// }
9393

94-
/** Defines the equality relation on DocumentRegions. This equivalence relation on allocated objects is finer
95-
* grained than the equivalence relation induced by compareTo because it requires equality on Position objects,
96-
* not just equality of the current offsets of Positions.
94+
/** Defines the equality relation on DocumentRegions. This equivalence relation is consistent with the equivalence
95+
* relation induced by the compareTo method.
9796
*/
9897
public final boolean equals(Object o) {
9998
if (o == null || ! (o instanceof IDocumentRegion)) return false;

drjava/src/edu/rice/cs/drjava/model/DummyGlobalModel.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@
6666
import java.util.Arrays;
6767
import java.util.Collections;
6868
import java.util.Comparator;
69+
import java.util.HashMap;
6970
import java.util.HashSet;
70-
import java.util.Hashtable;
7171
import java.util.LinkedList;
7272
import java.util.List;
7373
import java.util.ListIterator;
74-
import java.util.Vector;
7574

7675
import edu.rice.cs.plt.tuple.Pair;
7776
import edu.rice.cs.util.FileOps;
@@ -259,11 +258,11 @@ public void configNewProject() throws IOException {
259258
throw new UnsupportedOperationException("Tried to call configNewProject on a Dummy");
260259
}
261260

262-
public void saveProject(File f, Hashtable<OpenDefinitionsDocument,DocumentInfoGetter> ht) throws IOException {
261+
public void saveProject(File f, HashMap<OpenDefinitionsDocument,DocumentInfoGetter> ht) throws IOException {
263262
throw new UnsupportedOperationException("Tried to call saveProject on a Dummy");
264263
}
265264

266-
public void reloadProject(File f, Hashtable<OpenDefinitionsDocument,DocumentInfoGetter> ht) throws IOException {
265+
public void reloadProject(File f, HashMap<OpenDefinitionsDocument,DocumentInfoGetter> ht) throws IOException {
267266
throw new UnsupportedOperationException("Tried to call reloadProject on a Dummy");
268267
}
269268

0 commit comments

Comments
 (0)