1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 559674: Internationalization of UI texts

Change-Id: Ie88e2c6b37f68e8f6e7bb1f941d72f1db8fc748d
Signed-off-by: Martin Weber <fifteenknots505@gmail.com>
This commit is contained in:
Martin Weber 2020-06-04 21:49:31 +02:00
parent 22236ae356
commit 040b1351e8
29 changed files with 294 additions and 89 deletions

View file

@ -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);
}

View file

@ -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() {
}
}

View file

@ -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

View file

@ -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\
SPDX-License-Identifier: EPL-2.0
extension-point.name = Detection Participant

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="detectionParticipant" name="Detection Participant" schema="schema/participant.exsd"/>
<extension-point id="detectionParticipant" name="%extension-point.name" schema="schema/participant.exsd"/>
"org.eclipse.cdt.cmake.is.core.internal.ui.CompileCommandsJsonParserOptionPage">
<extension
point="org.eclipse.cdt.core.CBuildConsole">

View file

@ -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..

View file

@ -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() {
}
}

View file

@ -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() {
}
}

View file

@ -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

View file

@ -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<String> 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<String> 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) {
}
}

View file

@ -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);
}
}

View file

@ -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() {
}
}

View file

@ -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

View file

@ -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, ...

View file

@ -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.

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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.
}

View file

@ -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 {

View file

@ -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$
}
}

View file

@ -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$
}
}

View file

@ -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$
}
}

View file

@ -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)

View file

@ -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$
}
}

View file

@ -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<String> enablingArgs = Arrays.asList("-E", "-Xcompiler", "-P", "-Xcompiler", "-dM", "-Xcompiler",
"-v");

View file

@ -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)

View file

@ -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)

View file

@ -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 {