SymbolUtils { @CheckForNull public static Path pathOf(PythonFile pythonFile) { try { URI uri = pythonFile.uri(); if ("file".equalsIgnoreCase(uri.getScheme())) { return Paths.get(uri); } return null; } catch (InvalidPathException e) { return null; } } private  SymbolUtils(); static String getModuleFileName(String fileName); static String fullyQualifiedModuleName(String packageName, String fileName); static List<Expression> assignmentsLhs(AssignmentStatement assignmentStatement); static String pythonPackageName(File file, File projectBaseDir); @CheckForNull static Path pathOf(PythonFile pythonFile); static boolean isTypeShedFile(PythonFile pythonFile); static int firstParameterOffset(FunctionSymbol functionSymbol, boolean isStaticCall); static Optional<FunctionSymbol> getOverriddenMethod(FunctionSymbol functionSymbol);  }
@Test public void path_of() throws IOException, URISyntaxException { PythonFile pythonFile = Mockito.mock(PythonFile.class); URI uri = Files.createTempFile("foo.py", "py").toUri(); Mockito.when(pythonFile.uri()).thenReturn(uri); assertThat(pathOf(pythonFile)).isEqualTo(Paths.get(uri)); uri = new URI("myscheme", null, "/file1.py", null); Mockito.when(pythonFile.uri()).thenReturn(uri); assertThat(pathOf(pythonFile)).isNull(); Mockito.when(pythonFile.uri()).thenThrow(InvalidPathException.class); assertThat(pathOf(pythonFile)).isNull(); }