Skip to content

Commit 2f6aac8

Browse files
concavelenzblickly
authored andcommitted
Another set of cleanup changes to remove references to Guava Lists/Sets/Maps
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=92012344
1 parent 2cc05f1 commit 2f6aac8

24 files changed

+175
-187
lines changed

src/com/google/javascript/jscomp/BasicErrorManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616

1717
package com.google.javascript.jscomp;
1818

19-
import com.google.common.collect.Sets;
20-
2119
import java.util.ArrayList;
2220
import java.util.Comparator;
2321
import java.util.List;
2422
import java.util.SortedSet;
23+
import java.util.TreeSet;
2524

2625
/**
2726
* <p>A basic error manager that sorts all errors and warnings reported to it to
@@ -35,7 +34,7 @@
3534
*/
3635
public abstract class BasicErrorManager implements ErrorManager {
3736
private final SortedSet<ErrorWithLevel> messages =
38-
Sets.newTreeSet(new LeveledJSErrorComparator());
37+
new TreeSet<>(new LeveledJSErrorComparator());
3938
private int errorCount = 0;
4039
private int warningCount = 0;
4140
private double typedPercent = 0.0;

src/com/google/javascript/jscomp/CoalesceVariableNames.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import com.google.common.base.Joiner;
2020
import com.google.common.base.Preconditions;
21-
import com.google.common.collect.Sets;
2221
import com.google.javascript.jscomp.ControlFlowGraph.AbstractCfgNodeTraversalCallback;
2322
import com.google.javascript.jscomp.ControlFlowGraph.Branch;
2423
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState;
@@ -39,6 +38,7 @@
3938
import java.util.Iterator;
4039
import java.util.LinkedList;
4140
import java.util.Set;
41+
import java.util.TreeSet;
4242

4343
/**
4444
* Reuse variable names if possible.
@@ -172,7 +172,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {
172172
// we should not sacrifice performance for non-debugging compilation to
173173
// make this fast.
174174
String pseudoName = null;
175-
Set<String> allMergedNames = Sets.newTreeSet();
175+
Set<String> allMergedNames = new TreeSet<>();
176176
for (Iterator<Var> i = t.getScope().getVars(); i.hasNext();) {
177177
Var iVar = i.next();
178178

src/com/google/javascript/jscomp/DataFlowAnalysis.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
package com.google.javascript.jscomp;
1818

1919
import com.google.common.base.Preconditions;
20-
import com.google.common.collect.Lists;
21-
import com.google.common.collect.Sets;
20+
import com.google.common.collect.ImmutableList;
2221
import com.google.javascript.jscomp.ControlFlowGraph.Branch;
2322
import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback;
2423
import com.google.javascript.jscomp.graph.Annotation;
@@ -33,6 +32,7 @@
3332
import java.util.List;
3433
import java.util.Objects;
3534
import java.util.Set;
35+
import java.util.TreeSet;
3636

3737
/**
3838
* A framework to help writing static program analysis. A subclass of
@@ -123,7 +123,7 @@ abstract class DataFlowAnalysis<N, L extends LatticeElement> {
123123
Comparator<DiGraphNode<N, Branch>> nodeComparator =
124124
cfg.getOptionalNodeComparator(isForward());
125125
if (nodeComparator != null) {
126-
this.orderedWorkSet = Sets.newTreeSet(nodeComparator);
126+
this.orderedWorkSet = new TreeSet<>(nodeComparator);
127127
} else {
128128
this.orderedWorkSet = new LinkedHashSet<>();
129129
}
@@ -150,7 +150,7 @@ L getExitLatticeElement() {
150150

151151
@SuppressWarnings("unchecked")
152152
protected L join(L latticeA, L latticeB) {
153-
return joinOp.apply(Lists.newArrayList(latticeA, latticeB));
153+
return joinOp.apply(ImmutableList.of(latticeA, latticeB));
154154
}
155155

156156
/**

src/com/google/javascript/jscomp/GlobalNamespace.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.google.common.base.Predicate;
2323
import com.google.common.collect.ImmutableList;
2424
import com.google.common.collect.ImmutableSet;
25-
import com.google.common.collect.Sets;
2625
import com.google.javascript.jscomp.CodingConvention.SubclassRelationship;
2726
import com.google.javascript.rhino.JSDocInfo;
2827
import com.google.javascript.rhino.Node;
@@ -42,6 +41,7 @@
4241
import java.util.List;
4342
import java.util.Map;
4443
import java.util.Set;
44+
import java.util.TreeSet;
4545

4646
/**
4747
* Builds a global namespace of all the objects and their properties in
@@ -1401,7 +1401,7 @@ static class Tracker implements CompilerPass {
14011401
@Override public void process(Node externs, Node root) {
14021402
GlobalNamespace namespace = new GlobalNamespace(compiler, externs, root);
14031403

1404-
Set<String> currentSymbols = Sets.newTreeSet();
1404+
Set<String> currentSymbols = new TreeSet<>();
14051405
for (String name : namespace.getNameIndex().keySet()) {
14061406
if (isInterestingSymbol.apply(name)) {
14071407
currentSymbols.add(name);

src/com/google/javascript/jscomp/RuntimeTypeCheck.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import com.google.common.collect.ImmutableList;
2020
import com.google.common.collect.Iterables;
21-
import com.google.common.collect.Sets;
2221
import com.google.javascript.rhino.IR;
2322
import com.google.javascript.rhino.Node;
2423
import com.google.javascript.rhino.StaticSourceFile;
@@ -123,7 +122,7 @@ private void visitFunction(Node n) {
123122

124123
nodeToInsertAfter = addMarker(funType, nodeToInsertAfter, null);
125124

126-
TreeSet<ObjectType> stuff = Sets.newTreeSet(ALPHA);
125+
TreeSet<ObjectType> stuff = new TreeSet<>(ALPHA);
127126
Iterables.addAll(stuff, funType.getAllImplementedInterfaces());
128127
for (ObjectType interfaceType : stuff) {
129128
nodeToInsertAfter =
@@ -303,7 +302,7 @@ private Node createCheckTypeCallNode(JSType type, Node expr) {
303302
Node arrayNode = IR.arraylit();
304303
Collection<JSType> alternates;
305304
if (type.isUnionType()) {
306-
alternates = Sets.newTreeSet(ALPHA);
305+
alternates = new TreeSet<>(ALPHA);
307306
alternates.addAll(type.toMaybeUnionType().getAlternates());
308307
} else {
309308
alternates = ImmutableList.of(type);

src/com/google/javascript/jscomp/TypedCodeGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import com.google.common.base.Joiner;
2020
import com.google.common.base.Preconditions;
21-
import com.google.common.collect.Sets;
2221
import com.google.javascript.rhino.JSDocInfo;
2322
import com.google.javascript.rhino.Node;
2423
import com.google.javascript.rhino.TypeIRegistry;
@@ -28,6 +27,7 @@
2827
import com.google.javascript.rhino.jstype.ObjectType;
2928

3029
import java.util.Set;
30+
import java.util.TreeSet;
3131

3232
/**
3333
* A code generator that outputs type annotations for functions and
@@ -170,7 +170,7 @@ private String getFunctionAnnotation(Node fnNode) {
170170
}
171171

172172
// Avoid duplicates, add implemented type to a set first
173-
Set<String> interfaces = Sets.newTreeSet();
173+
Set<String> interfaces = new TreeSet<>();
174174
for (ObjectType interfaze : funType.getImplementedInterfaces()) {
175175
interfaces.add(interfaze.toAnnotationString());
176176
}

test/com/google/javascript/jscomp/CommandLineRunnerTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.google.common.base.Suppliers;
2727
import com.google.common.collect.ImmutableList;
2828
import com.google.common.collect.ImmutableSet;
29-
import com.google.common.collect.Lists;
3029
import com.google.javascript.jscomp.AbstractCommandLineRunner.FlagUsageException;
3130
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
3231
import com.google.javascript.jscomp.SourceMap.LocationMapping;
@@ -1547,11 +1546,11 @@ private Compiler compile(String[] original) {
15471546
inputsSupplier = Suppliers.ofInstance(inputs);
15481547
} else if (useModules == ModulePattern.STAR) {
15491548
modulesSupplier = Suppliers.<List<JSModule>>ofInstance(
1550-
Lists.newArrayList(
1549+
ImmutableList.copyOf(
15511550
CompilerTestCase.createModuleStar(original)));
15521551
} else if (useModules == ModulePattern.CHAIN) {
15531552
modulesSupplier = Suppliers.<List<JSModule>>ofInstance(
1554-
Lists.newArrayList(
1553+
ImmutableList.copyOf(
15551554
CompilerTestCase.createModuleChain(original)));
15561555
} else {
15571556
throw new IllegalArgumentException("Unknown module type: " + useModules);

test/com/google/javascript/jscomp/CompilerTest.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.google.common.base.Joiner;
2323
import com.google.common.collect.ImmutableList;
2424
import com.google.common.collect.ImmutableMap;
25-
import com.google.common.collect.Lists;
2625
import com.google.debugging.sourcemap.FilePosition;
2726
import com.google.debugging.sourcemap.SourceMapGeneratorV3;
2827
import com.google.debugging.sourcemap.proto.Mapping.OriginalMapping;
@@ -84,7 +83,7 @@ public void testCodeBuilderAppend() {
8483
}
8584

8685
public void testCyclicalDependencyInInputs() {
87-
List<SourceFile> inputs = Lists.newArrayList(
86+
List<SourceFile> inputs = ImmutableList.of(
8887
SourceFile.fromCode(
8988
"gin", "goog.provide('gin'); goog.require('tonic'); var gin = {};"),
9089
SourceFile.fromCode("tonic",
@@ -125,11 +124,11 @@ public void testLocalUndefined() throws Exception {
125124
}
126125

127126
public void testCommonJSProvidesAndRequire() throws Exception {
128-
List<SourceFile> inputs = Lists.newArrayList(
127+
List<SourceFile> inputs = ImmutableList.of(
129128
SourceFile.fromCode("gin.js", "require('tonic')"),
130129
SourceFile.fromCode("tonic.js", ""),
131130
SourceFile.fromCode("mix.js", "require('gin'); require('tonic');"));
132-
List<String> entryPoints = Lists.newArrayList("module$mix");
131+
List<String> entryPoints = ImmutableList.of("module$mix");
133132

134133
Compiler compiler = initCompilerForCommonJS(inputs, entryPoints);
135134
JSModuleGraph graph = compiler.getModuleGraph();
@@ -144,7 +143,7 @@ public void testCommonJSProvidesAndRequire() throws Exception {
144143
}
145144

146145
public void testCommonJSMissingRequire() throws Exception {
147-
List<SourceFile> inputs = Lists.newArrayList(
146+
List<SourceFile> inputs = ImmutableList.of(
148147
SourceFile.fromCode("gin.js", "require('missing')"));
149148
Compiler compiler = initCompilerForCommonJS(
150149
inputs, ImmutableList.of("module$gin"));
@@ -170,7 +169,7 @@ public void testInputSourceMaps() throws Exception {
170169
normalize("../original/source.html"),
171170
originalSourcePosition));
172171
String origSourceName = normalize("original/source.html");
173-
List<SourceFile> originalSources = Lists.newArrayList(
172+
List<SourceFile> originalSources = ImmutableList.of(
174173
SourceFile.fromCode(origSourceName, "<div ng-show='foo()'>"));
175174

176175
CompilerOptions options = new CompilerOptions();
@@ -505,7 +504,7 @@ public void testDefineNoOverriding() throws Exception {
505504

506505
public void testDefineOverriding1() throws Exception {
507506
List<String> defines =
508-
Lists.newArrayList(
507+
ImmutableList.of(
509508
"COMPILED",
510509
"DEF_TRUE=true",
511510
"DEF_FALSE=false",
@@ -521,46 +520,46 @@ public void testDefineOverriding1() throws Exception {
521520
}
522521

523522
public void testDefineOverriding2() throws Exception {
524-
List<String> defines = Lists.newArrayList("DEF_STRING='='");
523+
List<String> defines = ImmutableList.of("DEF_STRING='='");
525524
Map<String, Node> expected = ImmutableMap.of(
526525
"DEF_STRING", Node.newString("="));
527526
assertDefineOverrides(expected, defines);
528527
}
529528

530529
public void testDefineOverriding3() throws Exception {
531-
List<String> defines = Lists.newArrayList("a.DEBUG");
530+
List<String> defines = ImmutableList.of("a.DEBUG");
532531
Map<String, Node> expected = ImmutableMap.of(
533532
"a.DEBUG", new Node(Token.TRUE));
534533
assertDefineOverrides(expected, defines);
535534
}
536535

537536
public void testBadDefineOverriding1() throws Exception {
538-
List<String> defines = Lists.newArrayList("DEF_STRING=");
537+
List<String> defines = ImmutableList.of("DEF_STRING=");
539538
assertCreateDefinesThrowsException(defines);
540539
}
541540

542541
public void testBadDefineOverriding2() throws Exception {
543-
List<String> defines = Lists.newArrayList("DEF_STRING='xyz");
542+
List<String> defines = ImmutableList.of("DEF_STRING='xyz");
544543
assertCreateDefinesThrowsException(defines);
545544
}
546545

547546
public void testBadDefineOverriding3() throws Exception {
548-
List<String> defines = Lists.newArrayList("=true");
547+
List<String> defines = ImmutableList.of("=true");
549548
assertCreateDefinesThrowsException(defines);
550549
}
551550

552551
public void testBadDefineOverriding4() throws Exception {
553-
List<String> defines = Lists.newArrayList("DEF_STRING==");
552+
List<String> defines = ImmutableList.of("DEF_STRING==");
554553
assertCreateDefinesThrowsException(defines);
555554
}
556555

557556
public void testBadDefineOverriding5() throws Exception {
558-
List<String> defines = Lists.newArrayList("DEF_STRING='");
557+
List<String> defines = ImmutableList.of("DEF_STRING='");
559558
assertCreateDefinesThrowsException(defines);
560559
}
561560

562561
public void testBadDefineOverriding6() throws Exception {
563-
List<String> defines = Lists.newArrayList("DEF_STRING='''");
562+
List<String> defines = ImmutableList.of("DEF_STRING='''");
564563
assertCreateDefinesThrowsException(defines);
565564
}
566565

test/com/google/javascript/jscomp/DisambiguatePropertiesTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
import static com.google.common.truth.Truth.assertThat;
1919

20-
import com.google.common.collect.Maps;
2120
import com.google.common.collect.Multimap;
22-
import com.google.common.collect.Sets;
2321
import com.google.javascript.rhino.Node;
2422
import com.google.javascript.rhino.jstype.JSTypeNative;
2523
import com.google.javascript.rhino.jstype.JSTypeRegistry;
@@ -1313,11 +1311,11 @@ private void testSets(String js, String fieldTypes, DiagnosticType warning) {
13131311

13141312
/** Sorts the map and converts to a string for comparison purposes. */
13151313
private <T> String mapToString(Multimap<String, Collection<T>> map) {
1316-
TreeMap<String, String> retMap = Maps.newTreeMap();
1314+
TreeMap<String, String> retMap = new TreeMap<>();
13171315
for (String key : map.keySet()) {
1318-
TreeSet<String> treeSet = Sets.newTreeSet();
1316+
TreeSet<String> treeSet = new TreeSet<>();
13191317
for (Collection<T> collection : map.get(key)) {
1320-
Set<String> subSet = Sets.newTreeSet();
1318+
Set<String> subSet = new TreeSet<>();
13211319
for (T type : collection) {
13221320
subSet.add(type.toString());
13231321
}

0 commit comments

Comments
 (0)