Skip to content

Commit

Permalink
Removed some redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
cohansen committed Aug 2, 2023
1 parent 840c47d commit 1018777
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public static Map<String, String> parseMissionModelUnits(Elements elementUtils,
property = "/" + property;
}

parsedUnits.put(property, extractTagValue(UNITS_TAG, value));
parsedUnits.put(property, extractTagValue(value));
}
});

return parsedUnits;
}

/**
* Parses javadocs searching for parameters + unit paris and computed attributes + unit pairs.
* Parses javadocs searching for parameters + unit paris and computed attributes + unit pairs.
* @param elementUtils Utility functions for file parsing.
* @param element The element we're parsing the comments for.
* @return A pair of maps, one with the parameter units and one with the computed attribute units.
Expand All @@ -85,7 +85,7 @@ public static Pair<Map<String, String>, Map<String, String>> parseActivityTypeUn
var property = $.getKey();

if (value.contains(UNITS_TAG) && !value.contains(COMPUTED_ATTRIBUTE_TAG)) {
parameterUnits.put(property, extractTagValue(UNITS_TAG, value));
parameterUnits.put(property, extractTagValue(value));
}
});

Expand Down Expand Up @@ -129,16 +129,15 @@ public static String removeSingleLeadingSpaceFromEachLine(final String s) {
* Extracts the tag value from a given tag and comment.
* Ex: "@unit mass in grams" will return "mass in grams".
*
* @param tag The tag to search for.
* @param comment The entire comment string that we're parsing the tag value from.
* @return The comment value after the found tag.
*/
private static String extractTagValue(String tag, String comment) {
if (comment.isEmpty() || !comment.contains(tag)) {
private static String extractTagValue(String comment) {
if (!comment.contains(JavadocParser.UNITS_TAG)) {
return "";
}

return comment.substring(comment.indexOf(tag) + tag.length()).trim();
return comment.substring(comment.indexOf(JavadocParser.UNITS_TAG) + JavadocParser.UNITS_TAG.length()).trim();
}

private static void parseComment(String comment, Map<String, String> parsedUnits, String tag) {
Expand All @@ -151,7 +150,7 @@ private static void parseComment(String comment, Map<String, String> parsedUnits
}

if (!lastItem.isEmpty() && splitComment.contains(UNITS_TAG)) {
parsedUnits.put(lastItem, extractTagValue(UNITS_TAG, splitComment));
parsedUnits.put(lastItem, extractTagValue(splitComment));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ else if (this.initiallyEvaluatedTemporalContext == null) {
if (total.compareTo(this.durationRange.start) < 0) {
durToSchedule = this.durationRange.start.minus(total);
} else if (total.compareTo(this.durationRange.end) > 0) {
logger.warn(
"Need to decrease duration of activities from the plan, impossible because scheduler cannot remove activities");
return List.of(new UnsatisfiableGoalConflict(
this,
Expand Down

0 comments on commit 1018777

Please sign in to comment.