Skip to content

Commit 7cbabe0

Browse files
author
dlsmith
committed
Replaced edu.rice.cs.util.Lambda with edu.rice.cs.plt.lambda.*. Refactored all use sites. (Note some terminology changes: Lambda<To, From> becomes Lambda<From, To>; al.apply(arg) becomes l.value(arg) or r.run(arg).) Some uses of Lambda (such as Lambda<Object, Object>) seem like they're actually Runnable1s (or even just Runnables), but I was conservative in my translation, only changing the arity on types that previously used Void as a type argument.
git-svn-id: file:///tmp/test-svn/trunk@4633 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 1a21d93 commit 7cbabe0

38 files changed

+1501
-1662
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
import javax.swing.UIManager;
5454
import javax.swing.*;
5555

56+
import edu.rice.cs.plt.lambda.Runnable1;
5657
import edu.rice.cs.util.FileOpenSelector;
5758
import edu.rice.cs.util.UnexpectedException;
5859
import edu.rice.cs.util.OutputStreamRedirector;
59-
import edu.rice.cs.util.Lambda;
6060
import edu.rice.cs.util.newjvm.ExecJVM;
6161
import edu.rice.cs.util.swing.Utilities;
6262

@@ -368,8 +368,8 @@ public static void drop(DropTargetDropEvent dropTargetDropEvent) {
368368
* @param closeAction action to be performed when the window is closing
369369
* @return window listener */
370370
public static void installModalWindowAdapter(final Window w,
371-
final Lambda<Void,WindowEvent> toFrontAction,
372-
final Lambda<Void,WindowEvent> closeAction) {
371+
final Runnable1<? super WindowEvent> toFrontAction,
372+
final Runnable1<? super WindowEvent> closeAction) {
373373
_mainFrame.installModalWindowAdapter(w, toFrontAction, closeAction);
374374
}
375375

Lines changed: 141 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,141 @@
1-
/*BEGIN_COPYRIGHT_BLOCK
2-
*
3-
* Copyright (c) 2001-2008, JavaPLT group at Rice University (drjava@rice.edu)
4-
* All rights reserved.
5-
*
6-
* Redistribution and use in source and binary forms, with or without
7-
* modification, are permitted provided that the following conditions are met:
8-
* * Redistributions of source code must retain the above copyright
9-
* notice, this list of conditions and the following disclaimer.
10-
* * Redistributions in binary form must reproduce the above copyright
11-
* notice, this list of conditions and the following disclaimer in the
12-
* documentation and/or other materials provided with the distribution.
13-
* * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
14-
* names of its contributors may be used to endorse or promote products
15-
* derived from this software without specific prior written permission.
16-
*
17-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21-
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23-
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28-
*
29-
* This software is Open Source Initiative approved Open Source Software.
30-
* Open Source Initative Approved is a trademark of the Open Source Initiative.
31-
*
32-
* This file is part of DrJava. Download the current version of this project
33-
* from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
34-
*
35-
* END_COPYRIGHT_BLOCK*/
36-
37-
package edu.rice.cs.drjava.config;
38-
39-
import edu.rice.cs.drjava.DrJava;
40-
import edu.rice.cs.plt.lambda.Lambda2;
41-
import edu.rice.cs.util.Lambda;
42-
43-
import java.util.HashSet;
44-
import java.util.Iterator;
45-
46-
import static edu.rice.cs.util.HashUtilities.hash;
47-
48-
/** Class representing binary operations that can be inserted as variables in external processes.
49-
* @version $Id$
50-
*/
51-
public class BinaryOpProperty<P,Q,R> extends EagerProperty {
52-
/** Operation to perform. */
53-
protected Lambda2<P,Q,R> _op;
54-
/** Operator 1 name */
55-
protected String _op1Name;
56-
/** Operator 1 default */
57-
protected String _op1Default;
58-
/** Operator 2 name */
59-
protected String _op2Name;
60-
/** Operator 2 default */
61-
protected String _op2Default;
62-
/** Lambda to turn a string into the first operand. */
63-
protected Lambda<P,String> _parse1;
64-
/** Lambda to turn a string into the first operand. */
65-
protected Lambda<Q,String> _parse2;
66-
/** Lambda to format the result. */
67-
protected Lambda<String,R> _format;
68-
69-
/** Create an eager property. */
70-
public BinaryOpProperty(String name,
71-
String help,
72-
Lambda2<P,Q,R> op,
73-
String op1Name,
74-
String op1Default,
75-
Lambda<P,String> parse1,
76-
String op2Name,
77-
String op2Default,
78-
Lambda<Q,String> parse2,
79-
Lambda<String,R> format) {
80-
super(name, help);
81-
_op = op;
82-
_op1Name = op1Name;
83-
_op1Default = op1Default;
84-
_parse1 = parse1;
85-
_op2Name = op2Name;
86-
_op2Default = op2Default;
87-
_parse2 = parse2;
88-
_format = format;
89-
resetAttributes();
90-
}
91-
92-
/** Create an eager property. */
93-
public BinaryOpProperty(String name,
94-
String help,
95-
Lambda2<P,Q,R> op,
96-
Lambda<P,String> parse1,
97-
Lambda<Q,String> parse2,
98-
Lambda<String,R> format) {
99-
this(name,help,op,"op1",null,parse1,"op2",null,parse2,format);
100-
}
101-
102-
/** Update the property so the value is current.
103-
* @param pm PropertyMaps used for substitution when replacing variables */
104-
public void update(PropertyMaps pm) {
105-
P op1;
106-
if (_attributes.get(_op1Name)==null) {
107-
_value = "("+_name+" Error...)";
108-
return;
109-
}
110-
else {
111-
try {
112-
op1 = _parse1.apply(_attributes.get(_op1Name));
113-
}
114-
catch(Exception e) {
115-
_value = "("+_name+" Error...)";
116-
return;
117-
}
118-
}
119-
Q op2;
120-
if (_attributes.get(_op2Name)==null) {
121-
_value = "("+_name+" Error...)";
122-
return;
123-
}
124-
else {
125-
try {
126-
op2 = _parse2.apply(_attributes.get(_op2Name));
127-
}
128-
catch(Exception ee) {
129-
_value = "("+_name+" Error...)";
130-
return;
131-
}
132-
}
133-
_value = _format.apply(_op.value(op1,op2));
134-
}
135-
136-
public void resetAttributes() {
137-
_attributes.clear();
138-
_attributes.put(_op1Name, _op1Default);
139-
_attributes.put(_op2Name, _op2Default);
140-
}
141-
}
1+
/*BEGIN_COPYRIGHT_BLOCK
2+
*
3+
* Copyright (c) 2001-2008, JavaPLT group at Rice University (drjava@rice.edu)
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
14+
* names of its contributors may be used to endorse or promote products
15+
* derived from this software without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* This software is Open Source Initiative approved Open Source Software.
30+
* Open Source Initative Approved is a trademark of the Open Source Initiative.
31+
*
32+
* This file is part of DrJava. Download the current version of this project
33+
* from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
34+
*
35+
* END_COPYRIGHT_BLOCK*/
36+
37+
package edu.rice.cs.drjava.config;
38+
39+
import edu.rice.cs.drjava.DrJava;
40+
import edu.rice.cs.plt.lambda.Lambda;
41+
import edu.rice.cs.plt.lambda.Lambda2;
42+
43+
import java.util.HashSet;
44+
import java.util.Iterator;
45+
46+
import static edu.rice.cs.util.HashUtilities.hash;
47+
48+
/** Class representing binary operations that can be inserted as variables in external processes.
49+
* @version $Id$
50+
*/
51+
public class BinaryOpProperty<P,Q,R> extends EagerProperty {
52+
/** Operation to perform. */
53+
protected Lambda2<P,Q,R> _op;
54+
/** Operator 1 name */
55+
protected String _op1Name;
56+
/** Operator 1 default */
57+
protected String _op1Default;
58+
/** Operator 2 name */
59+
protected String _op2Name;
60+
/** Operator 2 default */
61+
protected String _op2Default;
62+
/** Lambda to turn a string into the first operand. */
63+
protected Lambda<String, P> _parse1;
64+
/** Lambda to turn a string into the first operand. */
65+
protected Lambda<String, Q> _parse2;
66+
/** Lambda to format the result. */
67+
protected Lambda<R, String> _format;
68+
69+
/** Create an eager property. */
70+
public BinaryOpProperty(String name,
71+
String help,
72+
Lambda2<P,Q,R> op,
73+
String op1Name,
74+
String op1Default,
75+
Lambda<String,P> parse1,
76+
String op2Name,
77+
String op2Default,
78+
Lambda<String,Q> parse2,
79+
Lambda<R,String> format) {
80+
super(name, help);
81+
_op = op;
82+
_op1Name = op1Name;
83+
_op1Default = op1Default;
84+
_parse1 = parse1;
85+
_op2Name = op2Name;
86+
_op2Default = op2Default;
87+
_parse2 = parse2;
88+
_format = format;
89+
resetAttributes();
90+
}
91+
92+
/** Create an eager property. */
93+
public BinaryOpProperty(String name,
94+
String help,
95+
Lambda2<P,Q,R> op,
96+
Lambda<String,P> parse1,
97+
Lambda<String,Q> parse2,
98+
Lambda<R,String> format) {
99+
this(name,help,op,"op1",null,parse1,"op2",null,parse2,format);
100+
}
101+
102+
/** Update the property so the value is current.
103+
* @param pm PropertyMaps used for substitution when replacing variables */
104+
public void update(PropertyMaps pm) {
105+
P op1;
106+
if (_attributes.get(_op1Name)==null) {
107+
_value = "("+_name+" Error...)";
108+
return;
109+
}
110+
else {
111+
try {
112+
op1 = _parse1.value(_attributes.get(_op1Name));
113+
}
114+
catch(Exception e) {
115+
_value = "("+_name+" Error...)";
116+
return;
117+
}
118+
}
119+
Q op2;
120+
if (_attributes.get(_op2Name)==null) {
121+
_value = "("+_name+" Error...)";
122+
return;
123+
}
124+
else {
125+
try {
126+
op2 = _parse2.value(_attributes.get(_op2Name));
127+
}
128+
catch(Exception ee) {
129+
_value = "("+_name+" Error...)";
130+
return;
131+
}
132+
}
133+
_value = _format.value(_op.value(op1,op2));
134+
}
135+
136+
public void resetAttributes() {
137+
_attributes.clear();
138+
_attributes.put(_op1Name, _op1Default);
139+
_attributes.put(_op2Name, _op2Default);
140+
}
141+
}

0 commit comments

Comments
 (0)