Skip to content

Commit aafaf7b

Browse files
author
rcartwright
committed
Separated working directory for master JVM from working directory for slave JVM. Fixed serious bug in hasOutOfSyncDocuments. Changed getFile() in ConcreteOpenDefDoc to return null instead of throwing an IllegalStateException on untitled files that do not yet have source files.
git-svn-id: file:///tmp/test-svn/trunk@3562 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent b555b0c commit aafaf7b

69 files changed

Lines changed: 1236 additions & 2532 deletions

File tree

Some content is hidden

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ private void checkFile(File relativeFile, String funnyName) throws IOException,
392392
Utilities.clearEventQueue();
393393
File root = doc.getSourceRoot();
394394
Utilities.clearEventQueue();
395+
// System.err.println("Source root is: " + root);
395396
assertEquals("source root", new File("").getCanonicalFile(), root);
396397

397398
// Close this doc to clean up after ourselves for the next check.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static void configureAndLoadDrJavaRoot(String[] args) {
180180
}
181181
catch (Throwable t) {
182182
// Show any errors to the System.err and in an AWTExceptionHandler
183-
System.err.println(t.getClass().getName() + ": " + t.getMessage());
183+
System.out.println(t.getClass().getName() + ": " + t.getMessage());
184184
t.printStackTrace(System.err);System.out.println("error thrown");
185185
new AWTExceptionHandler().handle(t);
186186
}
@@ -348,8 +348,8 @@ public static boolean classLoadersCanFind(String className) {
348348
/** Switches the config object to use a custom config file. Ensures that Java source files aren't
349349
* accidentally used.
350350
*/
351-
static void setPropertiesFile(String filename) {
352-
if (!filename.endsWith(".java")) _propertiesFile = new File(filename);
351+
static void setPropertiesFile(String fileName) {
352+
if (!fileName.endsWith(".java")) _propertiesFile = new File(fileName);
353353
}
354354

355355
/** Initializes the configuration object with the current notion of the properties file.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class IndentFiles {
7070
* @param args Command line arguments
7171
*/
7272
public static void main(String[] args) {
73-
Vector<String> filenames = new Vector<String>();
73+
Vector<String> fileNames = new Vector<String>();
7474
int indentLevel = 2;
7575
boolean silent = false;
7676
if (args.length < 1) _displayUsage();
@@ -86,9 +86,9 @@ public static void main(String[] args) {
8686
}
8787
}
8888
else if (arg.equals("-silent")) silent = true;
89-
else filenames.add(arg);
89+
else fileNames.add(arg);
9090
}
91-
indentFiles(filenames, indentLevel, silent);
91+
indentFiles(fileNames, indentLevel, silent);
9292
}
9393
}
9494

@@ -107,14 +107,14 @@ private static void _displayUsage() {
107107
* @param indentLevel The number of spaces to use for a level of indentation
108108
* @param silent Whether to print any output to System.out
109109
*/
110-
public static void indentFiles(Vector<String> filenames, int indentLevel, boolean silent) {
110+
public static void indentFiles(Vector<String> fileNames, int indentLevel, boolean silent) {
111111
//System.setProperty("java.awt.headless", "true"); // attempt headless AWT
112112
//System.out.println("Using Headless AWT: "+isHeadless());
113113
Indenter indenter = new Indenter(indentLevel);
114114

115115
if (!silent) System.out.println("DrJava - Indenting files:");
116-
for (int i = 0; i < filenames.size(); i++) {
117-
String fname = filenames.get(i);
116+
for (int i = 0; i < fileNames.size(); i++) {
117+
String fname = fileNames.get(i);
118118
File file = new File(fname);
119119
if (!silent) {
120120
System.out.print(" " + fname + " ... ");

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,16 @@ public <T> T setSetting(final Option<T> op, final T value) {
7979
}
8080

8181
/** Gets the current value of the given Option. */
82-
public <T> T getSetting(Option<T> op) {
83-
return map.getOption(op);
84-
}
82+
public <T> T getSetting(Option<T> op) { return map.getOption(op); }
8583

8684
/** Adds an OptionListener to the given Option, to be notified each time the option changes.
8785
* @param op Option to listen for changes on
8886
* @param l OptionListener wishing to listen
8987
*/
90-
public <T> void addOptionListener(Option<T> op, OptionListener<T> l) {
91-
op.addListener(this,l);
92-
}
88+
public <T> void addOptionListener(Option<T> op, OptionListener<T> l) { op.addListener(this,l); }
9389

9490
/** Removes an OptionListener from an Option to which it was listening. */
95-
public <T> void removeOptionListener(Option<T> op, OptionListener<T> l) {
96-
op.removeListener(this,l);
97-
}
91+
public <T> void removeOptionListener(Option<T> op, OptionListener<T> l) { op.removeListener(this,l); }
9892

9993
/** Resets to the default values, overwriting any existing values. */
10094
public void resetToDefaults() { OptionMapLoader.DEFAULT.loadInto(map); }
@@ -105,8 +99,8 @@ public <T> void removeOptionListener(Option<T> op, OptionListener<T> l) {
10599
/** Returns the exception caught during startup, or null if none were caught. */
106100
public Exception getStartupException() { return _startupException; }
107101

108-
/** Stores any exception caught during the creation of this Configuration object, so it can be displayed later by the UI.
109-
* @param e Exception caught during startup
102+
/** Stores exception caught during creation of this Configuration object, so it can be displayed later by the UI.
103+
* @param e Exception caught during startup
110104
*/
111105
public void storeStartupException(Exception e) { _startupException = e; }
112106

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

Lines changed: 0 additions & 109 deletions
This file was deleted.

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
*/
4141
public class FileOption extends Option<File> {
4242

43-
/** Special sentinal file indicating that this option is not set. Another definition of this File object is located
44-
* in edu.rice.cs.util.FileOps.
45-
*/
43+
/** Special sentinal file indicating that this option is not set. */
4644
public static final File NULL_FILE = new File("") {
4745
public String getAbsolutePath() { return ""; }
4846
public String getName() { return ""; }
@@ -53,8 +51,8 @@ public class FileOption extends Option<File> {
5351
/** @param key The name of this option. */
5452
public FileOption(String key, File def) { super(key,def); }
5553

56-
/** @param s The String to be parsed, must represent the absolute path of the File to be created.
57-
* @return The File object corresponding to path "p".
54+
/** @param s The String to be parsed, must represent a legal file path for the File to be created.
55+
* @return The absolute File object corresponding to the input path string.
5856
*/
5957
public File parse(String s) {
6058
if (s.trim().equals("")) return NULL_FILE;

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

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -52,45 +52,41 @@
5252
// TODO: Change the usage of these classes to Collections style.
5353
// TODO: Do these need to be synchronized?
5454

55-
/**
56-
* An instance of this class represents a configurable option in DrJava that has static type T.
57-
* Classes can extend this class and the rest of the Configuration typing framework will work
58-
* for it. Named subclasses aren't even necessary -- but may be convenient in order to re-use
59-
* code. For example, to make an anonymous class that handles options of static type Integer,
60-
* with the name "indent.level", you could use the following code:
61-
* <pre>
62-
* Option&lt;Integer&gt; INDENT_LEVEL = new Option&lt;Integer&gt;("indent.level") {
63-
* public Integer parse(String s) {
64-
* return new Integer(s);
65-
* }
66-
* };
67-
* </pre>
68-
* the above example is simple because Integers (like most data-type classes defined in the Java
69-
* ivaewhave handy toString() / parsing methods/constructors.
55+
/** An instance of this class represents a configurable option in DrJava that has static type T.
56+
* Classes can extend this class and the rest of the Configuration typing framework will work
57+
* for it. Named subclasses aren't even necessary -- but may be convenient in order to re-use
58+
* code. For example, to make an anonymous class that handles options of static type Integer,
59+
* with the name "indent.level", you could use the following code:
60+
* <pre>
61+
* Option&lt;Integer&gt; INDENT_LEVEL = new Option&lt;Integer&gt;("indent.level") {
62+
* public Integer parse(String s) {
63+
* return new Integer(s);
64+
* }
65+
* };
66+
* </pre>
67+
* The precedinjg example is simple because Integers (like most data-type classes defined in the Java
68+
* libraries) have handy toString() / parsing methods/constructors.
7069
*
71-
* @version $Id$
70+
* @version $Id$
7271
*/
7372
public abstract class Option<T> extends OptionParser<T> implements FormatStrategy<T> {
7473

75-
/**
76-
* a hashtable that maps Configuration Objects to a list of listeners for this
77-
* particular option. Part of the magic inner workings of this package.
74+
/** A hashtable that maps Configuration Objects to a list of listeners for this particular option. Part of the magic
75+
* inner workings of this package.
7876
*/
7977
final Hashtable<Configuration,Vector<OptionListener<T>>> listeners =
8078
new Hashtable<Configuration,Vector<OptionListener<T>>>();
8179

82-
/**
83-
* constructor that takes in a name and default value
84-
* @param name the name of this option (eg. "indent.level");
85-
* @param def the default value for this option (eg. "2")
80+
/** Constructor that takes in a name and default value
81+
* @param name the name of this option (eg. "indent.level");
82+
* @param def the default value for this option (eg. "2")
8683
*/
8784
public Option(String name, T def) { super(name,def); }
8885

89-
/**
90-
* the ability to format a statically typed T value to a String. Since T is an Object,
91-
* the default implementation uses the .toString() method.
92-
* @param value the statically-typed value to format into a String
93-
* @throws {@link NullPointerException} if value is null
86+
/** Formats a statically typed T value to a String. Since T is an Object, the default implementation uses the
87+
* toString() method.
88+
* @param value the statically-typed value to format into a String
89+
* @throws {@link NullPointerException} if value is null
9490
*/
9591
public String format(T value) { return value.toString(); }
9692

@@ -101,15 +97,11 @@ public abstract class Option<T> extends OptionParser<T> implements FormatStrateg
10197
// basically, it's achieved via a double-dispatch stunt, so that the type information
10298
// is saved.
10399

104-
/**
105-
* uses format() and getOption() so that any changes in format will automatically
106-
* be applied to getString().
107-
*/
100+
/** Uses format() and getOption() so that any changes in format will automatically be applied to getString(). */
108101
String getString(DefaultOptionMap om) {
109102
return format(getOption(om));
110103
}
111104

112-
113105
/** Sends an OptionEvent to all OptionListeners who have registered on this Option. */
114106
void notifyListeners(Configuration config, T val) {
115107
final Vector<OptionListener<T>> v = listeners.get(config);
@@ -123,7 +115,7 @@ public void run() {
123115
});
124116
}
125117

126-
/** magic listener-bag adder */
118+
/** Magic listener-bag adder */
127119
void addListener(Configuration c, OptionListener<T> l) {
128120
Vector<OptionListener<T>> v = listeners.get(c);
129121
if (v == null) {
@@ -133,13 +125,10 @@ void addListener(Configuration c, OptionListener<T> l) {
133125
v.add(l);
134126
}
135127

136-
/** magic listener-bag remover */
128+
/** Magic listener-bag remover */
137129
void removeListener(Configuration c, OptionListener<T> l) {
138130
Vector<OptionListener<T>> v = listeners.get(c);
139-
if (v==null) return;
140-
if (v.remove(l) && v.size() == 0) {
141-
listeners.remove(c);
142-
}
131+
if (v != null && v.remove(l) && v.size() == 0) listeners.remove(c); // v.remove(l) has a side effect!
143132
}
144133
}
145134

0 commit comments

Comments
 (0)