From efdbb0222b9b528ee5740f04c0fd0e61907e6412 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 15 Jan 2023 20:38:53 -0500 Subject: [PATCH] minor formatting changes --- .../processing/mode/java/ErrorChecker.java | 35 +++++++++++++++---- .../processing/mode/java/PreprocService.java | 2 +- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/java/src/processing/mode/java/ErrorChecker.java b/java/src/processing/mode/java/ErrorChecker.java index f302b5078..015673ed3 100644 --- a/java/src/processing/mode/java/ErrorChecker.java +++ b/java/src/processing/mode/java/ErrorChecker.java @@ -1,3 +1,23 @@ +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* +Part of the Processing project - http://processing.org +Copyright (c) 2012-23 The Processing Foundation + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + package processing.mode.java; import java.awt.EventQueue; @@ -84,7 +104,7 @@ public class ErrorChecker { private void handleSketchProblems(PreprocSketch ps) { - Map suggCache = + Map suggestCache = JavaMode.importSuggestEnabled ? new HashMap<>() : Collections.emptyMap(); List iproblems; @@ -117,7 +137,7 @@ public class ErrorChecker { if (p != null && JavaMode.importSuggestEnabled && isUndefinedTypeProblem(iproblem)) { ClassPath cp = searchClassPath.updateAndGet(prev -> prev != null ? prev : new ClassPathFactory().createFromPaths(ps.searchClassPathArray)); - String[] s = suggCache.computeIfAbsent(iproblem.getArguments()[0], + String[] s = suggestCache.computeIfAbsent(iproblem.getArguments()[0], name -> getImportSuggestions(cp, name)); p.setImportSuggestions(s); } @@ -243,11 +263,11 @@ public class ErrorChecker { for (IProblem iproblem : iproblems) { switch (iproblem.getID()) { - case IProblem.ParsingErrorDeleteToken: - case IProblem.ParsingErrorDeleteTokens: - case IProblem.ParsingErrorInvalidToken: - case IProblem.ParsingErrorReplaceTokens: - case IProblem.UnterminatedString: + case IProblem.ParsingErrorDeleteToken, + IProblem.ParsingErrorDeleteTokens, + IProblem.ParsingErrorInvalidToken, + IProblem.ParsingErrorReplaceTokens, + IProblem.UnterminatedString -> { SketchInterval in = ps.mapJavaToSketch(iproblem); if (in == SketchInterval.BEFORE_START) continue; String badCode = ps.getPdeCode(in); @@ -271,6 +291,7 @@ public class ErrorChecker { problems2.add(p); } } + } } } problems.addAll(problems2); diff --git a/java/src/processing/mode/java/PreprocService.java b/java/src/processing/mode/java/PreprocService.java index 31e15818f..b8bc52a2f 100644 --- a/java/src/processing/mode/java/PreprocService.java +++ b/java/src/processing/mode/java/PreprocService.java @@ -2,7 +2,7 @@ /* Part of the Processing project - http://processing.org -Copyright (c) 2012-19 The Processing Foundation +Copyright (c) 2012-23 The Processing Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2