diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFullIndexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFullIndexer.java deleted file mode 100644 index 040d93706cf..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFullIndexer.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 QNX Software Systems and others. - * 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: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) - *******************************************************************************/ - -package org.eclipse.cdt.internal.core.pdom.indexer; - -import org.eclipse.cdt.core.dom.IPDOMIndexerTask; -import org.eclipse.cdt.core.dom.IPDOMManager; -import org.eclipse.cdt.core.model.ITranslationUnit; - -/** - * The Full indexer does full parsing in order to gather index information. - * It has good accuracy but is relatively slow. - * - * @author Doug Schaefer - * - */ -public class PDOMFullIndexer extends AbstractPDOMIndexer { - public static final String ID = IPDOMManager.ID_FULL_INDEXER; - - public String getID() { - return ID; - } - - public IPDOMIndexerTask createTask(ITranslationUnit[] added, - ITranslationUnit[] changed, ITranslationUnit[] removed) { - return new PDOMFullIndexerTask(this, added, changed, removed); - } -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFullIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFullIndexerTask.java deleted file mode 100644 index 1c6d3ade5ea..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/PDOMFullIndexerTask.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 QNX Software Systems and others. - * 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: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) - *******************************************************************************/ - -package org.eclipse.cdt.internal.core.pdom.indexer; - -import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.parser.IncludeFileContentProvider; -import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics; -import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory; - - -/** - * Configures the indexer task as a fast indexer task. - */ -class PDOMFullIndexerTask extends PDOMIndexerTask { - public PDOMFullIndexerTask(PDOMFullIndexer indexer, ITranslationUnit[] added, - ITranslationUnit[] changed, ITranslationUnit[] removed) { - super(added, changed, removed, indexer, false); - } - - @Override - protected IncludeFileContentProvider createReaderFactory() { - return IncludeFileContentProvider.adapt(SavedCodeReaderFactory.getInstance()); - } - - @Override - protected IIncludeFileResolutionHeuristics createIncludeHeuristics() { - return new ProjectIndexerIncludeResolutionHeuristics(getCProject().getProject(), getInputAdapter()); - } -} diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index fd80f02dffc..f518d674662 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -479,12 +479,6 @@ point="org.eclipse.cdt.core.CIndexer"> - - - - - fIndexerConfigMap; + private String fTheOneIndexerID; private Composite fIndexerPageComposite; private AbstractIndexerPage fCurrentPage; private Properties fCurrentProperties; @@ -85,6 +88,7 @@ public class IndexerBlock extends AbstractCOptionPage { private Button fUseFixedBuildConfig; private Combo fBuildConfigComboBox; private ControlEnableState fEnableState; + private Group fBuildConfigGroup; public IndexerBlock(){ super(INDEXER_LABEL); @@ -96,9 +100,14 @@ public class IndexerBlock extends AbstractCOptionPage { * Create a profile page only on request */ private static class IndexerConfig implements IPluginContribution { - private AbstractIndexerPage fPage; + private static final String NULL = "null"; //$NON-NLS-1$ + private AbstractIndexerPage fPage; private IConfigurationElement fElement; + public IndexerConfig(NullIndexerBlock fixed) { + fPage= fixed; + } + public IndexerConfig(IConfigurationElement element) { fElement= element; } @@ -119,14 +128,20 @@ public class IndexerBlock extends AbstractCOptionPage { } public String getName() { + if (fElement == null) + return NULL; return fElement.getAttribute(ATTRIB_NAME); } public String getLocalId() { + if (fElement == null) + return NULL; return fElement.getAttribute(ATTRIB_ID); } public String getPluginId() { + if (fElement == null) + return NULL; return fElement.getContributor().getName(); } } @@ -160,17 +175,26 @@ public class IndexerBlock extends AbstractCOptionPage { gd= (GridData) fPreferenceContent.getLayoutData(); gd.horizontalIndent= 0; - // add combo to select indexer - Group group= ControlFactory.createGroup(fPreferenceContent,INDEXER_COMBO_LABEL, 1); - gd= (GridData) group.getLayoutData(); - gd.grabExcessHorizontalSpace= true; - fIndexersComboBox = ControlFactory.createSelectCombo(group,"", ""); //$NON-NLS-1$ //$NON-NLS-2$ - fIndexersComboBox.addSelectionListener(new SelectionAdapter() { + + // add option to enable indexer + final SelectionAdapter indexerChangeListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { onIndexerChange(); } - }); + }; + fEnableIndexer= ControlFactory.createCheckBox(fPreferenceContent, CUIPlugin.getResourceString("IndexerBlock.enable")); //$NON-NLS-1$ + fEnableIndexer.addSelectionListener(indexerChangeListener); + + // add combo to select indexer + Group group= ControlFactory.createGroup(fPreferenceContent,INDEXER_COMBO_LABEL, 1); + gd= (GridData) group.getLayoutData(); + gd.grabExcessHorizontalSpace= true; + + if (fIndexerConfigMap.size() > 2) { + fIndexersComboBox = ControlFactory.createSelectCombo(group,"", ""); //$NON-NLS-1$ //$NON-NLS-2$ + fIndexersComboBox.addSelectionListener(indexerChangeListener); + } // add composite for pages fIndexerPageComposite= ControlFactory.createComposite(group, 1); @@ -178,7 +202,7 @@ public class IndexerBlock extends AbstractCOptionPage { fIndexerPageComposite.setLayout(new TabFolderLayout()); if (needBuildConfigOptions()) { - group= ControlFactory.createGroup(composite, DialogsMessages.IndexerStrategyBlock_buildConfigGroup, 1); + fBuildConfigGroup= group= ControlFactory.createGroup(composite, DialogsMessages.IndexerStrategyBlock_buildConfigGroup, 1); gd= (GridData) group.getLayoutData(); gd.grabExcessHorizontalSpace= true; fUseActiveBuildButton= ControlFactory.createRadioButton(group, DialogsMessages.IndexerStrategyBlock_activeBuildConfig, null, null); @@ -222,11 +246,30 @@ public class IndexerBlock extends AbstractCOptionPage { ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager(); ICProjectDescriptionWorkspacePreferences prefs= prjDescMgr.getProjectDescriptionWorkspacePreferences(false); boolean useActive= prefs.getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE; - setUseActiveBuildConfig(useActive); + fUseActiveBuildButton.setSelection(useActive); + fUseFixedBuildConfig.setSelection(!useActive); } + updateBuildConfigEnablement(scope); } } + void updateBuildConfigEnablement(int scope) { + if (fBuildConfigGroup == null) + return; + + if (!fEnableIndexer.getSelection()) { + ControlEnableState.disable(fBuildConfigGroup); + } else { + final boolean notDerived = scope != IndexerPreferences.SCOPE_INSTANCE; + final boolean fixed = fUseFixedBuildConfig.getSelection(); + // independent of scope + fBuildConfigComboBox.setEnabled(fixed); + fUseActiveBuildButton.setEnabled(notDerived); + fUseFixedBuildConfig.setEnabled(notDerived); + fBuildConfigGroup.setEnabled(notDerived || fixed); + } + } + protected void setUseActiveBuildConfig(boolean useActive) { if (fBuildConfigComboBox != null) { if (useActive) { @@ -236,6 +279,7 @@ public class IndexerBlock extends AbstractCOptionPage { fBuildConfigComboBox.setEnabled(false); } else { + // independent of the scope fBuildConfigComboBox.setEnabled(true); } fUseActiveBuildButton.setSelection(useActive); @@ -246,20 +290,12 @@ public class IndexerBlock extends AbstractCOptionPage { private void enablePreferenceContent(boolean enable) { if (fEnableState != null) { fEnableState.restore(); - if (fUseActiveBuildButton != null) { - fUseActiveBuildButton.setEnabled(true); - fUseFixedBuildConfig.setEnabled(true); - } } if (enable) { fEnableState= null; } else { fEnableState= ControlEnableState.disable(fPreferenceContent); - if (fUseActiveBuildButton != null) { - fUseActiveBuildButton.setEnabled(false); - fUseFixedBuildConfig.setEnabled(false); - } } } @@ -284,15 +320,23 @@ public class IndexerBlock extends AbstractCOptionPage { } private void initializeIndexerCombo() { - String[] names= new String[fIndexerConfigMap.size()]; - int j= 0; - for (IndexerConfig config : fIndexerConfigMap.values()) { - names[j++]= config.getName(); - } - @SuppressWarnings("unchecked") - final Comparator collator = Collator.getInstance(); - Arrays.sort(names, collator); - fIndexersComboBox.setItems(names); + if (fIndexersComboBox != null) { + String[] names= new String[fIndexerConfigMap.size()-1]; + int j= 0; + for (String id : fIndexerConfigMap.keySet()) { + if (!IPDOMManager.ID_NO_INDEXER.equals(id)) { + names[j++]= fIndexerConfigMap.get(id).getName(); + } + } + @SuppressWarnings("unchecked") + final Comparator collator = Collator.getInstance(); + Arrays.sort(names, collator); + fIndexersComboBox.setItems(names); + } else { + if (!fIndexerConfigMap.isEmpty()) { + fTheOneIndexerID= fIndexerConfigMap.keySet().iterator().next(); + } + } } private void initializeBuildConfigs() { @@ -326,7 +370,6 @@ public class IndexerBlock extends AbstractCOptionPage { protected void onPreferenceScopeChange() { int scope= computeScope(); - updateBuildConfigForScope(scope); if (fCurrentProperties == null || scope != IndexerPreferences.SCOPE_PROJECT_PRIVATE) { Properties props= IndexerPreferences.getProperties(getProject(), scope); @@ -342,18 +385,26 @@ public class IndexerBlock extends AbstractCOptionPage { fCurrentProperties= props; } updateForNewProperties(scope); + updateBuildConfigForScope(scope); } private void updateForNewProperties(int scope) { String indexerId= fCurrentProperties.getProperty(IndexerPreferences.KEY_INDEXER_ID); - String indexerName = getIndexerName(indexerId); - String[] indexerList = fIndexersComboBox.getItems(); - int selectedIndex = 0; - for (int i=0; i entry : fIndexerConfigMap.entrySet()) { - String id = entry.getKey(); - IndexerConfig config = entry.getValue(); - if (indexerName.equals(config.getName())) { - return id; - } - } - return null; - } - private AbstractIndexerPage getIndexerPage(String indexerID) { IndexerConfig configElement= fIndexerConfigMap.get(indexerID); if (configElement != null) { @@ -528,7 +570,19 @@ public class IndexerBlock extends AbstractCOptionPage { } private String getSelectedIndexerID(){ - return getIndexerID(fIndexersComboBox.getText()); + if (fEnableIndexer.getSelection()) { + if (fIndexersComboBox == null) + return fTheOneIndexerID; + + final String indexerName = fIndexersComboBox.getText(); + for (Map.Entry entry : fIndexerConfigMap.entrySet()) { + if (indexerName.equals(entry.getValue().getName())) { + return entry.getKey(); + } + } + return null; + } + return IPDOMManager.ID_NO_INDEXER; } public IProject getProject() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java index de490a08905..7b34bbbd8e9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java @@ -10,14 +10,12 @@ * Anton Leherbauer (Wind River Systems) * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.ui.dialogs; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Preferences; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -79,10 +77,14 @@ public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionC return project; } - public Preferences getPreferences() { - throw new UnsupportedOperationException(); - } - public void updateContainer() { } + + /** + * @deprecated + */ + @Deprecated + public org.eclipse.core.runtime.Preferences getPreferences() { + throw new UnsupportedOperationException(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java index 71c0b1ba926..a16a90bd87a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java @@ -16,6 +16,7 @@ import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; @@ -37,6 +38,12 @@ abstract public class PreferenceScopeBlock { public void createControl(final Composite parent) { Composite group= ControlFactory.createComposite(parent,2); + GridLayout layout = (GridLayout)group.getLayout(); + layout.marginHeight= 0; + layout.marginWidth= 0; + GridData gd = (GridData) group.getLayoutData(); + gd.horizontalIndent= 0; + fUseProjectSettings= ControlFactory.createCheckBox(group, DialogsMessages.PreferenceScopeBlock_enableProjectSettings); Composite two= ControlFactory.createComposite(group, 1);