From 316f28e9c06b836d15aa9a5fc25701e89f525ea3 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Fri, 26 May 2006 18:38:15 +0000 Subject: [PATCH] Bug 134310 - Fix the GCC error parser which was really slow on long command lines. Now if the line is longer than a magic number (1000 for now), it is skipped since it's not likely to be an error message. Bug 143952 - Skipping over "instantiated from here" so that it doesn't appear as an error. --- .../tests/FileBasedErrorParserTests.java | 3 ++- .../errorparsers/tests/GCCErrorParserTests.java | 10 ++++++---- .../tests/GenericErrorParserTests.java | 17 ++++------------- .../eclipse/cdt/core/ErrorParserManager.java | 5 +++++ .../internal/errorparsers/GCCErrorParser.java | 5 +++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/FileBasedErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/FileBasedErrorParserTests.java index a9460d50412..cd2d014d9cd 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/FileBasedErrorParserTests.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/FileBasedErrorParserTests.java @@ -36,7 +36,8 @@ public class FileBasedErrorParserTests extends GenericErrorParserTests { File dir = CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/")); File[] testsfiles = dir.listFiles(); for (int i = 0; i < testsfiles.length; i++) { - suite.addTest(new FileBasedErrorParserTests(testsfiles[i])); + if (testsfiles[i].isFile()) + suite.addTest(new FileBasedErrorParserTests(testsfiles[i])); } return suite; } diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java index 8ea3924b085..0b1cd0e9636 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GCCErrorParserTests.java @@ -11,6 +11,8 @@ package org.eclipse.cdt.core.internal.errorparsers.tests; +import java.io.IOException; + import junit.framework.Test; import junit.framework.TestSuite; @@ -73,22 +75,22 @@ public class GCCErrorParserTests extends GenericErrorParserTests { return suite; } - public void testMultipleIncludesError() { + public void testMultipleIncludesError() throws IOException { runParserTest(GCC_ERROR_STREAM1, GCC_ERROR_STREAM1_ERRORS, GCC_ERROR_STREAM1_WARNINGS, GCC_ERROR_STREAM1_FILENAMES, null, new String[]{GCC_ERROR_PARSER_ID}); } - public void testMultiLineDescriptionError() { + public void testMultiLineDescriptionError() throws IOException { runParserTest(GCC_ERROR_STREAM2, GCC_ERROR_STREAM2_ERRORS, GCC_ERROR_STREAM2_WARNINGS, GCC_ERROR_STREAM2_FILENAMES, GCC_ERROR_STREAM2_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID}); } - public void testLongMultiLineDescriptionError() { + public void testLongMultiLineDescriptionError() throws IOException { runParserTest(GCC_ERROR_STREAM3, GCC_ERROR_STREAM3_ERRORS, GCC_ERROR_STREAM3_WARNINGS, GCC_ERROR_STREAM3_FILENAMES, GCC_ERROR_STREAM3_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID}); } - public void testMultiFileMultiLineSingleError() { + public void testMultiFileMultiLineSingleError() throws IOException { runParserTest(GCC_ERROR_STREAM4, GCC_ERROR_STREAM4_ERRORS, GCC_ERROR_STREAM4_WARNINGS, GCC_ERROR_STREAM4_FILENAMES, GCC_ERROR_STREAM4_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID}); } diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java index df08d0a14c2..717dde50361 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/GenericErrorParserTests.java @@ -102,7 +102,7 @@ public class GenericErrorParserTests extends TestCase { } protected void runParserTest(InputStream inputStream, int expectedErrorCount, int expectedWarningCount, - String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) { + String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) throws IOException { assertNotNull(inputStream); @@ -114,17 +114,8 @@ public class GenericErrorParserTests extends TestCase { ErrorParserManager manager; manager = new ImaginaryFilesErrorParserManager(project, markerGenerator, parserID); - try { - transferInputStreamToOutputStream(inputStream, manager.getOutputStream(), 1024); - } catch (Exception ex) { - assertTrue(false); - } finally { - try { - manager.close(); - } catch (Exception ex) { - /* Ignore */ - } - } + transferInputStreamToOutputStream(inputStream, manager.getOutputStream(), 1024); + manager.close(); manager.reportProblems(); if (expectedErrorCount >= 0) { @@ -150,7 +141,7 @@ public class GenericErrorParserTests extends TestCase { } protected void runParserTest(String[] dataStream, int expectedErrorCount, int expectedWarningCount, String[] expectedFileNames, - String[] expectedDescriptions, String[] parserID) { + String[] expectedDescriptions, String[] parserID) throws IOException { String errorStream = makeStringFromArray(dataStream, "\n"); ByteArrayInputStream inputStream = new ByteArrayInputStream(errorStream.getBytes()); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java index daa2b01375c..55c9afd1145 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java @@ -187,6 +187,11 @@ public class ErrorParserManager extends OutputStream { if (fErrorParsers.size() == 0) return; + // If the line is too long, it is most likely a command line and not an error message + // Don't process it since it'll probably be really slow and won't find an error anyway + if (line.length() > 1000) + return; + String[] parserIDs = new String[fErrorParsers.size()]; Iterator items = fErrorParsers.keySet().iterator(); for (int i = 0; items.hasNext(); i++) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java index bce0e44ffbd..83eb25cd10d 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GCCErrorParser.java @@ -30,8 +30,9 @@ public class GCCErrorParser extends AbstractErrorParser { new ErrorPattern("\\(Each undeclared identifier is reported only once"), new ErrorPattern("for each function it appears in.\\)"), new ErrorPattern(": note:"), + new ErrorPattern("instantiated from here"), // The following are not... - new ErrorPattern("((.:)?[^:]*):([0-9]*):([0-9]*:)? ((warning: )?.*)", 1, 3, 5, 0, 0) { + new ErrorPattern("(.*?):([0-9]+):([0-9]+:)? ((warning: )?.*)", 1, 2, 4, 0, 0) { public String getVarName(Matcher matcher) { String desc = getDesc(matcher); Matcher varMatcher = null; @@ -46,7 +47,7 @@ public class GCCErrorParser extends AbstractErrorParser { return varMatcher != null ? varMatcher.group(1) : null; } public int getSeverity(Matcher matcher) { - String warningGroup = matcher.group(6); + String warningGroup = matcher.group(5); if (warningGroup != null) return IMarkerGenerator.SEVERITY_WARNING; else