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

Bug 197989: Remove option to parse files up front from UI.

This commit is contained in:
Markus Schorn 2011-11-03 14:57:48 +01:00
parent 5a62f3280d
commit 0fb12d7d56
9 changed files with 21 additions and 109 deletions

View file

@ -37,7 +37,6 @@ import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.pdom.CModelListener;
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILogListener;
@ -67,7 +66,6 @@ public class BaseTestCase extends TestCase {
CPPASTNameBase.sAllowRecursionBindings= false;
CPPASTNameBase.sAllowNameComputation= false;
CModelListener.sSuppressUpdateOfLastRecentlyUsed= true;
AbstractPDOMIndexer.noFilesUpFront= true;
}
@Override
@ -132,6 +130,7 @@ public class BaseTestCase extends TestCase {
public void runBare() throws Throwable {
final List<IStatus> statusLog= Collections.synchronizedList(new ArrayList());
ILogListener logListener= new ILogListener() {
@Override
public void logging(IStatus status, String plugin) {
if (!status.isOK() && status.getSeverity() != IStatus.INFO) {
switch (status.getCode()) {
@ -274,6 +273,7 @@ public class BaseTestCase extends TestCase {
CoreModel.getDefault().removeElementChangedListener(this);
}
@Override
public void elementChanged(ElementChangedEvent event) {
// Only respond to post change events
if (event.getType() != ElementChangedEvent.POST_CHANGE)

View file

@ -148,17 +148,13 @@ public abstract class StandaloneIndexer {
*/
protected FilenameFilter fExclusionFilter;
/**
* Files to parse up front.
*/
protected String[] fFilesToParseUpFront = new String[0];
protected int fUpdateOptions = UPDATE_ALL;
private IndexerProgress fProgress = null;
private volatile StandaloneIndexerTask fDelegate;
private static FilenameFilter DEFAULT_FILTER = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return true;
}
@ -403,7 +399,6 @@ public abstract class StandaloneIndexer {
clearIndex();
fDelegate= createTask(getFilesAdded(tus), NO_TUS, NO_TUS);
fDelegate.setUpdateFlags(fUpdateOptions);
fDelegate.setParseUpFront();
if (fDelegate != null) {
fDelegate.run(monitor);
@ -489,21 +484,6 @@ public abstract class StandaloneIndexer {
fSkipReferences = skipReferences;
}
/**
* Returns an array of files that should be parsed up front.
*/
public String[] getFilesToParseUpFront() {
return fFilesToParseUpFront;
}
/**
* Sets an array of files that should be parsed up front.
* @param filesToParseUpFront
*/
public void setFilesToParseUpFront(String[] filesToParseUpFront) {
fFilesToParseUpFront = filesToParseUpFront;
}
/**
* Returns the exclusion filter for this indexer.
*/

View file

@ -90,15 +90,7 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
final public IndexerProgress getProgressInformation() {
return super.getProgressInformation();
}
/**
* Tells the parser which files to parse first
*/
final public void setParseUpFront() {
setParseUpFront(fIndexer.getFilesToParseUpFront());
}
/**
* Figures out whether all files (sources without config, headers not included)
* should be parsed.

View file

@ -328,10 +328,6 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
fUpdateFlags= flags;
}
// TODO(197989) remove
public final void setParseUpFront(String[] astFilePaths) {
}
public final void setForceFirstFiles(int number) {
fForceNumberFiles= number;
}

View file

@ -21,9 +21,6 @@ import org.eclipse.cdt.core.model.ICProject;
* Abstract base class for all indexers.
*/
public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
// For testing purposes
public static boolean noFilesUpFront= false;
protected ICProject project;
protected Properties fProperties= new Properties();
@ -34,25 +31,28 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
fProperties.put(IndexerPreferences.KEY_INDEX_ON_OPEN, String.valueOf(false));
fProperties.put(IndexerPreferences.KEY_INCLUDE_HEURISTICS, String.valueOf(true));
fProperties.put(IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB, String.valueOf(IndexerPreferences.DEFAULT_FILE_SIZE_LIMIT));
fProperties.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, ""); //$NON-NLS-1$
fProperties.put(IndexerPreferences.KEY_SKIP_ALL_REFERENCES, String.valueOf(false));
fProperties.put(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES, String.valueOf(false));
fProperties.put(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES, String.valueOf(false));
fProperties.put(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES, String.valueOf(false));
}
@Override
public ICProject getProject() {
return project;
}
@Override
public void setProject(ICProject project) {
this.project = project;
}
@Override
public String getProperty(String key) {
return fProperties.getProperty(key);
}
@Override
public boolean needsToRebuildForProperties(Properties props) {
for (Map.Entry<Object,Object> entry : fProperties.entrySet()) {
String key = (String) entry.getKey();
@ -72,6 +72,7 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
return fProperties;
}
@Override
public void setProperties(Properties props) {
// only set relevant properties as initialized in the constructor
for (Map.Entry<Object,Object> entry : props.entrySet()) {
@ -83,17 +84,4 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
}
}
}
public String[] getFilesToParseUpFront() {
if (!noFilesUpFront) {
String prefSetting= getProperty(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT);
if (prefSetting != null) {
prefSetting= prefSetting.trim();
if (prefSetting.length() > 0) {
return prefSetting.split(","); //$NON-NLS-1$
}
}
}
return new String[0];
}
}

View file

@ -25,9 +25,9 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
@ -50,7 +50,6 @@ public class IndexerPreferences {
public static final String KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG= "indexUnusedHeadersWithAlternateLang"; //$NON-NLS-1$
public static final String KEY_INDEX_ON_OPEN= "indexOnOpen"; //$NON-NLS-1$
public static final String KEY_INCLUDE_HEURISTICS= "useHeuristicIncludeResolution"; //$NON-NLS-1$
public static final String KEY_FILES_TO_PARSE_UP_FRONT= "filesToParseUpFront"; //$NON-NLS-1$
public static final String KEY_SKIP_ALL_REFERENCES= "skipReferences"; //$NON-NLS-1$
public static final String KEY_SKIP_IMPLICIT_REFERENCES= "skipImplicitReferences"; //$NON-NLS-1$
public static final String KEY_SKIP_TYPE_REFERENCES= "skipTypeReferences"; //$NON-NLS-1$
@ -62,18 +61,6 @@ public class IndexerPreferences {
private static final String KEY_INDEX_IMPORT_LOCATION = "indexImportLocation"; //$NON-NLS-1$
private static final String DEFAULT_INDEX_IMPORT_LOCATION = ".settings/cdt-index.zip"; //$NON-NLS-1$
// See http://bugs.eclipse.org/bugs/show_bug.cgi?id=259843,
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=294180 and
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=295518 for the rationale.
private static final String DEFAULT_FILES_TO_PARSE_UP_FRONT=
"cstdarg, " + // configures stdarg.h for c++ //$NON-NLS-1$
"stdarg.h, " + // can be fragmented //$NON-NLS-1$
"stddef.h, " + // can be fragmented //$NON-NLS-1$
"sys/resource.h, " + // configures bits/time.h, !! fragments stddef.h !! //$NON-NLS-1$
"ctime, " + // configures time.h for c++ //$NON-NLS-1$
"sys/types.h, " + // can be fragmented, !! fragments bits/time.h !! //$NON-NLS-1$
"signal.h, " + // configures bits/signum.h //$NON-NLS-1$
"cstdio"; // configures stdio.h for c++ !! fragments bits/signum.h !! //$NON-NLS-1$
private static final int DEFAULT_UPDATE_POLICY= 0;
public static final int DEFAULT_FILE_SIZE_LIMIT = 8;
@ -340,7 +327,6 @@ public class IndexerPreferences {
prefs.putBoolean(KEY_SKIP_TYPE_REFERENCES, false);
prefs.putBoolean(KEY_SKIP_MACRO_REFERENCES, false);
prefs.put(KEY_INDEX_IMPORT_LOCATION, DEFAULT_INDEX_IMPORT_LOCATION);
prefs.put(KEY_FILES_TO_PARSE_UP_FRONT, DEFAULT_FILES_TO_PARSE_UP_FRONT);
}
public static void setDefaultIndexerId(String defaultId) {

View file

@ -100,6 +100,7 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
union.addAll(Arrays.asList(changed));
final ITranslationUnit[] result = union.toArray(new ITranslationUnit[union.size()]);
Arrays.sort(result, new Comparator<ITranslationUnit>() {
@Override
public int compare(ITranslationUnit o1, ITranslationUnit o2) {
IResource res1= o1.getResource();
IResource res2= o2.getResource();
@ -125,14 +126,12 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
return result;
}
public final void setParseUpFront() {
setParseUpFront(fIndexer.getFilesToParseUpFront());
}
@Override
public final IPDOMIndexer getIndexer() {
return fIndexer;
}
@Override
public final void run(IProgressMonitor monitor) throws InterruptedException {
long start = System.currentTimeMillis();
runTask(monitor);

View file

@ -54,10 +54,12 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
return progress;
}
@Override
public IPDOMIndexer getIndexer() {
return fIndexer;
}
@Override
public void run(IProgressMonitor monitor) throws InterruptedException {
monitor.subTask(NLS.bind(Messages.PDOMIndexerTask_collectingFilesTask,
fIndexer.getProject().getElementName()));
@ -113,7 +115,6 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
if (delegate instanceof PDOMIndexerTask) {
final PDOMIndexerTask pdomIndexerTask = (PDOMIndexerTask) delegate;
pdomIndexerTask.setUpdateFlags(IIndexManager.UPDATE_ALL);
pdomIndexerTask.setParseUpFront();
pdomIndexerTask.setWriteInfoToLog();
}
synchronized (this) {
@ -121,10 +122,12 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
}
}
@Override
public synchronized IndexerProgress getProgressInformation() {
return fDelegate != null ? fDelegate.getProgressInformation() : fProgress;
}
@Override
public synchronized boolean acceptUrgentTask(IPDOMIndexerTask task) {
return fDelegate != null && fDelegate.acceptUrgentTask(task);
}

View file

@ -28,7 +28,6 @@ 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;
import org.eclipse.swt.widgets.Text;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
@ -51,13 +50,13 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
private Button fIndexOnOpen;
private Button fIncludeHeuristics;
private IntegerFieldEditor fFileSizeLimit;
private Text fFilesToParseUpFront;
private Button fSkipReferences;
private Button fSkipImplicitReferences;
private Button fSkipMacroAndTypeReferences;
private IPropertyChangeListener validityChangeListener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(FieldEditor.IS_VALID)) {
updateValidState();
}
@ -117,8 +116,6 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
fSkipImplicitReferences= createSkipImplicitReferencesButton(group);
fSkipMacroAndTypeReferences= createSkipMacroAndTypeReferencesButton(group);
fFilesToParseUpFront= createParseUpFrontTextField(page);
final SelectionAdapter selectionListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@ -184,10 +181,6 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
boolean skipMacroReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES));
fSkipMacroAndTypeReferences.setSelection(skipTypeReferences && skipMacroReferences);
}
if (fFilesToParseUpFront != null) {
String files = getNotNull(properties, IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT);
fFilesToParseUpFront.setText(files);
}
updateEnablement();
}
@ -215,9 +208,6 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
if (fFileSizeLimit != null) {
props.put(IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB, String.valueOf(fFileSizeLimit.getIntValue()));
}
if (fFilesToParseUpFront != null) {
props.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, fFilesToParseUpFront.getText());
}
if (fSkipReferences != null) {
props.put(IndexerPreferences.KEY_SKIP_ALL_REFERENCES, String.valueOf(fSkipReferences.getSelection()));
}
@ -273,20 +263,6 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
}
}
private String getNotNull(Properties properties, String key) {
String files= (String) properties.get(key);
if (files == null) {
files= ""; //$NON-NLS-1$
}
return files;
}
private Text createParseUpFrontTextField(Composite page) {
Label l= ControlFactory.createLabel(page, DialogsMessages.AbstractIndexerPage_indexUpFront);
((GridData) l.getLayoutData()).verticalIndent= 5;
return ControlFactory.createTextField(page);
}
private Button createAllFilesButton(Composite page) {
Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllFiles);
((GridData) result.getLayoutData()).horizontalSpan= 3;
@ -348,17 +324,9 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
}
/**
* Enable or disable support for parsing files up front. Essentially the according widget will be
* enabled or disabled.
* There will be no effect by calling this function before the IndexerPage is created
* (by {@link #createControl(Composite)}).
* <p> By default, support for parsing files up front is enabled.
*
* @since 5.3
* @deprecated parsing files up-front is no longer necessary.
*/
@Deprecated
protected void setSupportForFilesParsedUpFront(boolean enable){
if(fFilesToParseUpFront!=null){
fFilesToParseUpFront.setEnabled(enable);
}
}
}