From b5d0a617f24cadf51b8d5abf7a3ae458c854c96a Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sat, 9 Feb 2013 06:53:47 -0500 Subject: [PATCH 1/2] Added logging methods with severity as parameter --- .../src/org/eclipse/cdt/core/CCorePlugin.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 42387484aef..22a22903a2e 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -1331,6 +1331,34 @@ public class CCorePlugin extends Plugin { log(createStatus(e)); } + /** + * Print a message in the log + * + * @param severity - desired severity of the message in the log, + * one of {@link IStatus#INFO}, {@link IStatus#WARNING} or {@link IStatus#ERROR} + * @param msg - message + * + * @since 5.5 + * @noreference This method is not intended to be referenced by clients. + */ + public static void log(int severity, String msg) { + log(new Status(severity, PLUGIN_ID, msg)); + } + + /** + * Print a message in the log accompanied by stack trace + * + * @param severity - desired severity of the message in the log, + * one of {@link IStatus#INFO}, {@link IStatus#WARNING} or {@link IStatus#ERROR} + * @param msg - message + * + * @since 5.5 + * @noreference This method is not intended to be referenced by clients. + */ + public static void logStackTrace(int severity, String msg) { + log(new Status(severity, PLUGIN_ID, msg, new Exception())); + } + /** * @noreference This method is not intended to be referenced by clients. */ From e4966b7c0c0fc0c3841340a7c8f586d514eac9f1 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Mon, 18 Feb 2013 14:18:29 -0500 Subject: [PATCH 2/2] bug 401116: Built-in compiler settings cannot be scanner-discovered prior to a build by non-shared language settings providers --- .../settings/providers/AbstractBuiltinSpecsDetector.java | 6 +++--- .../src/org/eclipse/cdt/core/CommandLauncher.java | 5 +++++ .../utils/org/eclipse/cdt/internal/core/Messages.java | 1 + .../utils/org/eclipse/cdt/internal/core/messages.properties | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java index 4a732655bd2..7bf95aca69b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java @@ -325,9 +325,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti @Override protected URI getBuildDirURI(URI mappedRootURI) { - // Do not calculate buildDirURI for each line if (buildDirURI == null) { - buildDirURI = super.getBuildDirURI(mappedRootURI); + // do not use build directory from MBS which could be not-existent when the provider runs + buildDirURI = currentProject != null ? currentProject.getLocationURI() : null; } return buildDirURI; } @@ -347,7 +347,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti super.startup(cfgDescription, cwdTracker); mappedRootURI = null; - buildDirURI = super.getBuildDirURI(mappedRootURI); + buildDirURI = getBuildDirURI(mappedRootURI); } @Override diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java index a5e0555717e..b93f723cb34 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java @@ -25,6 +25,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.osgi.util.NLS; @@ -184,6 +185,10 @@ public class CommandLauncher implements ICommandLauncher { } File dir = workingDirectory != null ? workingDirectory.toFile() : null; + if (dir != null && !dir.isDirectory()) { + CCorePlugin.logStackTrace(IStatus.ERROR, NLS.bind(Messages.CommandLauncher_InvalidWorkingDirectory, dir)); + dir = null; + } try { fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java index 56fead20b7e..c63c806cecb 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java @@ -17,6 +17,7 @@ public class Messages extends NLS { public static String Util_unexpectedError; public static String Addr_valueOutOfRange; public static String CommandLauncher_CommandCancelled; + public static String CommandLauncher_InvalidWorkingDirectory; public static String CommandLauncher_ProgramNotFoundInPath; public static String convention_illegalIdentifier; public static String convention_invalid; diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties index 9c51cb755e7..0dcb682ba7b 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties @@ -48,6 +48,7 @@ Util_unexpectedError=Unexpected error Addr_valueOutOfRange=Address is outside valid range. CommandLauncher_CommandCancelled=Command canceled +CommandLauncher_InvalidWorkingDirectory=Launch attempt in non existent working directory "{0}" CommandLauncher_ProgramNotFoundInPath=Error: Program "{0}" not found in PATH XmlUtil_InternalErrorLoading=Internal error while trying to load XML document