From 040b1351e83ba29bbba37399433f42f99f5ea27b Mon Sep 17 00:00:00 2001 From: Martin Weber Date: Thu, 4 Jun 2020 21:49:31 +0200 Subject: [PATCH] Bug 559674: Internationalization of UI texts Change-Id: Ie88e2c6b37f68e8f6e7bb1f941d72f1db8fc748d Signed-off-by: Martin Weber --- .../IndexerSupportPreferencePage.java | 9 ++-- .../cmake/is/core/ui/internal/Messages.java | 33 ++++++++++++ .../is/core/ui/internal/messages.properties | 17 +++++++ .../plugin.properties | 3 +- .../org.eclipse.cdt.cmake.is.core/plugin.xml | 2 +- .../is/core/CompileCommandsJsonParser.java | 31 ++++++----- .../eclipse/cdt/cmake/is/core/Messages.java | 37 ++++++++++++++ .../cdt/cmake/is/core/internal/Messages.java | 34 +++++++++++++ .../internal/ParserPreferencesMetadata.java | 7 +-- .../builtins/CompilerBuiltinsDetector.java | 51 ++++++++----------- .../internal/builtins/DetectorConsole.java | 3 +- .../is/core/internal/builtins/Messages.java | 33 ++++++++++++ .../internal/builtins/messages.properties | 17 +++++++ .../is/core/internal/messages.properties | 18 +++++++ .../cdt/cmake/is/core/messages.properties | 21 ++++++++ .../HpeC11ToolDetectionParticipant.java | 2 +- .../HpeC89ToolDetectionParticipant.java | 2 +- .../HpeC99ToolDetectionParticipant.java | 2 +- .../is/intel/IccToolDetectionParticipant.java | 2 +- .../IclCandCppToolDetectionParticipant.java | 2 +- .../is/intel/IclToolDetectionParticipant.java | 2 +- .../IcpcClangToolDetectionParticipant.java | 2 +- .../intel/IcpcToolDetectionParticipant.java | 2 +- .../microsoft/MsclToolCommandlineParser.java | 30 +++++------ .../MsclToolDetectionParticipant.java | 2 +- .../nvidia/NvccBuiltinDetectionBehavior.java | 1 + .../cmake/is/nvidia/NvccLangStdArglet.java | 6 +-- .../nvidia/NvccSystemIncludePathArglet.java | 6 +-- .../nvidia/NvccToolDetectionParticipant.java | 6 +-- 29 files changed, 294 insertions(+), 89 deletions(-) create mode 100644 cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/Messages.java create mode 100644 cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/messages.properties create mode 100644 cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/Messages.java create mode 100644 cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/Messages.java create mode 100644 cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/Messages.java create mode 100644 cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/messages.properties create mode 100644 cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/messages.properties create mode 100644 cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/messages.properties diff --git a/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/IndexerSupportPreferencePage.java b/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/IndexerSupportPreferencePage.java index a9e750dd784..7bb2fb6fe23 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/IndexerSupportPreferencePage.java +++ b/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/IndexerSupportPreferencePage.java @@ -49,7 +49,7 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor public IndexerSupportPreferencePage() { prefsAccess = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()) .get(IParserPreferencesAccess.class); - setDescription("Configure how macros and include paths get extracted from the compile_commands.json file"); + setDescription(Messages.IndexerSupportPreferencePage_description); } /** @@ -64,12 +64,13 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor composite.setLayout(new GridLayout(1, false)); GridDataFactory.swtDefaults().applyTo(composite); - final Group gr = createGroup(composite, SWT.FILL, 1, "For compilers with version in name", 2); + final Group gr = createGroup(composite, SWT.FILL, 1, + Messages.IndexerSupportPreferencePage_label_version_suffix_group, 2); btnVersionsEnabled = createCheckbox(gr, SWT.BEGINNING, 2, prefsMeta.tryVersionSuffix()); btnVersionsEnabled.setSelection(prefs.getTryVersionSuffix()); { Label label = new Label(gr, SWT.NONE); - label.setText("&Suffix pattern:"); + label.setText(Messages.IndexerSupportPreferencePage_label_suffix_pattern); GridDataFactory.defaultsFor(label).applyTo(label); } @@ -87,7 +88,7 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor Pattern.compile(text); setErrorMessage(null); } catch (PatternSyntaxException ex) { - String msg = String.format("Suffix pattern regular expression: %1$s in '%2$s' at index %3$d", + String msg = String.format(Messages.IndexerSupportPreferencePage_errmsg_suffix_regex, ex.getDescription(), ex.getPattern(), ex.getIndex()); setErrorMessage(msg); } diff --git a/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/Messages.java b/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/Messages.java new file mode 100644 index 00000000000..360b6fef5d7 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/Messages.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core.ui.internal; + +import org.eclipse.osgi.util.NLS; + +/** + * @author weber + * + */ +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.is.core.ui.internal.messages"; //$NON-NLS-1$ + public static String IndexerSupportPreferencePage_description; + public static String IndexerSupportPreferencePage_errmsg_suffix_regex; + public static String IndexerSupportPreferencePage_label_suffix_pattern; + public static String IndexerSupportPreferencePage_label_version_suffix_group; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/messages.properties b/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/messages.properties new file mode 100644 index 00000000000..4beadc880de --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/messages.properties @@ -0,0 +1,17 @@ +############################################################################### +# Copyright (c) 2020 Martin Weber and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Martin Weber - initial API and implementation +############################################################################### +IndexerSupportPreferencePage_description=Configure how macros and include paths get extracted from the compile_commands.json file +IndexerSupportPreferencePage_errmsg_suffix_regex=Suffix pattern regular expression: %1$s in '%2$s' at index %3$d +IndexerSupportPreferencePage_label_suffix_pattern=&Suffix pattern: +IndexerSupportPreferencePage_label_version_suffix_group=For compilers with version in name diff --git a/cmake/org.eclipse.cdt.cmake.is.core/plugin.properties b/cmake/org.eclipse.cdt.cmake.is.core/plugin.properties index d4e704ddd36..a12de8f02fa 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/plugin.properties +++ b/cmake/org.eclipse.cdt.cmake.is.core/plugin.properties @@ -8,4 +8,5 @@ This program and the accompanying materials are made\n\ available under the terms of the Eclipse Public License 2.0\n\ which is available at https://www.eclipse.org/legal/epl-2.0/\n\ \n\ -SPDX-License-Identifier: EPL-2.0\n\ \ No newline at end of file +SPDX-License-Identifier: EPL-2.0 +extension-point.name = Detection Participant \ No newline at end of file diff --git a/cmake/org.eclipse.cdt.cmake.is.core/plugin.xml b/cmake/org.eclipse.cdt.cmake.is.core/plugin.xml index 1da39483055..d37c75d877e 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/plugin.xml +++ b/cmake/org.eclipse.cdt.cmake.is.core/plugin.xml @@ -1,7 +1,7 @@ - + "org.eclipse.cdt.cmake.is.core.internal.ui.CompileCommandsJsonParserOptionPage"> diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/CompileCommandsJsonParser.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/CompileCommandsJsonParser.java index 5cd47a16b9b..1535d984d4f 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/CompileCommandsJsonParser.java +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/CompileCommandsJsonParser.java @@ -35,8 +35,8 @@ import org.eclipse.cdt.cmake.is.core.internal.builtins.CompilerBuiltinsDetector; import org.eclipse.cdt.cmake.is.core.participant.DefaultToolDetectionParticipant; import org.eclipse.cdt.cmake.is.core.participant.IRawIndexerInfo; import org.eclipse.cdt.cmake.is.core.participant.IToolCommandlineParser; -import org.eclipse.cdt.cmake.is.core.participant.IToolDetectionParticipant; import org.eclipse.cdt.cmake.is.core.participant.IToolCommandlineParser.IResult; +import org.eclipse.cdt.cmake.is.core.participant.IToolDetectionParticipant; import org.eclipse.cdt.cmake.is.core.participant.builtins.IBuiltinsDetectionBehavior; import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.build.CBuildConfiguration; @@ -87,7 +87,7 @@ public class CompileCommandsJsonParser { private static final QualifiedName TIMESTAMP_COMPILE_COMMANDS_PROPERTY = new QualifiedName(null, "timestamp:compile_commands.json"); //$NON-NLS-1$ - private static final String WORKBENCH_WILL_NOT_KNOW_ALL_MSG = "Your workbench will not know all include paths and preprocessor defines."; + private static final String WORKBENCH_WILL_NOT_KNOW_ALL_MSG = Messages.CompileCommandsJsonParser_MSG_WORKBENCH_WILL_NOT_KNOW; private static final String MARKER_ID = Plugin.PLUGIN_ID + ".CompileCommandsJsonParserMarker"; //$NON-NLS-1$ @@ -135,8 +135,8 @@ public class CompileCommandsJsonParser { * information for each source file */ public CompileCommandsJsonParser(CBuildConfiguration buildConfiguration, IIndexerInfoConsumer indexerInfoConsumer) { - this.cBuildConfiguration = Objects.requireNonNull(buildConfiguration, "buildConfiguration"); - this.indexerInfoConsumer = Objects.requireNonNull(indexerInfoConsumer, "indexerInfoConsumer"); + this.cBuildConfiguration = Objects.requireNonNull(buildConfiguration, "buildConfiguration"); //$NON-NLS-1$ + this.indexerInfoConsumer = Objects.requireNonNull(indexerInfoConsumer, "indexerInfoConsumer"); //$NON-NLS-1$ prefsAccess = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()) .get(IParserPreferencesAccess.class); } @@ -165,8 +165,8 @@ public class CompileCommandsJsonParser { final java.nio.file.Path jsonFile = buildRoot.resolve("compile_commands.json"); //$NON-NLS-1$ if (!Files.exists(jsonFile)) { // no json file was produced in the build - final String msg = "File '" + jsonFile + "' was not created in the build. " - + WORKBENCH_WILL_NOT_KNOW_ALL_MSG; + final String msg = String.format(Messages.CompileCommandsJsonParser_errmsg_file_not_found, jsonFile, + WORKBENCH_WILL_NOT_KNOW_ALL_MSG); createMarker(project, msg); return false; } @@ -184,7 +184,7 @@ public class CompileCommandsJsonParser { Long sessionLastModified = (Long) buildContainer.getSessionProperty(TIMESTAMP_COMPILE_COMMANDS_PROPERTY); if (sessionLastModified == null || sessionLastModified.longValue() < tsJsonModified) { // must parse json file... - monitor.setTaskName("Processing compile_commands.json"); + monitor.setTaskName(Messages.CompileCommandsJsonParser_msg_processing); project.deleteMarkers(MARKER_ID, false, IResource.DEPTH_INFINITE); try (Reader in = new FileReader(jsonFile.toFile())) { @@ -196,11 +196,13 @@ public class CompileCommandsJsonParser { } } catch (JsonSyntaxException | JsonIOException ex) { // file format error - final String msg = "File does not seem to be in JSON format. " + WORKBENCH_WILL_NOT_KNOW_ALL_MSG; + final String msg = String.format(Messages.CompileCommandsJsonParser_errmsg_not_json, jsonFile, + WORKBENCH_WILL_NOT_KNOW_ALL_MSG); createMarker(jsonFileRc, msg); return false; } catch (IOException ex) { - final String msg = "Failed to read file " + jsonFile + ". " + WORKBENCH_WILL_NOT_KNOW_ALL_MSG; + final String msg = String.format(Messages.CompileCommandsJsonParser_errmsg_read_error, jsonFile, + WORKBENCH_WILL_NOT_KNOW_ALL_MSG); createMarker(jsonFileRc, msg); return false; } @@ -259,14 +261,15 @@ public class CompileCommandsJsonParser { } knownUnsupportedTools.add(unkownMarker); - String message = "No parser for command '" + cmdLine + "'. " + WORKBENCH_WILL_NOT_KNOW_ALL_MSG; - createMarker(jsonFile, message); + final String msg = String.format(Messages.CompileCommandsJsonParser_errmsg_no_parser_for_commandline, + cmdLine, WORKBENCH_WILL_NOT_KNOW_ALL_MSG); + createMarker(jsonFile, msg); } return; } // unrecognized entry, skipping - final String msg = "File format error: " + "'file', 'command' or 'directory' missing in JSON object. " - + WORKBENCH_WILL_NOT_KNOW_ALL_MSG; + final String msg = String.format(Messages.CompileCommandsJsonParser_errmsg_unexpected_json, jsonFile, + WORKBENCH_WILL_NOT_KNOW_ALL_MSG); createMarker(jsonFile, msg); } @@ -284,7 +287,7 @@ public class CompileCommandsJsonParser { throws CoreException { if (builtinDetectorsToRun == null || builtinDetectorsToRun.isEmpty()) return; - monitor.setTaskName("Detecting compiler built-ins"); + monitor.setTaskName(Messages.CompileCommandsJsonParser_msg_detecting_builtins); java.nio.file.Path buildDir = cBuildConfiguration.getBuildDirectory(); // run each built-in detector and collect the results.. diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/Messages.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/Messages.java new file mode 100644 index 00000000000..4ed2a8174c5 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/Messages.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core; + +import org.eclipse.osgi.util.NLS; + +/** + * @author weber + * + */ +/* package */ public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.is.core.messages"; //$NON-NLS-1$ + public static String CompileCommandsJsonParser_errmsg_file_not_found; + public static String CompileCommandsJsonParser_errmsg_no_parser_for_commandline; + public static String CompileCommandsJsonParser_errmsg_not_json; + public static String CompileCommandsJsonParser_errmsg_read_error; + public static String CompileCommandsJsonParser_errmsg_unexpected_json; + public static String CompileCommandsJsonParser_msg_detecting_builtins; + public static String CompileCommandsJsonParser_msg_processing; + public static String CompileCommandsJsonParser_MSG_WORKBENCH_WILL_NOT_KNOW; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/Messages.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/Messages.java new file mode 100644 index 00000000000..aff6c3696a6 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/Messages.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core.internal; + +import org.eclipse.osgi.util.NLS; + +/** + * @author weber + * + */ +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.is.core.internal.messages"; //$NON-NLS-1$ + public static String ParserPreferencesMetadata_label_console; + public static String ParserPreferencesMetadata_label_suffix; + public static String ParserPreferencesMetadata_label_try_suffix; + public static String ParserPreferencesMetadata_ttip_suffix; + public static String ParserPreferencesMetadata_ttip_try_suffix; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesMetadata.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesMetadata.java index 912da1fc289..63d4d6280ae 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesMetadata.java +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesMetadata.java @@ -26,11 +26,12 @@ final class ParserPreferencesMetadata implements IParserPreferencesMetadata { public ParserPreferencesMetadata() { this.tryVersionSuffixOption = new BaseOption<>(Boolean.class, "versionSuffixPatternEnabled", false, //$NON-NLS-1$ - "&Also try with version suffix", "Can recognize gcc-12.9.2, clang++-7.5.4, ..."); + Messages.ParserPreferencesMetadata_label_try_suffix, + Messages.ParserPreferencesMetadata_ttip_try_suffix); this.versionSuffixPatternOption = new BaseOption<>(String.class, "versionSuffixPattern", "-?\\d+(\\.\\d+)*", //$NON-NLS-1$ //$NON-NLS-2$ - "&Suffix pattern:", "Specify a Java regular expression pattern here"); + Messages.ParserPreferencesMetadata_label_suffix, Messages.ParserPreferencesMetadata_ttip_suffix); this.allocateConsoleOption = new BaseOption<>(Boolean.class, "allocateConsole", false, //$NON-NLS-1$ - "&Show output of compiler built-in detection in a console in the Console View"); + Messages.ParserPreferencesMetadata_label_console); } @Override diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/CompilerBuiltinsDetector.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/CompilerBuiltinsDetector.java index eb1a35bebf8..f8331b29706 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/CompilerBuiltinsDetector.java +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/CompilerBuiltinsDetector.java @@ -55,11 +55,9 @@ public class CompilerBuiltinsDetector { * console ID for extension point org.eclipse.cdt.core.CBuildConsole (see * plugin.xml) */ - @SuppressWarnings("nls") - private static final String CONSOLE_ID = Plugin.PLUGIN_ID + ".detectorConsole"; + private static final String CONSOLE_ID = Plugin.PLUGIN_ID + ".detectorConsole"; //$NON-NLS-1$ /** error marker ID */ - @SuppressWarnings("nls") - private static final String MARKER_ID = Plugin.PLUGIN_ID + ".CompilerBuiltinsDetectorMarker"; + private static final String MARKER_ID = Plugin.PLUGIN_ID + ".CompilerBuiltinsDetectorMarker"; //$NON-NLS-1$ private final String sourceFileExtension; private final String command; @@ -80,13 +78,12 @@ public class CompilerBuiltinsDetector { * {@code -std=c++17}). * @param sourceFileExtension the extension of the source file name */ - @SuppressWarnings("nls") public CompilerBuiltinsDetector(IBuiltinsDetectionBehavior builtinsDetectionBehavior, String command, List builtinsDetectionArgs, String sourceFileExtension) { - this.sourceFileExtension = Objects.requireNonNull(sourceFileExtension, "sourceFileExtension"); - this.builtinsDetectionBehavior = Objects.requireNonNull(builtinsDetectionBehavior, "builtinsDetectionBehavior"); - this.command = Objects.requireNonNull(command, "command"); - this.builtinsDetectionArgs = Objects.requireNonNull(builtinsDetectionArgs, "builtinsDetectionArgs"); + this.sourceFileExtension = Objects.requireNonNull(sourceFileExtension, "sourceFileExtension"); //$NON-NLS-1$ + this.builtinsDetectionBehavior = Objects.requireNonNull(builtinsDetectionBehavior, "builtinsDetectionBehavior"); //$NON-NLS-1$ + this.command = Objects.requireNonNull(command, "command"); //$NON-NLS-1$ + this.builtinsDetectionArgs = Objects.requireNonNull(builtinsDetectionArgs, "builtinsDetectionArgs"); //$NON-NLS-1$ } /** @@ -138,9 +135,9 @@ public class CompilerBuiltinsDetector { if (console != null) { final ConsoleOutputStream cis = console.getInfoStream(); try { - cis.write(String - .format("Detecting compiler built-ins took %d ms.\n", System.currentTimeMillis() - start) - .getBytes()); + cis.write(String.format(Messages.CompilerBuiltinsDetector_msg_detection_finished, + System.currentTimeMillis() - start).getBytes()); + cis.write("\n".getBytes()); //$NON-NLS-1$ } catch (IOException ignore) { } } @@ -149,7 +146,8 @@ public class CompilerBuiltinsDetector { final int exitValue = proc.exitValue(); if (exitValue != 0 && !builtinsDetectionBehavior.suppressErrormessage()) { // compiler had errors... - String errMsg = String.format("%1$s exited with status %2$d.", command, exitValue); + String errMsg = String.format(Messages.CompilerBuiltinsDetector_errmsg_command_failed, command, + exitValue); createMarker(errMsg); } } @@ -181,14 +179,13 @@ public class CompilerBuiltinsDetector { * @return String array of environment variables in format "var=value". Does not * return {@code null}. */ - @SuppressWarnings("nls") private String[] getEnvp() { IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager(); IEnvironmentVariable[] vars = mngr.getVariables(buildConfiguration, true); // Convert into envp strings Set strings = new HashSet<>(vars.length); for (IEnvironmentVariable var : vars) { - if (var.getName().startsWith("LANGUAGE" + '=') || var.getName().startsWith("LC_ALL" + '=')) + if (var.getName().startsWith("LANGUAGE" + '=') || var.getName().startsWith("LC_ALL" + '=')) //$NON-NLS-1$ //$NON-NLS-2$ continue; strings.add(var.getName() + '=' + var.getValue()); } @@ -198,8 +195,8 @@ public class CompilerBuiltinsDetector { // of the language as long as the encoding is set to UTF-8. // English language is set for parser because it relies on English messages // in the output of the 'gcc -v' builtinsDetectionArgs. - strings.add("LANGUAGE" + "=en"); // override for GNU gettext - strings.add("LC_ALL" + "=C.UTF-8"); // for other parts of the system libraries + strings.add("LANGUAGE" + "=en"); // override for GNU gettext //$NON-NLS-1$ //$NON-NLS-2$ + strings.add("LC_ALL" + "=C.UTF-8"); // for other parts of the system libraries //$NON-NLS-1$ //$NON-NLS-2$ return strings.toArray(new String[strings.size()]); } @@ -239,7 +236,6 @@ public class CompilerBuiltinsDetector { * * @throws CoreException */ - @SuppressWarnings("nls") private IConsole startOutputConsole(IConsole console) throws CoreException { IParserPreferences prefs = EclipseContextFactory .getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()) @@ -250,23 +246,20 @@ public class CompilerBuiltinsDetector { IProject project = buildConfiguration.getProject(); if (console == null) { // need to allocate console, but none is given - String consoleId = CONSOLE_ID + "." + project.getName(); + String consoleId = CONSOLE_ID + "." + project.getName(); //$NON-NLS-1$ console = CCorePlugin.getDefault().getConsole(CONSOLE_ID, consoleId, null, null); } console.start(project); try { final ConsoleOutputStream cis = console.getInfoStream(); - cis.write(SimpleDateFormat.getTimeInstance().format(new Date()).getBytes()); - cis.write(" Detecting compiler built-ins: ".getBytes()); - cis.write(project.getName().getBytes()); - if (!buildConfiguration.getName().isEmpty()) { - cis.write("::".getBytes()); - cis.write(buildConfiguration.getName().getBytes()); - } - cis.write(" for ".getBytes()); - cis.write(sourceFileExtension.getBytes()); - cis.write(" files\n".getBytes()); + String msg; + msg = String.format(Messages.CompilerBuiltinsDetector_msg_detection_start, + SimpleDateFormat.getTimeInstance().format(new Date()), project.getName(), + buildConfiguration.getName().isEmpty() ? "?" : buildConfiguration.getName(), //$NON-NLS-1$ + String.join(" ", builtinsDetectionArgs)); //$NON-NLS-1$ + cis.write(msg.getBytes()); + cis.write("\n".getBytes()); //$NON-NLS-1$ } catch (IOException ignore) { } } diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/DetectorConsole.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/DetectorConsole.java index 286d0b84252..2f7d86d3583 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/DetectorConsole.java +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/DetectorConsole.java @@ -22,8 +22,7 @@ public class DetectorConsole extends AbstractConsole { @Override protected IBuildConsoleManager getConsoleManager() { - return CUIPlugin.getDefault().getConsoleManager("Compiler Built-ins Detection Console", - CONSOLE_CONTEXT_MENU_ID); + return CUIPlugin.getDefault().getConsoleManager(Messages.DetectorConsole_title, CONSOLE_CONTEXT_MENU_ID); } } diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/Messages.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/Messages.java new file mode 100644 index 00000000000..15987bc3994 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/Messages.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core.internal.builtins; + +import org.eclipse.osgi.util.NLS; + +/** + * @author weber + * + */ +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.is.core.internal.builtins.messages"; //$NON-NLS-1$ + public static String CompilerBuiltinsDetector_errmsg_command_failed; + public static String CompilerBuiltinsDetector_msg_detection_finished; + public static String CompilerBuiltinsDetector_msg_detection_start; + public static String DetectorConsole_title; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/messages.properties b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/messages.properties new file mode 100644 index 00000000000..72bdef23577 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/messages.properties @@ -0,0 +1,17 @@ +############################################################################### +# Copyright (c) 2020 Martin Weber and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Martin Weber - initial API and implementation +############################################################################### +CompilerBuiltinsDetector_errmsg_command_failed=%1$s exited with status %2$d. +CompilerBuiltinsDetector_msg_detection_finished=Detecting compiler built-ins took %d ms. +CompilerBuiltinsDetector_msg_detection_start=%1$s Detecting compiler built-ins: %2$s::%3$s for '%4$s' +DetectorConsole_title=Compiler Built-ins Detection Console diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/messages.properties b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/messages.properties new file mode 100644 index 00000000000..e6d267870aa --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/messages.properties @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2020 Martin Weber and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Martin Weber - initial API and implementation +############################################################################### +ParserPreferencesMetadata_label_console=&Show output of compiler built-in detection in a console in the Console View +ParserPreferencesMetadata_label_suffix=&Suffix pattern: +ParserPreferencesMetadata_label_try_suffix=&Also try with version suffix +ParserPreferencesMetadata_ttip_suffix=Specify a Java regular expression pattern here +ParserPreferencesMetadata_ttip_try_suffix=Can recognize gcc-12.9.2, clang++-7.5.4, ... diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/messages.properties b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/messages.properties new file mode 100644 index 00000000000..77e951652f7 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/messages.properties @@ -0,0 +1,21 @@ +############################################################################### +# Copyright (c) 2020 Martin Weber and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Martin Weber - initial API and implementation +############################################################################### +CompileCommandsJsonParser_errmsg_file_not_found=File '%1$s' was not created in the build. %2$s +CompileCommandsJsonParser_errmsg_no_parser_for_commandline=No parser for command '%1$s'. %2$s +CompileCommandsJsonParser_errmsg_not_json=File '%1$s' does not seem to be in JSON format. %2$s +CompileCommandsJsonParser_errmsg_read_error=Failed to read file '%1$s'. %2$s +CompileCommandsJsonParser_errmsg_unexpected_json=Format error in file %1$s: 'file', 'command' or 'directory' missing in JSON object. %2$s +CompileCommandsJsonParser_msg_detecting_builtins=Detecting compiler built-ins +CompileCommandsJsonParser_msg_processing=Processing compile_commands.json +CompileCommandsJsonParser_MSG_WORKBENCH_WILL_NOT_KNOW=Your workbench will not know all include paths and preprocessor defines. diff --git a/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC11ToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC11ToolDetectionParticipant.java index f666502822d..03c596e4f1e 100644 --- a/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC11ToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC11ToolDetectionParticipant.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.cmake.is.core.participant.ResponseFileArglets; public class HpeC11ToolDetectionParticipant extends DefaultToolDetectionParticipant { public HpeC11ToolDetectionParticipant() { - super("c11", true, "exe", new ToolCommandlineParser()); + super("c11", true, "exe", new ToolCommandlineParser()); //$NON-NLS-1$ //$NON-NLS-2$ } private static class ToolCommandlineParser extends DefaultToolCommandlineParser { diff --git a/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC89ToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC89ToolDetectionParticipant.java index 3062afd0ee1..51b70826d58 100644 --- a/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC89ToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC89ToolDetectionParticipant.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.cmake.is.core.participant.ResponseFileArglets; public class HpeC89ToolDetectionParticipant extends DefaultToolDetectionParticipant { public HpeC89ToolDetectionParticipant() { - super("c89", true, "exe", new ToolCommandlineParser()); + super("c89", true, "exe", new ToolCommandlineParser()); //$NON-NLS-1$ //$NON-NLS-2$ } private static class ToolCommandlineParser extends DefaultToolCommandlineParser { diff --git a/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC99ToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC99ToolDetectionParticipant.java index 2e97423c290..130674ec093 100644 --- a/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC99ToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.hpenonstop/src/main/java/org/eclipse/cdt/cmake/is/hpenonstop/HpeC99ToolDetectionParticipant.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.cmake.is.core.participant.ResponseFileArglets; public class HpeC99ToolDetectionParticipant extends DefaultToolDetectionParticipant { public HpeC99ToolDetectionParticipant() { - super("c99", true, "exe", new ToolCommandlineParser()); + super("c99", true, "exe", new ToolCommandlineParser()); //$NON-NLS-1$ //$NON-NLS-2$ } private static class ToolCommandlineParser extends DefaultToolCommandlineParser { diff --git a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IccToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IccToolDetectionParticipant.java index d9e28749526..b149ffe46f6 100644 --- a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IccToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IccToolDetectionParticipant.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.cmake.is.core.participant.DefaultToolDetectionParticipant public class IccToolDetectionParticipant extends DefaultToolDetectionParticipant { public IccToolDetectionParticipant() { - super("icc", IntelCToolCommandlineParser.INSTANCE); + super("icc", IntelCToolCommandlineParser.INSTANCE); //$NON-NLS-1$ // for the record: builtin detection: -EP -dM for macros, -H for include FILES. // NOTE: Windows: /QdM. } diff --git a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IclCandCppToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IclCandCppToolDetectionParticipant.java index 2809479c79c..73355827ef9 100644 --- a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IclCandCppToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IclCandCppToolDetectionParticipant.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.cmake.is.core.participant.ResponseFileArglets; public class IclCandCppToolDetectionParticipant extends DefaultToolDetectionParticipant { public IclCandCppToolDetectionParticipant() { - super("icl", true, "exe", new CandCppToolCommandlineParser()); + super("icl", true, "exe", new CandCppToolCommandlineParser()); //$NON-NLS-1$ //$NON-NLS-2$ } private static class CandCppToolCommandlineParser extends DefaultToolCommandlineParser { diff --git a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IclToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IclToolDetectionParticipant.java index 4da306dc977..147e70d5ae7 100644 --- a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IclToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IclToolDetectionParticipant.java @@ -19,6 +19,6 @@ import org.eclipse.cdt.cmake.is.core.participant.DefaultToolDetectionParticipant public class IclToolDetectionParticipant extends DefaultToolDetectionParticipant { public IclToolDetectionParticipant() { - super("icl", IntelCToolCommandlineParser.INSTANCE); + super("icl", IntelCToolCommandlineParser.INSTANCE); //$NON-NLS-1$ } } diff --git a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IcpcClangToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IcpcClangToolDetectionParticipant.java index d8fe4c939c6..138067510f2 100644 --- a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IcpcClangToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IcpcClangToolDetectionParticipant.java @@ -19,6 +19,6 @@ import org.eclipse.cdt.cmake.is.core.participant.DefaultToolDetectionParticipant public class IcpcClangToolDetectionParticipant extends DefaultToolDetectionParticipant { public IcpcClangToolDetectionParticipant() { - super("icl\\+\\+", IntelCppToolCommandlineParser.INSTANCE); + super("icl\\+\\+", IntelCppToolCommandlineParser.INSTANCE); //$NON-NLS-1$ } } diff --git a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IcpcToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IcpcToolDetectionParticipant.java index d82d7bf9885..a273d2d19c9 100644 --- a/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IcpcToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.intel/src/main/java/org/eclipse/cdt/cmake/is/intel/IcpcToolDetectionParticipant.java @@ -19,6 +19,6 @@ import org.eclipse.cdt.cmake.is.core.participant.DefaultToolDetectionParticipant public class IcpcToolDetectionParticipant extends DefaultToolDetectionParticipant { public IcpcToolDetectionParticipant() { - super("icpc", IntelCppToolCommandlineParser.INSTANCE); + super("icpc", IntelCppToolCommandlineParser.INSTANCE); //$NON-NLS-1$ } } diff --git a/cmake/org.eclipse.cdt.cmake.is.microsoft/src/main/java/org/eclipse/cdt/cmake/is/microsoft/MsclToolCommandlineParser.java b/cmake/org.eclipse.cdt.cmake.is.microsoft/src/main/java/org/eclipse/cdt/cmake/is/microsoft/MsclToolCommandlineParser.java index 4dbe5923115..d648a49ade5 100644 --- a/cmake/org.eclipse.cdt.cmake.is.microsoft/src/main/java/org/eclipse/cdt/cmake/is/microsoft/MsclToolCommandlineParser.java +++ b/cmake/org.eclipse.cdt.cmake.is.microsoft/src/main/java/org/eclipse/cdt/cmake/is/microsoft/MsclToolCommandlineParser.java @@ -9,15 +9,15 @@ package org.eclipse.cdt.cmake.is.microsoft; -import org.eclipse.cdt.cmake.is.core.participant.DefaultToolCommandlineParser; -import org.eclipse.cdt.cmake.is.core.participant.IArglet; -import org.eclipse.cdt.cmake.is.core.participant.IToolCommandlineParser; -import org.eclipse.cdt.cmake.is.core.participant.ResponseFileArglets; import org.eclipse.cdt.cmake.is.core.participant.Arglets.IncludePathGeneric; import org.eclipse.cdt.cmake.is.core.participant.Arglets.MacroDefineGeneric; import org.eclipse.cdt.cmake.is.core.participant.Arglets.MacroUndefineGeneric; import org.eclipse.cdt.cmake.is.core.participant.Arglets.NameOptionMatcher; import org.eclipse.cdt.cmake.is.core.participant.Arglets.NameValueOptionMatcher; +import org.eclipse.cdt.cmake.is.core.participant.DefaultToolCommandlineParser; +import org.eclipse.cdt.cmake.is.core.participant.IArglet; +import org.eclipse.cdt.cmake.is.core.participant.IToolCommandlineParser; +import org.eclipse.cdt.cmake.is.core.participant.ResponseFileArglets; import org.eclipse.core.runtime.IPath; /** @@ -36,17 +36,17 @@ class MsclToolCommandlineParser extends DefaultToolCommandlineParser { //////////////////////////////////////////////////////////////////// /** matches a macro name, with optional macro parameter list */ - private static final String REGEX_MACRO_NAME = "([\\w$]+)(?:\\([\\w$, ]*?\\))?"; + private static final String REGEX_MACRO_NAME = "([\\w$]+)(?:\\([\\w$, ]*?\\))?"; //$NON-NLS-1$ /** * matches a macro name, skipping leading whitespace. Name in matcher group 1 */ - private static final String REGEX_MACRO_NAME_SKIP_LEADING_WS = "\\s*" + REGEX_MACRO_NAME; + private static final String REGEX_MACRO_NAME_SKIP_LEADING_WS = "\\s*" + REGEX_MACRO_NAME; //$NON-NLS-1$ /** matches an include path with quoted directory. Name in matcher group 2 */ - private static final String REGEX_INCLUDEPATH_QUOTED_DIR = "\\s*([\"'])(.+?)\\1"; + private static final String REGEX_INCLUDEPATH_QUOTED_DIR = "\\s*([\"'])(.+?)\\1"; //$NON-NLS-1$ /** * matches an include path with unquoted directory. Name in matcher group 1 */ - private static final String REGEX_INCLUDEPATH_UNQUOTED_DIR = "\\s*([^\\s]+)"; + private static final String REGEX_INCLUDEPATH_UNQUOTED_DIR = "\\s*([^\\s]+)"; //$NON-NLS-1$ /** * A tool argument parser capable to parse a cl (Microsoft c compiler) @@ -55,9 +55,9 @@ class MsclToolCommandlineParser extends DefaultToolCommandlineParser { public static class IncludePath_C_CL extends IncludePathGeneric implements IArglet { private static final NameOptionMatcher[] optionMatchers = { /* quoted directory */ - new NameOptionMatcher("[-/]I" + REGEX_INCLUDEPATH_QUOTED_DIR, 2), + new NameOptionMatcher("[-/]I" + REGEX_INCLUDEPATH_QUOTED_DIR, 2), //$NON-NLS-1$ /* unquoted directory */ - new NameOptionMatcher("[-/]I" + REGEX_INCLUDEPATH_UNQUOTED_DIR, 1), }; + new NameOptionMatcher("[-/]I" + REGEX_INCLUDEPATH_UNQUOTED_DIR, 1), }; //$NON-NLS-1$ /*- * @see org.eclipse.cdt.cmake.is.IArglet#processArgs(java.lang.String) @@ -76,13 +76,13 @@ class MsclToolCommandlineParser extends DefaultToolCommandlineParser { private static final NameValueOptionMatcher[] optionMatchers = { /* quoted value, whitespace in value, w/ macro arglist */ - new NameValueOptionMatcher("[-/]D" + REGEX_MACRO_NAME_SKIP_LEADING_WS + "((?:=)([\"'])(.+?)\\4)", 1, 5), + new NameValueOptionMatcher("[-/]D" + REGEX_MACRO_NAME_SKIP_LEADING_WS + "((?:=)([\"'])(.+?)\\4)", 1, 5), //$NON-NLS-1$ //$NON-NLS-2$ /* w/ macro arglist */ - new NameValueOptionMatcher("[-/]D" + REGEX_MACRO_NAME_SKIP_LEADING_WS + "((?:=)(\\S+))?", 1, 3), + new NameValueOptionMatcher("[-/]D" + REGEX_MACRO_NAME_SKIP_LEADING_WS + "((?:=)(\\S+))?", 1, 3), //$NON-NLS-1$ //$NON-NLS-2$ /* quoted name, whitespace in value, w/ macro arglist */ - new NameValueOptionMatcher("[-/]D" + REGEX_MACRO_NAME_SKIP_LEADING_WS + "((?:=)(.+?))?\\1", 2, 5), + new NameValueOptionMatcher("[-/]D" + REGEX_MACRO_NAME_SKIP_LEADING_WS + "((?:=)(.+?))?\\1", 2, 5), //$NON-NLS-1$ //$NON-NLS-2$ /* w/ macro arglist, shell escapes \' and \" in value */ - new NameValueOptionMatcher("[-/]D" + REGEX_MACRO_NAME_SKIP_LEADING_WS + "(?:=)((\\\\([\"']))(.*?)\\2)", + new NameValueOptionMatcher("[-/]D" + REGEX_MACRO_NAME_SKIP_LEADING_WS + "(?:=)((\\\\([\"']))(.*?)\\2)", //$NON-NLS-1$ //$NON-NLS-2$ 1, 2), }; /*- @@ -101,7 +101,7 @@ class MsclToolCommandlineParser extends DefaultToolCommandlineParser { public static class MacroUndefine_C_CL extends MacroUndefineGeneric implements IArglet { private static final NameOptionMatcher optionMatcher = new NameOptionMatcher( - "[-/]U" + REGEX_MACRO_NAME_SKIP_LEADING_WS, 1); + "[-/]U" + REGEX_MACRO_NAME_SKIP_LEADING_WS, 1); //$NON-NLS-1$ /*- * @see org.eclipse.cdt.cmake.is.IArglet#processArgument(java.util.List, java.lang.String) diff --git a/cmake/org.eclipse.cdt.cmake.is.microsoft/src/main/java/org/eclipse/cdt/cmake/is/microsoft/MsclToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.microsoft/src/main/java/org/eclipse/cdt/cmake/is/microsoft/MsclToolDetectionParticipant.java index 518c9ac4a65..2fe6dad0a1f 100644 --- a/cmake/org.eclipse.cdt.cmake.is.microsoft/src/main/java/org/eclipse/cdt/cmake/is/microsoft/MsclToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.microsoft/src/main/java/org/eclipse/cdt/cmake/is/microsoft/MsclToolDetectionParticipant.java @@ -19,6 +19,6 @@ import org.eclipse.cdt.cmake.is.core.participant.DefaultToolDetectionParticipant public class MsclToolDetectionParticipant extends DefaultToolDetectionParticipant { public MsclToolDetectionParticipant() { - super("cl", true, "exe", new MsclToolCommandlineParser()); + super("cl", true, "exe", new MsclToolCommandlineParser()); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccBuiltinDetectionBehavior.java b/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccBuiltinDetectionBehavior.java index ba9e62c1a9f..8f2df0b74f9 100644 --- a/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccBuiltinDetectionBehavior.java +++ b/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccBuiltinDetectionBehavior.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.cmake.is.core.participant.builtins.IBuiltinsOutputProcess */ class NvccBuiltinDetectionBehavior implements IBuiltinsDetectionBehavior { // -E -Xcompiler -P -Xcompiler -dM for macros, -Xcompiler -v for include paths + @SuppressWarnings("nls") private final List enablingArgs = Arrays.asList("-E", "-Xcompiler", "-P", "-Xcompiler", "-dM", "-Xcompiler", "-v"); diff --git a/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccLangStdArglet.java b/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccLangStdArglet.java index 863a1d51b36..f369a129992 100644 --- a/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccLangStdArglet.java +++ b/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccLangStdArglet.java @@ -12,8 +12,8 @@ package org.eclipse.cdt.cmake.is.nvidia; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.cdt.cmake.is.core.participant.IArglet; import org.eclipse.cdt.cmake.is.core.participant.Arglets.BuiltinDetctionArgsGeneric; +import org.eclipse.cdt.cmake.is.core.participant.IArglet; import org.eclipse.core.runtime.IPath; /** @@ -21,8 +21,8 @@ import org.eclipse.core.runtime.IPath; * standard {@code --std=xxx}. */ public class NvccLangStdArglet extends BuiltinDetctionArgsGeneric implements IArglet { - private static final Matcher[] optionMatchers = { Pattern.compile("--std \\S+").matcher(""), - Pattern.compile("-std \\S+").matcher(""), }; + private static final Matcher[] optionMatchers = { Pattern.compile("--std \\S+").matcher(""), //$NON-NLS-1$ //$NON-NLS-2$ + Pattern.compile("-std \\S+").matcher(""), }; //$NON-NLS-1$ //$NON-NLS-2$ /*- * @see org.eclipse.cdt.cmake.is.IArglet#processArgs(java.lang.String) diff --git a/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccSystemIncludePathArglet.java b/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccSystemIncludePathArglet.java index 7ee90c68a82..475039979b1 100644 --- a/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccSystemIncludePathArglet.java +++ b/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccSystemIncludePathArglet.java @@ -9,9 +9,9 @@ package org.eclipse.cdt.cmake.is.nvidia; -import org.eclipse.cdt.cmake.is.core.participant.IArglet; import org.eclipse.cdt.cmake.is.core.participant.Arglets.IncludePathGeneric; import org.eclipse.cdt.cmake.is.core.participant.Arglets.NameOptionMatcher; +import org.eclipse.cdt.cmake.is.core.participant.IArglet; import org.eclipse.core.runtime.IPath; /** @@ -25,9 +25,9 @@ import org.eclipse.core.runtime.IPath; class NvccSystemIncludePathArglet extends IncludePathGeneric implements IArglet { static final NameOptionMatcher[] optionMatchers = { /* quoted directory */ - new NameOptionMatcher("-isystem=" + "([\"'])(.+?)\\1", 2), + new NameOptionMatcher("-isystem=" + "([\"'])(.+?)\\1", 2), //$NON-NLS-1$ //$NON-NLS-2$ /* unquoted directory */ - new NameOptionMatcher("-isystem=" + "([^\\s]+)", 1), }; + new NameOptionMatcher("-isystem=" + "([^\\s]+)", 1), }; //$NON-NLS-1$ //$NON-NLS-2$ /*- * @see org.eclipse.cdt.cmake.is.IArglet#processArgs(java.lang.String) diff --git a/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccToolDetectionParticipant.java b/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccToolDetectionParticipant.java index c0eb4a850ea..64797d32641 100644 --- a/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccToolDetectionParticipant.java +++ b/cmake/org.eclipse.cdt.cmake.is.nvidia/src/main/java/org/eclipse/cdt/cmake/is/nvidia/NvccToolDetectionParticipant.java @@ -9,9 +9,6 @@ package org.eclipse.cdt.cmake.is.nvidia; -import java.util.Collections; -import java.util.Set; - import org.eclipse.cdt.cmake.is.core.participant.Arglets; import org.eclipse.cdt.cmake.is.core.participant.DefaultToolCommandlineParser; import org.eclipse.cdt.cmake.is.core.participant.DefaultToolDetectionParticipant; @@ -24,10 +21,9 @@ import org.eclipse.cdt.cmake.is.core.participant.ResponseFileArglets; * @author Martin Weber */ public class NvccToolDetectionParticipant extends DefaultToolDetectionParticipant { - static final String COM_NVIDIA_CUDA_LANGUAGE_ID = "com.nvidia.cuda.toolchain.language.cuda.cu"; public NvccToolDetectionParticipant() { - super("nvcc", true, "exe", new ToolCommandlineParser()); + super("nvcc", true, "exe", new ToolCommandlineParser()); //$NON-NLS-1$//$NON-NLS-2$ } private static class ToolCommandlineParser extends DefaultToolCommandlineParser {