Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5f20ceced99ab457a61617bb59d8a6946f3b4315 (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
117
118
119
120
121
122
/*******************************************************************************
 * Copyright (c) 2000, 2004 QNX Software Systems and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     QNX Software Systems - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.make.core;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;

/**
 * @deprecated
 * @author DInglis
 *
 */

public class MakeScannerInfo implements IScannerInfo {

	private IProject project;
	private ArrayList symbolList;
	private ArrayList pathList;
	boolean hasChanged = false;

	public MakeScannerInfo(IProject project) {
		this.project = project;
	}

	IProject getProject() {
		return project;
	}

	public void update() throws CoreException {
		if (hasChanged) {
			MakeScannerProvider.updateScannerInfo(this);
			hasChanged = false;
		}
	}

	public synchronized void setPreprocessorSymbols(String[] symbols) {
		if (!Arrays.equals(symbols, getSymbolList().toArray())) {
			hasChanged = true;
			// Clear out any existing symbols and add the new stuff
			getSymbolList().clear();
			getSymbolList().addAll(Arrays.asList(symbols));
		}
	}

	public synchronized void setIncludePaths(String[] paths) {
		if (!Arrays.equals(paths, getPathList().toArray())) {
			hasChanged = true;
			// Clear the existing list and add the paths
			getPathList().clear();
			getPathList().addAll(Arrays.asList(paths));
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
	 */
	public synchronized String[] getIncludePaths() {
		return (String[]) getPathList().toArray(new String[getPathList().size()]);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths()
	 */
	public synchronized Map getDefinedSymbols() {
		// Return the defined symbols for the default configuration
		HashMap symbols = new HashMap();
		String[] symbolList = getPreprocessorSymbols();
		for (int i = 0; i < symbolList.length; ++i) {
			String symbol = symbolList[i];
			if (symbol.length() == 0) {
				continue;
			}
			String key = new String();
			String value = new String();
			int index = symbol.indexOf("="); //$NON-NLS-1$
			if (index != -1) {
				key = symbol.substring(0, index).trim();
				value = symbol.substring(index + 1).trim();
			} else {
				key = symbol.trim();
			}
			symbols.put(key, value);
		}
		return symbols;
	}

	protected List getPathList() {
		if (pathList == null) {
			pathList = new ArrayList();
		}
		return pathList;
	}

	public synchronized String[] getPreprocessorSymbols() {
		return (String[]) getSymbolList().toArray(new String[getSymbolList().size()]);
	}

	protected List getSymbolList() {
		if (symbolList == null) {
			symbolList = new ArrayList();
		}
		return symbolList;
	}
}

Back to the top