blob: 66f382c4f29c377af6a4576b606c482c0f5f1bb2 [file] [log] [blame]
/*
* Copyright (c) 2011 Google Inc.
*
* 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
*/
package com.google.eclipse.protobuf.ui.builder.protoc.output;
import static com.google.common.collect.Lists.newArrayList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
/**
* @author alruiz@google.com (Alex Ruiz)
*/
class CompositeOutputParser implements ProtocOutputParser {
/*
* (.*):(\\d+):(\\d+):\\s*(.*)
* --1- ---2-- ---3-- -*- --4-
*
* 1: file name
* 2: line number
* 3: column
* *: whitespace
* 4: message
*/
private static final ProtocOutputParser PARSER1 = new RegexOutputParser("(.*):(\\d+):(\\d+):\\s*(.*)", 1, 2, 4);
/*
* (.*):\\s*(--.*)
* --1- -*- --2-
*
* 1: file name
* *: whitespace
* 2: message
*/
private static final ProtocOutputParser PARSER2 = new RegexOutputParser("(.*):\\s*(--.*)", 1, 2);
/*
* (--.*):\\s*(.*):\\s*(.*)
* --1--- -*- --2- -*- --3-
*
* 1: option (e.g. --java_out)
* *: whitespace
* 2: file name
* *: whitespace
* 3: message
*/
private static final ProtocOutputParser PARSER3 = new RegexOutputParser("(--.*):\\s*(.*):\\s*(.*)", 2, 3);
private static final List<ProtocOutputParser> PARSERS = newArrayList(PARSER1, PARSER2, PARSER3);
@Override
public boolean parseAndAddMarkerIfNecessary(String line, ProtocMarkerFactory markerFactory) throws CoreException {
for (ProtocOutputParser parser: PARSERS) {
if (parser.parseAndAddMarkerIfNecessary(line, markerFactory)) {
return true;
}
}
return false;
}
}