1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 01:06:01 +02:00

Removal of full indexer, bug 294864.

This commit is contained in:
Markus Schorn 2009-11-18 11:27:01 +00:00
parent 51ab620086
commit 68d9a584ff
9 changed files with 120 additions and 145 deletions

View file

@ -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);
}
}

View file

@ -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());
}
}

View file

@ -479,12 +479,6 @@
point="org.eclipse.cdt.core.CIndexer">
<run class="org.eclipse.cdt.internal.core.pdom.indexer.PDOMFastIndexer"/>
</extension>
<extension
name="%CDTIndexer.domsourceindexer"
id="domsourceindexer"
point="org.eclipse.cdt.core.CIndexer">
<run class="org.eclipse.cdt.internal.core.pdom.indexer.PDOMFullIndexer"/>
</extension>
<extension
point="org.eclipse.core.variables.dynamicVariables">
<variable

View file

@ -423,9 +423,8 @@ cSpellingEngine.label=C/C++ spelling engine
indexerPrefName=Indexer
# indexer names
CDTIndexer.domsourceindexer=Full C/C++ Indexer (complete parse)
CDTIndexer.nullindexer=No Indexer (search based features will not work correctly)
CDTIndexer.fastindexer=Fast C/C++ Indexer (recommended)
CDTIndexer.fastindexer=C/C++ Indexer
IndexView.name=C/C++ Index
RebuildIndex.name=&Rebuild

View file

@ -2685,12 +2685,6 @@
id="org.eclipse.cdt.ui.fastIndexer"
indexerID="org.eclipse.cdt.core.fastIndexer"
name="%CDTIndexer.fastindexer"/>
<indexerUI
class="org.eclipse.cdt.ui.dialogs.DOMSourceIndexerBlock"
id="org.eclipse.cdt.ui.DOMASTSourceIndexerUI"
indexerID="org.eclipse.cdt.core.domsourceindexer"
name="%CDTIndexer.domsourceindexer"/>
</extension>
<extension

View file

@ -40,7 +40,7 @@ BinaryParserBlock.desc=Set required binary parser for this project
BaseIndexerBlock.label=C/C++ Indexer
BaseIndexerBlock.desc=C/C++ Indexer setting for this project.
BaseIndexerBlock.comboLabel=Select indexer
BaseIndexerBlock.comboLabel=Indexer Options
ReferenceBlock.label= Projects
ReferenceBlock.desc= Referenced C/C++ Projects
@ -215,6 +215,7 @@ EditorUtility.closedproject = Project is closed
Editorutility.closedproject.description = The project {0} containing that declaration is closed.
# ------- Index View Text -----------
IndexerBlock.enable=Enable indexer
IndexView.rebuildIndex.name = Rebuild Index
IndexView.openDefinition.name = Open Definition
IndexView.findReferences.name = Find References

View file

@ -39,6 +39,7 @@ import org.eclipse.ui.dialogs.PropertyPage;
import com.ibm.icu.text.Collator;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
@ -74,8 +75,10 @@ public class IndexerBlock extends AbstractCOptionPage {
private static final String INDEXER_COMBO_LABEL = CUIPlugin.getResourceString("BaseIndexerBlock.comboLabel"); //$NON-NLS-1$
private PreferenceScopeBlock fPrefScopeBlock;
private Button fEnableIndexer;
private Combo fIndexersComboBox;
private HashMap<String, IndexerConfig> 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<Object> 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<Object> 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<indexerList.length; i++){
if (indexerList[i].equals(indexerName))
selectedIndex = i;
}
fIndexersComboBox.select(selectedIndex);
if (indexerId.equals(IPDOMManager.ID_NO_INDEXER)) {
fEnableIndexer.setSelection(false);
} else {
fEnableIndexer.setSelection(true);
if (fIndexersComboBox != null) {
String indexerName = getIndexerName(indexerId);
String[] indexerList = fIndexersComboBox.getItems();
int selectedIndex = 0;
for (int i=0; i<indexerList.length; i++){
if (indexerList[i].equals(indexerName))
selectedIndex = i;
}
fIndexersComboBox.select(selectedIndex);
}
}
setPage();
if (fPrefScopeBlock != null) {
enablePreferenceContent(scope != IndexerPreferences.SCOPE_INSTANCE);
@ -368,6 +419,7 @@ public class IndexerBlock extends AbstractCOptionPage {
}
}
setPage();
updateBuildConfigEnablement(computeScope());
}
private int computeScope() {
@ -425,6 +477,7 @@ public class IndexerBlock extends AbstractCOptionPage {
}
}
}
fIndexerConfigMap.put(IPDOMManager.ID_NO_INDEXER, new IndexerConfig(new NullIndexerBlock()));
}
private String getIndexerName(String indexerID) {
@ -435,17 +488,6 @@ public class IndexerBlock extends AbstractCOptionPage {
return null;
}
private String getIndexerID(String indexerName) {
for (Map.Entry<String, IndexerConfig> 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<String, IndexerConfig> entry : fIndexerConfigMap.entrySet()) {
if (indexerName.equals(entry.getValue().getName())) {
return entry.getKey();
}
}
return null;
}
return IPDOMManager.ID_NO_INDEXER;
}
public IProject getProject() {

View file

@ -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();
}
}

View file

@ -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);