mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +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:
parent
5839b72abe
commit
c27a51479b
9 changed files with 116 additions and 66 deletions
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
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.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
|
@ -96,7 +97,7 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
|||
IPDOMIndexer indexer = (IPDOMIndexer)rproject.getSessionProperty(indexerProperty);
|
||||
|
||||
if (indexer == null) {
|
||||
indexer = createIndexer(getIndexerId(project), project);
|
||||
indexer = createIndexer(project, getIndexerId(project));
|
||||
}
|
||||
|
||||
return indexer;
|
||||
|
@ -195,20 +196,29 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
|||
} catch (CoreException e) {
|
||||
}
|
||||
|
||||
if (indexerId == null)
|
||||
// make it the default
|
||||
if (indexerId == null || indexerId.equals(CtagsIndexer.ID))
|
||||
// make it the default, ctags is gone
|
||||
indexerId = getDefaultIndexerId();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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 String indexerId;
|
||||
public SetId(ICProject project, String indexerId) {
|
||||
public SetIndexerId(ICProject project, String indexerId) {
|
||||
super("Set Indexer Id");
|
||||
this.project = project;
|
||||
this.indexerId = indexerId;
|
||||
|
@ -216,7 +226,7 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
|||
}
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
setId(project, indexerId);
|
||||
setIndexerId(project, indexerId);
|
||||
return Status.OK_STATUS;
|
||||
} catch (CoreException e) {
|
||||
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);
|
||||
if (prefs == null)
|
||||
return; // TODO why would this be null?
|
||||
|
||||
prefs.put(INDEXER_ID_KEY, indexerId);
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
|
||||
String oldId = prefs.get(INDEXER_ID_KEY, null);
|
||||
if (!indexerId.equals(oldId)) {
|
||||
prefs.put(INDEXER_ID_KEY, indexerId);
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
}
|
||||
|
||||
createIndexer(project, indexerId).reindex();
|
||||
}
|
||||
}
|
||||
|
||||
public void setIndexerId(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 {
|
||||
private IPDOMIndexer createIndexer(ICProject project, String indexerId) throws CoreException {
|
||||
IPDOMIndexer indexer = null;
|
||||
// Look up in extension point
|
||||
IExtension indexerExt = Platform.getExtensionRegistry()
|
||||
|
|
|
@ -30,6 +30,8 @@ import org.osgi.service.prefs.BackingStoreException;
|
|||
*/
|
||||
public class CtagsIndexer implements IPDOMIndexer {
|
||||
|
||||
public static final String ID = "org.eclipse.cdt.core.ctagsindexer"; //$NON-NLS-1$
|
||||
|
||||
private ICProject project;
|
||||
|
||||
private boolean useCtagsOnPath = true;
|
||||
|
|
|
@ -11,10 +11,16 @@
|
|||
|
||||
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.model.ICElementDelta;
|
||||
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.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
|
@ -36,7 +42,24 @@ public class PDOMNullIndexer implements IPDOMIndexer {
|
|||
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 {
|
||||
new Reindex().schedule();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -531,28 +531,6 @@
|
|||
<extension point="org.eclipse.core.runtime.preferences">
|
||||
<initializer class="org.eclipse.cdt.internal.core.CCorePreferenceInitializer"/>
|
||||
</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
|
||||
id="nullindexer"
|
||||
name="%CDTIndexer.nullindexer"
|
||||
|
@ -575,6 +553,17 @@
|
|||
</run>
|
||||
</cextension>
|
||||
</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
|
||||
point="org.eclipse.core.variables.dynamicVariables">
|
||||
<variable
|
||||
|
|
|
@ -322,10 +322,9 @@ completionContributors=Content Assist Completion Contributor
|
|||
indexerPrefName=Indexer
|
||||
|
||||
# indexer names
|
||||
CDTIndexer.domsourceindexer=Full C/C++ Indexer (declarations and cross references)
|
||||
CDTIndexer.ctagsindexer=CTags Indexer (declarations only)
|
||||
CDTIndexer.domsourceindexer=Full C/C++ Indexer (slow but accurate)
|
||||
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
|
||||
UpdateIndex.name=Update Index
|
||||
|
|
|
@ -1304,33 +1304,21 @@
|
|||
</extension>
|
||||
<extension
|
||||
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
|
||||
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
|
||||
indexerID="org.eclipse.cdt.core.nullindexer"
|
||||
name="%CDTIndexer.nullindexer"
|
||||
id="org.eclipse.cdt.ui.nullindexerUI"/>
|
||||
<indexerUI
|
||||
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
|
||||
id="org.eclipse.cdt.ui.fastIndexer"
|
||||
indexerID="org.eclipse.cdt.core.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"/>
|
||||
<indexerUI
|
||||
class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
|
||||
id="org.eclipse.cdt.ui.fastIndexer"
|
||||
indexerID="org.eclipse.cdt.core.fastIndexer"
|
||||
name="%CDTIndexer.fastindexer"/>
|
||||
|
||||
</extension>
|
||||
<extension
|
||||
|
|
|
@ -45,7 +45,6 @@ ErrorParserBlock.desc=Set the error parsers for this project
|
|||
BinaryParserBlock.label=Binary Parser
|
||||
BinaryParserBlock.desc=Set required binary parser for this project
|
||||
|
||||
BaseIndexerBlock.usePDOM=Use PDOM (Work in progress)
|
||||
BaseIndexerBlock.label=C/C++ Indexer
|
||||
BaseIndexerBlock.desc=C/C++ Indexer setting for this project.
|
||||
BaseIndexerBlock.comboLabel=Available indexers
|
||||
|
@ -330,3 +329,5 @@ IndexView.setFastIndexer.name = Use Fast Indexer
|
|||
IndexView.CountSymbols.name = Count Symbols
|
||||
IndexView.CountSymbols.title = Symbol Count
|
||||
IndexView.CountSymbols.message = The PDOM contains {0} symbols.
|
||||
|
||||
IndexerPreferencePage.applyToAllProjects = Apply indexer to all projects now
|
||||
|
|
|
@ -10,15 +10,24 @@
|
|||
*******************************************************************************/
|
||||
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.dialogs.ICOptionContainer;
|
||||
import org.eclipse.cdt.ui.dialogs.IndexerBlock;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
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.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.preference.PreferencePage;
|
||||
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.Control;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
|
@ -28,6 +37,7 @@ public class IndexerPreferencePage extends PreferencePage implements
|
|||
IWorkbenchPreferencePage, ICOptionContainer {
|
||||
|
||||
private IndexerBlock fOptionBlock;
|
||||
private Button applyIndexerToAllButton;
|
||||
|
||||
public IndexerPreferencePage(){
|
||||
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
|
||||
|
@ -37,10 +47,14 @@ public class IndexerPreferencePage extends PreferencePage implements
|
|||
|
||||
protected Control createContents(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
composite.setLayout(new FillLayout());
|
||||
GridLayout layout = new GridLayout(1, true);
|
||||
composite.setLayout(layout);
|
||||
|
||||
fOptionBlock.createControl(composite);
|
||||
|
||||
applyIndexerToAllButton = new Button(composite, SWT.CHECK);
|
||||
applyIndexerToAllButton.setText(CUIPlugin.getResourceString("IndexerPreferencePage.applyToAllProjects")); //$NON-NLS-1$
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
|
@ -63,9 +77,34 @@ public class IndexerPreferencePage extends PreferencePage implements
|
|||
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() {
|
||||
try {
|
||||
fOptionBlock.performApply(null);
|
||||
if (applyIndexerToAllButton.getSelection()) {
|
||||
String indexerName = fOptionBlock.getSelectedIndexerID();
|
||||
String indexerId = fOptionBlock.getIndexerPageId(indexerName);
|
||||
new ApplyIndexer(indexerId).schedule();
|
||||
}
|
||||
} catch (CoreException e) {}
|
||||
CUIPlugin.getDefault().savePluginPreferences();
|
||||
return true;
|
||||
|
|
|
@ -271,7 +271,7 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
* @param indexerPageName
|
||||
* @return String
|
||||
*/
|
||||
protected String getIndexerPageId(String indexerPageName) {
|
||||
public String getIndexerPageId(String indexerPageName) {
|
||||
for (Iterator I = indexerPageMap.keySet().iterator(); I.hasNext();) {
|
||||
String indexerPageId = (String) I.next();
|
||||
String tempPageName = getIndexerPageName(indexerPageId);
|
||||
|
|
Loading…
Add table
Reference in a new issue