Changeset 19050 in josm for trunk/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java
- Timestamp:
- 2024-04-22T20:59:26+02:00 (4 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java
r19048 r19050 11 11 import java.nio.charset.StandardCharsets; 12 12 import java.nio.file.Files; 13 import java.nio.file.Path; 13 14 import java.nio.file.Paths; 14 15 import java.util.ArrayList; … … 30 31 import org.openstreetmap.josm.cli.CLIModule; 31 32 import org.openstreetmap.josm.data.Preferences; 33 import org.openstreetmap.josm.data.osm.DataSet; 32 34 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 33 35 import org.openstreetmap.josm.data.preferences.JosmUrls; … … 174 176 } 175 177 this.initialize(); 176 final var fileMonitor = progressMonitorFactory.get();178 final ProgressMonitor fileMonitor = progressMonitorFactory.get(); 177 179 fileMonitor.beginTask(tr("Processing files..."), this.input.size()); 178 180 for (String inputFile : this.input) { … … 200 202 */ 201 203 private static void processMapcssFile(final String inputFile) throws ParseException { 202 final varstyleSource = new MapCSSStyleSource(new File(inputFile).toURI().getPath(), inputFile, inputFile);204 final MapCSSStyleSource styleSource = new MapCSSStyleSource(new File(inputFile).toURI().getPath(), inputFile, inputFile); 203 205 styleSource.loadStyleSource(); 204 206 if (!styleSource.getErrors().isEmpty()) { … … 219 221 // Check asserts 220 222 Config.getPref().putBoolean("validator.check_assert_local_rules", true); 221 final var mapCSSTagChecker = new MapCSSTagChecker();222 final var assertionErrors = new ArrayList<String>();223 final MapCSSTagChecker mapCSSTagChecker = new MapCSSTagChecker(); 224 final Collection<String> assertionErrors = new ArrayList<>(); 223 225 final MapCSSTagChecker.ParseResult result = mapCSSTagChecker.addMapCSS(new File(inputFile).toURI().getPath(), 224 226 assertionErrors::add); … … 245 247 */ 246 248 private void processFile(final String inputFile) throws IllegalDataException, IOException { 247 final varinputFileFile = new File(inputFile);249 final File inputFileFile = new File(inputFile); 248 250 final List<FileImporter> inputFileImporters = ExtensionFileFilter.getImporters().stream() 249 251 .filter(importer -> importer.acceptFile(inputFileFile)).collect(Collectors.toList()); 250 final varstopwatch = Stopwatch.createStarted();252 final Stopwatch stopwatch = Stopwatch.createStarted(); 251 253 if (inputFileImporters.stream().noneMatch(fileImporter -> 252 254 fileImporter.importDataHandleExceptions(inputFileFile, progressMonitorFactory.get()))) { … … 261 263 .stream().filter(layer -> inputFileFile.equals(layer.getAssociatedFile())) 262 264 .findFirst().orElseThrow(() -> new JosmRuntimeException(tr("Could not find a layer for {0}", inputFile))); 263 final vardataSet = dataLayer.getDataSet();265 final DataSet dataSet = dataLayer.getDataSet(); 264 266 if (this.changeFiles.containsKey(inputFile)) { 265 final var changeFilesMonitor = progressMonitorFactory.get();267 final ProgressMonitor changeFilesMonitor = progressMonitorFactory.get(); 266 268 for (String changeFile : this.changeFiles.getOrDefault(inputFile, Collections.emptyList())) { 267 try ( varchangeStream = Compression.getUncompressedFileInputStream(Paths.get(changeFile))) {269 try (InputStream changeStream = Compression.getUncompressedFileInputStream(Paths.get(changeFile))) { 268 270 dataSet.mergeFrom(OsmChangeReader.parseDataSet(changeStream, changeFilesMonitor)); 269 271 } 270 272 } 271 273 } 272 final varpath = Paths.get(outputFile);274 final Path path = Paths.get(outputFile); 273 275 if (path.toFile().isFile() && !Files.deleteIfExists(path)) { 274 276 Logging.error("Could not delete {0}, attempting to append", outputFile); 275 277 } 276 final var geoJSONMapRouletteWriter = new GeoJSONMapRouletteWriter(dataSet);278 final GeoJSONMapRouletteWriter geoJSONMapRouletteWriter = new GeoJSONMapRouletteWriter(dataSet); 277 279 OsmValidator.initializeTests(); 278 280 279 try ( varfileOutputStream = Files.newOutputStream(path)) {281 try (OutputStream fileOutputStream = Files.newOutputStream(path)) { 280 282 // The first writeErrors catches anything that was written, for whatever reason. This is probably never 281 283 // going to be called. … … 346 348 /** 347 349 * Initialize everything that might be needed 348 * <p>350 * 349 351 * Arguments may need to be parsed first. 350 352 */ … … 367 369 Logging.setLogLevel(Level.INFO); 368 370 369 final var parser = new OptionParser("JOSM validate");370 final var currentInput = new AtomicReference<String>(null);371 OptionParser parser = new OptionParser("JOSM validate"); 372 final AtomicReference<String> currentInput = new AtomicReference<>(null); 371 373 for (Option o : Option.values()) { 372 374 if (o.requiresArgument()) { … … 423 425 break; 424 426 case LOAD_PREFERENCES: 425 final vartempPreferences = new Preferences();427 final Preferences tempPreferences = new Preferences(); 426 428 tempPreferences.enableSaveOnPut(false); 427 final var config = new CustomConfigurator.XMLCommandProcessor(tempPreferences);429 CustomConfigurator.XMLCommandProcessor config = new CustomConfigurator.XMLCommandProcessor(tempPreferences); 428 430 try (InputStream is = Utils.openStream(new File(argument).toURI().toURL())) { 429 431 config.openAndReadXML(is); … … 433 435 final IPreferences pref = Config.getPref(); 434 436 if (pref instanceof MemoryPreferences) { 435 final varmemoryPreferences = (MemoryPreferences) pref;437 final MemoryPreferences memoryPreferences = (MemoryPreferences) pref; 436 438 tempPreferences.getAllSettings().forEach(memoryPreferences::putSetting); 437 439 } else { … … 452 454 453 455 private static String getHelp() { 454 final varhelpPadding = "\t ";456 final String helpPadding = "\t "; 455 457 // CHECKSTYLE.OFF: SingleSpaceSeparator 456 458 return tr("JOSM Validation command line interface") + "\n\n" +
Note:
See TracChangeset
for help on using the changeset viewer.