mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Splits option to index all files, bug 266814.
This commit is contained in:
parent
3f794a608f
commit
eea82af3a1
25 changed files with 303 additions and 89 deletions
|
@ -1,3 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -62,6 +72,7 @@ public class Bug246129 extends IndexTestBase {
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
if (fProject == null) {
|
||||
|
@ -131,7 +142,7 @@ public class Bug246129 extends IndexTestBase {
|
|||
fExternalIncludeFolder.getAbsolutePath() };
|
||||
|
||||
IndexerPreferences.set(fProject.getProject(),
|
||||
IndexerPreferences.KEY_INDEX_ALL_FILES, "false");
|
||||
IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
|
||||
|
||||
File falseFriendDirectory = new File(fWrapperIncludeFolder
|
||||
.getLocation().toOSString()
|
||||
|
@ -145,6 +156,7 @@ public class Bug246129 extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
fExternalWrapperHeader.delete();
|
||||
fExternalWrapperIncludeFolder.delete();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Symbian Software Systems and others.
|
||||
* Copyright (c) 2006, 2009 Symbian 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
|
||||
|
@ -345,7 +345,6 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
pd.setReferencedProjects(refs);
|
||||
cproject.getProject().setDescription(pd, new NullProgressMonitor());
|
||||
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
||||
CCorePlugin.getIndexManager().reindex(cproject);
|
||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||
|
@ -366,7 +365,6 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
String content = testData[0].toString();
|
||||
IFile file = TestSourceReader.createFile(referenced.getProject(), new Path("header.h"), content);
|
||||
|
||||
IndexerPreferences.set(referenced.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
IndexerPreferences.set(referenced.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
||||
CCorePlugin.getIndexManager().reindex(referenced);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
|
||||
|
@ -81,11 +81,11 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
|
||||
public void testFastIndexer() throws Exception {
|
||||
CCorePlugin.getIndexManager().setIndexerId(fProject, IPDOMManager.ID_FAST_INDEXER);
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "false");
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
|
||||
waitForIndexer();
|
||||
checkHeader(false);
|
||||
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true");
|
||||
waitForIndexer();
|
||||
checkHeader(true);
|
||||
|
||||
|
@ -98,11 +98,11 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
|
||||
public void testFullIndexer() throws Exception {
|
||||
CCorePlugin.getIndexManager().setIndexerId(fProject, IPDOMManager.ID_FULL_INDEXER);
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "false");
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
|
||||
waitForIndexer();
|
||||
checkHeader(false);
|
||||
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true");
|
||||
waitForIndexer();
|
||||
checkHeader(true);
|
||||
|
||||
|
@ -261,7 +261,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
TestSourceReader.createFile(fProject.getProject(), "included_20070404.h", content1);
|
||||
TestSourceReader.createFile(fProject.getProject(), "notIncluded_20070404.h", "int notIncluded_20070404\n;");
|
||||
TestSourceReader.createFile(fProject.getProject(), "includer_20070404.cpp", content3);
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "false");
|
||||
IndexerPreferences.set(fProject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "false");
|
||||
CCorePlugin.getIndexManager().reindex(fProject);
|
||||
waitForIndexer();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2006, 2009 Symbian 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
|
||||
|
@ -39,6 +39,7 @@ public class TrilogyPerformanceTest extends IndexTestBase {
|
|||
super("TrilogyPerformance");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
Bundle b = CTestPlugin.getDefault().getBundle();
|
||||
|
@ -47,6 +48,7 @@ public class TrilogyPerformanceTest extends IndexTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
cproject.getProject().delete(true, new NullProgressMonitor());
|
||||
super.tearDown();
|
||||
|
@ -57,7 +59,7 @@ public class TrilogyPerformanceTest extends IndexTestBase {
|
|||
if(Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||
TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"};
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true");
|
||||
long start = System.currentTimeMillis();
|
||||
CCorePlugin.getIndexManager().reindex(cproject);
|
||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2009 Symbian 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
|
||||
|
@ -64,7 +64,6 @@ public class CPPClassTemplateTests extends PDOMTestBase {
|
|||
for(int i=0; i<contents.length; i++) {
|
||||
IFile file= TestSourceReader.createFile(cproject.getProject(), new Path("refs.cpp"), contents[i].toString());
|
||||
}
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
||||
for(int i=0; i<5 && !CCoreInternals.getPDOMManager().isProjectRegistered(cproject); i++) {
|
||||
Thread.sleep(200);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2009 Symbian 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 implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* QNX - Initial implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.pdom.tests;
|
||||
|
||||
|
@ -49,7 +49,6 @@ public class CPPFunctionTemplateTests extends PDOMTestBase {
|
|||
for(int i=0; i<contents.length; i++) {
|
||||
IFile file= TestSourceReader.createFile(cproject.getProject(), new Path("refs.cpp"), contents[i].toString());
|
||||
}
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
||||
CCorePlugin.getIndexManager().reindex(cproject);
|
||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2009 IBM Corporation 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
|
||||
|
@ -88,7 +88,7 @@ public class CProjectHelper {
|
|||
IWorkspaceRoot root = ws.getRoot();
|
||||
IProject project = root.getProject(projectName);
|
||||
if (indexerID != null) {
|
||||
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true");
|
||||
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, indexerID);
|
||||
}
|
||||
if (!project.exists()) {
|
||||
|
@ -169,7 +169,6 @@ public class CProjectHelper {
|
|||
IWorkspaceRoot root = ws.getRoot();
|
||||
IProject project = root.getProject(projectName);
|
||||
if (indexerID != null) {
|
||||
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, indexerID);
|
||||
}
|
||||
if (!project.exists()) {
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2009 Symbian 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:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.index.export;
|
||||
|
||||
import java.io.File;
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
|
@ -21,6 +19,9 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||
|
@ -154,8 +155,9 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider
|
|||
|
||||
newProject[0]= cproject;
|
||||
|
||||
IndexerPreferences.set(newProject[0].getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, Boolean.TRUE.toString());
|
||||
IndexerPreferences.set(newProject[0].getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
|
||||
IndexerPreferences.set(newProject[0].getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, Boolean.TRUE.toString());
|
||||
IndexerPreferences.set(newProject[0].getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, Boolean.TRUE.toString());
|
||||
}
|
||||
}, null);
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractLanguage[] getLanguages(Object tu) {
|
||||
public AbstractLanguage[] getLanguages(Object tu, boolean bothForHeaders) {
|
||||
ILanguage language = fIndexer.getLanguageMapper().getLanguage((String) tu);
|
||||
if (language instanceof AbstractLanguage) {
|
||||
return new AbstractLanguage[] {(AbstractLanguage) language};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
|
||||
|
@ -9,10 +9,8 @@
|
|||
* Markus Schorn - initial API and implementation
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.indexer;
|
||||
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
@ -29,6 +27,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* A task for index updates.
|
||||
*
|
||||
|
@ -58,11 +58,11 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
|||
|
||||
if (getIndexAllFiles()) {
|
||||
setIndexFilesWithoutBuildConfiguration(true);
|
||||
setIndexHeadersWithoutContext(true);
|
||||
setIndexHeadersWithoutContext(UnusedHeaderStrategy.useDefaultLanguage);
|
||||
}
|
||||
else {
|
||||
setIndexFilesWithoutBuildConfiguration(false);
|
||||
setIndexHeadersWithoutContext(false);
|
||||
setIndexHeadersWithoutContext(UnusedHeaderStrategy.skip);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,10 @@ import org.eclipse.osgi.util.NLS;
|
|||
* @since 5.0
|
||||
*/
|
||||
public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||
protected static enum UnusedHeaderStrategy {
|
||||
skip, useDefaultLanguage, useAlternateLanguage, useBoth
|
||||
}
|
||||
|
||||
private static final int MAX_ERRORS = 500;
|
||||
|
||||
private static class FileKey {
|
||||
|
@ -157,7 +161,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
protected enum MessageKind {parsingFileTask, errorWhileParsing, tooManyIndexProblems}
|
||||
|
||||
private int fUpdateFlags= IIndexManager.UPDATE_ALL;
|
||||
private boolean fIndexHeadersWithoutContext= true;
|
||||
private UnusedHeaderStrategy fIndexHeadersWithoutContext= UnusedHeaderStrategy.useDefaultLanguage;
|
||||
private boolean fIndexFilesWithoutConfiguration= true;
|
||||
private HashMap<FileKey, FileContent> fFileInfos= new HashMap<FileKey, FileContent>();
|
||||
|
||||
|
@ -180,12 +184,18 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
updateRequestedFiles(fFilesToUpdate.length + fFilesToRemove.size());
|
||||
}
|
||||
|
||||
public final void setIndexHeadersWithoutContext(boolean val) {
|
||||
fIndexHeadersWithoutContext= val;
|
||||
public final void setIndexHeadersWithoutContext(UnusedHeaderStrategy mode) {
|
||||
fIndexHeadersWithoutContext= mode;
|
||||
}
|
||||
public final void setIndexFilesWithoutBuildConfiguration(boolean val) {
|
||||
fIndexFilesWithoutConfiguration= val;
|
||||
}
|
||||
public UnusedHeaderStrategy getIndexHeadersWithoutContext() {
|
||||
return fIndexHeadersWithoutContext;
|
||||
}
|
||||
public boolean indexFilesWithoutConfiguration() {
|
||||
return fIndexFilesWithoutConfiguration;
|
||||
}
|
||||
public final void setUpdateFlags(int flags) {
|
||||
fUpdateFlags= flags;
|
||||
}
|
||||
|
@ -271,7 +281,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
|
||||
public final void runTask(IProgressMonitor monitor) throws InterruptedException {
|
||||
if (!fIndexFilesWithoutConfiguration) {
|
||||
fIndexHeadersWithoutContext= false;
|
||||
fIndexHeadersWithoutContext= UnusedHeaderStrategy.skip;
|
||||
}
|
||||
|
||||
fIndex= createIndex();
|
||||
|
@ -334,9 +344,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
final boolean isExcludedSource= isSourceUnit && !fIndexFilesWithoutConfiguration && !fResolver.isFileBuildConfigured(tu);
|
||||
final IIndexFragmentFile[] indexFiles= fIndex.getWritableFiles(ifl);
|
||||
|
||||
if ((isSourceUnit && !isExcludedSource) || fIndexHeadersWithoutContext) {
|
||||
if ((isSourceUnit && !isExcludedSource) || fIndexHeadersWithoutContext != UnusedHeaderStrategy.skip) {
|
||||
// headers or sources required with a specific linkage
|
||||
AbstractLanguage[] langs= fResolver.getLanguages(tu);
|
||||
AbstractLanguage[] langs= fResolver.getLanguages(tu, fIndexHeadersWithoutContext==UnusedHeaderStrategy.useBoth);
|
||||
for (AbstractLanguage lang : langs) {
|
||||
int linkageID = lang.getLinkageID();
|
||||
IIndexFragmentFile ifile= getFile(linkageID, indexFiles);
|
||||
|
@ -641,7 +651,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
private void parseFile(Object tu, int linkageID, IIndexFileLocation ifl, IScannerInfo scanInfo,
|
||||
IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||
IPath path= getPathForLabel(ifl);
|
||||
AbstractLanguage[] langs= fResolver.getLanguages(tu);
|
||||
AbstractLanguage[] langs= fResolver.getLanguages(tu, fIndexHeadersWithoutContext==UnusedHeaderStrategy.useBoth);
|
||||
AbstractLanguage lang= null;
|
||||
for (AbstractLanguage lang2 : langs) {
|
||||
if (lang2.getLinkageID() == linkageID) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. 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
|
||||
|
@ -58,7 +58,7 @@ public abstract class IndexerInputAdapter extends ASTFilePathResolver {
|
|||
/**
|
||||
* Obtains the languages the input file should be parsed with.
|
||||
*/
|
||||
public abstract AbstractLanguage[] getLanguages(Object tu);
|
||||
public abstract AbstractLanguage[] getLanguages(Object tu, boolean bothForHeaders);
|
||||
|
||||
/**
|
||||
* Obtains the scanner configuration for the input file.
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent;
|
||||
|
||||
/**
|
||||
* Task to notify the CModel manager of changes to the content types.
|
||||
*
|
||||
*/
|
||||
public class NotifyCModelManagerTask implements IPDOMIndexerTask {
|
||||
private final IProject fProject;
|
||||
|
||||
public NotifyCModelManagerTask(IProject prj) {
|
||||
fProject= prj;
|
||||
}
|
||||
|
||||
public IPDOMIndexer getIndexer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IndexerProgress getProgressInformation() {
|
||||
return new IndexerProgress();
|
||||
}
|
||||
|
||||
public void run(IProgressMonitor monitor) throws InterruptedException {
|
||||
IContentType ct1= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER);
|
||||
IContentType ct2= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
|
||||
if (ct1 != null && ct2 != null) {
|
||||
final ProjectScope scope = new ProjectScope(fProject);
|
||||
CModelManager.getDefault().contentTypeChanged(new ContentTypeChangeEvent[] {
|
||||
new ContentTypeChangeEvent(ct1, scope),
|
||||
new ContentTypeChangeEvent(ct2, scope)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.channels.FileChannel;
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -33,6 +32,8 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CCorePreferenceConstants;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
|
@ -73,6 +74,7 @@ import org.eclipse.cdt.internal.core.pdom.PDOM.IListener;
|
|||
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMProjectIndexLocationConverter;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.AbstractPDOMIndexer;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMNullIndexer;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMRebuildTask;
|
||||
|
@ -113,8 +115,6 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChange
|
|||
* The PDOM Provider. This is likely temporary since I hope
|
||||
* to integrate the PDOM directly into the core once it has
|
||||
* stabilized.
|
||||
*
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMManager implements IWritableIndexManager, IListener {
|
||||
private static final class PerInstanceSchedulingRule implements ISchedulingRule {
|
||||
|
@ -483,6 +483,12 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
IPDOMIndexer indexer= createIndexer(cproject, newid, props);
|
||||
registerIndexer(cproject, indexer);
|
||||
createPolicy(cproject).clearTUs();
|
||||
if (oldIndexer instanceof AbstractPDOMIndexer) {
|
||||
if (IndexerPreferences.preferDefaultLanguage(((AbstractPDOMIndexer) oldIndexer).getProperties()) !=
|
||||
IndexerPreferences.preferDefaultLanguage(props)) {
|
||||
enqueue(new NotifyCModelManagerTask(cproject.getProject()));
|
||||
}
|
||||
}
|
||||
enqueue(new PDOMRebuildTask(indexer));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,9 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
|
|||
protected Properties fProperties= new Properties();
|
||||
|
||||
public AbstractPDOMIndexer() {
|
||||
fProperties.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(true));
|
||||
fProperties.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, String.valueOf(false));
|
||||
fProperties.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG, String.valueOf(false));
|
||||
fProperties.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(false));
|
||||
fProperties.put(IndexerPreferences.KEY_INCLUDE_HEURISTICS, String.valueOf(true));
|
||||
fProperties.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, ""); //$NON-NLS-1$
|
||||
|
@ -60,6 +63,10 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Properties getProperties() {
|
||||
return fProperties;
|
||||
}
|
||||
|
||||
public void setProperties(Properties props) {
|
||||
// only set relevant properties as initialized in the constructor
|
||||
|
|
|
@ -45,6 +45,8 @@ public class IndexerPreferences {
|
|||
|
||||
public static final String KEY_INDEXER_ID= "indexerId"; //$NON-NLS-1$
|
||||
public static final String KEY_INDEX_ALL_FILES= "indexAllFiles"; //$NON-NLS-1$
|
||||
public static final String KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG= "indexUnusedHeadersWithDefaultLang"; //$NON-NLS-1$
|
||||
public static final String KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG= "indexUnusedHeadersWithAlternateLang"; //$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$
|
||||
|
@ -159,11 +161,23 @@ public class IndexerPreferences {
|
|||
public static Properties getProperties(IProject project, int scope) {
|
||||
Preferences[] prefs= getPreferences(project, scope);
|
||||
Properties props= new Properties();
|
||||
for (int i=prefs.length-1; i>=0; i--) {
|
||||
for (int i=0; i<prefs.length; i++) {
|
||||
readProperties(prefs[i], props);
|
||||
if (i==0) {
|
||||
migrateProperties(props);
|
||||
}
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
private static void migrateProperties(Properties props) {
|
||||
if (props.get(KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG) == null) {
|
||||
// backward compatibility
|
||||
if ("true".equals(props.get(KEY_INDEX_ALL_FILES))) { //$NON-NLS-1$
|
||||
props.put(KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, "true"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Properties getDefaultIndexerProperties() {
|
||||
Preferences prefs= getDefaultPreferences();
|
||||
|
@ -289,9 +303,11 @@ public class IndexerPreferences {
|
|||
String[] keys = preferences.keys();
|
||||
for (int i=0; i < keys.length; i++) {
|
||||
String key= keys[i];
|
||||
String val= preferences.get(key, null);
|
||||
if (val != null) {
|
||||
props.put(key, val);
|
||||
if (props.get(key) == null) {
|
||||
String val= preferences.get(key, null);
|
||||
if (val != null) {
|
||||
props.put(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (BackingStoreException e) {
|
||||
|
@ -301,7 +317,9 @@ public class IndexerPreferences {
|
|||
public static void initializeDefaultPreferences(IEclipsePreferences defaultPreferences) {
|
||||
Preferences prefs= defaultPreferences.node(INDEXER_NODE);
|
||||
prefs.put(KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
||||
prefs.putBoolean(KEY_INDEX_ALL_FILES, false);
|
||||
prefs.putBoolean(KEY_INDEX_ALL_FILES, true);
|
||||
prefs.putBoolean(KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, false);
|
||||
prefs.putBoolean(KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG, false);
|
||||
prefs.putBoolean(KEY_INCLUDE_HEURISTICS, true);
|
||||
prefs.putBoolean(KEY_SKIP_ALL_REFERENCES, false);
|
||||
prefs.putBoolean(KEY_SKIP_IMPLICIT_REFERENCES, false);
|
||||
|
@ -399,4 +417,28 @@ public class IndexerPreferences {
|
|||
}
|
||||
return DEFAULT_UPDATE_POLICY;
|
||||
}
|
||||
|
||||
public static boolean preferDefaultLanguage(IProject project) {
|
||||
IPreferencesService prefService = Platform.getPreferencesService();
|
||||
Preferences[] prefs= IndexerPreferences.getPreferences(project);
|
||||
if ("true".equals(prefService.get(KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG, null, prefs))) { //$NON-NLS-1$
|
||||
if ("true".equals(prefService.get(KEY_INDEX_ALL_FILES, null, prefs))) { //$NON-NLS-1$
|
||||
if (!"true".equals(prefService.get(KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, null, prefs))) { //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean preferDefaultLanguage(Properties props) {
|
||||
if ("true".equals(props.get(KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG))) { //$NON-NLS-1$
|
||||
if ("true".equals(props.get(KEY_INDEX_ALL_FILES))) { //$NON-NLS-1$
|
||||
if (!"true".equals(props.get(KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG))) { //$NON-NLS-1$
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ package org.eclipse.cdt.internal.core.pdom.indexer;
|
|||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||
|
@ -44,8 +46,6 @@ import org.eclipse.core.runtime.Status;
|
|||
import org.eclipse.core.runtime.content.IContentType;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
|
||||
/**
|
||||
* Configures the abstract indexer task suitable for indexing projects.
|
||||
*/
|
||||
|
@ -82,13 +82,20 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
|
|||
setSkipReferences(skipRefs);
|
||||
}
|
||||
}
|
||||
if (getIndexAllFiles()) {
|
||||
if (checkProperty(IndexerPreferences.KEY_INDEX_ALL_FILES)) {
|
||||
setIndexFilesWithoutBuildConfiguration(true);
|
||||
setIndexHeadersWithoutContext(true);
|
||||
}
|
||||
else {
|
||||
boolean i1= checkProperty(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG);
|
||||
boolean i2= checkProperty(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG);
|
||||
UnusedHeaderStrategy strategy;
|
||||
if (i1) {
|
||||
strategy= i2 ? UnusedHeaderStrategy.useBoth : UnusedHeaderStrategy.useDefaultLanguage;
|
||||
} else {
|
||||
strategy= i2 ? UnusedHeaderStrategy.useAlternateLanguage: UnusedHeaderStrategy.skip;
|
||||
}
|
||||
setIndexHeadersWithoutContext(strategy);
|
||||
} else {
|
||||
setIndexFilesWithoutBuildConfiguration(false);
|
||||
setIndexHeadersWithoutContext(false);
|
||||
setIndexHeadersWithoutContext(UnusedHeaderStrategy.skip);
|
||||
}
|
||||
setUpdateFlags(IIndexManager.UPDATE_CHECK_TIMESTAMPS);
|
||||
setForceFirstFiles(forceFiles.length);
|
||||
|
@ -127,10 +134,6 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
|
|||
return internallyActivated || (trace != null && trace.equalsIgnoreCase(value));
|
||||
}
|
||||
|
||||
private boolean getIndexAllFiles() {
|
||||
return checkProperty(IndexerPreferences.KEY_INDEX_ALL_FILES);
|
||||
}
|
||||
|
||||
private boolean checkProperty(String key) {
|
||||
return TRUE.equals(getIndexer().getProperty(key));
|
||||
}
|
||||
|
@ -253,14 +256,14 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
|
|||
System.out.println("C/C++ Indexer: Project '" + getProject().getElementName() //$NON-NLS-1$
|
||||
+ "' (" + info.fCompletedSources + " sources, " //$NON-NLS-1$//$NON-NLS-2$
|
||||
+ info.fCompletedHeaders + " headers)"); //$NON-NLS-1$
|
||||
boolean allFiles= getIndexAllFiles();
|
||||
boolean skipRefs= checkProperty(IndexerPreferences.KEY_SKIP_ALL_REFERENCES);
|
||||
boolean skipImplRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES);
|
||||
boolean skipTypeRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES);
|
||||
boolean skipMacroRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES);
|
||||
System.out.println(ident + " Options: " //$NON-NLS-1$
|
||||
+ "indexer='" + kind //$NON-NLS-1$
|
||||
+ "', parseAllFiles=" + allFiles //$NON-NLS-1$
|
||||
+ "', parseAllFiles=" + indexFilesWithoutConfiguration() //$NON-NLS-1$
|
||||
+ ", unusedHeaders=" + getIndexHeadersWithoutContext() //$NON-NLS-1$
|
||||
+ ", skipReferences=" + skipRefs //$NON-NLS-1$
|
||||
+ ", skipImplicitReferences=" + skipImplRefs //$NON-NLS-1$
|
||||
+ ", skipTypeReferences=" + skipTypeRefs //$NON-NLS-1$
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. 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
|
||||
|
@ -101,7 +101,9 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
|
|||
}
|
||||
|
||||
private void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
|
||||
boolean allFiles= TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||
boolean allFiles =
|
||||
TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG)) ||
|
||||
TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG));
|
||||
List<ITranslationUnit> sources= new ArrayList<ITranslationUnit>();
|
||||
List<ITranslationUnit> headers= allFiles ? sources : null;
|
||||
TranslationUnitCollector collector= new TranslationUnitCollector(sources, headers, monitor);
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.model.CoreModelUtil;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
|
@ -43,6 +44,8 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
|||
private final ICProject fCProject;
|
||||
private final HashMap<String, IIndexFileLocation> fIflCache;
|
||||
private final FileExistsCache fExistsCache;
|
||||
private AbstractLanguage fLangC;
|
||||
private AbstractLanguage fLangCpp;
|
||||
|
||||
public ProjectIndexerInputAdapter(ICProject cproject) {
|
||||
this(cproject, true);
|
||||
|
@ -53,11 +56,18 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
|||
if (useCache) {
|
||||
fIflCache= new HashMap<String, IIndexFileLocation>();
|
||||
fExistsCache= new FileExistsCache();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fIflCache= null;
|
||||
fExistsCache= null;
|
||||
}
|
||||
ILanguage l= LanguageManager.getInstance().getLanguageForContentTypeID(CCorePlugin.CONTENT_TYPE_CHEADER);
|
||||
if (l instanceof AbstractLanguage) {
|
||||
fLangC= (AbstractLanguage) l;
|
||||
}
|
||||
l= LanguageManager.getInstance().getLanguageForContentTypeID(CCorePlugin.CONTENT_TYPE_CXXHEADER);
|
||||
if (l instanceof AbstractLanguage) {
|
||||
fLangCpp= (AbstractLanguage) l;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -151,11 +161,22 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
|||
|
||||
|
||||
@Override
|
||||
public AbstractLanguage[] getLanguages(Object tuo) {
|
||||
public AbstractLanguage[] getLanguages(Object tuo, boolean bothForHeaders) {
|
||||
ITranslationUnit tu= (ITranslationUnit) tuo;
|
||||
try {
|
||||
ILanguage lang= tu.getLanguage();
|
||||
if (lang instanceof AbstractLanguage) {
|
||||
if (bothForHeaders && tu.isHeaderUnit()) {
|
||||
String filename= tu.getElementName();
|
||||
if (filename.indexOf('.') >= 0) {
|
||||
final String contentTypeId= tu.getContentTypeId();
|
||||
if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) && fLangC != null) {
|
||||
return new AbstractLanguage[] {(AbstractLanguage) lang, fLangC};
|
||||
} else if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CHEADER) && fLangCpp != null) {
|
||||
return new AbstractLanguage[] {(AbstractLanguage) lang, fLangCpp};
|
||||
}
|
||||
}
|
||||
}
|
||||
return new AbstractLanguage[] {(AbstractLanguage) lang};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
|
||||
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -52,7 +53,9 @@ public class CContentTypes {
|
|||
if (usesProjectSpecificContentTypes(project)) {
|
||||
scopeCtx= new ProjectScope(project);
|
||||
}
|
||||
preferCpp= CoreModel.hasCCNature(project) || !CoreModel.hasCNature(project);
|
||||
if (CoreModel.hasCNature(project)) {
|
||||
preferCpp= CoreModel.hasCCNature(project) == IndexerPreferences.preferDefaultLanguage(project);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
// fallback to workspace wide definitions.
|
||||
matcher= Platform.getContentTypeManager();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
|
||||
|
@ -23,8 +23,6 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
||||
|
||||
public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
|
||||
|
||||
|
@ -74,7 +72,6 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
|
|||
public void testInclusionAccrossProjects() throws Exception {
|
||||
ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||
try {
|
||||
IndexerPreferences.set(op.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");
|
||||
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {getProject(), op});
|
||||
|
||||
TestScannerProvider.sIncludes= new String[]{op.getProject().getLocation().toOSString()};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2009 Wind River Systems, Inc. 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
|
||||
|
@ -79,7 +79,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
|
|||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
|
||||
import org.eclipse.cdt.internal.core.model.ext.CElementHandleFactory;
|
||||
import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
|
||||
|
@ -429,7 +429,7 @@ public class IndexUI {
|
|||
node= ((IASTFunctionDefinition) node).getDeclarator();
|
||||
}
|
||||
if (node instanceof IASTDeclarator) {
|
||||
IASTDeclarator dtor= CPPVisitor.findTypeRelevantDeclarator((IASTDeclarator) node);
|
||||
IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) node);
|
||||
name= dtor.getName();
|
||||
}
|
||||
}
|
||||
|
@ -457,9 +457,11 @@ public class IndexUI {
|
|||
IResource res= tu.getResource();
|
||||
if (res != null) {
|
||||
Properties props= IndexerPreferences.getProperties(res.getProject());
|
||||
if (props == null || !"true".equals(props.get(IndexerPreferences.KEY_INDEX_ALL_FILES))) { //$NON-NLS-1$
|
||||
if (props == null || !"true".equals(props.get(IndexerPreferences.KEY_INDEX_ALL_FILES)) || //$NON-NLS-1$
|
||||
(!"true".equals(props.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG)) && //$NON-NLS-1$
|
||||
!"true".equals(props.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG)))) { //$NON-NLS-1$
|
||||
msg= msg+ " " + Messages.IndexUI_infoSelectIndexAllFiles; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.swt.widgets.Text;
|
|||
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
|
||||
import org.eclipse.cdt.internal.core.model.CProject;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
||||
|
||||
|
@ -35,7 +36,9 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
protected static final String INDEX_ALL_FILES = DialogsMessages.AbstractIndexerPage_indexAllFiles;
|
||||
protected static final String TRUE = String.valueOf(true);
|
||||
|
||||
private Button fAllFiles;
|
||||
private Button fAllSources;
|
||||
private Button fAllHeadersDefault;
|
||||
private Button fAllHeadersAlt;
|
||||
private Button fIncludeHeuristics;
|
||||
private Text fFilesToParseUpFront;
|
||||
private Button fSkipReferences;
|
||||
|
@ -58,7 +61,14 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
Composite page = ControlFactory.createComposite(parent, 1);
|
||||
fAllFiles= createAllFilesButton(page);
|
||||
fAllSources= createAllFilesButton(page);
|
||||
IProject prj= getCurrentProject();
|
||||
if (prj == null || !CProject.hasCCNature(prj)) {
|
||||
fAllHeadersDefault= createAllHeadersButton(page);
|
||||
} else {
|
||||
fAllHeadersDefault= createAllCppHeadersButton(page);
|
||||
fAllHeadersAlt= createAllCHeadersButton(page);
|
||||
}
|
||||
fIncludeHeuristics= createIncludeHeuristicsButton(page);
|
||||
fSkipReferences= createSkipReferencesButton(page);
|
||||
fSkipImplicitReferences= createSkipImplicitReferencesButton(page);
|
||||
|
@ -66,12 +76,14 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
fSkipMacroReferences= createSkipMacroReferencesButton(page);
|
||||
fFilesToParseUpFront= createParseUpFrontTextField(page);
|
||||
|
||||
fSkipReferences.addSelectionListener(new SelectionAdapter() {
|
||||
final SelectionAdapter selectionListener = new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateEnablement();
|
||||
}
|
||||
});
|
||||
};
|
||||
fSkipReferences.addSelectionListener(selectionListener);
|
||||
fAllSources.addSelectionListener(selectionListener);
|
||||
setControl(page);
|
||||
}
|
||||
|
||||
|
@ -81,9 +93,17 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
* @since 4.0
|
||||
*/
|
||||
public void setProperties(Properties properties) {
|
||||
if (fAllFiles != null) {
|
||||
if (fAllSources != null) {
|
||||
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||
fAllFiles.setSelection(indexAllFiles);
|
||||
fAllSources.setSelection(indexAllFiles);
|
||||
}
|
||||
if (fAllHeadersDefault != null) {
|
||||
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG));
|
||||
fAllHeadersDefault.setSelection(indexAllFiles);
|
||||
}
|
||||
if (fAllHeadersAlt != null) {
|
||||
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG));
|
||||
fAllHeadersAlt.setSelection(indexAllFiles);
|
||||
}
|
||||
if (fIncludeHeuristics != null) {
|
||||
Object prop= properties.get(IndexerPreferences.KEY_INCLUDE_HEURISTICS);
|
||||
|
@ -119,8 +139,14 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
*/
|
||||
public Properties getProperties(){
|
||||
Properties props= new Properties();
|
||||
if (fAllFiles != null) {
|
||||
props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllFiles.getSelection()));
|
||||
if (fAllSources != null) {
|
||||
props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllSources.getSelection()));
|
||||
}
|
||||
if (fAllHeadersDefault != null) {
|
||||
props.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, String.valueOf(fAllHeadersDefault.getSelection()));
|
||||
}
|
||||
if (fAllHeadersAlt != null) {
|
||||
props.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG, String.valueOf(fAllHeadersAlt.getSelection()));
|
||||
}
|
||||
if (fIncludeHeuristics != null) {
|
||||
props.put(IndexerPreferences.KEY_INCLUDE_HEURISTICS, String.valueOf(fIncludeHeuristics.getSelection()));
|
||||
|
@ -172,6 +198,15 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
fSkipMacroReferences.setEnabled(!skipReferences);
|
||||
}
|
||||
}
|
||||
if (fAllSources != null) {
|
||||
final boolean all= fAllSources.getSelection();
|
||||
if (fAllHeadersDefault != null) {
|
||||
fAllHeadersDefault.setEnabled(all);
|
||||
}
|
||||
if (fAllHeadersAlt != null) {
|
||||
fAllHeadersAlt.setEnabled(all);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getNotNull(Properties properties, String key) {
|
||||
|
@ -189,7 +224,19 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
}
|
||||
|
||||
private Button createAllFilesButton(Composite page) {
|
||||
return ControlFactory.createCheckBox(page, INDEX_ALL_FILES);
|
||||
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllFiles);
|
||||
}
|
||||
|
||||
private Button createAllHeadersButton(Composite page) {
|
||||
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeaders);
|
||||
}
|
||||
|
||||
private Button createAllCHeadersButton(Composite page) {
|
||||
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeadersC);
|
||||
}
|
||||
|
||||
private Button createAllCppHeadersButton(Composite page) {
|
||||
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeadersCpp);
|
||||
}
|
||||
|
||||
private Button createIncludeHeuristicsButton(Composite page) {
|
||||
|
|
|
@ -23,6 +23,12 @@ public class DialogsMessages extends NLS {
|
|||
/** @since 5.1 */
|
||||
public static String AbstractIndexerPage_heuristicIncludes;
|
||||
public static String AbstractIndexerPage_indexAllFiles;
|
||||
/** @since 5.1 */
|
||||
public static String AbstractIndexerPage_indexAllHeaders;
|
||||
/** @since 5.1 */
|
||||
public static String AbstractIndexerPage_indexAllHeadersC;
|
||||
/** @since 5.1 */
|
||||
public static String AbstractIndexerPage_indexAllHeadersCpp;
|
||||
public static String AbstractIndexerPage_indexUpFront;
|
||||
public static String AbstractIndexerPage_skipAllReferences;
|
||||
/** @since 5.1 */
|
||||
|
|
|
@ -14,7 +14,10 @@ PreferenceScopeBlock_enableProjectSettings=Enable project specific settings
|
|||
PreferenceScopeBlock_storeWithProject=Store settings with project
|
||||
PreferenceScopeBlock_preferenceLink=<a>Configure Workspace Settings...</a>
|
||||
AbstractIndexerPage_heuristicIncludes=Allow heuristic resolution of includes
|
||||
AbstractIndexerPage_indexAllFiles=Index all files (files neither built nor included, also)
|
||||
AbstractIndexerPage_indexAllFiles=Index all sources, including files that are not part of the build
|
||||
AbstractIndexerPage_indexAllHeaders=Index unused headers
|
||||
AbstractIndexerPage_indexAllHeadersC=Index unused headers as c-files
|
||||
AbstractIndexerPage_indexAllHeadersCpp=Index unused headers as c++-files
|
||||
AbstractIndexerPage_skipAllReferences=Skip all references (Call Hierarchy and Search will not work)
|
||||
AbstractIndexerPage_skipImplicitReferences=Skip implicit references (e.g. overloaded operators)
|
||||
AbstractIndexerPage_skipTypeReferences=Skip type references (Search for type references will not work)
|
||||
|
|
Loading…
Add table
Reference in a new issue