FileUtils { @SuppressWarnings("try") public static Optional<String> convertPathToClass(final Set<File> roots, final File file) throws IOException { try (TelemetryUtils.ScopedSpan scope = TelemetryUtils.startScopedSpanLow("FileUtils.convertPathToClass")) { TelemetryUtils.ScopedSpan.addAnnotation( TelemetryUtils.annotationBuilder() .put("roots", roots.toString()) .put("file", file.getPath()) .build("args")); for (File root : roots) { Optional<String> s = convertPathToClass(root, file); if (s.isPresent()) { return s; } } return Optional.empty(); } }  static boolean isJavaFile(final File file); @SuppressWarnings("try") static String getChecksum(final File file); static List<File> listJavaFiles(File parent); @SuppressWarnings("try") static List<File> collectFiles(final File root, final String ext); @SuppressWarnings("try") static Optional<File> collectFile(final File root, final String ext); static boolean filterFile(final File file); @SuppressWarnings("try") static Optional<String> findProjectID(final File root, final String target); static String getVersionInfo(); @SuppressWarnings("try") static Optional<File> getSourceFile(final String importClass, final Set<File> sourceRoots); @SuppressWarnings("try") static Optional<File> getClassFile(
      String path, final Set<File> sourceRoots, final File out); @SuppressWarnings("try") static Collection<File> getPackagePrivateSource(final List<File> compileFiles); @SuppressWarnings("try") static List<File> getModifiedSources(
      final File projectRoot,
      final List<File> sourceFiles,
      final Set<File> sourceRoots,
      final File output); @SuppressWarnings("try") static List<String> readLines(File file); @SuppressWarnings("try") static void readRangeLines(File file, long start, long end, Consumer<String> fn); @SuppressWarnings("try") static void formatJavaFile(final Properties properties, final String path); @SuppressWarnings("try") static void formatJavaFile(final String path); static Properties loadPropertiesFile(final File file); @SuppressWarnings("try") static Optional<File> existsFQCN(final Set<File> roots, final String fqcn); @SuppressWarnings("try") static Optional<Source> getSource(final File file); @SuppressWarnings("try") static Optional<String> convertPathToClass(final Set<File> roots, final File file); static String shortenPath(String path); static final String JAVA_EXT; static final String JAR_EXT; static final String CLASS_EXT; }
@Test public void testConvertPathToClass1() throws Exception { File f = new File(project.getProjectRootPath(), "./src/main/java/meghanada/session/Session.java") .getCanonicalFile(); try { Optional<String> s = FileUtils.convertPathToClass(project.getAllSources(), f); log.info("{}", s); } catch (IOException e) { log.catching(e); } }