Skip to content

Commit 3a763dc

Browse files
author
rcartwright
committed
This commit includes many small changes motivated by bug fixes and
modifications made to the DrScala code base. At some point, we need to refactor these code bases so they have a common core. The following files were modified: M src/edu/rice/cs/util/FileOps.java M src/edu/rice/cs/util/swing/DelegatingAction.java M src/edu/rice/cs/drjava/model/junit/ConcJUnitUtils.java M src/edu/rice/cs/drjava/model/AbstractDJDocument.java M src/edu/rice/cs/drjava/model/debug/jpda/JPDADebugger.java M src/edu/rice/cs/drjava/model/debug/jpda/PendingRequestManager.java M src/edu/rice/cs/drjava/model/compiler/JavacCompiler.java M src/edu/rice/cs/drjava/model/compiler/LanguageLevelStackTraceMapper.java M src/edu/rice/cs/drjava/model/definitions/indent/ActionStartPrevStmtPlus.java M src/edu/rice/cs/drjava/model/definitions/indent/QuestionNewParenPhrase.java M src/edu/rice/cs/drjava/config/OptionConstants.java M src/edu/rice/cs/drjava/config/ConfigOptionListeners.java M src/edu/rice/cs/drjava/project/ProjectProfile.java M src/edu/rice/cs/drjava/ui/DefinitionsPaneTest.java M src/edu/rice/cs/drjava/ui/config/ConfigFrame.java M src/edu/rice/cs/drjava/ui/config/ConfigDescriptions.java M src/edu/rice/cs/drjava/ui/config/VectorOptionComponent.java M src/edu/rice/cs/drjava/ui/avail/GUIAvailabilityNotifier.java M src/edu/rice/cs/drjava/ui/DefinitionsPane.java M src/edu/rice/cs/drjava/ui/FindReplacePanel.java M src/edu/rice/cs/drjava/ui/MainFrame.java M src/edu/rice/cs/drjava/DrJavaRoot.java git-svn-id: file:///tmp/test-svn/trunk@5611 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent c7cf978 commit 3a763dc

22 files changed

Lines changed: 739 additions & 740 deletions

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ public class DrJavaRoot {
8282

8383
// /** This field is only used in the instance of this class in the Interpreter JVM. */
8484

85-
private static SimpleInteractionsWindow _debugConsole = null;
85+
private static volatile SimpleInteractionsWindow _debugConsole = null;
8686

87-
private static boolean anyLineNumbersSpecified = false;
87+
private static volatile boolean anyLineNumbersSpecified = false;
8888

8989
/** Main frame of this DrJava instance. */
90-
private static MainFrame _mainFrame = null;
90+
private static volatile MainFrame _mainFrame = null;
9191

9292
/* Config objects can't be public static final, since we have to delay construction until we know the
9393
* config file's location. (Might be specified on command line.) Instead, use accessor methods to
@@ -127,7 +127,7 @@ public static void main(final String[] args) {
127127
"removing the key \"plastic.theme\" and restarting DrJava.\n" +
128128
"In the meantime, the system default Look and Feel will be used.\n";
129129
String failureTitle = "Theme not found";
130-
if(Utilities.isPlasticLaf(configLAFName)) {
130+
if (Utilities.isPlasticLaf(configLAFName)) {
131131
String themeName = PLASTIC_THEMES_PACKAGE + "." + DrJava.getConfig().getSetting(PLASTIC_THEMES);
132132
try {
133133
PlasticTheme theme = (PlasticTheme) Class.forName(themeName).getConstructor(new Class<?>[]{ }).newInstance();
@@ -321,7 +321,7 @@ public static void dragEnter(DropTargetDragEvent dropTargetDragEvent) {
321321
_mainFrame.dragEnter(dropTargetDragEvent);
322322
}
323323

324-
/** User dropped something on the component. */
324+
/** User dropped something on the component. Only runs in the event thread. */
325325
public static void drop(DropTargetDropEvent dropTargetDropEvent) {
326326
_mainFrame.drop(dropTargetDropEvent);
327327
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public static boolean checkHeapSize(long heapSize) {
436436
}
437437
catch(java.io.IOException e) { exitValue = 1; }
438438
catch(InterruptedException e) { exitValue = 1; }
439-
return (exitValue==0);
439+
return (exitValue == 0);
440440
}
441441

442442
/** Class that gets executed to check if the selected heap size is possible. */

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,22 +306,18 @@ static class LookAndFeels {
306306

307307
private static boolean _registered = false;
308308

309-
/** Return the look-and-feel to use by default */
309+
/** Return the look-and-feel class name to use by default */
310310
public static String getDefaultLookAndFeel() {
311311
if (PlatformFactory.ONLY.isMacPlatform())
312312
return UIManager.getSystemLookAndFeelClassName(); // Mac: Let the system decide.
313-
else if (PlatformFactory.ONLY.isWindowsPlatform())
314-
return UIManager.getCrossPlatformLookAndFeelClassName(); // Windows: Metal, because the Windows LAF is ugly
315-
else {
316-
if (JavaVersion.CURRENT.supports(JavaVersion.JAVA_6)) {
317-
// Linux with Java 6: Let the system decide. Probably GTK, which is ok.
318-
return UIManager.getSystemLookAndFeelClassName();
319-
}
320-
else {
321-
// Linux with Java older than Java 6: Metal
322-
return UIManager.getCrossPlatformLookAndFeelClassName();
323-
}
313+
else // Set CrossPlatform "Nimbus" LookAndFeel
314+
try {
315+
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
316+
if ("Nimbus".equals(info.getName())) return info.getClassName();
317+
} catch (Exception e) {
318+
// If Nimbus is not available, fall through and use CrossPlatformLookAndFeel
324319
}
320+
return UIManager.getCrossPlatformLookAndFeelClassName();
325321
}
326322

327323
/** Need to ensure that a look-and-feel can be instantiated and is valid.
@@ -330,7 +326,7 @@ else if (PlatformFactory.ONLY.isWindowsPlatform())
330326
* @return the list of available look-and-feel classnames
331327
*/
332328
public static ArrayList<String> getLookAndFeels() {
333-
if(!_registered && !PlatformFactory.ONLY.isMacPlatform()) {
329+
if(! _registered && ! PlatformFactory.ONLY.isMacPlatform()) {
334330
for(String[] newLaf : _registerLAFs) {
335331
try {
336332
Class.forName(newLaf[1]);
@@ -347,7 +343,8 @@ public static ArrayList<String> getLookAndFeels() {
347343
try {
348344
String currName = lafis[i].getClassName();
349345
LookAndFeel currLAF = (LookAndFeel) Class.forName(currName).newInstance();
350-
if (currLAF.isSupportedLookAndFeel()) lookAndFeels.add(currName);
346+
// Filter out "gtk" LookAndFeel; it is broken on Linux in several ways
347+
if (currLAF.isSupportedLookAndFeel() && ! currName.contains("gtk")) lookAndFeels.add(currName);
351348
}
352349
// failed to load/instantiate class, or it is not supported; it is not a valid choice.
353350
catch (ClassNotFoundException e) { /* do nothing */ }

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public abstract class AbstractDJDocument extends SwingDocument implements DJDocu
106106
// /** Constant specifying how large pos must be before incremental analysis is applied in posInParenPhrase */
107107
// public static final int POS_THRESHOLD = 10000;
108108
/** The set of closing braces recognized in most indenting operations. */
109-
public static final char[] CLOSING_BRACES = new char[] {'}', ')'};
109+
public static final char[] CLOSING_BRACES = {'}', ')'};
110110

111111
/*-------- FIELDS ----------*/
112112

@@ -244,9 +244,6 @@ protected static HashSet<String> _makePrimTypes() {
244244
return prims;
245245
}
246246

247-
// /** Computes the maximum of x and y. */
248-
// private int max(int x, int y) { return x <= y? y : x; }
249-
250247
/** Return all highlight status info for text between start and end. This should collapse adjoining blocks with the
251248
* same status into one. ONLY runs in the event thread. Perturbs _currentLocation to improve performance.
252249
*/
@@ -446,8 +443,8 @@ private void _addCharToReducedModel(char curChar) {
446443
}
447444

448445
/** Get the current location of the cursor in the document. Unlike the usual swing document model, which is
449-
* stateless, we maintain a cursor position within our implementation of the reduced model. Can be modified
450-
* by any thread locking _reduced. The returned value may be stale if _reduced lock is not held
446+
* stateless, we maintain a cursor position within our implementation of the reduced model. Only accessed
447+
* in the event thread.
451448
* @return where the cursor is as the number of characters into the document
452449
*/
453450
public int getCurrentLocation() { return _currentLocation; }
@@ -974,7 +971,7 @@ public void indentLines(int selStart, int selEnd, Indenter.IndentReason reason,
974971
// Utilities.showDebug("Indenting line at offset " + selStart);
975972
if (_indentLine(reason)) {
976973
setCurrentLocation(oldPosition.getOffset()); // moves currentLocation back to original offset on line
977-
if (onlyWhiteSpaceBeforeCurrent()) move(_getWhiteSpace()); // passes any additional spaces before firstNonWS
974+
if (onlySpacesBeforeCurrent()) move(_getWhiteSpace()); // passes any additional spaces before firstNonWS
978975
}
979976
}
980977
else _indentBlock(selStart, selEnd, reason, pm);
@@ -1065,8 +1062,9 @@ public int getIntelligentBeginLinePos(int currPos) throws BadLocationException {
10651062
return firstChar;
10661063
}
10671064

1068-
/** Returns the number of blanks in the indent prefix for the start of the statement identified by pos. Uses a
1069-
* default set of delimiters. (';', '{', '}') and a default set of whitespace characters (' ', '\t', n', ',')
1065+
/** Returns the number of blanks in the indent prefix for the start of the statement identified by pos assuming
1066+
* statement is already properly indented. Uses a default set of delimiters. (';', '{', '}') and a default set
1067+
* of whitespace characters (' ', '\t', n', ',')
10701068
* @param pos Cursor position
10711069
*/
10721070
public int _getIndentOfCurrStmt(int pos) {
@@ -1075,8 +1073,8 @@ public int _getIndentOfCurrStmt(int pos) {
10751073
return _getIndentOfCurrStmt(pos, delims, whitespace);
10761074
}
10771075

1078-
/** Returns the number of blanks in the indent prefix of the start of the statement identified by pos. Uses a
1079-
* default set of whitespace characters: {' ', '\t', '\n', ','}
1076+
/** Returns the number of blanks in the indent prefix of the start of the statement identified by pos assuming
1077+
* statement is already properly indented. Uses a default set of whitespace characters: {' ', '\t', '\n', ','}
10801078
* @param pos Cursor position
10811079
*/
10821080
public int _getIndentOfCurrStmt(int pos, char[] delims) {
@@ -1091,7 +1089,7 @@ public int _getIndentOfCurrStmt(int pos, char[] delims) {
10911089
* @param whitespace characters to skip when looking for beginning of next statement
10921090
*/
10931091
public int _getIndentOfCurrStmt(final int pos, final char[] delims, final char[] whitespace) {
1094-
/* */ assert Utilities.TEST_MODE || EventQueue.isDispatchThread();
1092+
assert Utilities.TEST_MODE || EventQueue.isDispatchThread();
10951093

10961094
try {
10971095
// Check cache
@@ -1108,7 +1106,7 @@ public int _getIndentOfCurrStmt(final int pos, final char[] delims, final char[]
11081106

11091107
if (prevDelim == -1) reachedStart = true; // no delimiter found
11101108

1111-
// From the previous delimiter or start, find the next non-whitespace character (why?)
1109+
// From the previous delimiter or start, find the next non-whitespace character (skips over blank lines)
11121110
int nextNonWSChar;
11131111
if (reachedStart) nextNonWSChar = getFirstNonWSCharPos(0);
11141112
else nextNonWSChar = getFirstNonWSCharPos(prevDelim + 1, whitespace, false);
@@ -1125,7 +1123,7 @@ public int _getIndentOfCurrStmt(final int pos, final char[] delims, final char[]
11251123
// Get the position of the first non-ws character on this line (or end of line if no such char
11261124
int firstNonWS = _getLineFirstCharPos(newLineStart);
11271125
int wSPrefix = firstNonWS - newLineStart;
1128-
_storeInCache(key, wSPrefix, firstNonWS); // relying on autoboxing
1126+
_storeInCache(key, wSPrefix, Math.max(pos - 1, firstNonWS)); // relying on autoboxing
11291127
return wSPrefix;
11301128
}
11311129
catch(BadLocationException e) { throw new UnexpectedException(e); }
@@ -1578,7 +1576,7 @@ protected boolean notInBlock(final int pos) {
15781576
* non-blank character). Only runs in the event thread.
15791577
* @return true if there are only blank characters before the current location on the current line.
15801578
*/
1581-
private boolean onlyWhiteSpaceBeforeCurrent() throws BadLocationException{
1579+
private boolean onlySpacesBeforeCurrent() throws BadLocationException{
15821580

15831581
assert Utilities.TEST_MODE || EventQueue.isDispatchThread();
15841582

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static void runCommand(String s, Class<?> c) throws Throwable {
179179
catch (java.lang.NoSuchMethodException e) { m = null; }
180180
if (m==null) {
181181
java.applet.Applet instance = null;
182-
if (args.length==0) {
182+
if (args.length == 0) {
183183
try {
184184
// try default (nullary) constructor first
185185
Constructor<?> ctor = c.getConstructor();
@@ -451,7 +451,7 @@ public String getOpenAllFilesInFolderExtension() {
451451
// " if (m==null) {\n" +
452452
// " java.applet.Applet instance = null;\n" +
453453
// " boolean fail = false;\n");
454-
// if (args.length==0) {
454+
// if (args.length == 0) {
455455
// command.append(
456456
// " try {\n" +
457457
// " // try default (nullary) constructor first\n" +

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public class LanguageLevelStackTraceMapper {
6060
public static final edu.rice.cs.util.Log LOG = new edu.rice.cs.util.Log("llstm.txt",false);
6161

6262
/** cache to store the tree maps */
63-
private HashMap<String,TreeMap<Integer,Integer>> cache;
63+
private volatile HashMap<String,TreeMap<Integer,Integer>> cache;
6464

6565
/** model used to get the OpenDefinitionsDocuments from files */
66-
private GlobalModel aGModel;
66+
private volatile GlobalModel aGModel;
6767

6868
/* constructor */
6969
public LanguageLevelStackTraceMapper(GlobalModel aGM){

drjava/src/edu/rice/cs/drjava/model/debug/jpda/JPDADebugger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ public static boolean isSimpleVariableOrFieldAccess(String var) {
447447
indexPart = indexPart.substring(1, indexPart.length()-1).trim();
448448
// indexPart now is "1" or "1][2" or "1] [2"
449449
String[] indices = indexPart.split("\\]\\s*\\[",-1);
450-
if (indices.length==0) return false;
450+
if (indices.length == 0) return false;
451451
for(String indexStr: indices) {
452452
indexStr = indexStr.trim();
453453
// System.out.println("\t\tindexStr: "+indexStr);

drjava/src/edu/rice/cs/drjava/model/debug/jpda/PendingRequestManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
*/
5858

5959
public class PendingRequestManager {
60-
private JPDADebugger _manager;
61-
private HashMap<String, Vector<DocumentDebugAction<?>>> _pendingActions;
60+
private volatile JPDADebugger _manager;
61+
private volatile HashMap<String, Vector<DocumentDebugAction<?>>> _pendingActions;
6262

6363
public PendingRequestManager(JPDADebugger manager) {
6464
_manager = manager;

drjava/src/edu/rice/cs/drjava/model/definitions/indent/ActionStartPrevStmtPlus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public boolean indentLine(AbstractDJDocument doc, Indenter.IndentReason reason)
8686

8787
try {
8888
char delim = doc.getText(prevDelimiterPos, 1).charAt(0); // get delimiter char
89-
char[] ws = {' ', '\t', '\n', ';'}; // Why is ';' a delimiter?
89+
char[] ws = {' ', '\t', '\n', ';'}; // Note that ';' is whitespace here
9090
if (delim == ';') {
9191
int testPos = doc._findPrevCharPos(prevDelimiterPos, ws); // find char preceding ';' delimiter
9292
char testDelim = doc.getText(testPos,1).charAt(0);
@@ -116,7 +116,7 @@ public boolean indentLine(AbstractDJDocument doc, Indenter.IndentReason reason)
116116
// user may be trying to indent code that is not balanced!
117117
return supResult;
118118
}
119-
prevDelimiterPos -= delta - 1; // Position just to right of matching '{' or '('
119+
prevDelimiterPos -= (delta - 1); // Position just to right of matching '{' or '('
120120
doc.setCurrentLocation(here);
121121

122122
assert doc.getText(prevDelimiterPos, 1).charAt(0) == '{' ||

drjava/src/edu/rice/cs/drjava/model/definitions/indent/QuestionNewParenPhrase.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
*/
4949
public class QuestionNewParenPhrase extends IndentRuleQuestion {
5050

51+
private static final char[] LOCAL_DELIMS =
52+
{';', ',', '(', '[', '&', '|', '+', '-', '*', '/', '%', '=', '<', '>', '}'};
5153
/** Constructs a new rule to determine if the current line starts new paren phrase.
5254
* @param yesRule Rule to use if this rule holds
5355
* @param noRule Rule to use if this rule does not hold
@@ -70,8 +72,7 @@ boolean applyRule(AbstractDJDocument doc, Indenter.IndentReason reason) {
7072

7173
if (startLine > 0) {
7274
// Find previous delimiter (looking in paren phrases)
73-
char[] delims = {';', ',', '(', '[', '&', '|', '+', '-', '*', '/', '%', '=', '<', '>', '}'};
74-
int prevDelim = doc.findPrevDelimiter(startLine, delims, false);
75+
int prevDelim = doc.findPrevDelimiter(startLine, LOCAL_DELIMS, false);
7576
if (prevDelim == -1) {
7677
return false;
7778
}

0 commit comments

Comments
 (0)