37
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
|
3 |
* All rights reserved. This program and the accompanying materials
|
|
4 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
5 |
* which accompanies this distribution, and is available at
|
|
6 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
7 |
*
|
|
8 |
* Contributors:
|
|
9 |
* IBM Corporation - initial API and implementation
|
|
10 |
* James Blackburn - Patch for PR 85264
|
|
11 |
* Norbert Ploett (Siemens AG) - externalized strings
|
|
12 |
*******************************************************************************/
|
|
13 |
|
|
14 |
package org.eclipse.cdt.internal.errorparsers;
|
|
15 |
|
|
16 |
import java.util.regex.Matcher;
|
|
17 |
import java.util.regex.Pattern;
|
|
18 |
|
|
19 |
import org.eclipse.cdt.core.IMarkerGenerator;
|
|
20 |
import org.eclipse.cdt.core.errorparsers.AbstractErrorParser;
|
|
21 |
import org.eclipse.cdt.core.errorparsers.ErrorPattern;
|
|
22 |
|
|
23 |
public class GCCErrorParser extends AbstractErrorParser {
|
|
24 |
|
|
25 |
private static final Pattern[] varPatterns = {
|
|
26 |
Pattern.compile(Messages.GCCErrorParser_varPattern_undeclared),
|
|
27 |
Pattern.compile(Messages.GCCErrorParser_varPattern_defdNotUsed),
|
|
28 |
Pattern.compile(Messages.GCCErrorParser_varPattern_conflictTypes),
|
|
29 |
Pattern.compile(Messages.GCCErrorParser_varPattern_parseError)
|
|
30 |
};
|
|
31 |
|
|
32 |
private static final ErrorPattern[] patterns = {
|
|
33 |
// The following are skipped
|
|
34 |
new ErrorPattern(Messages.GCCErrorParser_skip_UndeclaredOnlyOnce),
|
|
35 |
new ErrorPattern(Messages.GCCErrorParser_skip_forEachFunction),
|
|
36 |
new ErrorPattern(Messages.GCCErrorParser_skip_note),
|
|
37 |
new ErrorPattern(Messages.GCCErrorParser_sikp_instantiatedFromHere),
|
|
38 |
// The following are not...
|
|
39 |
new ErrorPattern(Messages.GCCErrorParser_Warnings, 1, 2, 5, 0, 0) {
|
|
40 |
@Override
|
|
41 |
public String getVarName(Matcher matcher) {
|
|
42 |
String desc = getDesc(matcher);
|
|
43 |
if (desc == null)
|
|
44 |
return null;
|
|
45 |
|
|
46 |
for (int i = 0; i < varPatterns.length; ++i) {
|
|
47 |
Matcher varMatcher = varPatterns[i].matcher(desc);
|
|
48 |
if (varMatcher.find())
|
|
49 |
return varMatcher.group(1);
|
|
50 |
}
|
|
51 |
return null;
|
|
52 |
}
|
|
53 |
@Override
|
|
54 |
public int getSeverity(Matcher matcher) {
|
|
55 |
String warningGroup = matcher.group(4);
|
58
|
56 |
if (warningGroup != null && (warningGroup.toLowerCase().endsWith("warning:") || //$NON-NLS-1$
|
|
57 |
warningGroup.trim().toLowerCase().startsWith("warning:")) ) { //$NON-NLS-1$
|
37
|
58 |
return IMarkerGenerator.SEVERITY_WARNING;
|
58
|
59 |
}
|
37
|
60 |
|
|
61 |
return IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
|
|
62 |
}
|
|
63 |
}
|
|
64 |
};
|
|
65 |
|
|
66 |
public GCCErrorParser() {
|
|
67 |
super(patterns);
|
|
68 |
}
|
|
69 |
|
|
70 |
}
|