Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c9666bc8099e9a99e4629a9fd618a1717840079b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*******************************************************************************
 * Copyright (c) 2005, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     James Blackburn - Patch for PR 85264
 *     Norbert Ploett (Siemens AG) - externalized strings
 *******************************************************************************/

package org.eclipse.cdt.internal.errorparsers;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.errorparsers.AbstractErrorParser;
import org.eclipse.cdt.core.errorparsers.ErrorPattern;

public class GCCErrorParser extends AbstractErrorParser {
	
	private static final Pattern[] varPatterns = {
		Pattern.compile(Messages.GCCErrorParser_varPattern_undeclared),
		Pattern.compile(Messages.GCCErrorParser_varPattern_defdNotUsed),
		Pattern.compile(Messages.GCCErrorParser_varPattern_conflictTypes),
		Pattern.compile(Messages.GCCErrorParser_varPattern_parseError)
	};
	
	private static final ErrorPattern[] patterns = {
		// The following are skipped
		new ErrorPattern(Messages.GCCErrorParser_skip_UndeclaredOnlyOnce),
		new ErrorPattern(Messages.GCCErrorParser_skip_forEachFunction),
		new ErrorPattern(Messages.GCCErrorParser_skip_note),
		new ErrorPattern(Messages.GCCErrorParser_sikp_instantiatedFromHere),
		// The following are not...
		new ErrorPattern(Messages.GCCErrorParser_Warnings, 1, 2, 5, 0, 0) {
			@Override
			public String getVarName(Matcher matcher) {
				String desc = getDesc(matcher);
				if (desc == null)
					return null;
				
				for (int i = 0; i < varPatterns.length; ++i) {
					Matcher varMatcher = varPatterns[i].matcher(desc);
					if (varMatcher.find())
						return varMatcher.group(1);
				}
				return null;
			}
			@Override
			public int getSeverity(Matcher matcher) {
				String warningGroup = matcher.group(4);
				if (warningGroup != null && warningGroup.toLowerCase().endsWith("warning:")) //$NON-NLS-1$
					return IMarkerGenerator.SEVERITY_WARNING;
				
				return IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
			}
		}
	};

	public GCCErrorParser() {
		super(patterns);
	}
	
}

Back to the top