Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 493f5fb06e419951d35dc41140ba3c47fdf081d6 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*******************************************************************************
 * Copyright (c) 2009, 2011 Alena Laskavaia
 *
 * 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:
 *    Alena Laskavaia  - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.codan.core;

import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
import org.eclipse.cdt.codan.core.model.ICodanBuilder;
import org.eclipse.cdt.codan.core.model.IProblemLocationFactory;
import org.eclipse.cdt.codan.core.model.IProblemReporter;
import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
import org.eclipse.cdt.codan.internal.core.CodanBuilder;
import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
import org.eclipse.cdt.codan.internal.core.model.ProblemLocationFactory;

/**
 * Runtime singleton class to get access to Codan framework parts
 *
 * Clients may extend this class to override default framework parts.
 *
 * <p>
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
 * of a work in progress. There is no guarantee that this API will work or that
 * it will remain the same.
 * </p>
 */
public class CodanRuntime {
	private static CodanRuntime instance = new CodanRuntime();
	private IProblemReporter problemReporter = new CodanMarkerProblemReporter();
	private ICodanBuilder builder = new CodanBuilder();
	private CheckersRegistry checkers = CheckersRegistry.getInstance();
	private IProblemLocationFactory locFactory = new ProblemLocationFactory();

	/**
	 * CodanRuntime - only can be called by subclasses to override default
	 * constructor
	 */
	protected CodanRuntime() {
		// nothing here
	}

	/**
	 * Get runtime problem reporter. Default reported generated problem markers.
	 *
	 * @return
	 */
	public IProblemReporter getProblemReporter() {
		return problemReporter;
	}

	/**
	 * Set different problem reporter.
	 *
	 * @param reporter
	 */
	public void setProblemReporter(IProblemReporter reporter) {
		problemReporter = reporter;
	}

	/**
	 * Get instance of of Codan Runtime
	 *
	 * @return
	 */
	public static CodanRuntime getInstance() {
		return instance;
	}

	/**
	 * Get builder. Builder can used to run code analysis on given resource
	 * using API.
	 *
	 * @return
	 */
	public ICodanBuilder getBuilder() {
		return builder;
	}

	/**
	 * Get checkers registry.
	 *
	 * @return
	 * @since 2.0
	 */
	public ICheckersRegistry getCheckersRegistry() {
		return checkers;
	}

	/**
	 * Get problem location factory.
	 *
	 * @return
	 */
	public IProblemLocationFactory getProblemLocationFactory() {
		return locFactory;
	}

	/**
	 * Set another problem location factory - only need if default is not
	 * sufficient, i.e IProblemLocation is implemented differently
	 *
	 * @param factory
	 */
	public void setProblemLocationFactory(IProblemLocationFactory factory) {
		locFactory = factory;
	}
}

Back to the top