Skip to content

Commit 0e0a6cd

Browse files
author
rcartwright
committed
This revision is the initial implementation of a no-document-locking
version of drjava; it fixes a bug in unit testing with modified files that persists in the main trunk. The following files were modified: M src/edu/rice/cs/drjava/DrJavaTestCase.java M src/edu/rice/cs/drjava/IndentFiles.java M src/edu/rice/cs/drjava/DrJava.java M src/edu/rice/cs/drjava/DrJavaRoot.java M src/edu/rice/cs/drjava/model/DummyGlobalModelListener.java M src/edu/rice/cs/drjava/model/debug/jpda/JPDADebugger.java M src/edu/rice/cs/drjava/model/GlobalModelIOTest.java M src/edu/rice/cs/drjava/model/GlobalModelTestCase.java M src/edu/rice/cs/drjava/model/GlobalModel.java M src/edu/rice/cs/drjava/model/GlobalModelCompileSuccessTest.java M src/edu/rice/cs/drjava/model/DefaultGlobalModel.java M src/edu/rice/cs/drjava/model/GlobalModelCompileErrorsTest.java M src/edu/rice/cs/drjava/model/definitions/indent/IndentRuleWithTraceTest.java M src/edu/rice/cs/drjava/model/definitions/indent/IndentRuleWithTrace.java M src/edu/rice/cs/drjava/model/definitions/indent/IndentRuleQuestion.java M src/edu/rice/cs/drjava/model/definitions/indent/IndentRulesTestCase.java M src/edu/rice/cs/drjava/model/definitions/ColoringView.java M src/edu/rice/cs/drjava/model/definitions/DefinitionsDocument.java M src/edu/rice/cs/drjava/model/definitions/DefinitionsDocumentTest.java M src/edu/rice/cs/drjava/model/definitions/reducedmodel/BraceInfoTest.java M src/edu/rice/cs/drjava/model/definitions/IndentHelperTest.java M src/edu/rice/cs/drjava/model/definitions/IndentTest.java M src/edu/rice/cs/drjava/model/GlobalEventNotifier.java M src/edu/rice/cs/drjava/model/junit/DefaultJUnitModel.java M src/edu/rice/cs/drjava/model/junit/JUnitErrorModelTest.java M src/edu/rice/cs/drjava/model/repl/InteractionsDocument.java M src/edu/rice/cs/drjava/model/repl/HistoryTest.java M src/edu/rice/cs/drjava/model/repl/History.java M src/edu/rice/cs/drjava/model/repl/InteractionsScriptModel.java M src/edu/rice/cs/drjava/model/repl/InteractionsDJDocumentTest.java M src/edu/rice/cs/drjava/model/repl/InteractionsDJDocument.java M src/edu/rice/cs/drjava/model/repl/InteractionsModelTest.java M src/edu/rice/cs/drjava/model/repl/InteractionsModel.java M src/edu/rice/cs/drjava/model/repl/newjvm/MainJVM.java M src/edu/rice/cs/drjava/model/repl/newjvm/MainJVMRemoteI.java M src/edu/rice/cs/drjava/model/repl/newjvm/NewJVMTest.java M src/edu/rice/cs/drjava/model/repl/newjvm/ClassPathManager.java M src/edu/rice/cs/drjava/model/repl/DefaultInteractionsModel.java M src/edu/rice/cs/drjava/model/repl/RMIInteractionsModel.java M src/edu/rice/cs/drjava/model/repl/SimpleInteractionsModel.java M src/edu/rice/cs/drjava/model/GlobalModelJUnitTest.java M src/edu/rice/cs/drjava/model/AbstractDJDocument.java M src/edu/rice/cs/drjava/model/GlobalModelCompileIOTest.java M src/edu/rice/cs/drjava/model/DummyOpenDefDoc.java M src/edu/rice/cs/drjava/model/compiler/CompilerListener.java M src/edu/rice/cs/drjava/model/compiler/DefaultCompilerModel.java M src/edu/rice/cs/drjava/model/compiler/CompilerEventNotifier.java M src/edu/rice/cs/drjava/model/compiler/DummyCompilerListener.java M src/edu/rice/cs/drjava/model/GlobalModelCompileTest.java M src/edu/rice/cs/drjava/model/FindReplaceMachine.java M src/edu/rice/cs/drjava/model/AbstractGlobalModel.java M src/edu/rice/cs/drjava/model/GlobalModelOtherTest.java M src/edu/rice/cs/drjava/model/OpenDefinitionsDocument.java M src/edu/rice/cs/drjava/model/DJDocument.java M src/edu/rice/cs/drjava/config/Configuration.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/config/IntegerOption.java M src/edu/rice/cs/drjava/ui/MainFrame.java M src/edu/rice/cs/drjava/ui/DrJavaErrorPopup.java M src/edu/rice/cs/drjava/ui/DefinitionsPane.java M src/edu/rice/cs/drjava/ui/ErrorPanel.java M src/edu/rice/cs/drjava/ui/config/IntegerOptionComponent.java M src/edu/rice/cs/drjava/ui/config/ToolbarOptionComponent.java M src/edu/rice/cs/drjava/ui/config/StringOptionComponent.java M src/edu/rice/cs/drjava/ui/config/FontOptionComponent.java M src/edu/rice/cs/drjava/ui/config/ConfigPanel.java M src/edu/rice/cs/drjava/ui/config/ForcedChoiceOptionComponent.java M src/edu/rice/cs/drjava/ui/config/KeyStrokeOptionComponent.java M src/edu/rice/cs/drjava/ui/AbstractDJPane.java M src/edu/rice/cs/drjava/ui/BrowserHistoryPanel.java M src/edu/rice/cs/drjava/ui/MainFrameTest.java M src/edu/rice/cs/drjava/ui/BreakpointsPanel.java M src/edu/rice/cs/drjava/ui/RegionsTreePanel.java M src/edu/rice/cs/drjava/ui/InteractionsPaneTest.java M src/edu/rice/cs/drjava/ui/DefinitionsPaneTest.java M src/edu/rice/cs/drjava/ui/RegionsListPanel.java M src/edu/rice/cs/drjava/ui/FindReplacePanel.java M src/edu/rice/cs/drjava/ui/InteractionsController.java M src/edu/rice/cs/drjava/ui/JUnitPanel.java M src/edu/rice/cs/drjava/ui/DrJavaErrorHandler.java M src/edu/rice/cs/drjava/ui/AbstractConsoleController.java M src/edu/rice/cs/util/FileOps.java M src/edu/rice/cs/util/text/ConsoleDocument.java M src/edu/rice/cs/util/text/ConsoleDocumentTest.java M src/edu/rice/cs/util/text/AbstractDocumentInterface.java M src/edu/rice/cs/util/text/EditDocumentInterface.java M src/edu/rice/cs/util/text/SwingDocument.java M src/edu/rice/cs/util/text/ReadersWritersLocking.java M src/edu/rice/cs/util/swing/ScrollableListSelectionDialog.java M src/edu/rice/cs/util/StringOps.java git-svn-id: file:///tmp/test-svn/trunk@4540 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent b8bd7d0 commit 0e0a6cd

File tree

91 files changed

+1943
-1647
lines changed

Some content is hidden

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

91 files changed

+1943
-1647
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,8 @@ protected static void _saveConfig() {
463463

464464
/* Erase all non-final bindings created in this class. Only used in testing. */
465465
public static void cleanUp() {
466-
_propertiesFile = null;
467466
_filesToOpen.clear();
468467
_jvmArgs.clear();
469-
// _config = null; // appears to cause problems in cleanup
470468
}
471469

472470
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ public static void main(final String[] args) {
137137

138138
// Utilities.showDebug("Creating MainFrame");
139139

140-
try {
141-
_mainFrame = new MainFrame();
142-
}
140+
try { _mainFrame = new MainFrame(); }
143141
catch(RuntimeException e) {
144142
Throwable c = e.getCause();
145143
if ((c instanceof java.rmi.server.ExportException) && (c.getMessage().equals("Listen failed on port: 0"))) {
@@ -335,7 +333,7 @@ public static void drop(DropTargetDropEvent dropTargetDropEvent) {
335333
_mainFrame.drop(dropTargetDropEvent);
336334
}
337335

338-
/** Return the modal window listener if available, otherwise returns a non-modal dummy listener.
336+
/** Installs the modal window adapter if available, otherwise installs a non-modal dummy listener.
339337
* @param w window trying to get the modal window listener
340338
* @param toFrontAction action to be performed after the window has been moved to the front again
341339
* @param closeAction action to be performed when the window is closing
@@ -346,7 +344,7 @@ public static void installModalWindowAdapter(final Window w,
346344
_mainFrame.installModalWindowAdapter(w, toFrontAction, closeAction);
347345
}
348346

349-
/** Removethe modal window adapter.
347+
/** Removes the modal window adapter.
350348
* @param w window releasing the modal window adapter */
351349
public static void removeModalWindowAdapter(Window w) {
352350
_mainFrame.removeModalWindowAdapter(w);

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,17 @@ protected void setUp() throws Exception {
6363
Utilities.TEST_MODE = true;
6464
final String newName = System.getProperty(TEST_DRJAVA_CONFIG_PROPERTY);
6565
assert newName != null;
66-
if (newName != null) {
66+
// if (newName != null) {
6767
// Utilities.show("Setting '" + newName + "' as DrJava configuration file");
68-
DrJava.setPropertiesFile(newName);
69-
Utilities.clearEventQueue();
70-
DrJava._initConfig();
71-
Utilities.clearEventQueue();
72-
}
68+
Utilities.invokeLater(new Runnable() {
69+
public void run() {
70+
DrJava.setPropertiesFile(newName);
71+
// Utilities.clearEventQueue();
72+
DrJava._initConfig();
73+
// Utilities.clearEventQueue();
74+
}
75+
});
76+
// }
7377
}
7478

7579
/** Clean up for every test case. Only used in unit tests. Added because Windows would intermittently throw

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ public static void indentFiles(Vector<String> fileNames, int indentLevel, boolea
111111
try {
112112
String fileContents = IOUtil.toString(file);
113113
DefinitionsDocument doc = new DefinitionsDocument(indenter, new GlobalEventNotifier());
114-
doc.acquireWriteLock();
115-
try {
116-
doc._insertString(0, fileContents, null); // (no attributes)
117-
int docLen = doc.getLength();
118-
doc.indentLines(0, docLen);
119-
fileContents = doc.getText();
120-
}
121-
finally { doc.releaseWriteLock(); }
114+
// doc.acquireWriteLock();
115+
// try {
116+
doc._insertString(0, fileContents, null); // (no attributes)
117+
int docLen = doc.getLength();
118+
doc.indentLines(0, docLen);
119+
fileContents = doc.getText();
120+
// }
121+
// finally { doc.releaseWriteLock(); }
122122
IOUtil.writeStringToFile(file, fileContents);
123123
if (!silent) System.out.println("done.");
124124
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public Configuration(OptionMap om) {
6565
*/
6666
public <T> T setSetting(final Option<T> op, final T value) {
6767
T ret = map.setOption(op, value);
68+
// System.err.println("setSetting(" + op + ", " + value + ") called");
6869
Utilities.invokeLater(new Runnable() { public void run() { op.notifyListeners(Configuration.this, value); } });
6970
return ret;
7071
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class IntegerOption extends Option<Integer> {
4545
* @param def The default value for this option
4646
*/
4747
public IntegerOption(String key, Integer def) {
48-
super(key,def);
48+
super(key, def);
4949
}
5050

5151
/** @param s The String to be parsed.

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
*/
6262
public abstract class Option<T> extends OptionParser<T> implements FormatStrategy<T> {
6363

64-
/** A hashtable that maps Configuration Objects to a list of listeners for this particular option. Part of the magic
64+
/** 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
*/
6767
final Hashtable<Configuration,Vector<OptionListener<T>>> listeners =
@@ -90,10 +90,12 @@ public abstract class Option<T> extends OptionParser<T> implements FormatStrateg
9090
String getString(DefaultOptionMap om) { return format(getOption(om)); }
9191

9292
/** Sends an OptionEvent to all OptionListeners who have registered on this Option. */
93-
void notifyListeners(Configuration config, T val) {
93+
synchronized void notifyListeners(Configuration config, T val) {
9494
final Vector<OptionListener<T>> v = listeners.get(config);
95+
// System.err.println("Notifying " + v + " with value " + val);
9596
if (v == null) return; // no listeners
9697
final OptionEvent<T> e = new OptionEvent<T>(this, val);
98+
// System.err.println("OptionEvent = " + e);
9799
Utilities.invokeLater(new Runnable() {
98100
public void run() {
99101
for (int i = 0; i < v.size(); ++i) v.get(i).optionChanged(e);
@@ -102,7 +104,7 @@ public void run() {
102104
}
103105

104106
/** Magic listener-bag adder */
105-
void addListener(Configuration c, OptionListener<T> l) {
107+
synchronized void addListener(Configuration c, OptionListener<T> l) {
106108
Vector<OptionListener<T>> v = listeners.get(c);
107109
if (v == null) {
108110
v = new Vector<OptionListener<T>>();
@@ -112,7 +114,7 @@ void addListener(Configuration c, OptionListener<T> l) {
112114
}
113115

114116
/** Magic listener-bag remover */
115-
void removeListener(Configuration c, OptionListener<T> l) {
117+
synchronized void removeListener(Configuration c, OptionListener<T> l) {
116118
Vector<OptionListener<T>> v = listeners.get(c);
117119
if (v != null && v.remove(l) && v.size() == 0) listeners.remove(c); // v.remove(l) has a side effect!
118120
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public abstract class OptionParser<T> implements ParseStrategy<T> {
4545
* and a String is immutable.
4646
*/
4747
public final String name;
48-
private final T defaultValue;
48+
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. */
5151
final Hashtable<DefaultOptionMap,T> map = new Hashtable<DefaultOptionMap,T>();
@@ -73,6 +73,9 @@ public abstract class OptionParser<T> implements ParseStrategy<T> {
7373
*/
7474
public abstract T parse(String value);
7575

76+
/** Returns a string representation of this OptionParser/Option suitable for debugging. */
77+
public String toString() { return "Option<" + name + ", " + defaultValue + ">"; }
78+
7679
/* PACKAGE PRIVATE MAGIC STUFF
7780
* This package-private magic stuff makes all of the config "magic" types work. Basically, it's achieved via a
7881
* double-dispatch stunt, so that the type information is saved. */

0 commit comments

Comments
 (0)