private Pair<List<String>, List<String>> findViews(final boolean layoutsOnly) { final Set<String> customViews = new HashSet<String>(); final Set<String> thirdPartyViews = new HashSet<String>(); ProjectState state = Sdk.getProjectState(mProject); final List<IProject> libraries = state != null ? state.getFullLibraryProjects() : Collections.<IProject>emptyList(); SearchRequestor requestor = new SearchRequestor() { @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { // Ignore matches in comments if (match.isInsideDocComment()) { return; } Object element = match.getElement(); if (element instanceof ResolvedBinaryType) { // Third party view ResolvedBinaryType type = (ResolvedBinaryType) element; IPackageFragment fragment = type.getPackageFragment(); IPath path = fragment.getPath(); String last = path.lastSegment(); // Filter out android.jar stuff if (last.equals(FN_FRAMEWORK_LIBRARY)) { return; } if (!isValidView(type, layoutsOnly)) { return; } IProject matchProject = match.getResource().getProject(); if (mProject == matchProject || libraries.contains(matchProject)) { String fqn = type.getFullyQualifiedName(); thirdPartyViews.add(fqn); } } else if (element instanceof ResolvedSourceType) { // User custom view IProject matchProject = match.getResource().getProject(); if (mProject == matchProject || libraries.contains(matchProject)) { ResolvedSourceType type = (ResolvedSourceType) element; if (!isValidView(type, layoutsOnly)) { return; } String fqn = type.getFullyQualifiedName(); fqn = fqn.replace('$', '.'); customViews.add(fqn); } } } }; try { IJavaProject javaProject = BaseProjectHelper.getJavaProject(mProject); if (javaProject != null) { String className = layoutsOnly ? CLASS_VIEWGROUP : CLASS_VIEW; IType viewType = javaProject.findType(className); if (viewType != null) { IJavaSearchScope scope = SearchEngine.createHierarchyScope(viewType); SearchParticipant[] participants = new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}; int matchRule = SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE; SearchPattern pattern = SearchPattern.createPattern( "*", IJavaSearchConstants.CLASS, IJavaSearchConstants.IMPLEMENTORS, matchRule); SearchEngine engine = new SearchEngine(); engine.search(pattern, participants, scope, requestor, new NullProgressMonitor()); } } } catch (CoreException e) { AdtPlugin.log(e, null); } List<String> custom = new ArrayList<String>(customViews); List<String> thirdParty = new ArrayList<String>(thirdPartyViews); if (!layoutsOnly) { // Update our cached answers (unless we were filtered on only layouts) mCustomViews = custom; mThirdPartyViews = thirdParty; } return Pair.of(custom, thirdParty); }