summaryrefslogtreecommitdiffstats
path: root/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
blob: f1e502894e58e1cd73da7bebde346505005807d1 (plain)
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
69
70
71
72
73
74
75
76
/*******************************************************************************
 * Copyright (c) 2009 Alena Laskavaia 
 * 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:
 *    Alena Laskavaia  - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.codan.core.model;

import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;

public abstract class AbstractChecker implements IChecker {
	protected String name;

	public AbstractChecker() {
	}

	/**
	 * @return true if checker is enabled in context of resource, if returns
	 *         false checker's "processResource" method won't be called
	 */
	public boolean enabledInContext(IResource res) {
		return true;
	}

	/**
	 * Reports a simple problem for given file and line
	 * 
	 * @param id
	 *            - problem id
	 * @param file
	 *            - file
	 * @param lineNumber
	 *            - line
	 * @param arg
	 *            - problem argument, if problem does not define error message
	 *            it will be error message (not recommended because of
	 *            internationalization)
	 */
	public void reportProblem(String id, IFile file, int lineNumber, String arg) {
		getProblemReporter().reportProblem(id,
				new ProblemLocation(file, lineNumber), arg);
	}

	/**
	 * Reports a simple problem for given file and line, error message comes
	 * from problem definition
	 * 
	 * @param id
	 *            - problem id
	 * @param file
	 *            - file
	 * @param lineNumber
	 *            - line
	 */
	public void reportProblem(String id, IFile file, int lineNumber) {
		getProblemReporter().reportProblem(id,
				new ProblemLocation(file, lineNumber), new Object[] {});
	}

	/**
	 * @return problem reporter for given checker
	 */
	protected IProblemReporter getProblemReporter() {
		return CodanRuntime.getInstance().getProblemReporter();
	}

	public boolean runInEditor() {
		return false;
	}
}