From 8c72823ab16b2b0a42af8a61d8f068e518146814 Mon Sep 17 00:00:00 2001 From: "Ray J. Greenwell" Date: Wed, 29 Oct 2014 09:54:08 -0700 Subject: [PATCH] De-static some bits on ImportSet. Statics can't be overridden. This class shouldn't have to know about all threerings projects everywhere. --- .../threerings/presents/tools/ImportSet.java | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/tools/src/main/java/com/threerings/presents/tools/ImportSet.java b/tools/src/main/java/com/threerings/presents/tools/ImportSet.java index 8edee73b0..71b33ea28 100644 --- a/tools/src/main/java/com/threerings/presents/tools/ImportSet.java +++ b/tools/src/main/java/com/threerings/presents/tools/ImportSet.java @@ -376,6 +376,35 @@ public class ImportSet return StringUtil.toString(_imports); } + /** + * Find the index of the best import group to use for the specified import. + */ + protected int findImportGroup (String imp) + { + int bestGroup = -1; + int bestPrefixLength = -1; + int ii = -1; + for (String prefix : getImportGroups()) { + ii++; + if (!imp.startsWith(prefix)) { + continue; + } + if (prefix.length() > bestPrefixLength) { + bestPrefixLength = prefix.length(); + bestGroup = ii; + } + } + return bestGroup; + } + + /** + * Return an iterable over the import prefixes that should be grouped together. + */ + protected Iterable getImportGroups () + { + return IMPORT_GROUPS; + } + /** * Create a real regular expression from the dumbed down input. * @param input the dumbed down wildcard expression @@ -405,20 +434,6 @@ public class ImportSet return Pattern.compile(pattern.toString()); } - protected static int findImportGroup (String imp) - { - String longest = null; - for (String prefix : IMPORT_GROUPS) { - if (!imp.startsWith(prefix)) { - continue; - } - if (longest == null || prefix.length() > longest.length()) { - longest = prefix; - } - } - return IMPORT_GROUPS.indexOf(longest); - } - protected HashSet _imports = Sets.newHashSet(); protected List _pushed = Lists.newArrayList();