@Test public void shouldRead() { List<String> classNames = classpathCache.getMatchingClassNames("google.common.base.str", 5); assertThat(classNames).contains("com.google.common.base.Strings"); }
synchronized ImmutableList<String> getMatchingClassNames(String partialClassName, int limit) { updateCache(); PartialClassNameMatcher matcher = new PartialClassNameMatcher(partialClassName); Set<String> fullMatchingClassNames = Sets.newLinkedHashSet(); Set<String> matchingClassNames = Sets.newLinkedHashSet(); Iterator<String> i = classNameLocations.keySet().iterator(); if (instrumentation != null) { List<String> loadedClassNames = Lists.newArrayList(); for (Class<?> clazz : instrumentation.getAllLoadedClasses()) { if (!clazz.getName().startsWith("[")) { loadedClassNames.add(clazz.getName()); } } i = Iterators.concat(i, loadedClassNames.iterator()); } while (i.hasNext()) { String className = i.next(); String classNameUpper = className.toUpperCase(Locale.ENGLISH); boolean potentialFullMatch = matcher.isPotentialFullMatch(classNameUpper); if (matchingClassNames.size() == limit && !potentialFullMatch) { continue; } if (fullMatchingClassNames.size() == limit) { break; } if (matcher.isPotentialMatch(classNameUpper)) { if (potentialFullMatch) { fullMatchingClassNames.add(className); } else { matchingClassNames.add(className); } } } return combineClassNamesWithLimit(fullMatchingClassNames, matchingClassNames, limit); }
ClasspathCache { synchronized ImmutableList<String> getMatchingClassNames(String partialClassName, int limit) { updateCache(); PartialClassNameMatcher matcher = new PartialClassNameMatcher(partialClassName); Set<String> fullMatchingClassNames = Sets.newLinkedHashSet(); Set<String> matchingClassNames = Sets.newLinkedHashSet(); Iterator<String> i = classNameLocations.keySet().iterator(); if (instrumentation != null) { List<String> loadedClassNames = Lists.newArrayList(); for (Class<?> clazz : instrumentation.getAllLoadedClasses()) { if (!clazz.getName().startsWith("[")) { loadedClassNames.add(clazz.getName()); } } i = Iterators.concat(i, loadedClassNames.iterator()); } while (i.hasNext()) { String className = i.next(); String classNameUpper = className.toUpperCase(Locale.ENGLISH); boolean potentialFullMatch = matcher.isPotentialFullMatch(classNameUpper); if (matchingClassNames.size() == limit && !potentialFullMatch) { continue; } if (fullMatchingClassNames.size() == limit) { break; } if (matcher.isPotentialMatch(classNameUpper)) { if (potentialFullMatch) { fullMatchingClassNames.add(className); } else { matchingClassNames.add(className); } } } return combineClassNamesWithLimit(fullMatchingClassNames, matchingClassNames, limit); } }
ClasspathCache { synchronized ImmutableList<String> getMatchingClassNames(String partialClassName, int limit) { updateCache(); PartialClassNameMatcher matcher = new PartialClassNameMatcher(partialClassName); Set<String> fullMatchingClassNames = Sets.newLinkedHashSet(); Set<String> matchingClassNames = Sets.newLinkedHashSet(); Iterator<String> i = classNameLocations.keySet().iterator(); if (instrumentation != null) { List<String> loadedClassNames = Lists.newArrayList(); for (Class<?> clazz : instrumentation.getAllLoadedClasses()) { if (!clazz.getName().startsWith("[")) { loadedClassNames.add(clazz.getName()); } } i = Iterators.concat(i, loadedClassNames.iterator()); } while (i.hasNext()) { String className = i.next(); String classNameUpper = className.toUpperCase(Locale.ENGLISH); boolean potentialFullMatch = matcher.isPotentialFullMatch(classNameUpper); if (matchingClassNames.size() == limit && !potentialFullMatch) { continue; } if (fullMatchingClassNames.size() == limit) { break; } if (matcher.isPotentialMatch(classNameUpper)) { if (potentialFullMatch) { fullMatchingClassNames.add(className); } else { matchingClassNames.add(className); } } } return combineClassNamesWithLimit(fullMatchingClassNames, matchingClassNames, limit); } ClasspathCache(AnalyzedWorld analyzedWorld, @Nullable Instrumentation instrumentation); }
ClasspathCache { synchronized ImmutableList<String> getMatchingClassNames(String partialClassName, int limit) { updateCache(); PartialClassNameMatcher matcher = new PartialClassNameMatcher(partialClassName); Set<String> fullMatchingClassNames = Sets.newLinkedHashSet(); Set<String> matchingClassNames = Sets.newLinkedHashSet(); Iterator<String> i = classNameLocations.keySet().iterator(); if (instrumentation != null) { List<String> loadedClassNames = Lists.newArrayList(); for (Class<?> clazz : instrumentation.getAllLoadedClasses()) { if (!clazz.getName().startsWith("[")) { loadedClassNames.add(clazz.getName()); } } i = Iterators.concat(i, loadedClassNames.iterator()); } while (i.hasNext()) { String className = i.next(); String classNameUpper = className.toUpperCase(Locale.ENGLISH); boolean potentialFullMatch = matcher.isPotentialFullMatch(classNameUpper); if (matchingClassNames.size() == limit && !potentialFullMatch) { continue; } if (fullMatchingClassNames.size() == limit) { break; } if (matcher.isPotentialMatch(classNameUpper)) { if (potentialFullMatch) { fullMatchingClassNames.add(className); } else { matchingClassNames.add(className); } } } return combineClassNamesWithLimit(fullMatchingClassNames, matchingClassNames, limit); } ClasspathCache(AnalyzedWorld analyzedWorld, @Nullable Instrumentation instrumentation);  }
ClasspathCache { synchronized ImmutableList<String> getMatchingClassNames(String partialClassName, int limit) { updateCache(); PartialClassNameMatcher matcher = new PartialClassNameMatcher(partialClassName); Set<String> fullMatchingClassNames = Sets.newLinkedHashSet(); Set<String> matchingClassNames = Sets.newLinkedHashSet(); Iterator<String> i = classNameLocations.keySet().iterator(); if (instrumentation != null) { List<String> loadedClassNames = Lists.newArrayList(); for (Class<?> clazz : instrumentation.getAllLoadedClasses()) { if (!clazz.getName().startsWith("[")) { loadedClassNames.add(clazz.getName()); } } i = Iterators.concat(i, loadedClassNames.iterator()); } while (i.hasNext()) { String className = i.next(); String classNameUpper = className.toUpperCase(Locale.ENGLISH); boolean potentialFullMatch = matcher.isPotentialFullMatch(classNameUpper); if (matchingClassNames.size() == limit && !potentialFullMatch) { continue; } if (fullMatchingClassNames.size() == limit) { break; } if (matcher.isPotentialMatch(classNameUpper)) { if (potentialFullMatch) { fullMatchingClassNames.add(className); } else { matchingClassNames.add(className); } } } return combineClassNamesWithLimit(fullMatchingClassNames, matchingClassNames, limit); } ClasspathCache(AnalyzedWorld analyzedWorld, @Nullable Instrumentation instrumentation);   }