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

bug 71511: Fixed scanner discovery for minGW

Trim line by scanner discovery console parsers
This commit is contained in:
Andrew Gvozdev 2012-03-22 17:53:03 -04:00
parent 32e726817d
commit 362cd87be0
5 changed files with 113 additions and 64 deletions

View file

@ -40,60 +40,62 @@ import org.eclipse.core.runtime.Path;
*/
public class ScannerInfoConsoleParserFactory {
/**
* Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser
* and a utility.
*/
public static ConsoleOutputSniffer getESIProviderOutputSniffer(
OutputStream outputStream,
OutputStream errorStream,
IProject currentProject,
String providerId,
IScannerConfigBuilderInfo2 scBuildInfo,
IScannerInfoCollector collector,
IMarkerGenerator markerGenerator) {
return getESIProviderOutputSniffer(outputStream, errorStream, currentProject, new InfoContext(currentProject), providerId, scBuildInfo, collector, markerGenerator);
}
/**
* Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser
* and a utility.
*/
public static ConsoleOutputSniffer getESIProviderOutputSniffer(
OutputStream outputStream,
OutputStream errorStream,
IProject currentProject,
InfoContext context,
String providerId,
IScannerConfigBuilderInfo2 scBuildInfo,
IScannerInfoCollector collector,
IMarkerGenerator markerGenerator) {
if (scBuildInfo.isProviderOutputParserEnabled(providerId)) {
// get the ESIProvider console parser
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId());
IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId);
IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(currentProject, MakeBuilder.BUILDER_ID);
clParser.startup(currentProject, buildDirectory, collector, markerGenerator);
// create an output stream sniffer
return new ConsoleOutputSniffer(outputStream, errorStream, new
IScannerInfoConsoleParser[] {clParser});
}
return null;
}
/**
* Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser
* Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser
* and a utility.
*/
public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
OutputStream outputStream,
OutputStream errorStream,
IProject currentProject,
IPath workingDirectory,
IScannerConfigBuilderInfo2 scBuildInfo,
IMarkerGenerator markerGenerator,
IScannerInfoCollector collector) {
return getMakeBuilderOutputSniffer(outputStream, errorStream, currentProject, new InfoContext(currentProject), workingDirectory, scBuildInfo, markerGenerator, collector);
public static ConsoleOutputSniffer getESIProviderOutputSniffer(OutputStream outputStream,
OutputStream errorStream,
IProject project,
String id,
IScannerConfigBuilderInfo2 info2,
IScannerInfoCollector collector,
IMarkerGenerator markerGenerator) {
return getESIProviderOutputSniffer(outputStream, errorStream, project, new InfoContext(project), id, info2, collector, markerGenerator);
}
/**
* Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser
* and a utility.
*/
public static ConsoleOutputSniffer getESIProviderOutputSniffer(OutputStream outputStream,
OutputStream errorStream,
IProject project,
InfoContext infoContext,
String id,
IScannerConfigBuilderInfo2 info2,
IScannerInfoCollector collector,
IMarkerGenerator markerGenerator) {
IScannerInfoConsoleParser parser = getESIConsoleParser(project, infoContext, id, info2, collector, markerGenerator);
if (parser != null) {
return new ConsoleOutputSniffer(outputStream, errorStream, new IScannerInfoConsoleParser[] { parser });
}
return null;
}
/**
/* Get the ESIProvider console parser.
*/
public static IScannerInfoConsoleParser getESIConsoleParser(IProject project,
InfoContext infoContext,
String id,
IScannerConfigBuilderInfo2 info2,
IScannerInfoCollector collector,
IMarkerGenerator markerGenerator) {
if (info2.isProviderOutputParserEnabled(id)) {
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
getSCProfileInstance(project, infoContext, info2.getSelectedProfileId());
IScannerInfoConsoleParser parser = profileInstance.createExternalScannerInfoParser(id);
IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(project, MakeBuilder.BUILDER_ID);
parser.startup(project, buildDirectory, collector, markerGenerator);
return parser;
}
return null;
}
/**
@ -101,14 +103,30 @@ public class ScannerInfoConsoleParserFactory {
* and a utility.
*/
public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
OutputStream outputStream,
OutputStream errorStream,
IProject project,
InfoContext infoContext,
IPath workingDirectory,
IScannerConfigBuilderInfo2 info2,
IMarkerGenerator markerGenerator,
IScannerInfoCollector collector) {
OutputStream outputStream,
OutputStream errorStream,
IProject project,
IPath workingDirectory,
IScannerConfigBuilderInfo2 info2,
IMarkerGenerator markerGenerator,
IScannerInfoCollector collector) {
return getMakeBuilderOutputSniffer(outputStream, errorStream, project, new InfoContext(project), workingDirectory, info2, markerGenerator, collector);
}
/**
* Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser
* and a utility.
*/
public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
OutputStream outputStream,
OutputStream errorStream,
IProject project,
InfoContext infoContext,
IPath workingDirectory,
IScannerConfigBuilderInfo2 info2,
IMarkerGenerator markerGenerator,
IScannerInfoCollector collector) {
IScannerInfoConsoleParser parser = getScannerInfoConsoleParserInternal(project, infoContext, workingDirectory, info2, markerGenerator, collector);
if (parser != null) {
@ -119,8 +137,12 @@ public class ScannerInfoConsoleParserFactory {
return null;
}
private static IScannerInfoConsoleParser getScannerInfoConsoleParserInternal(IProject project, InfoContext infoContext, IPath workingDirectory,
IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, IScannerInfoCollector collector) {
private static IScannerInfoConsoleParser getScannerInfoConsoleParserInternal(IProject project,
InfoContext infoContext,
IPath workingDirectory,
IScannerConfigBuilderInfo2 info2,
IMarkerGenerator markerGenerator,
IScannerInfoCollector collector) {
IScannerInfoConsoleParser parser = null;
// try {
@ -166,8 +188,12 @@ public class ScannerInfoConsoleParserFactory {
}
// TODO - perhaps this be unified with the other one?
public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, InfoContext infoContext, IPath workingDirectory,
IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, IScannerInfoCollector collector) {
public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project,
InfoContext infoContext,
IPath workingDirectory,
IScannerConfigBuilderInfo2 info2,
IMarkerGenerator markerGenerator,
IScannerInfoCollector collector) {
IScannerInfoConsoleParser parser = null;
if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) {

View file

@ -94,6 +94,10 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole
*/
@Override
public boolean processLine(String line) {
line= line.trim();
if (line.length() == 0) {
return false;
}
boolean rc = false;
int lineBreakPos = line.length()-1;
char[] lineChars = line.toCharArray();

View file

@ -15,12 +15,14 @@ import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.internal.core.BuildRunnerHelper;
@ -33,6 +35,7 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@ -123,8 +126,14 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
ErrorParserManager epm = new ErrorParserManager(project, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID});
List<IConsoleParser> parsers = new ArrayList<IConsoleParser>();
IConsoleParser parser = ScannerInfoConsoleParserFactory.getESIConsoleParser(project, context, providerId, buildInfo, collector, markerGenerator);
if (parser != null) {
parsers.add(parser);
}
buildRunnerHelper.setLaunchParameters(launcher, program, comandLineOptions, workingDirectoryURI, envp );
buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
buildRunnerHelper.greeting(MakeMessages.getFormattedString("ExternalScannerInfoProvider.Greeting", project.getName())); //$NON-NLS-1$
buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));

View file

@ -110,6 +110,11 @@ public abstract class AbstractXLCBuildOutputParser implements IScannerInfoConsol
*/
@Override
public boolean processLine(String line) {
line= line.trim();
if (line.length() == 0) {
return false;
}
boolean rc = false;
int lineBreakPos = line.length() - 1;
char[] lineChars = line.toCharArray();

View file

@ -97,6 +97,11 @@ public class XlCSpecsConsoleParser implements IScannerInfoConsoleParser {
TraceUtil.outputTrace(
"XLCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$
line= line.trim();
if (line.length() == 0) {
return false;
}
// testing the output line against the pattern of interest
Matcher lineMatcher = linePattern.matcher(line);
if (lineMatcher.matches()) {