Skip to content

Commit e94a01f

Browse files
committed
This revision includes minor cleanups of the code base.
The following files were modified or deleted: deleted: drjava/lib/looks-2.2.2.jar modified: drjava/src/edu/rice/cs/drjava/DrJavaTestCase.java modified: drjava/src/edu/rice/cs/drjava/model/AbstractGlobalModel.java modified: drjava/src/edu/rice/cs/drjava/model/DefaultGlobalModel.java modified: drjava/src/edu/rice/cs/drjava/model/GlobalModel.java modified: drjava/src/edu/rice/cs/drjava/model/GlobalModelCompileSuccessTest.java modified: drjava/src/edu/rice/cs/drjava/model/JDKToolsLibrary.java modified: drjava/src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java modified: drjava/src/edu/rice/cs/drjava/model/cache/DocumentCache.java modified: drjava/src/edu/rice/cs/drjava/model/compiler/DefaultCompilerModel.java modified: drjava/src/edu/rice/cs/drjava/model/compiler/Javac160FilteringCompiler.java modified: drjava/src/edu/rice/cs/drjava/model/debug/jpda/DebugContextTest.java modified: drjava/src/edu/rice/cs/drjava/model/debug/jpda/DebugTest.java modified: drjava/src/edu/rice/cs/drjava/model/repl/DefaultInteractionsModel.java modified: drjava/src/edu/rice/cs/drjava/model/repl/History.java modified: drjava/src/edu/rice/cs/drjava/model/repl/InteractionsModel.java modified: drjava/src/edu/rice/cs/drjava/model/repl/InteractionsModelCallback.java modified: drjava/src/edu/rice/cs/drjava/model/repl/newjvm/InterpreterJVM.java modified: drjava/src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java modified: drjava/src/edu/rice/cs/drjava/project/ProjectFileParser.java modified: drjava/src/edu/rice/cs/drjava/project/ProjectTest.java modified: drjava/src/edu/rice/cs/drjava/ui/ClipboardHistoryFrame.java modified: drjava/src/edu/rice/cs/util/XMLConfig.java modified: drjava/src/edu/rice/cs/util/newjvm/AbstractMasterJVM.java modified: drjava/src/edu/rice/cs/util/sexp/Atom.java deleted: drjava/src/edu/rice/cs/util/sexp/BoolAtom.java deleted: drjava/src/edu/rice/cs/util/sexp/NumberAtom.java modified: drjava/src/edu/rice/cs/util/sexp/SExpParser.java modified: drjava/src/edu/rice/cs/util/sexp/SExpParserTest.java modified: drjava/src/edu/rice/cs/util/sexp/SExpVisitor.java deleted: drjava/src/edu/rice/cs/util/sexp/TextAtom.java modified: drjava/src/edu/rice/cs/util/swing/CheckBoxJList.java modified: platform/src-jdk7/edu/rice/cs/drjava/model/compiler/Javac170Compiler.java
1 parent a3e3f4c commit e94a01f

33 files changed

+1800
-1887
lines changed

drjava/lib/looks-2.2.2.jar

-397 KB
Binary file not shown.

drjava/src/edu/rice/cs/drjava/DrJavaTestCase.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ protected void setUp() throws Exception {
6969
Utilities.TEST_MODE = true;
7070
final String newName = System.getProperty("drjava.test.config");
7171
assert newName != null;
72+
73+
Utilities.show("newName = '" + newName + "'");
7274

7375
if (newName != null) { // in deployed code, assertion checking may be turned off
7476
Utilities.invokeAndWait(new Runnable() {

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,8 @@ public boolean accept(OpenDefinitionsDocument d) {
19901990

19911991
/** Performs any needed operations on the model after project files have been closed. This method is not
19921992
* responsible for closing any files; both the files in the project and the project file have already been
1993-
* closed (by MainFrame._closeProject()). Resets interations unless suppressReset is true.
1993+
* closed (by MainFrame._closeProject()). Resets interations unless suppressReset is true, which only happens
1994+
* when DrJava is quitting.
19941995
*/
19951996
public void closeProject(boolean suppressReset) {
19961997
setDocumentNavigator(new AWTContainerNavigatorFactory<OpenDefinitionsDocument>().
@@ -2697,7 +2698,11 @@ public void updateSyntaxHighlighting() {
26972698
* The GlobalModel interacts with DefinitionsDocuments through this wrapper.<br>
26982699
* This call was formerly called the <code>DefinitionsDocumentHandler</code> but was renamed (2004-Jun-8) to be more
26992700
* descriptive/intuitive.
2700-
* Note that this class has a natural ordering that determines a coarser equivalence relation than equals.
2701+
*
2702+
* Note that this class has a natural ordering based on hashCode (with LexiName as a tiebreaker) that determines a
2703+
* coarser equivalence relation than equals.
2704+
* NOTE: do not override equals or hashCode for this class or any descendants because objects of this class are mutable
2705+
* and used as hash keys.
27012706
*/
27022707
class ConcreteOpenDefDoc implements OpenDefinitionsDocument {
27032708

@@ -2770,7 +2775,7 @@ private ConcreteOpenDefDoc(File f, File dir, long stamp) {
27702775
_cacheAdapter = _cache.register(this, ddr);
27712776
} catch(IllegalStateException e) { throw new UnexpectedException(e); }
27722777

2773-
/* The following table is not affected by inconsistency between hashCode/equals in DocumentRegion, because
2778+
/* The following table is not affected by the inconsistency between hashCode and equals in DocumentRegion, because
27742779
* BrowserDocumentRegion is NOT a subclass of DocumentRegion. */
27752780
_browserRegions = new HashSet<BrowserDocumentRegion>();
27762781
}
@@ -3651,7 +3656,8 @@ public void removeFromDebugger() { /* do nothing because it is called in methods
36513656

36523657
public String toString() { return getFileName(); }
36533658

3654-
/** Orders ODDs by their lexical names. Note that equals defines a finer equivalence relation than compareTo. */
3659+
/** Orders ODDs by <hashCode, LexiName>. Note that equals defines a finer equivalence relation than compareTo because
3660+
* unequal ODDs could have the same LexiName. */
36553661
public int compareTo(OpenDefinitionsDocument o) {
36563662
int diff = hashCode() - o.hashCode();
36573663
if (diff != 0) return diff;

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,11 @@ public void ensureJVMStarterFinished() {
430430

431431
public void resetInteractions(File wd) { resetInteractions(wd, false); }
432432

433-
/** Clears and resets the slave JVM with working directory wd. Also clears the console if the option is
434-
* indicated (on by default). The reset operation is suppressed if the existing slave JVM has not been
435-
* used, {@code wd} matches its working directory, and forceReset is false. {@code wd} may be {@code null}
436-
* if a valid directory cannot be determined. In that case, the former working directory is used. This
437-
* method may run outside the event thread.
433+
/** Clears and resets the slave JVM with working directory wd. Also clears the console if the option is indicated
434+
* (on by default). The reset operation is suppressed (as an optimization) if the existing slave JVM has not been
435+
* used, {@code wd} matches its working directory, and forceReset is false. {@code wd} may be {@code null} if a
436+
* valid directory cannot be determined. In that case, the former working directory is used. This method may run
437+
* outside the event thread.
438438
*/
439439
public void resetInteractions(File wd, boolean forceReset) {
440440
assert _interactionsModel._pane != null;
@@ -446,6 +446,7 @@ public void resetInteractions(File wd, boolean forceReset) {
446446
forceReset |= !wd.equals(workDir);
447447
// update the setting
448448
DrJava.getConfig().setSetting(LAST_INTERACTIONS_DIRECTORY, wd);
449+
449450
getDebugger().setAutomaticTraceEnabled(false);
450451
_interactionsModel.resetInterpreter(wd, forceReset);
451452
debug.logEnd();

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,13 @@ public void openFolder(File dir, boolean rec, String ext)
326326
*/
327327
public InteractionsDJDocument getSwingInteractionsDocument();
328328

329-
/** Clears and resets the interactions pane in the specified working directory, provided that the operation has some effect. */
329+
/** Clears and resets the interactions pane in the specified working directory. Convenience form of the following
330+
* method. */
330331
public void resetInteractions(File wd);
331332

332-
/** Clears and resets the interactions pane in the specified working directory. */
333+
/** Clears and resets the interactions pane in the specified working directory. Usually called by preceding method.
334+
* Invoked by "Reset interactions" command (in MainFrame) and as part of other actions such as the run, project
335+
* loading, compilation and unit testing commands.*/
333336
public void resetInteractions(File wd, boolean forceReset);
334337

335338
/** Interprets the current given text at the prompt in the interactions pane. */

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
*/
4949
public final class GlobalModelCompileSuccessTest extends GlobalModelCompileSuccessTestCase {
5050

51-
/** Tests calling compileAll with different source roots works.
52-
*/
51+
/** Tests calling compileAll with different source roots works. */
5352
public void testCompileAllDifferentSourceRoots() throws BadLocationException, IOException, InterruptedException {
5453
// System.out.println("testCompileAllDifferentSourceRoots()");
5554
File aDir = new File(_tempDir, "a");

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ public static String adapterForCompiler(JavaVersion.FullVersion version) {
118118

119119
public static String adapterForDebugger(JavaVersion.FullVersion version) {
120120
switch (version.majorVersion()) {
121+
case FUTURE:
122+
case JAVA_8:
121123
case JAVA_7:
122124
case JAVA_6:
123125
case JAVA_5: return "edu.rice.cs.drjava.model.debug.jpda.JPDADebugger";
@@ -130,12 +132,13 @@ protected static CompilerInterface getCompilerInterface(String className, FullVe
130132
List<File> bootClassPath = null;
131133
String bootProp = System.getProperty("sun.boot.class.path");
132134
if (bootProp != null) { bootClassPath = CollectUtil.makeList(IOUtil.parsePath(bootProp)); }
133-
File toolsJar = edu.rice.cs.drjava.DrJava.getConfig().getSetting(edu.rice.cs.drjava.config.OptionConstants.JAVAC_LOCATION);
135+
File toolsJar =
136+
edu.rice.cs.drjava.DrJava.getConfig().getSetting(edu.rice.cs.drjava.config.OptionConstants.JAVAC_LOCATION);
134137
try {
135138
Class<?>[] sig = { FullVersion.class, String.class, List.class };
136139
Object[] args = { version, "the runtime class path", bootClassPath };
137140
CompilerInterface attempt = (CompilerInterface) ReflectUtil.loadObject(className, sig, args);
138-
msg(" attempt = " + attempt + ", isAvailable() = "+attempt.isAvailable());
141+
msg(" attempt = " + attempt + ", isAvailable() = " + attempt.isAvailable());
139142
if (attempt.isAvailable()) { return attempt; }
140143
}
141144
catch (ReflectException e) { /* can't load */ }

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ else if (f.getName().equals("tools.jar")) {
209209
bootClassPath.add(f);
210210
for(File acf: additionalCompilerFiles) { bootClassPath.add(acf); };
211211
}
212-
if (additionalBootClassPath!=null) { bootClassPath.addAll(additionalBootClassPath); }
212+
if (additionalBootClassPath != null) { bootClassPath.addAll(additionalBootClassPath); }
213213
if (bootClassPath.isEmpty()) { bootClassPath = null; } // null defers to the compiler's default behavior
214214

215215
try {
@@ -464,13 +464,15 @@ protected static LinkedHashMap<File,Set<JDKDescriptor>> getDefaultSearchRoots()
464464

465465
/* Entries for Linux java packages */
466466
addIfDir(new File("/usr/lib/jvm"), roots);
467+
addIfDir(new File("/usr/lib/jvm/java-8-oracle"), roots);
468+
addIfDir(new File("/usr/lib/jvm/java-8-openjdk"), roots);
467469
addIfDir(new File("/usr/lib/jvm/java-7-oracle"), roots);
468470
addIfDir(new File("/usr/lib/jvm/java-7-openjdk"), roots);
469471
addIfDir(new File("/usr/lib/jvm/java-6-sun"), roots);
470472
addIfDir(new File("/usr/lib/jvm/java-6-openjdk"), roots);
471473
addIfDir(new File("/usr/lib/jvm/java-1.5.0-sun"), roots);
472474

473-
addIfDir(new File("/home/javaplt/java/Linux-i686"), roots);
475+
// addIfDir(new File("/home/javaplt/java/Linux-i686"), roots);
474476

475477
return roots;
476478
}

drjava/src/edu/rice/cs/drjava/model/cache/DocumentCache.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
* <p>
7474
* Since the cache and document managers can both be concurrently accessed from multiple threads, the methods in the
7575
* DocumentCache and DocManager classes are synchronized. Some operations require locks on both the cache and a
76-
* document manager, but the code is written so that none of require these locks to be held simultaneously.
76+
* document manager, but the code is written so that none of them require these locks to be held simultaneously.
7777
*/
7878

7979
public class DocumentCache {
@@ -86,6 +86,7 @@ public class DocumentCache {
8686
/** invariant _residentQueue.size() <= CACHE_SIZE */
8787
private volatile int CACHE_SIZE;
8888

89+
/** Data structure representing the queue of resident unmodified documents. */
8990
private final LinkedHashSet<DocManager> _residentQueue;
9091

9192
private final Object _cacheLock = new Object();
@@ -140,11 +141,15 @@ public void setCacheSize(int size) {
140141
private static final int UNTITLED = 1; // An untitled document not in queue (may or may not be modified)
141142
private static final int NOT_IN_QUEUE = 2; // Virtualized and not in the QUEUE
142143
private static final int UNMANAGED = 3; // A modified, titled document not in the queue
144+
143145
/** Note: before extending this table, check that the extension does not conflict with isUnmangedOrUntitled() */
144146

145147
/** Manages the retrieval of a document for a corresponding open definitions document. This manager only
146148
* maintains its document data if it contained in _residentQueue, which is maintained using a round-robin
147149
* replacement scheme.
150+
*
151+
* NOTE: DO NOT OVERRIDE hashcode or equals for DocManager or any descendant of DocManager! DocManagers are mutable
152+
* yet they are used as hash keys.
148153
*/
149154
private class DocManager implements DCacheAdapter {
150155

drjava/src/edu/rice/cs/drjava/model/compiler/DefaultCompilerModel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ private void _doCompile(List<OpenDefinitionsDocument> docs) throws IOException {
254254
}
255255

256256
Utilities.invokeLater(new Runnable() { public void run() { _notifier.compileStarted(); } });
257+
257258
try {
258259
if (! packageErrors.isEmpty()) { _distributeErrors(packageErrors); }
259260
else {

0 commit comments

Comments
 (0)