1
/*******************************************************************************
2
* Copyright (c) 2004, 2007 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM - Initial API and implementation
10
*******************************************************************************/
12
package org.eclipse.cdt.managedbuilder.internal.core;
14
import java.util.ArrayList;
15
import java.util.StringTokenizer;
17
import org.eclipse.cdt.core.CCorePlugin;
18
import org.eclipse.cdt.core.ICDescriptor;
19
import org.eclipse.cdt.core.ICOwner;
20
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
21
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
22
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
23
import org.eclipse.cdt.managedbuilder.core.IToolChain;
24
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
25
import org.eclipse.core.resources.IProject;
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.Preferences;
32
public class ManagedMakeProject implements ICOwner {
35
* Zero-argument constructor to fulfill the contract for
36
* implementation classes supplied via an extension point
38
public ManagedMakeProject() {
43
* @see org.eclipse.cdt.core.ICOwner#configure(org.eclipse.cdt.core.ICDescriptor)
45
public void configure(ICDescriptor cproject) throws CoreException {
46
cproject.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
47
cproject.remove(CCorePlugin.BUILDER_MODEL_ID);
48
cproject.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
50
// updateIndexers(cproject);
54
* @see org.eclipse.cdt.core.ICOwner#update(org.eclipse.cdt.core.ICDescriptor, java.lang.String)
56
public void update(ICDescriptor cproject, String extensionID) throws CoreException {
57
/* if (extensionID.equals(CCorePlugin.BINARY_PARSER_UNIQ_ID)) {
58
updateBinaryParsers(cproject);
61
if (extensionID.equals(CCorePlugin.INDEXER_UNIQ_ID)) {
62
updateIndexers(cproject);
67
private void updateBinaryParsers(ICDescriptor cDescriptor) throws CoreException {
68
IManagedBuildInfo buildInfo = null;
70
IProject project = cDescriptor.getProject();
72
// If we cannot get the build information, it may be due to the fact that the
73
// build information is yet to be created, due to a synchronization issue
74
// Don't do anything now to the binary parsers because there is nothing meaningful to do.
75
// This routine should be invoked later, when the required build information is available
76
if (!ManagedBuildManager.canGetBuildInfo(project)) return;
78
buildInfo = ManagedBuildManager.getBuildInfo(project);
79
if (buildInfo != null) {
80
IConfiguration config = buildInfo.getDefaultConfiguration();
81
if (config == null && buildInfo.getManagedProject() != null) {
82
IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations();
83
if (configs != null && configs.length > 0)
87
// Get the values from the current configuration
88
IToolChain toolChain = config.getToolChain();
89
if (toolChain != null) {
90
ITargetPlatform targPlatform = toolChain.getTargetPlatform();
91
if (targPlatform != null) {
92
ids = targPlatform.getBinaryParserList();
98
cDescriptor.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
100
for (int i = 0; i < ids.length; i++) {
101
cDescriptor.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, ids[i]);
106
private void updateIndexers(ICDescriptor cDescriptor) throws CoreException {
107
cDescriptor.remove(CCorePlugin.INDEXER_UNIQ_ID);
108
Preferences corePrefs = CCorePlugin.getDefault().getPluginPreferences();
109
String id = corePrefs.getString(CCorePlugin.PREF_INDEXER);
110
if (id != null && id.length() != 0) {
111
String[] ids = parseStringToArray(id);
112
for (int i = 0; i < ids.length; i++) {
113
cDescriptor.create(CCorePlugin.INDEXER_UNIQ_ID, ids[i]);
118
private String[] parseStringToArray(String syms) {
119
if (syms != null && syms.length() > 0) {
120
StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
121
ArrayList list = new ArrayList(tok.countTokens());
122
while (tok.hasMoreElements()) {
123
list.add(tok.nextToken());
125
return (String[]) list.toArray(new String[list.size()]);
127
return new String[0];