Skip to content

Commit 37e8b3c

Browse files
committed
Do not shadow variable names
1 parent 18b5801 commit 37e8b3c

File tree

5 files changed

+57
-59
lines changed

5 files changed

+57
-59
lines changed

src/main/java/org/scijava/annotations/AbstractIndexWriter.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ protected synchronized void merge(final String annotationName,
126126
if (in == null) {
127127
return;
128128
}
129-
Map<String, Object> map = this.map.get(annotationName);
130-
if (map == null) {
131-
map = new LinkedHashMap<String, Object>();
132-
this.map.put(annotationName, map);
129+
Map<String, Object> m = map.get(annotationName);
130+
if (m == null) {
131+
m = new LinkedHashMap<String, Object>();
132+
map.put(annotationName, m);
133133
}
134134
/*
135135
* To determine whether the index needs to be written out,
136136
* we need to keep track of changed entries.
137137
*/
138-
int changedCount = map.size();
138+
int changedCount = m.size();
139139
boolean hasObsoletes = false;
140140

141141
final IndexReader reader =
@@ -151,13 +151,13 @@ protected synchronized void merge(final String annotationName,
151151
if (factory.isClassObsolete(className)) {
152152
hasObsoletes = true;
153153
}
154-
else if (map.containsKey(className)) {
155-
if (!hasObsoletes && entry.equals(map.get(className))) {
154+
else if (m.containsKey(className)) {
155+
if (!hasObsoletes && entry.equals(m.get(className))) {
156156
changedCount--;
157157
}
158158
}
159159
else {
160-
map.put(className, entry);
160+
m.put(className, entry);
161161
}
162162
}
163163
}
@@ -166,7 +166,7 @@ else if (map.containsKey(className)) {
166166
}
167167
// if this annotation index is unchanged, no need to write it out again
168168
if (changedCount == 0 && !hasObsoletes) {
169-
this.map.remove(annotationName);
169+
map.remove(annotationName);
170170
}
171171
}
172172

@@ -278,12 +278,12 @@ protected void writeMap(final PrintStream out, final Object... pairs)
278278
out.write('}');
279279
}
280280

281-
private void writeMap(final PrintStream out, final Map<?, ?> map)
281+
private void writeMap(final PrintStream out, final Map<?, ?> m)
282282
throws IOException
283283
{
284284
out.write('{');
285285
boolean first = true;
286-
for (Map.Entry<?, ?> entry : map.entrySet()) {
286+
for (Map.Entry<?, ?> entry : m.entrySet()) {
287287
if (first) {
288288
first = false;
289289
}

src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -204,89 +204,89 @@ private Map<String, Map<String, Object>> getAnnotations() {
204204
new TreeMap<String, Map<String, Object>>();
205205
for (final Attribute attr : attributes) {
206206
if ("RuntimeVisibleAnnotations".equals(attr.getName())) {
207-
final byte[] buffer = attr.attribute;
208-
int count = getU2(buffer, 0);
207+
final byte[] buf = attr.attribute;
208+
int count = getU2(buf, 0);
209209
int offset = 2;
210210
for (int i = 0; i < count; i++) {
211211
final String className =
212-
raw2className(getStringConstant(getU2(buffer, offset)));
212+
raw2className(getStringConstant(getU2(buf, offset)));
213213
offset += 2;
214214
final Map<String, Object> values =
215215
new TreeMap<String, Object>();
216216
annotations.put(className, values);
217-
offset = parseAnnotationValues(buffer, offset, values);
217+
offset = parseAnnotationValues(buf, offset, values);
218218
}
219219
}
220220
}
221221
return annotations;
222222
}
223223

224-
private int parseAnnotationValues(final byte[] buffer, int offset,
224+
private int parseAnnotationValues(final byte[] buf, int offset,
225225
final Map<String, Object> values)
226226
{
227-
int count = getU2(buffer, offset);
227+
int count = getU2(buf, offset);
228228
offset += 2;
229229
for (int i = 0; i < count; i++) {
230-
final String key = getStringConstant(getU2(buffer, offset));
230+
final String key = getStringConstant(getU2(buf, offset));
231231
offset += 2;
232-
offset = parseAnnotationValue(buffer, offset, values, key);
232+
offset = parseAnnotationValue(buf, offset, values, key);
233233
}
234234
return offset;
235235
}
236236

237-
private int parseAnnotationValue(byte[] buffer, int offset,
237+
private int parseAnnotationValue(byte[] buf, int offset,
238238
Map<String, Object> map, String key)
239239
{
240240
Object value;
241-
switch (getU1(buffer, offset++)) {
241+
switch (getU1(buf, offset++)) {
242242
case 'Z':
243-
value = Boolean.valueOf(getIntegerConstant(getU2(buffer, offset)) != 0);
243+
value = Boolean.valueOf(getIntegerConstant(getU2(buf, offset)) != 0);
244244
offset += 2;
245245
break;
246246
case 'B':
247-
value = Byte.valueOf((byte) getIntegerConstant(getU2(buffer, offset)));
247+
value = Byte.valueOf((byte) getIntegerConstant(getU2(buf, offset)));
248248
offset += 2;
249249
break;
250250
case 'C':
251251
value =
252-
Character.valueOf((char) getIntegerConstant(getU2(buffer, offset)));
252+
Character.valueOf((char) getIntegerConstant(getU2(buf, offset)));
253253
offset += 2;
254254
break;
255255
case 'S':
256256
value =
257-
Short.valueOf((short) getIntegerConstant(getU2(buffer, offset)));
257+
Short.valueOf((short) getIntegerConstant(getU2(buf, offset)));
258258
offset += 2;
259259
break;
260260
case 'I':
261261
value =
262-
Integer.valueOf((int) getIntegerConstant(getU2(buffer, offset)));
262+
Integer.valueOf((int) getIntegerConstant(getU2(buf, offset)));
263263
offset += 2;
264264
break;
265265
case 'J':
266-
value = Long.valueOf(getLongConstant(getU2(buffer, offset)));
266+
value = Long.valueOf(getLongConstant(getU2(buf, offset)));
267267
offset += 2;
268268
break;
269269
case 'F':
270-
value = Float.valueOf(getFloatConstant(getU2(buffer, offset)));
270+
value = Float.valueOf(getFloatConstant(getU2(buf, offset)));
271271
offset += 2;
272272
break;
273273
case 'D':
274-
value = Double.valueOf(getDoubleConstant(getU2(buffer, offset)));
274+
value = Double.valueOf(getDoubleConstant(getU2(buf, offset)));
275275
offset += 2;
276276
break;
277277
case 's':
278-
value = getStringConstant(getU2(buffer, offset));
278+
value = getStringConstant(getU2(buf, offset));
279279
offset += 2;
280280
break;
281281
case 'c':
282-
value = raw2className(getStringConstant(getU2(buffer, offset)));
282+
value = raw2className(getStringConstant(getU2(buf, offset)));
283283
offset += 2;
284284
break;
285285
case '[': {
286-
final Object[] array = new Object[getU2(buffer, offset)];
286+
final Object[] array = new Object[getU2(buf, offset)];
287287
offset += 2;
288288
for (int i = 0; i < array.length; i++) {
289-
offset = parseAnnotationValue(buffer, offset, map, key);
289+
offset = parseAnnotationValue(buf, offset, map, key);
290290
array[i] = map.get(key);
291291
}
292292
value = array;
@@ -295,10 +295,10 @@ private int parseAnnotationValue(byte[] buffer, int offset,
295295
case 'e': {
296296
final Map<String, Object> enumValue =
297297
new TreeMap<String, Object>();
298-
enumValue.put("enum", raw2className(getStringConstant(getU2(buffer,
298+
enumValue.put("enum", raw2className(getStringConstant(getU2(buf,
299299
offset))));
300300
offset += 2;
301-
enumValue.put("value", getStringConstant(getU2(buffer, offset)));
301+
enumValue.put("value", getStringConstant(getU2(buf, offset)));
302302
offset += 2;
303303
value = enumValue;
304304
break;
@@ -307,13 +307,13 @@ private int parseAnnotationValue(byte[] buffer, int offset,
307307
// skipping annotation type
308308
offset += 2;
309309
final Map<String, Object> values = new TreeMap<String, Object>();
310-
offset = parseAnnotationValues(buffer, offset, values);
310+
offset = parseAnnotationValues(buf, offset, values);
311311
value = values;
312312
break;
313313
}
314314
default:
315315
throw new RuntimeException("Unhandled annotation value type: " +
316-
(char) getU1(buffer, offset - 1));
316+
(char) getU1(buf, offset - 1));
317317
}
318318
if (value == null) {
319319
throw new NullPointerException();

src/main/java/org/scijava/annotations/DirectoryIndexer.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,9 @@ public InputStream openInput(String annotationName) throws IOException {
151151
public OutputStream openOutput(String annotationName) throws IOException {
152152
final File file =
153153
new File(directory, Index.INDEX_PREFIX + annotationName);
154-
final File directory = file.getParentFile();
155-
if (directory != null && !directory.isDirectory() &&
156-
!directory.mkdirs())
157-
{
158-
throw new IOException("Could not make directory " + directory);
154+
final File dir = file.getParentFile();
155+
if (dir != null && !dir.isDirectory() && !dir.mkdirs()) {
156+
throw new IOException("Could not make directory " + dir);
159157
}
160158
return new FileOutputStream(file) {
161159

src/main/java/org/scijava/script/History.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ public void add(final String command) {
9292
currentCommand = "";
9393
}
9494

95-
public boolean replace(final String currentCommand) {
95+
public boolean replace(final String command) {
9696
if (position < 0) {
97-
this.currentCommand = currentCommand;
97+
currentCommand = command;
9898
return false;
9999
}
100-
return entries.replace(position, currentCommand);
100+
return entries.replace(position, command);
101101
}
102102

103103
/**
@@ -131,14 +131,14 @@ public String previous() {
131131
@Override
132132
public String toString() {
133133
final StringBuilder builder = new StringBuilder();
134-
int position = -1;
134+
int pos = -1;
135135
for (;;) {
136-
position = entries.previous(position);
137-
if (position < 0) break;
136+
pos = entries.previous(pos);
137+
if (pos < 0) break;
138138
if (builder.length() > 0) builder.append(" -> ");
139-
if (this.position == position) builder.append("[");
140-
builder.append(entries.get(position));
141-
if (this.position == position) builder.append("]");
139+
if (this.position == pos) builder.append("[");
140+
builder.append(entries.get(pos));
141+
if (this.position == pos) builder.append("]");
142142
}
143143
return builder.toString();
144144
}

src/test/java/org/scijava/app/DefaultStatusServiceTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class DefaultStatusServiceTest {
5353
private Context context;
5454
private StatusListener statusListener;
5555
private BlockingQueue<StatusEvent> queue;
56-
private StatusService statusService;
56+
private StatusService ss;
5757

5858
private class StatusListener extends AbstractContextual {
5959

@@ -79,12 +79,12 @@ public void setUp() throws Exception {
7979
queue = new ArrayBlockingQueue<StatusEvent>(10);
8080
statusListener = new StatusListener();
8181
statusListener.setContext(context);
82-
statusService = statusListener.statusService;
82+
ss = statusListener.statusService;
8383
}
8484

8585
@Test
8686
public void testShowProgress() {
87-
statusService.showProgress(15, 45);
87+
ss.showProgress(15, 45);
8888
try {
8989
final StatusEvent event = queue.poll(10, TimeUnit.SECONDS);
9090
assertEquals(event.getProgressValue(), 15);
@@ -100,7 +100,7 @@ public void testShowProgress() {
100100
@Test
101101
public void testShowStatusString() {
102102
final String text = "Hello, world";
103-
statusService.showStatus(text);
103+
ss.showStatus(text);
104104
try {
105105
final StatusEvent event = queue.poll(10, TimeUnit.SECONDS);
106106
assertEquals(event.getStatusMessage(), text);
@@ -115,7 +115,7 @@ public void testShowStatusString() {
115115
@Test
116116
public void testShowStatusIntIntString() {
117117
final String text = "Working...";
118-
statusService.showStatus(25, 55, text);
118+
ss.showStatus(25, 55, text);
119119
try {
120120
final StatusEvent event = queue.poll(10, TimeUnit.SECONDS);
121121
assertEquals(event.getProgressValue(), 25);
@@ -132,7 +132,7 @@ public void testShowStatusIntIntString() {
132132
@Test
133133
public void testWarn() {
134134
final String text = "Totally hosed";
135-
statusService.warn(text);
135+
ss.warn(text);
136136
try {
137137
final StatusEvent event = queue.poll(10, TimeUnit.SECONDS);
138138
assertEquals(event.getStatusMessage(), text);
@@ -147,7 +147,7 @@ public void testWarn() {
147147
@Test
148148
public void testShowStatusIntIntStringBoolean() {
149149
final String text = "Working and hosed...";
150-
statusService.showStatus(33, 44, text, true);
150+
ss.showStatus(33, 44, text, true);
151151
try {
152152
final StatusEvent event = queue.poll(10, TimeUnit.SECONDS);
153153
assertEquals(event.getStatusMessage(), text);
@@ -163,7 +163,7 @@ public void testShowStatusIntIntStringBoolean() {
163163

164164
@Test
165165
public void testClearStatus() {
166-
statusService.clearStatus();
166+
ss.clearStatus();
167167
try {
168168
final StatusEvent event = queue.poll(10, TimeUnit.SECONDS);
169169
assertEquals(event.getStatusMessage(), "");

0 commit comments

Comments
 (0)