Skip to content

Commit 4a7db82

Browse files
author
rcartwright
committed
This revision fixes a problem in the guessVersion method of
JarJDKToolsLibrary rregarding Mac OS X Java 7 distributions. It also reinstates code supporting JUnit testing that was mistakenly commented out as part of disabling language level s support (which is not applicable to Scala). JUnit errors are now properly reported in the JUnit testing panel and highlighted in source documents. The following files were modified: M plt/src/edu/rice/cs/plt/reflect/JavaVersion.java M drjava/lib/plt.jar M drjava/src/edu/rice/cs/drjava/model/JarJDKToolsLibrary.java M drjava/src/edu/rice/cs/drjava/model/junit/DefaultJUnitModel.java M drjava/src/edu/rice/cs/drjava/model/compiler/CompilerErrorModel.java M drjava/src/edu/rice/cs/drjava/MainController.java M drjava/src/edu/rice/cs/drjava/ui/MainFrame.java M drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java M drjava/src/edu/rice/cs/drjava/ui/ErrorCaretListener.java M drjava/src/edu/rice/cs/util/sexp/SExpParser.java git-svn-id: file:///tmp/test-svn/branches/drscala@5543 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 9e742dc commit 4a7db82

File tree

10 files changed

+149
-101
lines changed

10 files changed

+149
-101
lines changed

drjava/lib/plt.jar

0 Bytes
Binary file not shown.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class MainController {
6262
* PreferencesWindow (to be refactored in another pass)
6363
* Configuration
6464
*
65-
* All CompilerErrorCaretListeners need to be aware of each other.
65+
* All ErrorCaretListeners need to be aware of each other.
6666
*
6767
* Behaviors that MainController will support:
6868
* Lock edits

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,22 @@ public static FullVersion guessVersion(File f, JDKDescriptor desc) {
282282
else if (path.toLowerCase().contains("oracle")) vendor = "oracle";
283283
}
284284
if (name.startsWith("jdk-")) {
285-
result = JavaVersion.parseFullVersion(parsedVersion = name.substring(4), vendor, vendor, f);
285+
parsedVersion = name.substring(4);
286+
result = JavaVersion.parseFullVersion(parsedVersion, vendor, vendor, f);
286287
}
287288
else if (name.startsWith("jdk")) {
288-
result = JavaVersion.parseFullVersion(parsedVersion = name.substring(3), vendor, vendor, f);
289+
parsedVersion = name.substring(3);
290+
result = JavaVersion.parseFullVersion(parsedVersion, vendor, vendor, f);
289291
}
290292
else if (name.startsWith("j2sdk") || name.startsWith("java-")) {
291-
result = JavaVersion.parseFullVersion(parsedVersion = name.substring(5), vendor, vendor, f);
293+
parsedVersion = name.substring(5);
294+
result = JavaVersion.parseFullVersion(parsedVersion, vendor, vendor, f);
292295
}
293296
else if (name.matches("\\d+\\.\\d+\\.\\d+.*")) { // The \d+ fields actually match single digits; .* matches an arbitrary suffix
294-
msg("invoking parseFullVersion on " + name + ", " + vendor + ", " + vendor + ", " + f); //Strip off 1.x where x is 6 or 7
295-
result = JavaVersion.parseFullVersion(parsedVersion = name, vendor, vendor, f);
297+
msg("Invoking parseFullVersion on " + name + ", " + vendor + ", " + vendor + ", " + f); //Strip off 1.x where x is 6 or 7
298+
parsedVersion = name.substring(0, 5); // could be generalized to multi-digit matches by using index of first char in .* instead of 5
299+
result = JavaVersion.parseFullVersion(parsedVersion, vendor, vendor, f);
300+
msg("Result is: " + result.versionString());
296301
}
297302
current = current.getParentFile();
298303
} while (current != null && result == null);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@
5757
import edu.rice.cs.util.UnexpectedException;
5858
import edu.rice.cs.util.swing.Utilities;
5959

60-
/** Contains the CompilerErrors for a set of compiled file after a compile has ended.
60+
/** Contains the Errors for a set of compiled/tested filea after a compile or test step has ended.
61+
* TODO: refactor most of the code in this class into an abstract ErrorModel class. JUnitErrorModel should inherit
62+
* from this abstract class not from CompilerErrorModel! JavadocErrorModel should also inherit from
63+
* this abstract class instead of decorating a CompilerErrorModel!
6164
* @version $Id$
6265
*/
6366
public class CompilerErrorModel {

drjava/src/edu/rice/cs/drjava/model/junit/DefaultJUnitModel.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,15 @@ public void testEnded(final String testName, final boolean wasSuccessful, final
605605
* @param errors The array of errors from all failed tests in the suite.
606606
*/
607607
public void testSuiteEnded(final JUnitError[] errors) {
608-
//Disable Java language level processing
609608
// new ScrollableDialog(null, "DefaultJUnitModel.testSuiteEnded(...) called", "", "").show();
610-
Utilities.invokeLater(new Runnable() { public void run() {
609+
610+
Utilities.invokeLater(new Runnable() { public void run() {
611+
// disable languge level processing
611612
// List<File> files = new ArrayList<File>();
612-
// for(OpenDefinitionsDocument odd: _model.getLLOpenDefinitionsDocuments()) { files.add(odd.getRawFile()); }
613-
//// Utilities.show("errors.length = " + errors.length + " files = " + files);
614-
// for(JUnitError e: errors){
613+
// for (OpenDefinitionsDocument odd: _model.getOpenDefinitionsDocuments()) { files.add(odd.getRawFile()); }
614+
// Utilities.show("errors.length = " + errors.length + " files = " + files);
615+
//
616+
// for(JUnitError e: errors) {
615617
// try {
616618
// e.setStackTrace(_compilerModel.getLLSTM().replaceStackTrace(e.stackTrace(),files));
617619
// } catch(Exception ex) { DrJavaErrorHandler.record(ex); }
@@ -623,7 +625,7 @@ public void testSuiteEnded(final JUnitError[] errors) {
623625
// e.setLineNumber(ste.getLineNumber());
624626
// }
625627
// }
626-
// _junitErrorModel = new JUnitErrorModel(errors, _model, true);
628+
_junitErrorModel = new JUnitErrorModel(errors, _model, true);
627629
_notifyJUnitEnded();
628630
_testInProgress = false;
629631
// new ScrollableDialog(null, "DefaultJUnitModel.testSuiteEnded(...) finished", "", "").show();

drjava/src/edu/rice/cs/drjava/ui/DefinitionsPane.java

Lines changed: 106 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -532,94 +532,127 @@ public void focusGained(FocusEvent e) {
532532
_displayRightMargin = DrJava.getConfig().getSetting(DISPLAY_RIGHT_MARGIN);
533533
_numRightMarginColumns = DrJava.getConfig().getSetting(RIGHT_MARGIN_COLUMNS);
534534
_rightMarginColor = DrJava.getConfig().getSetting(RIGHT_MARGIN_COLOR);
535-
536-
OptionListener<Color> cListener;
537-
Pair<Option<Color>, OptionListener<Color>> cPair;
538535

539536
// Setup the color listeners. NOTE: the Foreground/Background listeners add themselves to DrJava.getConfig()
540-
// in their own constructors. Rather than refactor it, we decided to work with that design decision.
541-
cListener = new ForegroundColorListener(this);
542-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEFINITIONS_NORMAL_COLOR, cListener);
543-
_colorOptionListeners.add(cPair);
537+
// in their own constructors. Rather than refactor it, we decided to work with that design decision.
538+
// A separate block is used for each listener to avoid polluting the variable name space.
539+
{
540+
final OptionListener<Color> fcListener = new ForegroundColorListener(this);
541+
final Pair<Option<Color>, OptionListener<Color>> fcPair =
542+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEFINITIONS_NORMAL_COLOR, fcListener);
543+
_colorOptionListeners.add(fcPair);
544+
}
545+
546+
{
547+
final OptionListener<Color> bcListener = new BackgroundColorListener(this);
548+
final Pair<Option<Color>, OptionListener<Color>> bcPair =
549+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEFINITIONS_BACKGROUND_COLOR, bcListener);
550+
_colorOptionListeners.add(bcPair);
551+
}
544552

545-
cListener = new BackgroundColorListener(this);
546-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEFINITIONS_BACKGROUND_COLOR, cListener);
547-
_colorOptionListeners.add(cPair);
548-
549553
// These listeners do not register themselves in their own constructors. We do.
550-
cListener = new MatchColorOptionListener();
551-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEFINITIONS_MATCH_COLOR, cListener);
552-
_colorOptionListeners.add(cPair);
553-
DrJava.getConfig().addOptionListener(OptionConstants.DEFINITIONS_MATCH_COLOR, cListener);
554+
{
555+
final OptionListener<Color> mcListener = new MatchColorOptionListener();
556+
final Pair<Option<Color>, OptionListener<Color>> mcPair =
557+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEFINITIONS_MATCH_COLOR, mcListener);
558+
_colorOptionListeners.add(mcPair);
559+
DrJava.getConfig().addOptionListener(OptionConstants.DEFINITIONS_MATCH_COLOR, mcListener);
560+
}
554561

555-
cListener = new ErrorColorOptionListener();
556-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.COMPILER_ERROR_COLOR, cListener);
557-
_colorOptionListeners.add(cPair);
558-
DrJava.getConfig().addOptionListener(OptionConstants.COMPILER_ERROR_COLOR, cListener);
562+
{
563+
final OptionListener<Color> ecListener = new ErrorColorOptionListener();
564+
final Pair<Option<Color>, OptionListener<Color>> ecPair =
565+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.COMPILER_ERROR_COLOR, ecListener);
566+
_colorOptionListeners.add(ecPair);
567+
DrJava.getConfig().addOptionListener(OptionConstants.COMPILER_ERROR_COLOR, ecListener);
568+
}
559569

560-
cListener = new BookmarkColorOptionListener();
561-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.BOOKMARK_COLOR, cListener);
562-
_colorOptionListeners.add(cPair);
563-
DrJava.getConfig().addOptionListener(OptionConstants.BOOKMARK_COLOR, cListener);
570+
{
571+
final OptionListener<Color> bcListener = new BookmarkColorOptionListener();
572+
final Pair<Option<Color>, OptionListener<Color>> bcPair =
573+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.BOOKMARK_COLOR, bcListener);
574+
_colorOptionListeners.add(bcPair);
575+
DrJava.getConfig().addOptionListener(OptionConstants.BOOKMARK_COLOR, bcListener);
576+
}
564577

565578
for (int i = 0; i < FIND_RESULTS_COLORS.length; ++i) {
566-
cListener = new FindResultsColorOptionListener(i);
567-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.FIND_RESULTS_COLORS[i], cListener);
579+
final OptionListener<Color> cListener = new FindResultsColorOptionListener(i);
580+
final Pair<Option<Color>, OptionListener<Color>> cPair =
581+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.FIND_RESULTS_COLORS[i], cListener);
568582
_colorOptionListeners.add(cPair);
569583
DrJava.getConfig().addOptionListener(OptionConstants.FIND_RESULTS_COLORS[i], cListener);
570584
}
571585

572-
cListener = new BreakpointColorOptionListener();
573-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEBUG_BREAKPOINT_COLOR, cListener);
574-
_colorOptionListeners.add(cPair);
575-
DrJava.getConfig().addOptionListener(OptionConstants.DEBUG_BREAKPOINT_COLOR, cListener);
586+
{
587+
final OptionListener<Color> bcListener = new BreakpointColorOptionListener();
588+
final Pair<Option<Color>, OptionListener<Color>> bcPair =
589+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEBUG_BREAKPOINT_COLOR, bcListener);
590+
_colorOptionListeners.add(bcPair);
591+
DrJava.getConfig().addOptionListener(OptionConstants.DEBUG_BREAKPOINT_COLOR, bcListener);
592+
}
576593

577-
cListener = new DisabledBreakpointColorOptionListener();
578-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEBUG_BREAKPOINT_DISABLED_COLOR, cListener);
579-
_colorOptionListeners.add(cPair);
580-
DrJava.getConfig().addOptionListener( OptionConstants.DEBUG_BREAKPOINT_DISABLED_COLOR, cListener);
594+
{
595+
final OptionListener<Color> dbcListener = new DisabledBreakpointColorOptionListener();
596+
final Pair<Option<Color>, OptionListener<Color>> dbcPair =
597+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEBUG_BREAKPOINT_DISABLED_COLOR, dbcListener);
598+
_colorOptionListeners.add(dbcPair);
599+
DrJava.getConfig().addOptionListener( OptionConstants.DEBUG_BREAKPOINT_DISABLED_COLOR, dbcListener);
600+
}
581601

582-
cListener = new ThreadColorOptionListener();
583-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEBUG_THREAD_COLOR, cListener);
584-
_colorOptionListeners.add(cPair);
585-
DrJava.getConfig().addOptionListener( OptionConstants.DEBUG_THREAD_COLOR, cListener);
586-
587-
OptionListener<Boolean> bListener = new AntiAliasOptionListener();
588-
Pair<Option<Boolean>, OptionListener<Boolean>> bPair =
589-
new Pair<Option<Boolean>, OptionListener<Boolean>>(OptionConstants.TEXT_ANTIALIAS, bListener);
590-
_booleanOptionListeners.add(bPair);
591-
DrJava.getConfig().addOptionListener(OptionConstants.TEXT_ANTIALIAS, bListener);
592-
593-
bListener = new OptionListener<Boolean>() {
594-
public void optionChanged(OptionEvent<Boolean> oce) {
595-
_displayRightMargin = oce.value;
596-
DefinitionsPane.this.repaint();
597-
}
598-
};
599-
bPair = new Pair<Option<Boolean>, OptionListener<Boolean>>(OptionConstants.DISPLAY_RIGHT_MARGIN, bListener);
600-
_booleanOptionListeners.add(bPair);
601-
DrJava.getConfig().addOptionListener(OptionConstants.DISPLAY_RIGHT_MARGIN, bListener);
602-
603-
OptionListener<Integer> iTemp = new OptionListener<Integer>() {
604-
public void optionChanged(OptionEvent<Integer> oce) {
605-
_numRightMarginColumns = oce.value;
606-
DefinitionsPane.this.repaint();
607-
}
608-
};
609-
Pair<Option<Integer>, OptionListener<Integer>> iPair =
610-
new Pair<Option<Integer>, OptionListener<Integer>>(OptionConstants.RIGHT_MARGIN_COLUMNS, iTemp);
611-
_integerOptionListeners.add(iPair);
612-
DrJava.getConfig().addOptionListener(OptionConstants.RIGHT_MARGIN_COLUMNS, iTemp);
602+
{
603+
final OptionListener<Color> tcListener = new ThreadColorOptionListener();
604+
final Pair<Option<Color>, OptionListener<Color>> tcPair =
605+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.DEBUG_THREAD_COLOR, tcListener);
606+
_colorOptionListeners.add(tcPair);
607+
DrJava.getConfig().addOptionListener( OptionConstants.DEBUG_THREAD_COLOR, tcListener);
608+
}
609+
610+
{
611+
final OptionListener<Boolean> aaListener = new AntiAliasOptionListener();
612+
final Pair<Option<Boolean>, OptionListener<Boolean>> aaPair =
613+
new Pair<Option<Boolean>, OptionListener<Boolean>>(OptionConstants.TEXT_ANTIALIAS, aaListener);
614+
_booleanOptionListeners.add(aaPair);
615+
DrJava.getConfig().addOptionListener(OptionConstants.TEXT_ANTIALIAS, aaListener);
616+
}
613617

614-
cListener = new OptionListener<Color>() {
615-
public void optionChanged(OptionEvent<Color> oce) {
616-
_rightMarginColor = oce.value;
617-
DefinitionsPane.this.repaint();
618-
}
619-
};
620-
cPair = new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.RIGHT_MARGIN_COLOR, cListener);
621-
_colorOptionListeners.add(cPair);
622-
DrJava.getConfig().addOptionListener(OptionConstants.RIGHT_MARGIN_COLOR, cListener);
618+
{
619+
final OptionListener<Boolean> rmListener = new OptionListener<Boolean>() {
620+
public void optionChanged(OptionEvent<Boolean> oce) {
621+
_displayRightMargin = oce.value;
622+
DefinitionsPane.this.repaint();
623+
}
624+
};
625+
final Pair<Option<Boolean>, OptionListener<Boolean>> rmPair =
626+
new Pair<Option<Boolean>, OptionListener<Boolean>>(OptionConstants.DISPLAY_RIGHT_MARGIN, rmListener);
627+
_booleanOptionListeners.add(rmPair);
628+
DrJava.getConfig().addOptionListener(OptionConstants.DISPLAY_RIGHT_MARGIN, rmListener);
629+
}
630+
631+
{
632+
final OptionListener<Integer> iListener = new OptionListener<Integer>() {
633+
public void optionChanged(OptionEvent<Integer> oce) {
634+
_numRightMarginColumns = oce.value;
635+
DefinitionsPane.this.repaint();
636+
}
637+
};
638+
final Pair<Option<Integer>, OptionListener<Integer>> iPair =
639+
new Pair<Option<Integer>, OptionListener<Integer>>(OptionConstants.RIGHT_MARGIN_COLUMNS, iListener);
640+
_integerOptionListeners.add(iPair);
641+
DrJava.getConfig().addOptionListener(OptionConstants.RIGHT_MARGIN_COLUMNS, iListener);
642+
}
643+
644+
{
645+
final OptionListener<Color> rmcListener = new OptionListener<Color>() {
646+
public void optionChanged(OptionEvent<Color> oce) {
647+
_rightMarginColor = oce.value;
648+
DefinitionsPane.this.repaint();
649+
}
650+
};
651+
final Pair<Option<Color>, OptionListener<Color>> rmcPair =
652+
new Pair<Option<Color>, OptionListener<Color>>(OptionConstants.RIGHT_MARGIN_COLOR, rmcListener);
653+
_colorOptionListeners.add(rmcPair);
654+
DrJava.getConfig().addOptionListener(OptionConstants.RIGHT_MARGIN_COLOR, rmcListener);
655+
}
623656

624657
createPopupMenu();
625658

drjava/src/edu/rice/cs/drjava/ui/ErrorCaretListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ public ErrorCaretListener(OpenDefinitionsDocument doc, DefinitionsPane defPane,
7070
*/
7171
public void caretUpdate(final CaretEvent evt) {
7272
assert EventQueue.isDispatchThread();
73-
if (_frame.getSelectedCompilerErrorPanel() == null) return;
73+
if (_frame.getSelectedErrorPanel() == null) return;
7474
updateHighlight(evt.getDot());
7575
}
7676

7777
/** Update the highlight appropriately. */
7878
public void updateHighlight(final int curPos) {
7979
assert EventQueue.isDispatchThread();
80-
CompilerErrorPanel panel = _frame.getSelectedCompilerErrorPanel();
80+
ErrorPanel panel = _frame.getSelectedErrorPanel();
8181
if (panel == null) return; // no error panel is currently selected; redundant!
8282

8383
CompilerErrorModel model = panel.getErrorModel();

drjava/src/edu/rice/cs/drjava/ui/MainFrame.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,10 +4442,10 @@ public File getSaveFile(JFileChooser jfc) throws OperationCanceledException {
44424442
/** Returns the javadoc error panel. */
44434443
public JavadocErrorPanel getJavadocErrorPanel() { return _javadocErrorPanel; }
44444444

4445-
/** Returns the currently shown error panel if there is one. Otherwise returns null. */
4446-
public CompilerErrorPanel getSelectedCompilerErrorPanel() {
4445+
/** Returns the currently shown error (Compiler or JUnit) panel if there is one. Otherwise returns null. */
4446+
public ErrorPanel getSelectedErrorPanel() {
44474447
Component c = _tabbedPane.getSelectedComponent();
4448-
if (c instanceof CompilerErrorPanel) return (CompilerErrorPanel) c;
4448+
if (c instanceof ErrorPanel) return (ErrorPanel) c;
44494449
return null;
44504450
}
44514451

@@ -7439,7 +7439,7 @@ else if (_tabbedPane.getSelectedIndex() == CONSOLE_TAB) {
74397439
// System.err.println("Console Scroll Selected");
74407440
EventQueue.invokeLater(new Runnable() { public void run() { _consoleScroll.requestFocusInWindow(); } });
74417441
}
7442-
// Update error highlights?
7442+
// Update error highlights
74437443
if (_currentDefPane != null) {
74447444
int pos = _currentDefPane.getCaretPosition();
74457445
_currentDefPane.removeErrorHighlight(); // removes highlighting whenever the current tabbed pane is switched
@@ -9239,6 +9239,7 @@ public void junitEnded() {
92399239
assert EventQueue.isDispatchThread();
92409240
// new ScrollableDialog(null, "MainFrame.junitEnded() called", "", "").show();
92419241
_guiAvailabilityNotifier.junitFinished(); // JUNIT and COMPILER
9242+
92429243
// Use EventQueue invokeLater to ensure that JUnit panel is "reset" after it is updated with test results
92439244
EventQueue.invokeLater(new Runnable() { public void run() { _junitPanel.reset(); } });
92449245
_model.refreshActiveDocument();

drjava/src/edu/rice/cs/util/sexp/SExpParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import java.util.ArrayList;
4646
import java.util.LinkedList;
4747

48+
import edu.rice.cs.util.sexp.QuotedTextAtom;
49+
4850
/**
4951
* This parser is not meant to be instantiated. It has
5052
* static methods that do all the work for you. These

0 commit comments

Comments
 (0)