Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c2a9fc43125bbd6ac4ee52a1321b365475bc1483 (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
/*******************************************************************************
 * Copyright (c) 2009,2012 QNX Software Systems
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     QNX Software Systems (Alena Laskavaia)  - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.codan.core.model;

import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
import org.eclipse.core.resources.IResource;

/**
 * Abstract implementation of a IProblemReporter
 *
 * @since 2.0
 */
public abstract class AbstractProblemReporter implements IProblemReporter {
	@Override
	public void reportProblem(String id, IProblemLocation loc, Object... args) {
		IResource file = loc.getFile();
		if (file == null)
			throw new NullPointerException("file"); //$NON-NLS-1$
		if (id == null)
			throw new NullPointerException("id"); //$NON-NLS-1$
		IProblem problem = CheckersRegistry.getInstance().getResourceProfile(file).findProblem(id);
		if (problem == null)
			throw new IllegalArgumentException("Id is not registered:" + id); //$NON-NLS-1$
		if (!problem.isEnabled())
			return; // skip
		ICodanProblemMarker codanProblemMarker = new CodanProblemMarker(problem, loc, args);
		reportProblem(codanProblemMarker);
	}

	/**
	 * @param codanProblemMarker
	 */
	protected abstract void reportProblem(ICodanProblemMarker codanProblemMarker);
}

Back to the top