1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Removed the ctags indexer from the UI. Added a check box to the indexer preference page to allow for all projects to be updated to the new preference.

This commit is contained in:
Doug Schaefer 2006-05-22 19:39:55 +00:00
parent 5839b72abe
commit c27a51479b
9 changed files with 116 additions and 66 deletions

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IElementChangedListener; import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.internal.core.pdom.indexer.ctags.CtagsIndexer;
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer; import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope; import org.eclipse.core.resources.ProjectScope;
@ -96,7 +97,7 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
IPDOMIndexer indexer = (IPDOMIndexer)rproject.getSessionProperty(indexerProperty); IPDOMIndexer indexer = (IPDOMIndexer)rproject.getSessionProperty(indexerProperty);
if (indexer == null) { if (indexer == null) {
indexer = createIndexer(getIndexerId(project), project); indexer = createIndexer(project, getIndexerId(project));
} }
return indexer; return indexer;
@ -195,20 +196,29 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
} catch (CoreException e) { } catch (CoreException e) {
} }
if (indexerId == null) if (indexerId == null || indexerId.equals(CtagsIndexer.ID))
// make it the default // make it the default, ctags is gone
indexerId = getDefaultIndexerId(); indexerId = getDefaultIndexerId();
// Start a job to set the id. // Start a job to set the id.
new SetId(project, indexerId).schedule(); new SetIndexerId(project, indexerId).schedule();
} else if (indexerId.equals(CtagsIndexer.ID)) {
// make it the default, ctags is gone
indexerId = getDefaultIndexerId();
// Start a job to set the id.
new SetIndexerId(project, indexerId).schedule();
} }
return indexerId; return indexerId;
} }
private static class SetId extends Job { // This job is only used when setting during a get. Sometimes the get is being
// done in an unfriendly environment, e.g. startup.
private class SetIndexerId extends Job {
private final ICProject project; private final ICProject project;
private final String indexerId; private final String indexerId;
public SetId(ICProject project, String indexerId) { public SetIndexerId(ICProject project, String indexerId) {
super("Set Indexer Id"); super("Set Indexer Id");
this.project = project; this.project = project;
this.indexerId = indexerId; this.indexerId = indexerId;
@ -216,7 +226,7 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
} }
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
try { try {
setId(project, indexerId); setIndexerId(project, indexerId);
return Status.OK_STATUS; return Status.OK_STATUS;
} catch (CoreException e) { } catch (CoreException e) {
return e.getStatus(); return e.getStatus();
@ -224,25 +234,24 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
} }
} }
private static void setId(ICProject project, String indexerId) throws CoreException { public void setIndexerId(ICProject project, String indexerId) throws CoreException {
IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID); IEclipsePreferences prefs = new ProjectScope(project.getProject()).getNode(CCorePlugin.PLUGIN_ID);
if (prefs == null) if (prefs == null)
return; // TODO why would this be null? return; // TODO why would this be null?
String oldId = prefs.get(INDEXER_ID_KEY, null);
if (!indexerId.equals(oldId)) {
prefs.put(INDEXER_ID_KEY, indexerId); prefs.put(INDEXER_ID_KEY, indexerId);
try { try {
prefs.flush(); prefs.flush();
} catch (BackingStoreException e) { } catch (BackingStoreException e) {
} }
createIndexer(project, indexerId).reindex();
}
} }
public void setIndexerId(ICProject project, String indexerId) throws CoreException { private IPDOMIndexer createIndexer(ICProject project, String indexerId) throws CoreException {
setId(project, indexerId);
if (project.getProject().getSessionProperty(indexerProperty) != null)
createIndexer(indexerId, project);
}
private IPDOMIndexer createIndexer(String indexerId, ICProject project) throws CoreException {
IPDOMIndexer indexer = null; IPDOMIndexer indexer = null;
// Look up in extension point // Look up in extension point
IExtension indexerExt = Platform.getExtensionRegistry() IExtension indexerExt = Platform.getExtensionRegistry()

View file

@ -30,6 +30,8 @@ import org.osgi.service.prefs.BackingStoreException;
*/ */
public class CtagsIndexer implements IPDOMIndexer { public class CtagsIndexer implements IPDOMIndexer {
public static final String ID = "org.eclipse.cdt.core.ctagsindexer"; //$NON-NLS-1$
private ICProject project; private ICProject project;
private boolean useCtagsOnPath = true; private boolean useCtagsOnPath = true;

View file

@ -11,10 +11,16 @@
package org.eclipse.cdt.internal.core.pdom.indexer.nulli; package org.eclipse.cdt.internal.core.pdom.indexer.nulli;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMIndexer; import org.eclipse.cdt.core.dom.IPDOMIndexer;
import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
@ -36,7 +42,24 @@ public class PDOMNullIndexer implements IPDOMIndexer {
public void handleDelta(ICElementDelta delta) { public void handleDelta(ICElementDelta delta) {
} }
private class Reindex extends Job {
public Reindex() {
super("Null Reindex"); //$NON-NLS-1$
setSystem(true);
}
protected IStatus run(IProgressMonitor monitor) {
try {
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
pdom.clear();
pdom.fireChange();
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
}
}
}
public void reindex() throws CoreException { public void reindex() throws CoreException {
new Reindex().schedule();
} }
} }

View file

@ -531,28 +531,6 @@
<extension point="org.eclipse.core.runtime.preferences"> <extension point="org.eclipse.core.runtime.preferences">
<initializer class="org.eclipse.cdt.internal.core.CCorePreferenceInitializer"/> <initializer class="org.eclipse.cdt.internal.core.CCorePreferenceInitializer"/>
</extension> </extension>
<extension
name="%CDTIndexer.domsourceindexer"
id="domsourceindexer"
point="org.eclipse.cdt.core.CIndexer">
<cextension>
<run
class="org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexer">
</run>
</cextension>
<run class="org.eclipse.cdt.internal.core.pdom.indexer.full.PDOMFullIndexer"/>
</extension>
<extension
id="ctagsindexer"
name="%CDTIndexer.ctagsindexer"
point="org.eclipse.cdt.core.CIndexer">
<cextension>
<run
class="org.eclipse.cdt.internal.core.index.ctagsindexer.CTagsIndexer">
</run>
</cextension>
<run class="org.eclipse.cdt.internal.core.pdom.indexer.ctags.CtagsIndexer"/>
</extension>
<extension <extension
id="nullindexer" id="nullindexer"
name="%CDTIndexer.nullindexer" name="%CDTIndexer.nullindexer"
@ -575,6 +553,17 @@
</run> </run>
</cextension> </cextension>
</extension> </extension>
<extension
name="%CDTIndexer.domsourceindexer"
id="domsourceindexer"
point="org.eclipse.cdt.core.CIndexer">
<cextension>
<run
class="org.eclipse.cdt.internal.core.index.domsourceindexer.DOMSourceIndexer">
</run>
</cextension>
<run class="org.eclipse.cdt.internal.core.pdom.indexer.full.PDOMFullIndexer"/>
</extension>
<extension <extension
point="org.eclipse.core.variables.dynamicVariables"> point="org.eclipse.core.variables.dynamicVariables">
<variable <variable

View file

@ -322,10 +322,9 @@ completionContributors=Content Assist Completion Contributor
indexerPrefName=Indexer indexerPrefName=Indexer
# indexer names # indexer names
CDTIndexer.domsourceindexer=Full C/C++ Indexer (declarations and cross references) CDTIndexer.domsourceindexer=Full C/C++ Indexer (slow but accurate)
CDTIndexer.ctagsindexer=CTags Indexer (declarations only)
CDTIndexer.nullindexer=No Indexer (search-based features will not work correctly) CDTIndexer.nullindexer=No Indexer (search-based features will not work correctly)
CDTIndexer.fastindexer=Fast C/C++ Indexer (declarations and cross references) CDTIndexer.fastindexer=Fast C/C++ Indexer (faster but less accurate)
IndexView.name=C/C++ Index IndexView.name=C/C++ Index
UpdateIndex.name=Update Index UpdateIndex.name=Update Index

View file

@ -1304,33 +1304,21 @@
</extension> </extension>
<extension <extension
point="org.eclipse.cdt.ui.IndexerPage"> point="org.eclipse.cdt.ui.IndexerPage">
<!--
<indexerUI
class="org.eclipse.cdt.ui.dialogs.DOMSourceIndexerBlock"
id="org.eclipse.cdt.ui.DOMASTSourceIndexerUI"
indexerID="org.eclipse.cdt.core.domsourceindexer"
name="%CDTIndexer.domsourceindexer"/>
-->
<indexerUI
class="org.eclipse.cdt.ui.dialogs.CTagsIndexerBlock"
indexerID="org.eclipse.cdt.core.ctagsindexer"
name="%CDTIndexer.ctagsindexer"
id="org.eclipse.cdt.ui.ctagsIndexerUI"/>
<indexerUI <indexerUI
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock" class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
indexerID="org.eclipse.cdt.core.nullindexer" indexerID="org.eclipse.cdt.core.nullindexer"
name="%CDTIndexer.nullindexer" name="%CDTIndexer.nullindexer"
id="org.eclipse.cdt.ui.nullindexerUI"/> id="org.eclipse.cdt.ui.nullindexerUI"/>
<indexerUI
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
id="org.eclipse.cdt.ui.DOMASTSourceIndexerUI"
indexerID="org.eclipse.cdt.core.domsourceindexer"
name="%CDTIndexer.domsourceindexer"/>
<indexerUI <indexerUI
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock" class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
id="org.eclipse.cdt.ui.fastIndexer" id="org.eclipse.cdt.ui.fastIndexer"
indexerID="org.eclipse.cdt.core.fastIndexer" indexerID="org.eclipse.cdt.core.fastIndexer"
name="%CDTIndexer.fastindexer"/> name="%CDTIndexer.fastindexer"/>
<indexerUI
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
id="org.eclipse.cdt.ui.DOMASTSourceIndexerUI"
indexerID="org.eclipse.cdt.core.domsourceindexer"
name="%CDTIndexer.domsourceindexer"/>
</extension> </extension>
<extension <extension

View file

@ -45,7 +45,6 @@ ErrorParserBlock.desc=Set the error parsers for this project
BinaryParserBlock.label=Binary Parser BinaryParserBlock.label=Binary Parser
BinaryParserBlock.desc=Set required binary parser for this project BinaryParserBlock.desc=Set required binary parser for this project
BaseIndexerBlock.usePDOM=Use PDOM (Work in progress)
BaseIndexerBlock.label=C/C++ Indexer BaseIndexerBlock.label=C/C++ Indexer
BaseIndexerBlock.desc=C/C++ Indexer setting for this project. BaseIndexerBlock.desc=C/C++ Indexer setting for this project.
BaseIndexerBlock.comboLabel=Available indexers BaseIndexerBlock.comboLabel=Available indexers
@ -330,3 +329,5 @@ IndexView.setFastIndexer.name = Use Fast Indexer
IndexView.CountSymbols.name = Count Symbols IndexView.CountSymbols.name = Count Symbols
IndexView.CountSymbols.title = Symbol Count IndexView.CountSymbols.title = Symbol Count
IndexView.CountSymbols.message = The PDOM contains {0} symbols. IndexView.CountSymbols.message = The PDOM contains {0} symbols.
IndexerPreferencePage.applyToAllProjects = Apply indexer to all projects now

View file

@ -10,15 +10,24 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences; package org.eclipse.cdt.internal.ui.preferences;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer; import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.IndexerBlock; import org.eclipse.cdt.ui.dialogs.IndexerBlock;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
@ -28,6 +37,7 @@ public class IndexerPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage, ICOptionContainer { IWorkbenchPreferencePage, ICOptionContainer {
private IndexerBlock fOptionBlock; private IndexerBlock fOptionBlock;
private Button applyIndexerToAllButton;
public IndexerPreferencePage(){ public IndexerPreferencePage(){
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
@ -37,10 +47,14 @@ public class IndexerPreferencePage extends PreferencePage implements
protected Control createContents(Composite parent) { protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE); Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout()); GridLayout layout = new GridLayout(1, true);
composite.setLayout(layout);
fOptionBlock.createControl(composite); fOptionBlock.createControl(composite);
applyIndexerToAllButton = new Button(composite, SWT.CHECK);
applyIndexerToAllButton.setText(CUIPlugin.getResourceString("IndexerPreferencePage.applyToAllProjects")); //$NON-NLS-1$
return composite; return composite;
} }
@ -63,9 +77,34 @@ public class IndexerPreferencePage extends PreferencePage implements
return null; return null;
} }
private static class ApplyIndexer extends Job {
private final String indexerId;
public ApplyIndexer(String indexerId) {
super("ApplyIndexer"); //$NON-NLS-1$
setSystem(true);
this.indexerId = indexerId;
}
protected IStatus run(IProgressMonitor monitor) {
try {
IPDOMManager manager = CCorePlugin.getPDOMManager();
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
for (int i = 0; i < projects.length; ++i) {
manager.setIndexerId(projects[i], indexerId);
}
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
}
}
}
public boolean performOk() { public boolean performOk() {
try { try {
fOptionBlock.performApply(null); fOptionBlock.performApply(null);
if (applyIndexerToAllButton.getSelection()) {
String indexerName = fOptionBlock.getSelectedIndexerID();
String indexerId = fOptionBlock.getIndexerPageId(indexerName);
new ApplyIndexer(indexerId).schedule();
}
} catch (CoreException e) {} } catch (CoreException e) {}
CUIPlugin.getDefault().savePluginPreferences(); CUIPlugin.getDefault().savePluginPreferences();
return true; return true;

View file

@ -271,7 +271,7 @@ public class IndexerBlock extends AbstractCOptionPage {
* @param indexerPageName * @param indexerPageName
* @return String * @return String
*/ */
protected String getIndexerPageId(String indexerPageName) { public String getIndexerPageId(String indexerPageName) {
for (Iterator I = indexerPageMap.keySet().iterator(); I.hasNext();) { for (Iterator I = indexerPageMap.keySet().iterator(); I.hasNext();) {
String indexerPageId = (String) I.next(); String indexerPageId = (String) I.next();
String tempPageName = getIndexerPageName(indexerPageId); String tempPageName = getIndexerPageName(indexerPageId);