@Override public Iterable<? extends Path> getLocationAsPaths(Location location) { if (location instanceof LocationWrapper) { return ((LocationWrapper) location).paths; } LocationWrapper loc = this.locationHandler.getLocation(location); if (loc == null) { return null; } return loc.getPaths(); }
private void deriveOutputLocationForModules(String moduleName, Collection<? extends Path> paths) { LocationWrapper wrapper = this.locationHandler.getLocation(StandardLocation.CLASS_OUTPUT, moduleName); if (wrapper == null) { // First get from our internally known location for legacy/unnamed location wrapper = this.locationHandler.getLocation(StandardLocation.CLASS_OUTPUT, ""); //$NON-NLS-1$ if (wrapper == null) { wrapper = this.locationHandler.getLocation(StandardLocation.CLASS_OUTPUT); } if (wrapper != null) { Iterator<? extends Path> iterator = wrapper.paths.iterator(); if (iterator.hasNext()) { try { // Per module output location is always a singleton list Path path = iterator.next().resolve(moduleName); this.locationHandler.setLocation(StandardLocation.CLASS_OUTPUT, moduleName, Collections.singletonList(path)); } catch(Exception e) { e.printStackTrace(); } } } } } private void deriveSourceOutputLocationForModules(String moduleName, Collection<? extends Path> paths) {
private void deriveSourceOutputLocationForModules(String moduleName, Collection<? extends Path> paths) { LocationWrapper wrapper = this.locationHandler.getLocation(StandardLocation.SOURCE_OUTPUT, moduleName); if (wrapper == null) { // First get from our internally known location for legacy/unnamed location wrapper = this.locationHandler.getLocation(StandardLocation.SOURCE_OUTPUT, ""); //$NON-NLS-1$ if (wrapper == null) { wrapper = this.locationHandler.getLocation(StandardLocation.SOURCE_OUTPUT); } if (wrapper != null) { Iterator<? extends Path> iterator = wrapper.paths.iterator(); if (iterator.hasNext()) { try { // Per module output location is always a singleton list Path path = iterator.next().resolve(moduleName); this.locationHandler.setLocation(StandardLocation.SOURCE_OUTPUT, moduleName, Collections.singletonList(path)); } catch(Exception e) { e.printStackTrace(); } } } } } @Override
@Override public Location getLocationForModule(Location location, JavaFileObject fo) { validateModuleLocation(location, ""); //$NON-NLS-1$ Path path = null; if (fo instanceof ArchiveFileObject) { path = ((ArchiveFileObject) fo).file.toPath(); return this.locationHandler.getLocation(location, path); } else if (fo instanceof EclipseFileObject) { path = ((EclipseFileObject) fo).f.toPath(); try { path = path.toRealPath(); } catch (IOException e) { e.printStackTrace(); } LocationContainer container = this.locationHandler.getLocation(location); while (path != null) { Location loc = container.get(path); if (loc != null) return loc; path = path.getParent(); } } return null; }
@Override public void setLocationForModule(Location location, String moduleName, Collection<? extends Path> paths) throws IOException { validateModuleLocation(location, moduleName); this.locationHandler.setLocation(location, moduleName, paths); if (location == StandardLocation.MODULE_SOURCE_PATH) { LocationWrapper wrapper = this.locationHandler.getLocation(StandardLocation.CLASS_OUTPUT, moduleName); if (wrapper == null) { wrapper = this.locationHandler.getLocation(StandardLocation.CLASS_OUTPUT, ""); //$NON-NLS-1$ if (wrapper != null) { Iterator<? extends Path> iterator = wrapper.paths.iterator(); if (iterator.hasNext()) { // Per module output location is always a singleton list Path path = iterator.next().resolve(moduleName); this.locationHandler.setLocation(StandardLocation.CLASS_OUTPUT, moduleName, Collections.singletonList(path)); } } } } } }
@Override public Location getLocationForModule(Location location, String moduleName) throws IOException { validateModuleLocation(location, moduleName); Location result = this.locationHandler.getLocation(location, moduleName); if (result == null && location == StandardLocation.CLASS_OUTPUT) { LocationWrapper wrapper = this.locationHandler.getLocation(StandardLocation.MODULE_SOURCE_PATH, moduleName); deriveOutputLocationForModules(moduleName, wrapper.paths); result = getLocationForModule(location, moduleName); } else if (result == null && location == StandardLocation.SOURCE_OUTPUT) { LocationWrapper wrapper = this.locationHandler.getLocation(StandardLocation.MODULE_SOURCE_PATH, moduleName); deriveSourceOutputLocationForModules(moduleName, wrapper.paths); result = getLocationForModule(location, moduleName); } return result; }
@Override public Iterable<? extends File> getLocation(Location location) { if (location instanceof LocationWrapper) { return getFiles(((LocationWrapper) location).paths); } LocationWrapper loc = this.locationHandler.getLocation(location, ""); //$NON-NLS-1$ if (loc == null) { return null; } return getFiles(loc.getPaths()); }