Skip to content

Commit f9a4a8c

Browse files
marchofGodin
authored andcommitted
Access to static members should use qualifier of declaring type (jacoco#962)
1 parent 3787b82 commit f9a4a8c

File tree

8 files changed

+15
-19
lines changed

8 files changed

+15
-19
lines changed

org.jacoco.core.test/.settings/org.eclipse.jdt.ui.prefs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ sp_cleanup.organize_imports=true
3333
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
3434
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
3535
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
36-
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
36+
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
3737
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
3838
sp_cleanup.remove_private_constructors=true
3939
sp_cleanup.remove_redundant_modifiers=false

org.jacoco.core.test/src/org/jacoco/core/internal/analysis/InstructionsBuilderTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import java.util.Map;
1818

19-
import org.jacoco.core.analysis.ISourceFileCoverage;
19+
import org.jacoco.core.analysis.ISourceNode;
2020
import org.jacoco.core.internal.flow.LabelInfo;
2121
import org.junit.Before;
2222
import org.junit.Test;
@@ -53,7 +53,7 @@ public void current_line_number_should_be_applied_to_instructions() {
5353
builder.addInstruction(i4);
5454

5555
Map<AbstractInsnNode, Instruction> map = builder.getInstructions();
56-
assertEquals(ISourceFileCoverage.UNKNOWN_LINE, map.get(i1).getLine());
56+
assertEquals(ISourceNode.UNKNOWN_LINE, map.get(i1).getLine());
5757
assertEquals(10, map.get(i2).getLine());
5858
assertEquals(10, map.get(i3).getLine());
5959
assertEquals(20, map.get(i4).getLine());

org.jacoco.core.test/src/org/jacoco/core/internal/analysis/MethodCoverageCalculatorTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.HashSet;
2020
import java.util.Map;
2121

22-
import org.jacoco.core.analysis.ISourceFileCoverage;
22+
import org.jacoco.core.analysis.ISourceNode;
2323
import org.junit.Before;
2424
import org.junit.Test;
2525
import org.objectweb.asm.Opcodes;
@@ -205,15 +205,15 @@ public void should_replace_branches_with_merged_instructions() {
205205

206206
@Test
207207
public void should_work_without_lines() {
208-
addInsn(ISourceFileCoverage.UNKNOWN_LINE, false);
209-
addInsn(ISourceFileCoverage.UNKNOWN_LINE, false);
210-
addInsn(ISourceFileCoverage.UNKNOWN_LINE, true);
208+
addInsn(ISourceNode.UNKNOWN_LINE, false);
209+
addInsn(ISourceNode.UNKNOWN_LINE, false);
210+
addInsn(ISourceNode.UNKNOWN_LINE, true);
211211

212212
MethodCoverageCalculator c = new MethodCoverageCalculator(instructions);
213213
c.calculate(coverage);
214214

215-
assertEquals(ISourceFileCoverage.UNKNOWN_LINE, coverage.getFirstLine());
216-
assertEquals(ISourceFileCoverage.UNKNOWN_LINE, coverage.getLastLine());
215+
assertEquals(ISourceNode.UNKNOWN_LINE, coverage.getFirstLine());
216+
assertEquals(ISourceNode.UNKNOWN_LINE, coverage.getLastLine());
217217
assertEquals(CounterImpl.getInstance(2, 1),
218218
coverage.getInstructionCounter());
219219
}

org.jacoco.core/.settings/org.eclipse.jdt.ui.prefs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sp_cleanup.organize_imports=true
3434
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
3535
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
3636
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
37-
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
37+
sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
3838
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
3939
sp_cleanup.remove_private_constructors=true
4040
sp_cleanup.remove_redundant_modifiers=false

org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageCalculator.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Map.Entry;
2121
import java.util.Set;
2222

23-
import org.jacoco.core.analysis.ISourceFileCoverage;
2423
import org.jacoco.core.analysis.ISourceNode;
2524
import org.jacoco.core.internal.analysis.filter.IFilterOutput;
2625
import org.objectweb.asm.tree.AbstractInsnNode;
@@ -122,8 +121,8 @@ private void applyReplacements() {
122121

123122
private void ensureCapacity(final MethodCoverageImpl coverage) {
124123
// Determine line range:
125-
int firstLine = ISourceFileCoverage.UNKNOWN_LINE;
126-
int lastLine = ISourceFileCoverage.UNKNOWN_LINE;
124+
int firstLine = ISourceNode.UNKNOWN_LINE;
125+
int lastLine = ISourceNode.UNKNOWN_LINE;
127126
for (final Entry<AbstractInsnNode, Instruction> entry : instructions
128127
.entrySet()) {
129128
if (!ignored.contains(entry.getKey())) {

org.jacoco.core/src/org/jacoco/core/internal/analysis/filter/KotlinWhenFilter.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.objectweb.asm.Opcodes;
2020
import org.objectweb.asm.tree.AbstractInsnNode;
21-
import org.objectweb.asm.tree.InsnNode;
2221
import org.objectweb.asm.tree.JumpInsnNode;
2322
import org.objectweb.asm.tree.LabelNode;
2423
import org.objectweb.asm.tree.LookupSwitchInsnNode;
@@ -45,7 +44,7 @@ public void filter(final MethodNode methodNode,
4544

4645
private static class Matcher extends AbstractMatcher {
4746
void match(final AbstractInsnNode start, final IFilterOutput output) {
48-
if (start.getType() != InsnNode.LABEL) {
47+
if (start.getType() != AbstractInsnNode.LABEL) {
4948
return;
5049
}
5150
cursor = start;

org.jacoco.report/src/org/jacoco/report/internal/html/table/BarColumn.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
package org.jacoco.report.internal.html.table;
1414

1515
import java.io.IOException;
16-
import java.text.DecimalFormat;
1716
import java.text.NumberFormat;
1817
import java.util.Comparator;
1918
import java.util.List;
@@ -55,7 +54,7 @@ public class BarColumn implements IColumnRenderer {
5554
*/
5655
public BarColumn(final CounterEntity entity, final Locale locale) {
5756
this.entity = entity;
58-
this.integerFormat = DecimalFormat.getIntegerInstance(locale);
57+
this.integerFormat = NumberFormat.getIntegerInstance(locale);
5958
this.comparator = new TableItemComparator(
6059
CounterComparator.MISSEDITEMS.reverse().on(entity).second(
6160
CounterComparator.TOTALITEMS.reverse().on(entity)));

org.jacoco.report/src/org/jacoco/report/internal/html/table/CounterColumn.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
package org.jacoco.report.internal.html.table;
1414

1515
import java.io.IOException;
16-
import java.text.DecimalFormat;
1716
import java.text.NumberFormat;
1817
import java.util.Comparator;
1918
import java.util.List;
@@ -114,7 +113,7 @@ protected int getValue(final ICounter counter) {
114113
protected CounterColumn(final CounterEntity entity, final Locale locale,
115114
final Comparator<ICoverageNode> comparator) {
116115
this.entity = entity;
117-
this.integerFormat = DecimalFormat.getIntegerInstance(locale);
116+
this.integerFormat = NumberFormat.getIntegerInstance(locale);
118117
this.comparator = new TableItemComparator(comparator);
119118
}
120119

0 commit comments

Comments
 (0)