JavaFileObject (String qName) { final JavaFileObject result = myInputSourcesIndex.get(qName); if (result != null) { return result; } if (!Iterators.isEmpty(myInputSources)) { // the logic assumes the source is located in the directory structure reflecting the package name. // todo: repeatedly cut prefixes and try shorter suffixes final String uriSuffix = "/" + qName.replace('.', '/') + JavaFileObject.Kind.SOURCE.extension; for (JavaFileObject source : myInputSources) { final URI uri = source.toUri(); if (uri != null) { final String path = uri.getPath(); if (path != null && path.endsWith(uriSuffix)) { myInputSourcesIndex.put(qName, source); return source; } } } } return null; }