Skip to content

Commit

Permalink
Remove both of equals/hashCode from classes in lib/packages where eit…
Browse files Browse the repository at this point in the history
…her only one of them was implemented (potentially incorrectly) or the class really intends to have reference equality.

RELNOTES:

--
MOS_MIGRATED_REVID=103778746
  • Loading branch information
haxorz authored and philwo committed Sep 24, 2015
1 parent 55dbdbd commit f769787
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,4 @@ public RuleVisibility getVisibility() {
public static String targetKind() {
return "environment group";
}

@Override
public boolean equals(Object o) {
// In a distributed implementation these may not be the same object.
if (o == this) {
return true;
} else if (!(o instanceof EnvironmentGroup)) {
return false;
} else {
return ((EnvironmentGroup) o).getLabel().equals(getLabel());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ public String toString() {
return getTargetKind() + "(" + getLabel() + ")"; // Just for debugging
}

@Override
public int hashCode() {
return label.hashCode();
}

@Override
public Set<DistributionType> getDistributions() {
return getPackage().getDefaultDistribs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ public PathFragment getExecPath() {
return label.getPackageIdentifier().getPathFragment().getRelative(label.getName());
}

@Override
public int hashCode() {
return label.hashCode();
}

@Override
public String getTargetKind() {
return "source file";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,4 @@ public Rule getAssociatedRule() {
public Location getLocation() {
return generatingRule.getLocation();
}

@Override
public int hashCode() {
return label.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ public String getWorkspaceName() {

@Override
public Label getLabel() {
return attributeMap.getLabel();
return label;
}

@Override
public String getName() {
return attributeMap.getName();
return label.getName();
}

@Override
Expand Down Expand Up @@ -572,11 +572,6 @@ void reportWarning(String message, EventHandler eventHandler) {
eventHandler.handle(Event.warn(location, message));
}

@Override
public int hashCode() {
return label.hashCode();
}

/**
* Returns a string of the form "cc_binary rule //foo:foo"
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private SrcTargetUtil() {
public static List<FileTarget> getSrcTargets(EventHandler eventHandler, Rule rule,
TargetProvider provider)
throws NoSuchTargetException, NoSuchPackageException, InterruptedException {
return getTargets(eventHandler, rule, SOURCE_ATTRIBUTES, Sets.newHashSet(rule), provider);
return getTargets(eventHandler, rule, SOURCE_ATTRIBUTES, Sets.newHashSet(rule.getLabel()),
provider);
}

// Attributes referring to "sources".
Expand Down Expand Up @@ -89,23 +90,25 @@ public static List<FileTarget> getSrcAndHdrTargets(EventHandler eventHandler, Ru
.add(HEADER_ATTRIBUTE)
.add(TEXTUAL_HEADER_ATTRIBUTE)
.build();
return getTargets(eventHandler, rule, srcAndHdrAttributes, Sets.newHashSet(rule), provider);
return getTargets(eventHandler, rule, srcAndHdrAttributes, Sets.newHashSet(rule.getLabel()),
provider);
}

@ThreadSafety.ThreadSafe
public static List<FileTarget> getHdrTargets(EventHandler eventHandler, Rule rule,
TargetProvider provider)
throws NoSuchTargetException, NoSuchPackageException, InterruptedException {
return getTargets(
eventHandler, rule, ImmutableSet.of(HEADER_ATTRIBUTE), Sets.newHashSet(rule), provider);
eventHandler, rule, ImmutableSet.of(HEADER_ATTRIBUTE), Sets.newHashSet(rule.getLabel()),
provider);
}

@ThreadSafety.ThreadSafe
public static List<FileTarget> getTextualHdrTargets(
EventHandler eventHandler, Rule rule, TargetProvider provider)
throws NoSuchTargetException, NoSuchPackageException, InterruptedException {
return getTargets(eventHandler, rule, ImmutableSet.of(TEXTUAL_HEADER_ATTRIBUTE),
Sets.newHashSet(rule), provider);
Sets.newHashSet(rule.getLabel()), provider);
}

/**
Expand All @@ -114,7 +117,7 @@ public static List<FileTarget> getTextualHdrTargets(
private static List<FileTarget> getTargets(EventHandler eventHandler,
Rule rule,
ImmutableSet<String> attributes,
Set<Rule> visitedRules,
Set<Label> visitedRuleLabels,
TargetProvider targetProvider)
throws NoSuchTargetException, NoSuchPackageException, InterruptedException {
List<Label> srcLabels = Lists.newArrayList();
Expand Down Expand Up @@ -142,11 +145,11 @@ private static List<FileTarget> getTargets(EventHandler eventHandler,
srcTargets.add((FileTarget) target);
} else {
Rule srcRule = target.getAssociatedRule();
if (srcRule != null && !visitedRules.contains(srcRule)) {
visitedRules.add(srcRule);
if (srcRule != null && !visitedRuleLabels.contains(srcRule.getLabel())) {
visitedRuleLabels.add(srcRule.getLabel());
if ("filegroup".equals(srcRule.getRuleClass())) {
srcTargets.addAll(getTargets(eventHandler, srcRule, FILEGROUP_ATTRIBUTES, visitedRules,
targetProvider));
srcTargets.addAll(getTargets(eventHandler, srcRule, FILEGROUP_ATTRIBUTES,
visitedRuleLabels, targetProvider));
} else {
srcTargets.addAll(srcRule.getOutputFiles());
}
Expand Down

0 comments on commit f769787

Please sign in to comment.