From 7d84a3a4103de49253d635fe58fd67c26fdd62d6 Mon Sep 17 00:00:00 2001 From: David Inglis Date: Sat, 3 Apr 2004 20:40:36 +0000 Subject: [PATCH] properly set binary parsers --- .../cdt/make/internal/core/MakeProject.java | 71 ++++++++++++------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeProject.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeProject.java index 097cab020b7..6085b53d7ea 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeProject.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeProject.java @@ -1,15 +1,16 @@ -/********************************************************************** - * Copyright (c) 2002,2003 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 +/******************************************************************************* + * Copyright (c) 2002,2003 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 - ***********************************************************************/ + * Contributors: QNX Software Systems - Initial API and implementation + ******************************************************************************/ package org.eclipse.cdt.make.internal.core; +import java.util.ArrayList; +import java.util.StringTokenizer; + import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.core.ICOwner; @@ -20,27 +21,43 @@ import org.eclipse.core.runtime.Preferences; public class MakeProject implements ICOwner { - public void configure(ICDescriptor cproject) throws CoreException { - cproject.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); - cproject.remove(CCorePlugin.BUILDER_MODEL_ID); - cproject.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, MakeScannerProvider.INTERFACE_IDENTITY); - Preferences makePrefs = MakeCorePlugin.getDefault().getPluginPreferences(); - String id = makePrefs.getString(CCorePlugin.PREF_BINARY_PARSER); - if (id != null && id.length() != 0) { - cproject.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, id); + public void configure(ICDescriptor cDescriptor) throws CoreException { + cDescriptor.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); + cDescriptor.remove(CCorePlugin.BUILDER_MODEL_ID); + cDescriptor.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, MakeScannerProvider.INTERFACE_IDENTITY); + updateBinaryParsers(cDescriptor); + } + + public void update(ICDescriptor cDescriptor, String extensionID) throws CoreException { + if (extensionID.equals(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID)) { + cDescriptor.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, MakeScannerProvider.INTERFACE_IDENTITY); + } + if (extensionID.equals(CCorePlugin.BINARY_PARSER_UNIQ_ID)) { + updateBinaryParsers(cDescriptor); } } - public void update(ICDescriptor cproject, String extensionID) throws CoreException { - if (extensionID.equals(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID)) { - cproject.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, MakeScannerProvider.INTERFACE_IDENTITY); - } - if (extensionID.equals(CCorePlugin.BINARY_PARSER_UNIQ_ID)) { - Preferences makePrefs = MakeCorePlugin.getDefault().getPluginPreferences(); - String id = makePrefs.getString(CCorePlugin.PREF_BINARY_PARSER); - if (id != null && id.length() != 0) { - cproject.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, id); + private void updateBinaryParsers(ICDescriptor cDescriptor) throws CoreException { + cDescriptor.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID); + Preferences makePrefs = MakeCorePlugin.getDefault().getPluginPreferences(); + String id = makePrefs.getString(CCorePlugin.PREF_BINARY_PARSER); + if (id != null && id.length() != 0) { + String[] ids = parseStringToArray(id); + for (int i = 0; i < ids.length; i++) { + cDescriptor.create(CCorePlugin.BINARY_PARSER_UNIQ_ID, ids[i]); } } } -} + + private String[] parseStringToArray(String syms) { + if (syms != null && syms.length() > 0) { + StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$ + ArrayList list = new ArrayList(tok.countTokens()); + while (tok.hasMoreElements()) { + list.add(tok.nextToken()); + } + return (String[]) list.toArray(new String[list.size()]); + } + return new String[0]; + } +} \ No newline at end of file