diff options
author | Michael Valenta | 2003-03-03 21:25:59 +0000 |
---|---|---|
committer | Michael Valenta | 2003-03-03 21:25:59 +0000 |
commit | fe513c91fccd0a152196ccd00d35d234f64cc141 (patch) | |
tree | 12e9988522baabe1580d9d61c694ef1445cf14e7 /bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java | |
parent | 732cb29574f483221063950b279747703c7c8f2a (diff) | |
download | eclipse.platform.team-fe513c91fccd0a152196ccd00d35d234f64cc141.tar.gz eclipse.platform.team-fe513c91fccd0a152196ccd00d35d234f64cc141.tar.xz eclipse.platform.team-fe513c91fccd0a152196ccd00d35d234f64cc141.zip |
20960: [CVS Core] Putting resources under version control creates lots of garbage
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java')
-rw-r--r-- | bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java index c08f8c11b..57547af49 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.StringTokenizer; +import java.util.Vector; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -73,6 +74,7 @@ public final class Team { // The ignore list that is read at startup from the persisted file private static Map globalIgnore, pluginIgnore; + private static StringMatcher[] ignoreMatchers; private static class FileTypeInfo implements IFileTypeInfo { private String extension; @@ -135,35 +137,25 @@ public final class Team { * @param file the file * @return whether the file should be ignored */ - public static boolean isIgnoredHint(IFile file) { - if (file.isDerived()) return true; - IIgnoreInfo[] ignorePatterns = getAllIgnores(); - StringMatcher matcher; - for (int i = 0; i < ignorePatterns.length; i++) { - IIgnoreInfo info = ignorePatterns[i]; - if (info.getEnabled()) { - matcher = new StringMatcher(info.getPattern(), true, false); - if (matcher.match(file.getName())) return true; - } + public static boolean isIgnoredHint(IResource resource) { + if (resource.isDerived()) return true; + return matchesEnabledIgnore(resource); + } + + private static boolean matchesEnabledIgnore(IResource resource) { + StringMatcher[] matchers = getStringMatchers(); + for (int i = 0; i < matchers.length; i++) { + if (matchers[i].match(resource.getName())) return true; } return false; } - + /** * Returns whether the given file should be ignored. * @deprecated use isIgnoredHint instead */ public static boolean isIgnored(IFile file) { - IIgnoreInfo[] ignorePatterns = getAllIgnores(); - StringMatcher matcher; - for (int i = 0; i < ignorePatterns.length; i++) { - IIgnoreInfo info = ignorePatterns[i]; - if (info.getEnabled()) { - matcher = new StringMatcher(info.getPattern(), true, false); - if (matcher.match(file.getName())) return true; - } - } - return false; + return matchesEnabledIgnore(file); } /** @@ -189,6 +181,7 @@ public final class Team { public synchronized static IIgnoreInfo[] getAllIgnores() { if (globalIgnore == null) { globalIgnore = new HashMap(); + ignoreMatchers = null; try { readIgnoreState(); } catch (TeamException e) { @@ -216,6 +209,21 @@ public final class Team { return result; } + private synchronized static StringMatcher[] getStringMatchers() { + if (ignoreMatchers==null) { + IIgnoreInfo[] ignorePatterns = getAllIgnores(); + Vector matchers = new Vector(ignorePatterns.length); + for (int i = 0; i < ignorePatterns.length; i++) { + if (ignorePatterns[i].getEnabled()) { + matchers.add(new StringMatcher(ignorePatterns[i].getPattern(), true, false)); + } + } + ignoreMatchers = new StringMatcher[matchers.size()]; + matchers.copyInto(ignoreMatchers); + } + return ignoreMatchers; + } + private synchronized static Hashtable getFileTypeTable() { if (fileTypes == null) loadTextState(); return fileTypes; @@ -264,6 +272,7 @@ public final class Team { */ public static void setAllIgnores(String[] patterns, boolean[] enabled) { globalIgnore = new Hashtable(11); + ignoreMatchers = null; for (int i = 0; i < patterns.length; i++) { globalIgnore.put(patterns[i], new Boolean(enabled[i])); } |