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