1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-09-16 07:27:08 -04:00
commit 6347d40bf6
93 changed files with 644 additions and 653 deletions

View file

@ -13,49 +13,45 @@ package org.eclipse.cdt.managedbuilder.envvar;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
/**
*
* this interface is to be implemented by the tool-integrator
* for supplying the configuration-specific environment
* This interface is to be implemented by the tool-integrator for supplying the configuration-specific
* environment.
*
* @since 3.0
*/
public interface IConfigurationEnvironmentVariableSupplier{
public interface IConfigurationEnvironmentVariableSupplier {
/**
*
* @param variableName the variable name
* @param configuration configuration
* @param variableName - the variable name.
* @param configuration - configuration.
* @param provider the instance of the environment variable provider to be used for querying the
* environment variables from within the supplier. The supplier should use this provider to obtain
* the already defined environment instead of using the "default" provider returned by the
* ManagedBuildManager.getEnvironmentVariableProvider().
* The provider passed to a supplier will ignore searching the variables for the levels
* higher than the current supplier level, will query only the lower-precedence suppliers
* for the current level and will query all suppliers for the lower levels.
* This is done to avoid infinite loops that could be caused if the supplier calls the provider
* and the provider in turn calls that supplier again. Also the supplier should not know anything
* about the environment variables defined for the higher levels.
* @return the reference to the IBuildEnvironmentVariable interface representing
* the variable of a given name
* environment variables from within the supplier. The supplier should use this provider to obtain
* the already defined environment instead of using the "default" provider returned by the
* ManagedBuildManager.getEnvironmentVariableProvider().
* The provider passed to a supplier will ignore searching the variables for the levels
* higher than the current supplier level, will query only the lower-precedence suppliers
* for the current level and will query all suppliers for the lower levels.
* This is done to avoid infinite loops that could be caused if the supplier calls the provider
* and the provider in turn calls that supplier again. Also the supplier should not know anything
* about the environment variables defined for the higher levels.
* @return The reference to the IBuildEnvironmentVariable interface representing
* the variable of a given name or {@code null} if the variable is not defined.
*/
IBuildEnvironmentVariable getVariable(String variableName,
IConfiguration configuration,
IEnvironmentVariableProvider provider);
IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider);
/**
* @param configuration configuration
* @param provider the instance of the environment variable provider to be used for querying the
* environment variables from within the supplier. The supplier should use this provider to obtain
* the already defined environment instead of using the "default" provider returned by the
* ManagedBuildManager.getEnvironmentVariableProvider().
* The provider passed to a supplier will ignore searching the variables for the levels
* higher than the current supplier level, will query only the lower-precedence suppliers
* for the current level and will query all suppliers for the lower levels.
* This is done to avoid infinite loops that could be caused if the supplier calls the provider
* and the provider in turn calls that supplier again. Also the supplier should not know anything
* about the environment variables defined for the higher levels.
* @return the array of IBuildEnvironmentVariable that represents the environment variables
* @param configuration - configuration.
* @param provider - the instance of the environment variable provider to be used for querying the
* environment variables from within the supplier. The supplier should use this provider to obtain
* the already defined environment instead of using the "default" provider returned by the
* ManagedBuildManager.getEnvironmentVariableProvider().
* The provider passed to a supplier will ignore searching the variables for the levels
* higher than the current supplier level, will query only the lower-precedence suppliers
* for the current level and will query all suppliers for the lower levels.
* This is done to avoid infinite loops that could be caused if the supplier calls the provider
* and the provider in turn calls that supplier again. Also the supplier should not know anything
* about the environment variables defined for the higher levels.
* @return The array of IBuildEnvironmentVariable that represents the environment variables.
* If the array contains any {@code null} it will be ignored.
*/
IBuildEnvironmentVariable[] getVariables (IConfiguration configuration,
IEnvironmentVariableProvider provider);
IBuildEnvironmentVariable[] getVariables(IConfiguration configuration, IEnvironmentVariableProvider provider);
}

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
@ -178,8 +179,9 @@ public class BuildConfigurationData extends CConfigurationData {
String msg = null;
if(!fCfg.isSupported()){
flags |= CConfigurationStatus.TOOLCHAIN_NOT_SUPPORTED;
msg = DataProviderMessages.getString("BuildConfigurationData.NoConfigurationSupport"); //$NON-NLS-1$
IToolChain toolChain = fCfg.getToolChain();
String tname = toolChain != null ? toolChain.getName() : ""; //$NON-NLS-1$
msg = NLS.bind(DataProviderMessages.getString("BuildConfigurationData.NoToolchainSupport"), tname); //$NON-NLS-1$
} else if (ManagedBuildManager.getExtensionConfiguration(fCfg)==null){
flags |= CConfigurationStatus.SETTINGS_INVALID;
msg = NLS.bind(DataProviderMessages.getString("BuildConfigurationData.OrphanedConfiguration"), fCfg.getId()); //$NON-NLS-1$

View file

@ -21,5 +21,5 @@ ProjectConverter.6=the project conversion failed
ProjectConverter.7=targets conversion
ProjectConverter.8=the project conversion failed due to unknown reason
ProjectConverter.9=the given project is not a valid CDT project
BuildConfigurationData.NoConfigurationSupport=The configuration support is not installed on the system
BuildConfigurationData.NoToolchainSupport=Toolchain "{0}" is not detected. Refer to "C/C++ Development User Guide", "Before you begin" about installing toolchains.
BuildConfigurationData.OrphanedConfiguration=Orphaned configuration. No base extension cfg exists for {0}

View file

@ -148,7 +148,7 @@ public class CheckerTestCase extends CodanTestCase {
public void runOnProject() {
try {
indexFiles();
} catch (CoreException e) {
} catch (Exception e) {
fail(e.getMessage());
}
runCodan();

View file

@ -127,7 +127,7 @@ public class CodanTestCase extends BaseTestCase {
return cprojects[0];
}
protected void indexFiles() throws CoreException {
protected void indexFiles() throws CoreException, InterruptedException {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
@ -138,9 +138,7 @@ public class CodanTestCase extends BaseTestCase {
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(cproject);
// wait until the indexer is done
assertTrue(CCorePlugin.getIndexManager().joinIndexer(1000 * 60, // 1 min
new NullProgressMonitor()));
return;
waitForIndexer(cproject);
}
/**

View file

@ -113,7 +113,7 @@ public class ASTCacheTests extends BaseTestCase {
assertNotNull(fTU1);
fTU2= (ITranslationUnit) CoreModel.getDefault().create(file2);
assertNotNull(fTU2);
CCorePlugin.getIndexManager().joinIndexer(5000, npm);
waitForIndexer(fProject);
fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
fIndex.acquireReadLock();
}

View file

@ -15,10 +15,8 @@ import java.io.FileNotFoundException;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
@ -48,12 +46,13 @@ import org.eclipse.cdt.core.model.IVariableDeclaration;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
public class CModelElementsTests extends TestCase {
public class CModelElementsTests extends BaseTestCase {
private ICProject fCProject;
private IFile headerFile;
private IFile includedFile;
@ -90,7 +89,7 @@ public class CModelElementsTests extends TestCase {
}
}
// make sure the index is up-to-date
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor()));
waitForIndexer(fCProject);
}

View file

@ -18,7 +18,6 @@ import java.util.List;
import junit.framework.Test;
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.ICElement;
@ -67,7 +66,7 @@ public class CModelIdentifierTests extends BaseTestCase {
e.printStackTrace();
}
}
CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor());
waitForIndexer(fCProject);
}
@Override

View file

@ -17,8 +17,6 @@ package org.eclipse.cdt.core.model.tests;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import junit.framework.TestCase;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.CModelException;
@ -27,6 +25,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@ -36,7 +35,7 @@ import org.eclipse.core.runtime.Path;
* @author bnicolle
*
*/
public abstract class IntegratedCModelTest extends TestCase {
public abstract class IntegratedCModelTest extends BaseTestCase {
private ICProject fCProject;
private IFile sourceFile;
@ -84,7 +83,7 @@ public abstract class IntegratedCModelTest extends TestCase {
e.printStackTrace();
}
}
CCorePlugin.getIndexManager().joinIndexer(2000, new NullProgressMonitor());
waitForIndexer(fCProject);
}
@Override

View file

@ -15,7 +15,6 @@ import java.io.FileNotFoundException;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
@ -48,12 +47,13 @@ import org.eclipse.cdt.core.model.IVariableDeclaration;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
public class StructuralCModelElementsTests extends TestCase {
public class StructuralCModelElementsTests extends BaseTestCase {
private ICProject fCProject;
private IFile headerFile;
private IFile includedFile;
@ -89,7 +89,7 @@ public class StructuralCModelElementsTests extends TestCase {
e.printStackTrace();
}
}
CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor());
waitForIndexer(fCProject);
}

View file

@ -6011,4 +6011,27 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testIsPOD_367993() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
// template<typename T, void (T::*M)()> class A {
// public:
// static void Delegate(void* thiz) { ((T*)thiz->*M)(); }
// };
// class B {
// public:
// void Method() {}
// };
// class C {
// public:
// template<typename T, void (T::*M)()>
// void callDelegate(A<T, M>& thiz) { A<T, M>::Delegate(&thiz); }
// };
// void Run() {
// C c;
// B b;
// A<B, &B::Method> a; /* no error this line */
// c.callDelegate(a); /* Invalid arguments 'Candidates are: void callDelegate(A<#0,#1> &)' */
// }
public void testDeductionOfNonTypeTemplateArg_372587() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
}

View file

@ -59,8 +59,7 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
boolean joined = CCorePlugin.getIndexManager().joinIndexer(20000, new NullProgressMonitor());
assertTrue("The indexing operation of the test CProject has not finished jet. This should not happen...", joined);
waitForIndexer(cproject);
IASTTranslationUnit unit = CoreModelUtil.findTranslationUnit(testFile).getAST();
final ChangeGenerator changeGenerator =

View file

@ -151,7 +151,7 @@ public class Bug246129 extends IndexTestBase {
fFalseFriendsAccepted = falseFriendDirectory.exists();
CCorePlugin.getIndexManager().reindex(fProject);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, npm()));
waitForIndexer(fProject);
fIndex = CCorePlugin.getIndexManager().getIndex(fProject);
}
}

View file

@ -50,7 +50,6 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.osgi.framework.Bundle;
@ -66,7 +65,6 @@ import org.osgi.framework.Bundle;
*/
public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
private static final boolean DEBUG= false;
private static final int INDEXER_TIMEOUT_SEC = 300;
protected ITestStrategy strategy;
public void setStrategy(ITestStrategy strategy) {
@ -339,7 +337,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
return;
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor()));
waitForIndexer(cproject);
if (DEBUG) {
System.out.println("Project PDOM: " + getName());
@ -424,10 +422,10 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor()));
waitForIndexer(cproject);
IFile cppfile= TestSourceReader.createFile(cproject.getProject(), new Path("references.c" + (cpp ? "pp" : "")), testData[1].toString());
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor()));
waitForIndexer(cproject);
if (DEBUG) {
System.out.println("Project PDOM: " + getName());
@ -537,7 +535,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
}
}
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor()));
waitForIndexer(cproject);
if (DEBUG) {
System.out.println("Project PDOM: " + getName());
@ -621,7 +619,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(cproject);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor()));
waitForIndexer(cproject);
if (DEBUG) {
System.out.println("Online: "+getName());
@ -633,7 +631,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
ast= TestSourceReader.createIndexBasedAST(index, cproject, references);
}
protected ICProject createReferencedContent() throws CoreException {
private ICProject createReferencedContent() throws Exception {
ICProject referenced = cpp ?
CProjectHelper.createCCProject("ReferencedContent" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) :
CProjectHelper.createCProject("ReferencedContent" + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
@ -643,7 +641,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
IndexerPreferences.set(referenced.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(referenced);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, new NullProgressMonitor()));
waitForIndexer(referenced);
if (DEBUG) {
System.out.println("Referenced: "+getName());

View file

@ -303,14 +303,7 @@ public class IndexBugsTests extends BaseTestCase {
}
private void waitForIndexer() throws InterruptedException {
final IIndexManager indexManager = CCorePlugin.getIndexManager();
assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()));
long waitms= 1;
while (waitms < 2000 && indexManager.isIndexerSetupPostponed(fCProject)) {
Thread.sleep(waitms);
waitms *= 2;
}
assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()));
waitForIndexer(fCProject);
}
protected Pattern[] getPattern(String qname) {
@ -424,7 +417,7 @@ public class IndexBugsTests extends BaseTestCase {
content.append("unsigned int arrayDataSize = sizeof(arrayData);\n");
int indexOfDecl = content.indexOf(varName);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()));
waitForIndexer();
IFile file= createFile(getProject(), fileName, content.toString());
// must be done in a reasonable amount of time
waitUntilFileIsIndexed(file, INDEXER_TIMEOUT_SEC * 1000);

View file

@ -94,8 +94,8 @@ public class IndexIncludeTest extends IndexTestBase {
checkContext();
}
private void waitForIndexer() {
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, npm()));
private void waitForIndexer() throws InterruptedException {
waitForIndexer(fProject);
}
private void checkHeader(boolean all) throws Exception {
@ -564,9 +564,9 @@ public class IndexIncludeTest extends IndexTestBase {
final IFile h1= TestSourceReader.createFile(fProject.getProject(), "h1.h", h1Contents.toString());
IFile h2= TestSourceReader.createFile(fProject.getProject(), "h2.h", contents[1].toString());
IFile s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", contents[2].toString());
waitUntilFileIsIndexed(fIndex, s1);
IFile s2= TestSourceReader.createFile(fProject.getProject(), "s2.cpp", contents[3].toString());
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_WAIT_TIME);
TestSourceReader.waitUntilFileIsIndexed(fIndex, s2, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, s2);
fIndex.acquireReadLock();
try {

View file

@ -28,7 +28,6 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.NullProgressMonitor;
public class IndexListenerTest extends BaseTestCase {
private ICProject fProject1;
@ -42,7 +41,8 @@ public class IndexListenerTest extends BaseTestCase {
protected void setUp() throws Exception {
fProject1 = CProjectHelper.createCCProject("testIndexListener1", null, IPDOMManager.ID_FAST_INDEXER);
fProject2 = CProjectHelper.createCCProject("testIndexListener2", null, IPDOMManager.ID_FAST_INDEXER);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(2000, new NullProgressMonitor()));
waitForIndexer(fProject1);
waitForIndexer(fProject2);
}
@Override
@ -55,7 +55,8 @@ public class IndexListenerTest extends BaseTestCase {
final Object mutex= new Object();
final int[] state= new int[] {0, 0, 0};
IIndexManager im= CCorePlugin.getIndexManager();
assertTrue(im.joinIndexer(10000, npm()));
waitForIndexer(fProject1);
waitForIndexer(fProject2);
IIndexerStateListener listener = new IIndexerStateListener() {
@Override
@ -99,7 +100,8 @@ public class IndexListenerTest extends BaseTestCase {
final List projects= new ArrayList();
IIndexManager im= CCorePlugin.getIndexManager();
assertTrue(im.joinIndexer(10000, npm()));
waitForIndexer(fProject1);
waitForIndexer(fProject2);
IIndexChangeListener listener = new IIndexChangeListener() {
@Override
public void indexChanged(IIndexChangeEvent event) {

View file

@ -98,7 +98,7 @@ public class IndexLocationTest extends BaseTestCase {
IFile file3 = TestSourceReader.createFile(cproject.getProject(), "source.cpp", content);
CCorePlugin.getIndexManager().reindex(cproject);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor()));
waitForIndexer(cproject);
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
index.acquireReadLock();
@ -166,7 +166,6 @@ public class IndexLocationTest extends BaseTestCase {
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
TestSourceReader.waitUntilFileIsIndexed(index, content.getFile("external2.h"), 4000);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor()));
index.acquireReadLock();
try {
IBinding[] bs= index.findBindings("External".toCharArray(), IndexFilter.ALL, npm());

View file

@ -76,8 +76,8 @@ public class IndexNamesTests extends BaseTestCase {
return TestSourceReader.createFile(container, new Path(fileName), contents);
}
protected void waitForIndexer() {
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, npm()));
protected void waitForIndexer() throws InterruptedException {
waitForIndexer(fCProject);
}
protected Pattern[] getPattern(String qname) {

View file

@ -238,8 +238,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
return true;
}
};
CCorePlugin.getIndexManager().joinIndexer(8000, npm()); // ensure IPM is called only once under test conditions
waitForIndexer(cproject);
setExpectedNumberOfLoggedNonOKStatusObjects(3); // foo, bar and baz have no compatible fragments available
ipm.reset(VERSION_405); ipm.startup();
@ -298,7 +297,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
}
};
CCorePlugin.getIndexManager().joinIndexer(8000, npm()); // ensure IPM is called only once under test conditions
waitForIndexer(cproject);
setExpectedNumberOfLoggedNonOKStatusObjects(1); // contentA has no compatible fragments available
ipm.reset(VERSION_502); ipm.startup();
@ -348,21 +347,21 @@ public class IndexProviderManagerTest extends IndexTestBase {
core.setProjectDescription(project, pd);
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
CCorePlugin.getIndexManager().joinIndexer(8000, npm());
waitForIndexer(cproject);
DPT.reset(DP1);
changeConfigRelations(project, ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
changeConfigRelations(cproject, ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
assertEquals(0, DPT.getCfgsTrace(DP1).size());
changeActiveConfiguration(project, cfg1);
changeActiveConfiguration(cproject, cfg1);
DPT.reset(DP1);
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
assertEquals(1, DPT.getCfgsTrace(DP1).size());
assertEquals("project.config1", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
changeActiveConfiguration(project, cfg2);
changeActiveConfiguration(cproject, cfg2);
DPT.reset(DP1);
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
@ -370,11 +369,11 @@ public class IndexProviderManagerTest extends IndexTestBase {
assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
DPT.reset(DP1);
changeConfigRelations(project, ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT);
changeConfigRelations(cproject, ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
assertEquals(0, DPT.getCfgsTrace(DP1).size());
changeActiveConfiguration(project, cfg1);
changeActiveConfiguration(cproject, cfg1);
DPT.reset(DP1);
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
@ -382,7 +381,7 @@ public class IndexProviderManagerTest extends IndexTestBase {
// should still be config2, as the change in active configuration does not matter
assertEquals("project.config2", ((ICConfigurationDescription)DPT.getCfgsTrace(DP1).get(0)).getId());
changeActiveConfiguration(project, cfg2);
changeActiveConfiguration(cproject, cfg2);
DPT.reset(DP1);
index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTION);
assertEquals(0, DPT.getProjectsTrace(DP1).size());
@ -556,18 +555,18 @@ public class IndexProviderManagerTest extends IndexTestBase {
return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data);
}
private void changeActiveConfiguration(IProject project, ICConfigurationDescription cfg) throws CoreException {
ICProjectDescription pd= core.getProjectDescription(project);
private void changeActiveConfiguration(ICProject cproject, ICConfigurationDescription cfg) throws CoreException, InterruptedException {
ICProjectDescription pd= core.getProjectDescription(cproject.getProject());
pd.setActiveConfiguration(pd.getConfigurationById(cfg.getId()));
core.setProjectDescription(project, pd);
CCorePlugin.getIndexManager().joinIndexer(8000, npm());
core.setProjectDescription(cproject.getProject(), pd);
waitForIndexer(cproject);
}
private void changeConfigRelations(IProject project, int option) throws CoreException {
ICProjectDescription pd= core.getProjectDescription(project);
private void changeConfigRelations(ICProject cproject, int option) throws CoreException, InterruptedException {
ICProjectDescription pd= core.getProjectDescription(cproject.getProject());
pd.setConfigurationRelations(option);
core.setProjectDescription(project, pd);
CCorePlugin.getIndexManager().joinIndexer(8000, npm());
core.setProjectDescription(cproject.getProject(), pd);
waitForIndexer(cproject);
}
}
@ -830,7 +829,7 @@ class MockState {
public static final String DBG_V2_ID = "dbg_v2";
public static final List states = new ArrayList(Arrays.asList(new String[]{REL_V1_ID, REL_V2_ID, DBG_V1_ID, DBG_V2_ID}));
private IProject project;
private final IProject project;
private String currentConfig;
public MockState(ICProject cproject) {

View file

@ -25,7 +25,6 @@ import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
public class IndexTestBase extends BaseTestCase {
protected static int INDEXER_WAIT_TIME= 8000;
@ -34,7 +33,7 @@ public class IndexTestBase extends BaseTestCase {
super(name);
}
protected ICProject createProject(final boolean useCpp, final String importSource) throws CoreException {
protected ICProject createProject(final boolean useCpp, final String importSource) throws CoreException, InterruptedException {
// Create the project
final ICProject[] result= new ICProject[] {null};
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
@ -52,7 +51,7 @@ public class IndexTestBase extends BaseTestCase {
}, null);
CCorePlugin.getIndexManager().setIndexerId(result[0], IPDOMManager.ID_FAST_INDEXER);
// wait until the indexer is done
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor()));
waitForIndexer(result[0]);
return result[0];
}

View file

@ -102,7 +102,8 @@ public class IndexUpdateTests extends IndexTestBase {
if (fCProject == null) {
fCProject= CProjectHelper.createCProject("indexUpdateTestsC", null, IPDOMManager.ID_FAST_INDEXER);
}
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(fCppProject);
waitForIndexer(fCProject);
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCppProject});
}
@ -113,7 +114,8 @@ public class IndexUpdateTests extends IndexTestBase {
}
IProject project= cpp ? fCppProject.getProject() : fCProject.getProject();
fHeader= TestSourceReader.createFile(project, "header.h", fContents[++fContentUsed].toString());
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()));
waitForIndexer(fCppProject);
waitForIndexer(fCProject);
}
private void updateHeader() throws Exception {
@ -122,7 +124,7 @@ public class IndexUpdateTests extends IndexTestBase {
IProject project= fHeader.getProject();
fHeader= TestSourceReader.createFile(project, "header.h",
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
TestSourceReader.waitUntilFileIsIndexed(fIndex, fHeader, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, fHeader);
}
private void setupFile(int totalFileVersions, boolean cpp) throws Exception {
@ -130,10 +132,10 @@ public class IndexUpdateTests extends IndexTestBase {
fContents= getContentsForTest(totalFileVersions);
fContentUsed= -1;
}
IProject project= cpp ? fCppProject.getProject() : fCProject.getProject();
fFile= TestSourceReader.createFile(project, "file" + (cpp ? ".cpp" : ".c"), fContents[++fContentUsed].toString());
ICProject cproject= cpp ? fCppProject : fCProject;
fFile= TestSourceReader.createFile(cproject.getProject(), "file" + (cpp ? ".cpp" : ".c"), fContents[++fContentUsed].toString());
TestSourceReader.waitUntilFileIsIndexed(fIndex, fFile, INDEXER_WAIT_TIME);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()));
waitForIndexer(cproject);
}
private void updateFile() throws Exception {
@ -141,7 +143,7 @@ public class IndexUpdateTests extends IndexTestBase {
// Indexer would not reindex the file if its contents remain the same.
fFile= TestSourceReader.createFile(fFile.getParent(), fFile.getName(),
fContents[++fContentUsed].toString() + "\n// " + fContentUsed);
TestSourceReader.waitUntilFileIsIndexed(fIndex, fFile, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, fFile);
}
@Override
@ -153,7 +155,6 @@ public class IndexUpdateTests extends IndexTestBase {
if (fHeader != null) {
fHeader.delete(true, npm());
}
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm());
super.tearDown();
}
@ -945,8 +946,7 @@ public class IndexUpdateTests extends IndexTestBase {
}
fHeader= TestSourceReader.createFile(fHeader.getParent(), fHeader.getName(), fContents[0].toString().replaceAll("globalVar", "newVar"));
TestSourceReader.waitUntilFileIsIndexed(fIndex, fHeader, INDEXER_WAIT_TIME);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm()));
waitUntilFileIsIndexed(fIndex, fHeader);
fIndex.acquireReadLock();
try {

View file

@ -48,7 +48,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
return suite(TeamSharedIndexTest.class);
}
private Collection fProjects= new LinkedList();
private final Collection fProjects= new LinkedList();
private static final IIndexManager fPDOMManager = CCorePlugin.getIndexManager();
public TeamSharedIndexTest(String name) {
@ -77,7 +77,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
fProjects.remove(prj);
}
private ICProject createProject(String name) throws CoreException {
private ICProject createProject(String name) throws CoreException, InterruptedException {
ModelJoiner mj= new ModelJoiner();
try {
ICProject project= CProjectHelper.createCCProject(name, null, IPDOMManager.ID_NO_INDEXER);
@ -88,7 +88,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
mj.join(); // in order we are sure the indexer task has been scheduled before joining the indexer
fPDOMManager.setIndexerId(project, IPDOMManager.ID_FAST_INDEXER);
assertTrue(fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm()));
waitForIndexer(project);
return project;
} finally {
mj.dispose();
@ -151,7 +151,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
checkVariable(prj, "a", 0);
checkVariable(prj, "b", 0);
checkVariable(prj, "c", 0);
@ -182,7 +182,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
fPDOMManager.export(prj, loc, 0, npm());
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
// change file
changeFile(prj);
@ -228,13 +228,13 @@ public class TeamSharedIndexTest extends IndexTestBase {
// export the project.
fPDOMManager.export(prj, loc, 0, npm());
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
// set indexer to the fake one.
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
checkVariable(prj, "a", 0);
checkVariable(prj, "b", 0);
checkVariable(prj, "c", 0);
@ -264,7 +264,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
fPDOMManager.export(prj, loc, 0, npm());
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
// add file
TestSourceReader.createFile(prj.getProject(), "d.cpp", "int d;");
@ -290,13 +290,13 @@ public class TeamSharedIndexTest extends IndexTestBase {
// export the project.
fPDOMManager.export(prj, loc, 0, npm());
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
// set indexer to the fake one.
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
checkVariable(prj, "a", 0);
checkVariable(prj, "b", 0);
checkVariable(prj, "c", 0);
@ -327,7 +327,7 @@ public class TeamSharedIndexTest extends IndexTestBase {
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
fPDOMManager.export(prj, loc, 0, npm());
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
// delete file
prj.getProject().getFile("a.cpp").delete(true, npm());
@ -352,13 +352,13 @@ public class TeamSharedIndexTest extends IndexTestBase {
// export the project.
fPDOMManager.export(prj, loc, 0, npm());
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
// set indexer to the fake one.
fPDOMManager.setIndexerId(prj, FakeIndexer.ID);
IndexerPreferences.setScope(prj.getProject(), IndexerPreferences.SCOPE_PROJECT_SHARED);
new ProjectScope(prj.getProject()).getNode(CCorePlugin.PLUGIN_ID).flush();
fPDOMManager.joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(prj);
checkVariable(prj, "a", 0);
checkVariable(prj, "b", 0);
checkVariable(prj, "c", 0);

View file

@ -55,14 +55,14 @@ public class TrilogyPerformanceTest extends IndexTestBase {
}
// you must have the Windows SDK installed and the INETSDK env var setup
public void testIndexTrilogyPerformanceTimes() throws CoreException {
public void testIndexTrilogyPerformanceTimes() throws CoreException, InterruptedException {
if(Platform.getOS().equals(Platform.OS_WIN32)) {
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(cproject);
TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"};
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()));
waitForIndexer(cproject);
System.out.println("Took: "+(System.currentTimeMillis() - start));
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
IBinding[] binding = index.findBindings(Pattern.compile("IXMLElementCollection"), false, IndexFilter.ALL, new NullProgressMonitor());

View file

@ -14,7 +14,6 @@ import java.util.Arrays;
import junit.framework.Test;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -40,7 +39,6 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
/**
@ -67,11 +65,7 @@ public class CPPClassTemplateTests extends PDOMTestBase {
IFile file= TestSourceReader.createFile(cproject.getProject(), new Path("refs.cpp"), content.toString());
}
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);
}
assertTrue(CCoreInternals.getPDOMManager().isProjectRegistered(cproject));
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(cproject);
pdom= (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
pdom.acquireReadLock();
}

View file

@ -43,11 +43,11 @@ public class ChangeConfigurationTests extends PDOMTestBase {
return suite(ChangeConfigurationTests.class);
}
private void changeConfigRelations(IProject project, int option) throws CoreException {
ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(project);
private void changeConfigRelations(ICProject project, int option) throws CoreException, InterruptedException {
ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(project.getProject());
pd.setConfigurationRelations(option);
CCorePlugin.getDefault().setProjectDescription(project, pd);
CCorePlugin.getIndexManager().joinIndexer(8000, npm());
CCorePlugin.getDefault().setProjectDescription(project.getProject(), pd);
waitForIndexer(project);
}
// Emulates ChangeConfigAction
@ -79,7 +79,7 @@ public class ChangeConfigurationTests extends PDOMTestBase {
IFile file= TestSourceReader.createFile(cProject.getProject(), new Path("test.c"), contents[0].toString());
mj.join();
mj.dispose();
changeConfigRelations(cProject.getProject(), ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
changeConfigRelations(cProject, ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
ICProjectDescription prjd = CCorePlugin.getDefault().getProjectDescriptionManager().getProjectDescription(project);
ICConfigurationDescription configuration1 = prjd.getConfigurations()[0];

View file

@ -64,7 +64,7 @@ public class FilesOnReindexTests extends PDOMTestBase {
CCoreInternals.getPDOMManager().reindex(project);
// wait until the indexer is done
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(project);
pdom.acquireReadLock();
performAssertions(file);
}

View file

@ -58,7 +58,7 @@ public class PDOMCBugsTest extends BaseTestCase {
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(cproject);
pdom= (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
super.setUp();

View file

@ -58,7 +58,7 @@ public class PDOMCPPBugsTest extends BaseTestCase {
protected void setUp() throws Exception {
super.setUp();
cproject= CProjectHelper.createCCProject("PDOMBugsTest"+System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm()));
waitForIndexer(cproject);
}
@Override
@ -122,7 +122,7 @@ public class PDOMCPPBugsTest extends BaseTestCase {
assertFalse("Project pdom ID equals export PDOM id", id2.equals(id));
pdomManager.reindex(cproject);
assertTrue(pdomManager.joinIndexer(4000, new NullProgressMonitor()));
waitForIndexer(cproject);
String id3= pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
assertNotNull("Exported pdom ID is null after project reindex", id3);
@ -217,7 +217,7 @@ public class PDOMCPPBugsTest extends BaseTestCase {
IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().reindex(cproject);
CCorePlugin.getIndexManager().joinIndexer(10000, npm());
waitForIndexer(cproject);
final PDOM pdom= (PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject);
pdom.acquireReadLock();

View file

@ -57,7 +57,7 @@ public class PDOMProviderTests extends PDOMTestBase {
{
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
waitForIndexer(cproject);
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
index.acquireReadLock();
@ -78,7 +78,7 @@ public class PDOMProviderTests extends PDOMTestBase {
final URI baseURI= new File("c:/ExternalSDK/").toURI();
final ICProject cproject2= CProjectHelper.createCCProject("bar" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n");
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
waitForIndexer(cproject2);
IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(
@ -129,7 +129,7 @@ public class PDOMProviderTests extends PDOMTestBase {
{
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
waitForIndexer(cproject);
IIndex index= CCorePlugin.getIndexManager().getIndex(cproject, A_FRAGMENT_OPTIONS);
index.acquireReadLock();
@ -149,12 +149,12 @@ public class PDOMProviderTests extends PDOMTestBase {
final ICProject cproject3= CProjectHelper.createCCProject("bar" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject3.getProject(), new Path("/source.cpp"), "namespace Y { class A {}; }\n\n");
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
waitForIndexer(cproject3);
final URI baseURI= new File("c:/ExternalSDK/").toURI();
final ICProject cproject2= CProjectHelper.createCCProject("baz" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n");
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
waitForIndexer(cproject2);
IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(
@ -247,7 +247,7 @@ public class PDOMProviderTests extends PDOMTestBase {
{
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject.getProject(), new Path("/this.h"), "class A {};\n\n");
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
waitForIndexer(cproject);
ResourceContainerRelativeLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject());
CCoreInternals.getPDOMManager().exportProjectPDOM(cproject, tempPDOM, cvr);
CProjectHelper.delete(cproject);
@ -266,7 +266,7 @@ public class PDOMProviderTests extends PDOMTestBase {
final URI baseURI= new File("c:/ExternalSDK/").toURI();
final ICProject cproject2= CProjectHelper.createCCProject("baz" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
TestSourceReader.createFile(cproject2.getProject(), new Path("/source.cpp"), "namespace X { class A {}; }\n\n");
CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm());
waitForIndexer(cproject2);
IndexProviderManager ipm= CCoreInternals.getPDOMManager().getIndexProviderManager();
ipm.addIndexProvider(new ReadOnlyPDOMProviderBridge(

View file

@ -18,13 +18,12 @@ package org.eclipse.cdt.core.tests;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import junit.framework.TestCase;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.FileManager;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@ -38,7 +37,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
/**
* @author aniefer
*/
abstract public class BaseTestFramework extends TestCase {
abstract public class BaseTestFramework extends BaseTestCase {
static protected NullProgressMonitor monitor;
static protected IWorkspace workspace;
static protected IProject project;
@ -109,13 +108,13 @@ abstract public class BaseTestFramework extends TestCase {
return;
IResource [] members = project.members();
for (int i = 0; i < members.length; i++) {
if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
for (IResource member : members) {
if (member.getName().equals(".project") || member.getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
continue;
if (members[i].getName().equals(".settings"))
if (member.getName().equals(".settings"))
continue;
try {
members[i].delete(false, monitor);
member.delete(false, monitor);
} catch (Throwable e) {
/*boo*/
}

View file

@ -27,6 +27,7 @@ import junit.framework.TestResult;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICProject;
@ -37,12 +38,15 @@ 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.core.resources.IFile;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
public class BaseTestCase extends TestCase {
protected static final int INDEXER_TIMEOUT_SEC = 10;
@ -247,7 +251,7 @@ public class BaseTestCase extends TestCase {
* is a very basic means of doing that.
*/
static protected class ModelJoiner implements IElementChangedListener {
private boolean[] changed= new boolean[1];
private final boolean[] changed= new boolean[1];
public ModelJoiner() {
CoreModel.getDefault().addElementChangedListener(this);
@ -290,6 +294,8 @@ public class BaseTestCase extends TestCase {
}
public static void waitForIndexer(ICProject project) throws InterruptedException {
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
final PDOMManager indexManager = CCoreInternals.getPDOMManager();
assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()));
long waitms= 1;
@ -297,6 +303,11 @@ public class BaseTestCase extends TestCase {
Thread.sleep(waitms);
waitms *= 2;
}
assertTrue(indexManager.isProjectRegistered(project));
assertTrue(indexManager.joinIndexer(INDEXER_TIMEOUT_SEC * 1000, npm()));
}
public static void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception {
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000);
}
}

View file

@ -327,10 +327,12 @@ public class TestSourceReader {
try {
IIndexFile[] files= index.getFiles(ILinkage.CPP_LINKAGE_ID, indexFileLocation);
if (files.length > 0 && areAllFilesNotOlderThan(files, fileTimestamp)) {
Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor()));
return;
}
files= index.getFiles(ILinkage.C_LINKAGE_ID, indexFileLocation);
if (files.length > 0 && areAllFilesNotOlderThan(files, fileTimestamp)) {
Assert.assertTrue(CCorePlugin.getIndexManager().joinIndexer(timeLeft, new NullProgressMonitor()));
return;
}
} finally {

View file

@ -65,11 +65,10 @@ public class BinaryRunner {
ICElement root = factory.getCModel();
CElementDelta cdelta = new CElementDelta(root);
cdelta.changed(cproj, ICElementDelta.F_CONTENT);
for (int j = 0; j < containers.length; ++j) {
for (IParent container : containers) {
if (fMonitor.isCanceled()) {
return;
}
IParent container = containers[j];
ICElement[] children = container.getChildren();
if (children.length > 0) {
cdelta.added((ICElement)container);
@ -171,9 +170,9 @@ public class BinaryRunner {
}
private class Visitor implements IResourceProxyVisitor {
private IProgressMonitor vMonitor;
private IProject project;
private IContentType textContentType;
private final IProgressMonitor vMonitor;
private final IProject project;
private final IContentType textContentType;
public Visitor(IProgressMonitor monitor) {
vMonitor = monitor;
@ -200,7 +199,7 @@ public class BinaryRunner {
// check against known content types
// if the file has an extension
String name = proxy.getName();
if (name.contains(".")) {
if (name.contains(".")) { //$NON-NLS-1$
IContentType contentType = CCorePlugin.getContentType(project, name);
if (contentType != null && textContentType != null) {
if (contentType.isKindOf(textContentType)) {
@ -217,8 +216,8 @@ public class BinaryRunner {
// we have a candidate
IPath path = proxy.requestFullPath();
if (path != null) {
for (int i = 0; i < entries.length; ++i) {
if (isOnOutputEntry(entries[i], path)) {
for (IOutputEntry entrie : entries) {
if (isOnOutputEntry(entrie, path)) {
IFile file = (IFile) proxy.requestResource();
CModelManager factory = CModelManager.getDefault();
IBinaryFile bin = factory.createBinaryFile(file);

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTSimpleTypeTemplateParameter extends ICPPASTTemplateParameter, IASTNameOwner {
/**
* Relation between template parameter and its name.
*/

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTTemplateParameter extends IASTNode {
public static final ICPPASTTemplateParameter[] EMPTY_TEMPLATEPARAMETER_ARRAY = new ICPPASTTemplateParameter[0];
public static final ICPPASTTemplateParameter[] EMPTY_TEMPLATEPARAMETER_ARRAY = {};
/**
* Returns whether this template parameter is a parameter pack.

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
/**
* Models the value of a template parameter or for the argument of a template-id.
@ -42,6 +43,14 @@ public interface ICPPTemplateArgument {
*/
IType getTypeValue();
/**
* If this is a non-type value (suitable for a template non-type parameters),
* the evaluation object is returned.
* For type values, <code>null</code> is returned.
* @noreference This method is not intended to be referenced by clients.
*/
ICPPEvaluation getNonTypeEvaluation();
/**
* If this is a non-type value (suitable for a template non-type parameters),
* the value is returned.

View file

@ -69,7 +69,8 @@ public interface IIndex {
*/
final int FIND_DECLARATIONS_DEFINITIONS = FIND_DECLARATIONS | FIND_DEFINITIONS;
/**
* Constant to search for all occurrences of a binding. This includes declarations, definitions and references.
* Constant to search for all occurrences of a binding. This includes declarations, definitions
* and references.
*/
final int FIND_ALL_OCCURRENCES = FIND_DECLARATIONS | FIND_DEFINITIONS | FIND_REFERENCES;
@ -95,7 +96,7 @@ public interface IIndex {
public void releaseReadLock();
/**
* @return <code>true</code> if there are threads waiting for read locks.
* @return {@code true} if there are threads waiting for read locks.
* @since 5.2
*/
public boolean hasWaitingReaders();
@ -131,13 +132,13 @@ public interface IIndex {
public long getLastWriteAccess();
/**
* Returns the file object for the given location and linkage or <code>null</code> if the file
* Returns the file object for the given location and linkage or {@code null} if the file
* was not indexed in this linkage.
* <p>
* When a header file is stored in the index in multiple variants for different sets of macro
* definitions, this method will return an arbitrary one of these variants.
* @param location an IIndexFileLocation representing the location of the file
* @return the file in the index or <code>null</code>
* @return the file in the index or {@code null}
* @throws CoreException
* @deprecated Use {@link #getFile(int, IIndexFileLocation, ISignificantMacros)} or
* {@link #getFiles(int, IIndexFileLocation)}.
@ -147,13 +148,13 @@ public interface IIndex {
/**
* Returns the file for the given location, linkage, and significant macros
* May return <code>null</code>, if no such file exists.
* May return {@code null}, if no such file exists.
*
* @param linkageID the id of the linkage in which the file has been parsed.
* @param location the IIndexFileLocation representing the location of the file
* @param macroDictionary The names and definitions of the macros used to disambiguate between
* variants of the file contents corresponding to different inclusion points.
* @return the file for the location, or <code>null</code> if the file is not present in
* @return the file for the location, or {@code null} if the file is not present in
* the index
* @throws CoreException
* @since 5.4
@ -223,13 +224,13 @@ public interface IIndex {
public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws CoreException;
/**
* Resolves the file that is included by the given include directive. May return <code>null</code>
* Resolves the file that is included by the given include directive. May return {@code null}
* in case the file cannot be found. This is usually more efficient than using:
* <pre>
* getFile(include.getIncludesLocation())
* getFiles(include.getIncludesLocation())
* </pre>
* @param include
* @return the file included or <code>null</code>.
* @return the file included or {@code null}.
* @throws CoreException
* @since 4.0
*/
@ -240,7 +241,7 @@ public interface IIndex {
*
* @param name a name, that has to be matched by the macros.
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be <code>null</code>.
* @param monitor a monitor to report progress, may be {@code null}.
* @return an array of macros matching the name.
* @throws CoreException
* @since 4.0.2
@ -252,7 +253,7 @@ public interface IIndex {
*
* @param prefix the prefix with which all returned macros must start
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor for progress reporting and cancellation, may be <code>null</code>
* @param monitor a monitor for progress reporting and cancellation, may be {@code null}
* @return an array of bindings with the prefix
* @throws CoreException
* @since 4.0.2
@ -261,16 +262,16 @@ public interface IIndex {
/**
* Searches for the binding of a name. The name may be originated by
* an AST or by a search in an index. May return <code>null</code>.
* an AST or by a search in an index. May return {@code null}.
* @param name a name to find the binding for
* @return the binding or <code>null</code>
* @return the binding or {@code null}
* @throws CoreException
*/
public IIndexBinding findBinding(IName name) throws CoreException;
/**
* Searches for all bindings with simple names that match the given pattern. In case a binding exists
* in multiple projects, no duplicate bindings are returned.
* Searches for all bindings with simple names that match the given pattern. In case a binding
* exists in multiple projects, no duplicate bindings are returned.
* This is fully equivalent to
* <pre>
* findBindings(new Pattern[]{pattern}, isFullyQualified, filter, monitor);
@ -278,20 +279,23 @@ public interface IIndex {
* @param pattern the pattern the name of the binding has to match.
* @param isFullyQualified if <code>true</code>, binding must be in global scope
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be <code>null</code>.
* @param monitor a monitor to report progress, may be {@code null}.
* @return an array of bindings matching the pattern
* @throws CoreException
*/
public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
/**
* Searches for all bindings with qualified names that seen as an array of simple names match the given array
* of patterns. In case a binding exists in multiple projects, no duplicate bindings are returned.
* You can search with an array of patterns that specifies a partial qualification only.
* @param patterns an array of patterns the names of the qualified name of the bindings have to match.
* @param isFullyQualified if <code>true</code>, the array of pattern specifies the fully qualified name
* Searches for all bindings with qualified names that seen as an array of simple names match
* the given array of patterns. In case a binding exists in multiple projects, no duplicate
* bindings are returned. You can search with an array of patterns that specifies a partial
* qualification only.
* @param patterns an array of patterns the names of the qualified name of the bindings
* have to match.
* @param isFullyQualified if <code>true</code>, the array of pattern specifies the fully
* qualified name
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be <code>null</code>.
* @param monitor a monitor to report progress, may be {@code null}.
* @return an array of bindings matching the pattern
* @throws CoreException
*/
@ -299,23 +303,25 @@ public interface IIndex {
/**
* Searches for all macro containers (one for macros with the same name) with names that
* match the given pattern. In case a binding exists in multiple projects, no duplicate bindings
* are returned.
* match the given pattern. In case a binding exists in multiple projects, no duplicate
* bindings are returned.
* @param pattern a pattern the name of the bindings have to match.
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be <code>null</code>
* @param monitor a monitor to report progress, may be {@code null}
* @return an array of bindings matching the pattern
* @throws CoreException
*/
IIndexBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
/**
* Searches for all bindings in global scope with a given name. In case a binding exists in multiple projects, no duplicate bindings are returned.
* This method makes use of the BTree and is faster than the methods using patterns.
* Searches for all bindings in global scope with a given name. In case a binding exists in
* multiple projects, no duplicate bindings are returned. This method makes use of the BTree
* and is faster than the methods using patterns.
* <p>
* @param names an array of names, which has to be matched by the qualified name of the bindings.
* @param names an array of names, which has to be matched by the qualified name of
* the bindings.
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be <code>null</code>.
* @param monitor a monitor to report progress, may be {@code null}.
* @return an array of bindings matching the pattern
* @throws CoreException
*/
@ -332,7 +338,7 @@ public interface IIndex {
* </pre>
* @param name a name, which has to be matched by the qualified name of the bindings.
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be <code>null</code>.
* @param monitor a monitor to report progress, may be {@code null}.
* @return an array of bindings matching the pattern
* @throws CoreException
*/
@ -346,7 +352,7 @@ public interface IIndex {
* @param name a name, which has to be matched by the qualified name of the bindings.
* @param fileScopeOnly if true, only bindings at file scope are returned
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be <code>null</code>.
* @param monitor a monitor to report progress, may be {@code null}.
* @return an array of bindings matching the pattern
* @throws CoreException
*/
@ -357,7 +363,7 @@ public interface IIndex {
* @param prefix the prefix with which all returned bindings must start
* @param fileScopeOnly if true, only bindings at file scope are returned
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor for progress reporting and cancellation, may be <code>null</code>
* @param monitor a monitor for progress reporting and cancellation, may be {@code null}
* @return an array of bindings with the prefix
* @throws CoreException
*/
@ -444,7 +450,7 @@ public interface IIndex {
public IIndexFile[] getDefectiveFiles() throws CoreException;
/**
* Returns an array of files containg unresolved includes.
* Returns an array of files containing unresolved includes.
* @noreference This method is not intended to be referenced by clients.
* @since 5.4
*/

View file

@ -370,7 +370,7 @@ public class Value implements IValue {
* Tests whether the value depends on a template parameter.
*/
public static boolean isDependentValue(IValue nonTypeValue) {
return nonTypeValue.getEvaluation() != null;
return nonTypeValue != null && nonTypeValue.getEvaluation() != null;
}
/**

View file

@ -35,7 +35,6 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArraySet;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
/**
* For example in the constructor definition <br>

View file

@ -312,7 +312,7 @@ public class CPPASTFunctionCallExpression extends ASTNode
IBinding b= name.resolvePreBinding();
if (b instanceof IType) {
ICPPEvaluation[] args= new ICPPEvaluation[fArguments.length];
for (int i = 1; i < args.length; i++) {
for (int i = 0; i < args.length; i++) {
args[i]= ((ICPPASTExpression) fArguments[i]).getEvaluation();
}
return new EvalTypeId((IType) b, args);

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
@ -27,9 +28,15 @@ import org.eclipse.core.runtime.Assert;
public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
private final ICPPEvaluation fEvaluation;
public CPPTemplateNonTypeArgument(ICPPEvaluation evaluation) {
public CPPTemplateNonTypeArgument(ICPPEvaluation evaluation, IASTNode point) {
Assert.isNotNull(evaluation);
fEvaluation= evaluation;
if (evaluation instanceof EvalFixed || point == null ||
evaluation.isTypeDependent() || evaluation.isValueDependent()) {
fEvaluation= evaluation;
} else {
fEvaluation= new EvalFixed(evaluation.getTypeOrFunctionSet(point),
evaluation.getValueCategory(point), evaluation.getValue(point));
}
}
public CPPTemplateNonTypeArgument(IValue value, IType type) {
@ -51,6 +58,11 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
return null;
}
@Override
public ICPPEvaluation getNonTypeEvaluation() {
return fEvaluation;
}
@Override
public IValue getNonTypeValue() {
return fEvaluation.getValue(null);
@ -79,7 +91,7 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
} else {
evaluation = new EvalTypeId(t, fEvaluation);
}
return new CPPTemplateNonTypeArgument(evaluation);
return new CPPTemplateNonTypeArgument(evaluation, null);
}
}
return null;
@ -94,8 +106,4 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
public String toString() {
return getNonTypeValue().toString();
}
public ICPPEvaluation getEvaluation() {
return fEvaluation;
}
}

View file

@ -43,6 +43,11 @@ public class CPPTemplateTypeArgument implements ICPPTemplateArgument {
return fType;
}
@Override
public ICPPEvaluation getNonTypeEvaluation() {
return null;
}
@Override
public IValue getNonTypeValue() {
return null;

View file

@ -27,7 +27,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.core.runtime.CoreException;
@ -112,9 +111,9 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
@Override
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
if (arg instanceof CPPTemplateNonTypeArgument) {
if (arg.isNonTypeValue()) {
putByte(VALUE);
((CPPTemplateNonTypeArgument) arg).getEvaluation().marshal(this, true);
arg.getNonTypeEvaluation().marshal(this, true);
} else {
marshalType(arg.getTypeValue());
}

View file

@ -29,7 +29,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
@ -44,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -56,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
@ -1074,13 +1075,11 @@ public class CPPTemplates {
if (arg == null)
return null;
if (arg.isNonTypeValue()) {
final IValue origValue= arg.getNonTypeValue();
final IType origType= arg.getTypeOfNonTypeValue();
final IValue instValue= instantiateValue(origValue, tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point);
final IType instType= instantiateType(origType, tpMap, packOffset, within, point);
if (origType == instType && origValue == instValue)
final ICPPEvaluation eval = arg.getNonTypeEvaluation();
final ICPPEvaluation newEval= eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point);
if (eval == newEval)
return arg;
return new CPPTemplateNonTypeArgument(instValue, instType);
return new CPPTemplateNonTypeArgument(newEval, point);
}
final IType orig= arg.getTypeValue();
@ -1676,11 +1675,9 @@ public class CPPTemplates {
IASTNode arg= args[i];
if (arg instanceof IASTTypeId) {
result[i]= new CPPTemplateTypeArgument(CPPVisitor.createType((IASTTypeId) arg));
} else if (arg instanceof IASTExpression) {
IASTExpression expr= (IASTExpression) arg;
IType type= expr.getExpressionType();
IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH);
result[i]= new CPPTemplateNonTypeArgument(value, type);
} else if (arg instanceof ICPPASTExpression) {
ICPPASTExpression expr= (ICPPASTExpression) arg;
result[i]= new CPPTemplateNonTypeArgument(expr.getEvaluation(), expr);
} else {
throw new IllegalArgumentException("Unexpected type: " + arg.getClass().getName()); //$NON-NLS-1$
}
@ -2190,11 +2187,11 @@ public class CPPTemplates {
if (map != null && pType != null) {
pType= instantiateType(pType, map, -1, null, point);
}
if (argType instanceof ICPPUnknownType || argType instanceof ISemanticProblem || isNonTypeArgumentConvertible(pType, argType, point)) {
if (argType instanceof ICPPUnknownType) {
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType);
}
return null;
return convertNonTypeTemplateArgument(pType, arg, point);
} catch (DOMException e) {
return null;
}
@ -2257,22 +2254,45 @@ public class CPPTemplates {
}
/**
* Returns whether the template argument <code>arg</code> can be converted to
* the same type as <code>paramType</code> using the rules specified in 14.3.2.5.
* @param paramType
* @param arg
* @return
* Converts the template argument <code>arg</code> to match the parameter type
* <code>paramType</code> or returns <code>null</code>, if this violates the rules
* specified in 14.3.2 - 5.
* @throws DOMException
*/
private static boolean isNonTypeArgumentConvertible(IType paramType, IType arg, IASTNode point) throws DOMException {
private static ICPPTemplateArgument convertNonTypeTemplateArgument(final IType paramType, ICPPTemplateArgument arg, IASTNode point) throws DOMException {
//14.1s8 function to pointer and array to pointer conversions
IType a= arg.getTypeOfNonTypeValue();
IType p;
if (paramType instanceof IFunctionType) {
paramType = new CPPPointerType(paramType);
p = new CPPPointerType(paramType);
} else if (paramType instanceof IArrayType) {
paramType = new CPPPointerType(((IArrayType) paramType).getType());
p = new CPPPointerType(((IArrayType) paramType).getType());
} else {
p= paramType;
if (p.isSameType(a))
return arg;
}
Cost cost = Conversions.checkImplicitConversionSequence(paramType, arg, LVALUE, UDCMode.FORBIDDEN, Context.ORDINARY, point);
return cost != null && cost.converts();
if (a instanceof FunctionSetType) {
if (p instanceof IPointerType) {
p= ((IPointerType) p).getType();
}
if (p instanceof IFunctionType) {
final CPPFunctionSet functionSet = ((FunctionSetType) a).getFunctionSet();
for (ICPPFunction f : functionSet.getBindings()) {
if (p.isSameType(f.getType())) {
functionSet.applySelectedFunction(f);
return new CPPTemplateNonTypeArgument(new EvalBinding(f, null), point);
}
}
}
return null;
}
Cost cost = Conversions.checkImplicitConversionSequence(p, a, LVALUE, UDCMode.FORBIDDEN, Context.ORDINARY, point);
if (cost == null || !cost.converts())
return null;
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), paramType);
}
static boolean argsAreTrivial(ICPPTemplateParameter[] pars, ICPPTemplateArgument[] args) {
@ -2320,7 +2340,7 @@ public class CPPTemplates {
if (arg.isTypeValue())
return isDependentType(arg.getTypeValue());
return Value.isDependentValue(arg.getNonTypeValue());
return arg.getNonTypeEvaluation().isValueDependent();
}
public static boolean containsDependentType(List<IType> ts) {

View file

@ -223,9 +223,8 @@ public class EvalBinding extends CPPEvaluation {
return new EvalFixed(type, ValueCategory.PRVALUE, value);
} else if (fBinding instanceof ICPPTemplateNonTypeParameter) {
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) fBinding);
if (argument != null) {
IValue value = argument.getNonTypeValue();
return new EvalFixed(null, ValueCategory.PRVALUE, value);
if (argument != null && argument.isNonTypeValue()) {
return argument.getNonTypeEvaluation();
}
// TODO(sprigogin): Do we need something similar for pack expansion?
} else if (fBinding instanceof ICPPUnknownBinding) {

View file

@ -238,6 +238,9 @@ public class EvalUnary extends CPPEvaluation {
}
IValue val = fArgument.getValue(point);
if (val == null)
return Value.UNKNOWN;
Long num = val.numericalValue();
if (num != null) {
return Value.evaluateUnaryExpression(fOperator, num);

View file

@ -437,6 +437,9 @@ public class SemanticUtil {
}
public static IType mapToAST(IType type, IASTNode node) {
if (node == null)
return type;
if (type instanceof IFunctionType) {
final ICPPFunctionType ft = (ICPPFunctionType) type;
final IType r = ft.getReturnType();

View file

@ -54,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.internal.core.dom.parser.Value;
@ -185,6 +186,20 @@ public class TemplateArgumentDeduction {
if (!map.addDeducedArgs(deduct.fDeducedArgs))
return false;
// 14.8.2.5 - 17
for (ICPPTemplateParameter tpar : tmplPars) {
if (tpar instanceof ICPPTemplateNonTypeParameter) {
ICPPTemplateArgument arg = deduct.fDeducedArgs.getArgument(tpar);
if (arg != null) {
IType type1 = ((ICPPTemplateNonTypeParameter) tpar).getType();
type1= CPPTemplates.instantiateType(type1, map, -1, null, point);
IType type2= arg.getTypeOfNonTypeValue();
if (!type1.isSameType(type2))
return false;
}
}
}
return verifyDeduction(tmplPars, map, true, point);
} catch (DOMException e) {
}
@ -649,8 +664,6 @@ public class TemplateArgumentDeduction {
if (Value.referencesTemplateParameter(tval)) {
int parId= Value.isTemplateParameter(tval);
if (parId >= 0) {
if (!p.getTypeOfNonTypeValue().isSameType(a.getTypeOfNonTypeValue()))
return false;
ICPPTemplateArgument old= fDeducedArgs.getArgument(parId, fPackOffset);
if (old == null) {
return deduce(parId, a);

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.index;
import org.eclipse.cdt.core.index.IIndexInclude;
@ -19,7 +18,7 @@ public interface IIndexFragmentInclude extends IIndexInclude {
* Empty array constant
* @since 4.0.1
*/
IIndexFragmentInclude[] EMPTY_FRAGMENT_INCLUDES_ARRAY = new IIndexFragmentInclude[0];
IIndexFragmentInclude[] EMPTY_FRAGMENT_INCLUDES_ARRAY = {};
/**
* Returns the fragment that owns this include.

View file

@ -93,17 +93,19 @@ public class TemplateInstanceUtil {
}
static ICPPTemplateArgument convert(ICompositesFactory cf, ICPPTemplateArgument arg) throws DOMException {
if (arg instanceof CPPTemplateTypeArgument) {
if (arg == null)
return null;
if (arg.isTypeValue()) {
final IType typeValue = arg.getTypeValue();
IType t= cf.getCompositeType(typeValue);
if (t != typeValue) {
return new CPPTemplateTypeArgument(t);
}
} else if (arg instanceof CPPTemplateNonTypeArgument) {
ICPPEvaluation eval = ((CPPTemplateNonTypeArgument) arg).getEvaluation();
} else {
ICPPEvaluation eval = arg.getNonTypeEvaluation();
ICPPEvaluation eval2 = ((CPPCompositesFactory) cf).getCompositeEvaluation(eval);
if (eval2 != eval) {
return new CPPTemplateNonTypeArgument(eval2);
return new CPPTemplateNonTypeArgument(eval2, null);
}
}
return arg;

View file

@ -222,10 +222,11 @@ public class PDOM extends PlatformObject implements IPDOM {
* 130.0 - Dependent expressions, bug 299911.
* 131.0 - Dependent expressions part 2, bug 299911.
* 132.0 - Explicit virtual overrides, bug 380623.
* 133.0 - Storing template arguments via direct marshalling, bug 299911.
*/
private static final int MIN_SUPPORTED_VERSION= version(132, 0);
private static final int MAX_SUPPORTED_VERSION= version(132, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(132, 0);
private static final int MIN_SUPPORTED_VERSION= version(133, 0);
private static final int MAX_SUPPORTED_VERSION= version(133, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(133, 0);
private static int version(int major, int minor) {
return (major << 16) + minor;

View file

@ -211,6 +211,9 @@ public class PDOMManager implements IWritableIndexManager, IListener {
public Job startup() {
fInShutDown= false;
// Set path canonicalization strategy early on to avoid a race condition.
updatePathCanonicalizationStrategy();
Job postStartupJob= new Job(CCorePlugin.getResourceString("CCorePlugin.startupJob")) { //$NON-NLS-1$
@Override
protected IStatus run(IProgressMonitor monitor) {
@ -230,9 +233,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
* Called from a job after plugin start.
*/
protected void postStartup() {
// the model listener is attached outside of the job in
// order to avoid a race condition where its not noticed
// that new projects are being created
// The model listener is attached outside of the job in order to avoid a race condition
// where it is not noticed that new projects are being created.
InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).addPreferenceChangeListener(fPreferenceChangeListener);
Job.getJobManager().addJobChangeListener(fJobChangeListener);
adjustCacheSize();

View file

@ -77,6 +77,7 @@ public class Database {
public static final int PTR_SIZE = 4; // size of a pointer in the database in bytes
public static final int TYPE_SIZE = 2+PTR_SIZE; // size of a type in the database in bytes
public static final int VALUE_SIZE = TYPE_SIZE; // size of a value in the database in bytes
public static final int ARGUMENT_SIZE = TYPE_SIZE; // size of a template argument in the database in bytes
public static final long MAX_DB_SIZE= ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS));

View file

@ -189,9 +189,9 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
if (arg instanceof CPPTemplateNonTypeArgument) {
if (arg.isNonTypeValue()) {
putByte(VALUE);
((CPPTemplateNonTypeArgument) arg).getEvaluation().marshal(this, true);
arg.getNonTypeEvaluation().marshal(this, true);
} else {
marshalType(arg.getTypeValue());
}
@ -201,7 +201,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException {
int firstByte= getByte();
if (firstByte == VALUE) {
return new CPPTemplateNonTypeArgument((ICPPEvaluation) unmarshalEvaluation());
return new CPPTemplateNonTypeArgument((ICPPEvaluation) unmarshalEvaluation(), null);
} else {
fPos--;
return new CPPTemplateTypeArgument(unmarshalType());

View file

@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
import org.eclipse.cdt.core.index.IIndexLinkage;
import org.eclipse.cdt.core.parser.util.CharArrayMap;
@ -496,6 +497,68 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
return new TypeMarshalBuffer(this, data).unmarshalType();
}
public void storeTemplateArgument(long offset, ICPPTemplateArgument arg) throws CoreException {
final Database db= getDB();
deleteArgument(db, offset);
storeArgument(db, offset, arg);
}
private void storeArgument(Database db, long offset, ICPPTemplateArgument arg) throws CoreException {
if (arg != null) {
TypeMarshalBuffer bc= new TypeMarshalBuffer(this);
bc.marshalTemplateArgument(arg);
int len= bc.getPosition();
if (len > 0) {
if (len <= Database.ARGUMENT_SIZE) {
db.putBytes(offset, bc.getBuffer(), len);
} else if (len <= Database.MAX_MALLOC_SIZE-2){
long ptr= db.malloc(len+2);
db.putShort(ptr, (short) len);
db.putBytes(ptr+2, bc.getBuffer(), len);
db.putByte(offset, TypeMarshalBuffer.INDIRECT_TYPE);
db.putRecPtr(offset+2, ptr);
}
}
}
}
private void deleteArgument(Database db, long offset) throws CoreException {
byte firstByte= db.getByte(offset);
if (firstByte == TypeMarshalBuffer.INDIRECT_TYPE) {
long ptr= db.getRecPtr(offset+2);
clearArgument(db, offset);
db.free(ptr);
} else {
clearArgument(db, offset);
}
}
private void clearArgument(Database db, long offset) throws CoreException {
db.clearBytes(offset, Database.ARGUMENT_SIZE);
}
public ICPPTemplateArgument loadTemplateArgument(long offset) throws CoreException {
final Database db= getDB();
final byte firstByte= db.getByte(offset);
byte[] data= null;
switch(firstByte) {
case TypeMarshalBuffer.INDIRECT_TYPE:
long ptr= db.getRecPtr(offset+2);
int len= db.getShort(ptr) & 0xffff;
data= new byte[len];
db.getBytes(ptr+2, data);
break;
case TypeMarshalBuffer.UNSTORABLE_TYPE:
case TypeMarshalBuffer.NULL_TYPE:
return null;
default:
data= new byte[Database.TYPE_SIZE];
db.getBytes(offset, data);
break;
}
return new TypeMarshalBuffer(this, data).unmarshalTemplateArgument();
}
public void storeValue(long offset, IValue type) throws CoreException {
final Database db= getDB();
deleteValue(db, offset);

View file

@ -11,11 +11,8 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
@ -27,8 +24,7 @@ import org.eclipse.core.runtime.CoreException;
* Collects methods to store an argument list in the database
*/
public class PDOMCPPArgumentList {
private static final int VALUE_OFFSET= Database.TYPE_SIZE;
private static final int NODE_SIZE = VALUE_OFFSET + Database.VALUE_SIZE;
private static final int NODE_SIZE = Database.ARGUMENT_SIZE;
/**
* Stores the given template arguments in the database.
@ -45,13 +41,7 @@ public class PDOMCPPArgumentList {
p += 2;
for (int i= 0; i < len; i++, p += NODE_SIZE) {
final ICPPTemplateArgument arg = templateArguments[i];
final boolean isNonType= arg.isNonTypeValue();
if (isNonType) {
linkage.storeType(p, arg.getTypeOfNonTypeValue());
linkage.storeValue(p + VALUE_OFFSET, arg.getNonTypeValue());
} else {
linkage.storeType(p, arg.getTypeValue());
}
linkage.storeTemplateArgument(p, arg);
}
return block;
}
@ -67,8 +57,7 @@ public class PDOMCPPArgumentList {
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE - 2) / NODE_SIZE);
long p= record + 2;
for (int i= 0; i < len; i++) {
linkage.storeType(p, null);
linkage.storeValue(p + VALUE_OFFSET, null);
linkage.storeTemplateArgument(p, null);
p+= NODE_SIZE;
}
db.free(record);
@ -90,16 +79,11 @@ public class PDOMCPPArgumentList {
rec += 2;
ICPPTemplateArgument[] result= new ICPPTemplateArgument[len];
for (int i= 0; i < len; i++) {
IType type= linkage.loadType(rec);
if (type == null) {
type= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
}
IValue val= linkage.loadValue(rec + VALUE_OFFSET);
if (val != null) {
result[i]= new CPPTemplateNonTypeArgument(val, type);
} else {
result[i]= new CPPTemplateTypeArgument(type);
ICPPTemplateArgument arg= linkage.loadTemplateArgument(rec);
if (arg == null) {
arg= new CPPTemplateTypeArgument(new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED));
}
result[i]= arg;
rec += NODE_SIZE;
}
return result;

View file

@ -39,9 +39,9 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding
implements IPDOMMemberOwner, ICPPTemplateNonTypeParameter, IPDOMCPPTemplateParameter {
private static final int TYPE_OFFSET= PDOMCPPBinding.RECORD_SIZE;
private static final int PARAMETERID= TYPE_OFFSET + Database.TYPE_SIZE;
private static final int DEFAULTVAL= PARAMETERID + Database.VALUE_SIZE;
private static final int DEFAULTVAL= PARAMETERID + 4;
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = DEFAULTVAL + Database.PTR_SIZE;
protected static final int RECORD_SIZE = DEFAULTVAL + Database.VALUE_SIZE;
private int fCachedParamID= -1;
private volatile IType fType;

View file

@ -11,12 +11,9 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -28,9 +25,7 @@ import org.eclipse.core.runtime.CoreException;
* Collects methods to store an argument list in the database
*/
public class PDOMCPPTemplateParameterMap {
private static final int TYPE_OFFSET= 0;
private static final int VALUE_OFFSET= TYPE_OFFSET + Database.TYPE_SIZE;
private static final int NODE_SIZE = VALUE_OFFSET + Database.VALUE_SIZE;
private static final int NODE_SIZE = Database.ARGUMENT_SIZE;
/**
* Stores the given template parameter map in the database.
@ -78,12 +73,7 @@ public class PDOMCPPTemplateParameterMap {
private static void storeArgument(final Database db, final PDOMLinkage linkage, long p,
final ICPPTemplateArgument arg) throws CoreException {
if (arg.isNonTypeValue()) {
linkage.storeType(p + TYPE_OFFSET, arg.getTypeOfNonTypeValue());
linkage.storeValue(p + VALUE_OFFSET, arg.getNonTypeValue());
} else {
linkage.storeType(p + TYPE_OFFSET, arg.getTypeValue());
}
linkage.storeTemplateArgument(p, arg);
}
/**
@ -102,8 +92,7 @@ public class PDOMCPPTemplateParameterMap {
if (packSize == -1)
packSize= 1;
for (int j = 0; j < packSize; j++) {
linkage.storeType(p + TYPE_OFFSET, null);
linkage.storeValue(p + VALUE_OFFSET, null);
linkage.storeTemplateArgument(p, null);
p+= NODE_SIZE;
}
}
@ -143,16 +132,9 @@ public class PDOMCPPTemplateParameterMap {
private static ICPPTemplateArgument readArgument(long rec, final PDOMLinkage linkage, final Database db)
throws CoreException {
IType type= linkage.loadType(rec + TYPE_OFFSET);
if (type == null) {
type= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
}
IValue val= linkage.loadValue(rec + VALUE_OFFSET);
ICPPTemplateArgument arg;
if (val != null) {
arg= new CPPTemplateNonTypeArgument(val, type);
} else {
arg= new CPPTemplateTypeArgument(type);
ICPPTemplateArgument arg = linkage.loadTemplateArgument(rec);
if (arg == null) {
arg= new CPPTemplateTypeArgument(new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED));
}
return arg;
}

View file

@ -20,14 +20,14 @@ import java.io.IOException;
* symbolic links is undesirable. The default is to use File.getCanonicalPath.
*/
public abstract class PathCanonicalizationStrategy {
private static PathCanonicalizationStrategy instance;
private static volatile PathCanonicalizationStrategy instance;
static {
setPathCanonicalization(true);
}
public static String getCanonicalPath(File file) {
return getInstance().getCanonicalPathInternal(file);
return instance.getCanonicalPathInternal(file);
}
/**
@ -38,7 +38,7 @@ public abstract class PathCanonicalizationStrategy {
* @param canonicalize <code>true</code> to use File.getCanonicalPath, <code>false</code>
* to use File.getAbsolutePath.
*/
public static synchronized void setPathCanonicalization(boolean canonicalize) {
public static void setPathCanonicalization(boolean canonicalize) {
if (canonicalize) {
instance = new PathCanonicalizationStrategy() {
@Override
@ -60,9 +60,5 @@ public abstract class PathCanonicalizationStrategy {
}
}
private static synchronized PathCanonicalizationStrategy getInstance() {
return instance;
}
protected abstract String getCanonicalPathInternal(File file);
}

View file

@ -53,8 +53,8 @@ public class UNCPathConverterImpl extends UNCPathConverter {
for (IConfigurationElement ce : ext.getConfigurationElements()) {
if (ce.getAttribute(CLASS_ATTRIBUTE) != null) {
try {
UNCPathConverter converter = (UNCPathConverter) ce
.createExecutableExtension(CLASS_ATTRIBUTE);
UNCPathConverter converter =
(UNCPathConverter) ce.createExecutableExtension(CLASS_ATTRIBUTE);
list.add(converter);
} catch (Exception e) {
CCorePlugin.log(e);

View file

@ -19,16 +19,16 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
* Base class for the UNC path conversion extension point. UNC paths are used to represent remote include
* locations, and this class is used to translate between UNC, IPath and URI representations. By default,
* paths are translated into the equivalent local file version to preserve existing behavior, but by providing
* an appropriate extension, these paths can be mapped into locations on a remote system.
* Base class for the UNC path conversion extension point. UNC paths are used to represent remote
* include locations, and this class is used to translate between UNC, IPath and URI
* representations. By default, paths are translated into the equivalent local file version to
* preserve existing behavior, but by providing an appropriate extension, these paths can be mapped
* into locations on a remote system.
*
* May be subclassed by clients.
* @since 5.3
*/
public abstract class UNCPathConverter {
/**
* Get the instance of the class that combines the registered converters.
* @return instance of UNCPathConverter
@ -37,7 +37,6 @@ public abstract class UNCPathConverter {
return UNCPathConverterImpl.getInstance();
}
/**
* Test if the string path is in UNC format.
*
@ -56,7 +55,6 @@ public abstract class UNCPathConverter {
return false;
}
/**
* Convert a URI to an IPath.
* Resolves to local path if possible, including using EFS where required.

View file

@ -43,13 +43,9 @@ import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.WorkbenchPartReference;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
@ -112,43 +108,6 @@ public class BaseUITestCase extends BaseTestCase {
return TestSourceReader.createIndexBasedAST(index, project, file);
}
protected void waitForIndexer(IIndex index, IFile file, int maxmillis) throws Exception {
boolean firstTime= true;
long endTime= System.currentTimeMillis() + maxmillis;
long sleep= 1;
while (firstTime || System.currentTimeMillis() < endTime) {
if (!firstTime) {
Thread.sleep(sleep);
sleep= Math.min(250, sleep * 2);
}
firstTime= false;
if (CCorePlugin.getIndexManager().isIndexerSetupPostponed(CoreModel.getDefault().create(file.getProject())))
continue;
try {
index.acquireReadLock();
try {
IIndexFile[] indexFiles= index.getFiles(IndexLocationFactory.getWorkspaceIFL(file));
for (IIndexFile indexFile : indexFiles) {
if (indexFile != null && indexFile.getTimestamp() >= file.getLocalTimeStamp()) {
return;
}
}
} finally {
index.releaseReadLock();
int time= (int) (endTime - System.currentTimeMillis());
if (time > 0) {
CCorePlugin.getIndexManager().joinIndexer(time, npm());
}
}
}
catch (InterruptedException e) {
// index.acquireReadLock() can be interrupted
}
}
throw new Exception("Indexer did not complete in time!");
}
protected void runEventQueue(int time) {
final long endTime= System.currentTimeMillis() + time;
while (true) {

View file

@ -59,7 +59,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestFunctions(String filename) throws IOException, Exception, PartInitException {
String content = readTaggedComment("testFunctions");
IFile file= createFile(getProject(), filename, content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("proto"), 5);
@ -103,7 +103,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestVariables(String filename) throws Exception {
String content = readTaggedComment("testVariables");
IFile file= createFile(getProject(), filename, content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("extern_var"), 0);
@ -158,7 +158,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
private void doTestEnumerator(String filename, String contentTag) throws Exception {
String content = readTaggedComment(contentTag);
IFile file= createFile(getProject(), filename, content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("enumerator"), 0);
@ -213,7 +213,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
public void testStructMembersC() throws Exception {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), "struct_member.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem1"), 0);
@ -259,7 +259,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
public void testStructMembersCpp() throws Exception {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), "struct_member.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem1"), 0);
@ -305,7 +305,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
public void testAnonymousStructMembersC_156671() throws Exception {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), "anon_struct_member.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem3"), 0);
@ -333,7 +333,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
public void testAnonymousStructMembersCpp_156671() throws Exception {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), "anon_struct_member.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem3"), 0);
@ -395,7 +395,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
public void testUnionMembersC() throws Exception {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), "union_member.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem1"), 0);
@ -441,7 +441,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
public void testUnionMembersCpp() throws Exception {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), "union_member.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem1"), 0);
@ -487,7 +487,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
public void testAnonymousUnionMembersC_156671() throws Exception {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), "anon_union_member.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem3"), 0);
@ -515,7 +515,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
public void testAnonymousUnionMembersCpp_156671() throws Exception {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), "anon_union_member.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem3"), 0);
@ -556,8 +556,8 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content1= content2 + sbs[1].toString();
IFile file1= createFile(getProject(), "staticFunc1.c", content1);
IFile file2= createFile(getProject(), "staticFunc2.c", content2);
waitForIndexer(fIndex, file1, INDEXER_WAIT_TIME);
waitForIndexer(fIndex, file2, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file1);
waitUntilFileIsIndexed(fIndex, file2);
TreeItem i1, i2, i3, i4, i5, i6;
Tree tree;
@ -625,8 +625,8 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content1= content2 + sbs[1].toString();
IFile file1= createFile(getProject(), "staticFunc1.cpp", content1);
IFile file2= createFile(getProject(), "staticFunc2.cpp", content2);
waitForIndexer(fIndex, file1, INDEXER_WAIT_TIME);
waitForIndexer(fIndex, file2, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file1);
waitUntilFileIsIndexed(fIndex, file2);
TreeItem i0, i1, i2, i3, i4, i5, i6;
Tree tree;
@ -701,7 +701,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
try {
String content = readTaggedComment("testFunctionsWithParams");
IFile file= createFile(getProject(), filename, content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("proto"), 5);

View file

@ -51,7 +51,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testMethods() throws Exception {
String content = readTaggedComment("testMethods");
IFile file= createFile(getProject(), "testMethods.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("method"), 2);
@ -134,7 +134,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testStaticMethods() throws Exception {
String content = readTaggedComment("testStaticMethods");
IFile file= createFile(getProject(), "testStaticMethods.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("method"), 2);
@ -222,7 +222,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testFields() throws Exception {
String content = readTaggedComment("testFields");
IFile file= createFile(getProject(), "testFields.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("field"), 2);
@ -296,7 +296,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testAutomaticConstructor_156668() throws Exception {
String content = readTaggedComment("testAutomaticConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
@ -309,7 +309,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void _testAutomaticDestructor_156668() throws Exception {
String content = readTaggedComment("testAutomaticConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
openCallHierarchy(editor);
Tree tree = getCHTreeViewer().getTree();
@ -334,7 +334,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testConstructor() throws Exception {
String content = readTaggedComment("testConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
@ -347,7 +347,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testDestructor_156669() throws Exception {
String content = readTaggedComment("testConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("~MyClass()"), 2);
@ -382,7 +382,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testNamespace() throws Exception {
String content = readTaggedComment("testNamespace");
IFile file= createFile(getProject(), "testNamespace.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("var"), 2);
@ -439,7 +439,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
public void testNamespacePart2_156519() throws Exception {
String content = readTaggedComment("testNamespace");
IFile file= createFile(getProject(), "testNamespace.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("var; // r1"), 2);

View file

@ -46,7 +46,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
fCProject2= CProjectHelper.createCCProject("__chTest_2__", "bin", IPDOMManager.ID_NO_INDEXER);
CCorePlugin.getIndexManager().setIndexerId(fCProject2, IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(fCProject2);
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCProject2});
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
}
@ -86,9 +86,9 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
String header= content[0].toString();
String source = content[1].toString();
IFile headerFile= createFile(fCProject.getProject(), "testMethods.h", header);
waitForIndexer(fIndex, headerFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, headerFile);
IFile sourceFile= createFile(fCProject2.getProject(), "testMethods.cpp", source);
waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, sourceFile);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= openEditor(sourceFile);
@ -164,7 +164,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
IFile sourceFile2= createFile(fCProject2.getProject(), "testMethods2.cpp", source2);
CEditor editor= openEditor(sourceFile1);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, sourceFile2);
editor.selectAndReveal(source1.indexOf("method3"), 2);
openCallHierarchy(editor);
@ -214,8 +214,8 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
CEditor editor= openEditor(sourceFile1);
waitForIndexer(fIndex, sourceFile1, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, sourceFile1);
waitUntilFileIsIndexed(fIndex, sourceFile2);
editor.selectAndReveal(source1.indexOf("method3"), 2);
openCallHierarchy(editor);
@ -275,7 +275,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
CEditor editor= openEditor(sourceFile2);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, sourceFile2);
editor.selectAndReveal(source2.indexOf("main"), 2);
openCallHierarchy(editor, false);

View file

@ -53,7 +53,7 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
CallHierarchyUI.setIsJUnitTest(true);
String prjName= "chTest"+sProjectCounter++;
fCProject= CProjectHelper.createCCProject(prjName, "bin", IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(fCProject);
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewReference[] refs= page.getViewReferences();

View file

@ -57,7 +57,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
StringBuilder[] contents = getContentsForTest(2);
IFile file1= createFile(getProject(), "SomeClass.h", contents[0].toString());
IFile file2= createFile(getProject(), "SomeClass.cpp", contents[1].toString());
waitForIndexer(fIndex, file2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file2);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
final IViewPart outline= activateView(IPageLayout.ID_OUTLINE);
@ -98,7 +98,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
StringBuilder[] contents = getContentsForTest(2);
IFile file1= createFile(getProject(), "SomeClass.h", contents[0].toString());
IFile file2= createFile(getProject(), "SomeClass.cpp", contents[1].toString());
waitForIndexer(fIndex, file2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file2);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
final IViewPart outline= activateView(IPageLayout.ID_OUTLINE);
@ -161,7 +161,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
public void testPolyMorphicMethodCalls_156689() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "SomeClass.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow();
@ -217,7 +217,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
public void testReversePolyMorphicMethodCalls_156689() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "SomeClass.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow();
@ -253,7 +253,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
public void testMethodInstance_Bug240599() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "CSome.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow();
@ -293,7 +293,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
public void testMultiplePolyMorphicMethodCalls_244987() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "SomeClass244987.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow();
@ -335,7 +335,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
public void testMacrosHidingCall_249801() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "file249801.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
@ -370,7 +370,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
IFile header= createFile(getProject(), "260262.h", hcontent);
IFile f1= createFile(getProject(), "260262.c", content_full);
IFile f2= createFile(getProject(), "260262.cpp", content_inc);
waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, f2);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
@ -400,7 +400,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
IFile header= createFile(getProject(), "260262.h", hcontent);
IFile f1= createFile(getProject(), "260262.c", content_full);
IFile f2= createFile(getProject(), "260262.cpp", content_inc);
waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, f2);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
@ -428,7 +428,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
final StringBuilder[] contents = getContentsForTest(1);
final String content = contents[0].toString();
IFile f2= createFile(getProject(), "testUnnamedNamespace_283679.cpp", content);
waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, f2);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
@ -463,7 +463,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
final StringBuilder[] contents = getContentsForTest(1);
final String content = contents[0].toString();
IFile f2= createFile(getProject(), "testCallsToFromVirtualMethod_246064.cpp", content);
waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, f2);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
@ -491,7 +491,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
public void testCallsToInstanceofSpecializedTemplate_361999() throws Exception {
final String content = getAboveComment();
IFile f2= createFile(getProject(), "testCallsToInstanceofSpecializedTemplate_361999.cpp", content);
waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, f2);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);

View file

@ -19,8 +19,6 @@ import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.ui.editor.CEditor;
@ -62,7 +60,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
String source = content[1].toString();
IFile headerFile= createFile(getProject(), "testMethods.h", header);
IFile sourceFile= createFile(getProject(), "testMethods.cpp", source);
waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, sourceFile);
CEditor editor= openEditor(sourceFile);
editor.selectAndReveal(source.indexOf("method"), 2);
@ -136,7 +134,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
CEditor editor= openEditor(sourceFile1);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, sourceFile2);
editor.selectAndReveal(source1.indexOf("method3"), 2);
openCallHierarchy(editor);
@ -185,7 +183,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, sourceFile2);
CEditor editor= openEditor(sourceFile1);
editor.selectAndReveal(source1.indexOf("method3"), 2);
@ -246,7 +244,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
CEditor editor= openEditor(sourceFile2);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, sourceFile2);
editor.selectAndReveal(source2.indexOf("main"), 2);
openCallHierarchy(editor, false);
@ -300,8 +298,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
IFile cFile= createFile(getProject(), "s.c", cSource);
IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
CEditor editor= openEditor(cFile);
waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm());
waitUntilFileIsIndexed(fIndex, cppFile);
editor.selectAndReveal(cSource.indexOf("cfunc"), 2);
openCallHierarchy(editor);
@ -346,8 +343,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= openEditor(cFile);
waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm());
waitUntilFileIsIndexed(fIndex, cppFile);
editor.selectAndReveal(cSource.indexOf("cfunc"), 2);
openCallHierarchy(editor, false);
@ -415,8 +411,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
String source = content[0].toString();
IFile file= createFile(getProject(), "testTemplates.cpp", source);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm());
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
int pos= source.indexOf("f(");
@ -479,8 +474,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
String source = content[0].toString();
IFile file= createFile(getProject(), "testClosures.cpp", source);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm());
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
int pos= source.indexOf("a(");

View file

@ -33,7 +33,7 @@ public class InitializersInCallHierarchyTest extends CallHierarchyBaseTest {
public void testCIntVarInitializer() throws Exception {
String content = readTaggedComment("intvar");
IFile file= createFile(getProject(), "intvar.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("a"), 1);

View file

@ -48,7 +48,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
IFile user= createFile(project, "user.h", "");
IFile system= createFile(project, "system.h", "");
IFile source= createFile(project, "source.cpp", contents[0].toString());
waitForIndexer(fIndex, source, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, source);
openIncludeBrowser(source);
Tree tree = getIBTree();
@ -83,7 +83,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
IFile system= createFile(op.getProject(), "system.h", "");
IFile source= createFile(getProject().getProject(), "source.cpp", contents[0].toString());
CCorePlugin.getIndexManager().reindex(op);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
waitForIndexer(op);
openIncludeBrowser(source);
Tree tree = getIBTree();

View file

@ -78,7 +78,7 @@ public class BasicOutlineTest extends BaseUITestCase {
}
private void waitForIndexer(IProject project, IFile source) throws Exception, CoreException {
waitForIndexer(CCorePlugin.getIndexManager().getIndex(fCProject), source, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(CCorePlugin.getIndexManager().getIndex(fCProject), source);
}
private void checkTreeItems(TreeItem[] items, String... labels) {

View file

@ -130,8 +130,7 @@ public abstract class RefactoringTestBase extends BaseTestCase {
selectedFile = testFiles.iterator().next();
}
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(INDEXER_TIMEOUT_SEC * 1000,
NULL_PROGRESS_MONITOR));
waitForIndexer(cproject);
}
@Override

View file

@ -18,9 +18,6 @@ import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.internal.ui.refactoring.rename.CRefactoringArgument;
import org.eclipse.cdt.internal.ui.refactoring.rename.CRefactory;
import org.eclipse.cdt.internal.ui.refactoring.rename.CRenameProcessor;
@ -140,15 +137,7 @@ public class RenameTests extends RefactoringTests {
}
protected void waitForIndexer() throws InterruptedException {
final IIndexManager im = CCorePlugin.getIndexManager();
assertTrue(im.joinIndexer(10000, NPM));
int sleep= 1;
while (im.isIndexerSetupPostponed(cproject)) {
Thread.sleep(sleep);
sleep *= 2;
assertTrue(sleep < 2000);
}
assertTrue(im.joinIndexer(10000, NPM));
waitForIndexer(cproject);
}
@Override

View file

@ -22,11 +22,8 @@ import junit.framework.TestSuite;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ILabelProvider;
@ -74,10 +71,10 @@ public class BasicSearchTest extends BaseUITestCase {
IFile file = TestSourceReader.createFile(fCProject.getProject(), new Path("header.h"), testData[0].toString());
CCorePlugin.getIndexManager().setIndexerId(fCProject, IPDOMManager.ID_FAST_INDEXER);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(fCProject);
IFile cppfile= TestSourceReader.createFile(fCProject.getProject(), new Path("references.cpp"), testData[1].toString());
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(fCProject);
}
@Override
@ -106,7 +103,7 @@ public class BasicSearchTest extends BaseUITestCase {
// rebuild the index
TestScannerProvider.sIncludes= new String[] {dir.getAbsolutePath()};
CCorePlugin.getIndexManager().reindex(fCProject);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(fCProject);
// open a query
CSearchQuery query= makeProjectQuery("foo");
@ -149,7 +146,7 @@ public class BasicSearchTest extends BaseUITestCase {
// rebuild the index with no indexer
CCorePlugin.getIndexManager().setIndexerId(fCProject, IPDOMManager.ID_NO_INDEXER);
CCorePlugin.getIndexManager().reindex(fCProject);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(fCProject);
// open a query
CSearchQuery query= makeProjectQuery("x");
@ -220,7 +217,7 @@ public class BasicSearchTest extends BaseUITestCase {
coreTestIndexerInProgress(false);
// now join and test again to get the full results
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(fCProject);
coreTestIndexerInProgress(true);
}
@ -322,8 +319,7 @@ public class BasicSearchTest extends BaseUITestCase {
String newContent= "void bar() {}";
IFile file = fCProject.getProject().getFile(new Path("references.cpp"));
file.setContents(new ByteArrayInputStream(newContent.getBytes()), IResource.FORCE, npm());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(fCProject);
assertOccurrences(query, 1);
}
@ -343,14 +339,13 @@ public class BasicSearchTest extends BaseUITestCase {
runEventQueue(1000);
IIndexManager indexManager = CCorePlugin.getIndexManager();
indexManager.update(new ICElement[] {fCProject}, IIndexManager.UPDATE_ALL);
assertTrue(indexManager.joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(fCProject);
assertOccurrences(query, 2);
String newContent2= "void bar() {foo(); foo();}";
file.setContents(new ByteArrayInputStream(newContent2.getBytes()), IResource.FORCE, npm());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
assertTrue(indexManager.joinIndexer(360000, new NullProgressMonitor()));
waitForIndexer(fCProject);
assertOccurrences(query, 3);
}

View file

@ -15,7 +15,6 @@ import java.util.ListResourceBundle;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.NullProgressMonitor;
@ -27,6 +26,7 @@ import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.testplugin.EditorTestHelper;
import org.eclipse.cdt.ui.testplugin.ResourceTestHelper;
@ -37,7 +37,7 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
/**
* Tests the AddIncludeOnSelectionAction.
*/
public class AddIncludeTest extends TestCase {
public class AddIncludeTest extends BaseTestCase {
private static final String PROJECT= "AddIncludeTests";
private static final class EmptyBundle extends ListResourceBundle {
@ -59,8 +59,7 @@ public class AddIncludeTest extends TestCase {
super.setUp();
fCProject= EditorTestHelper.createCProject(PROJECT, "resources/addInclude");
CCorePlugin.getIndexManager().setIndexerId(fCProject, IPDOMManager.ID_FAST_INDEXER);
// Wait until the indexer is done
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, new NullProgressMonitor()));
waitForIndexer(fCProject);
}
@Override

View file

@ -31,7 +31,6 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
@ -51,26 +50,25 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistProcessor;
* @author aniefer
*/
public class ContentAssistTests extends BaseUITestCase {
private NullProgressMonitor monitor= new NullProgressMonitor();
private final NullProgressMonitor monitor= new NullProgressMonitor();
static IProject project;
static ICProject cproject;
static boolean disabledHelpContributions = false;
@Override
public void setUp() {
public void setUp() throws InterruptedException {
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
if (project == null) {
ICProject cPrj;
try {
cPrj = CProjectHelper.createCCProject("ContentAssistTestProject", "bin", IPDOMManager.ID_FAST_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
project = cPrj.getProject();
cproject = CProjectHelper.createCCProject("ContentAssistTestProject", "bin", IPDOMManager.ID_FAST_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
project = cproject.getProject();
waitForIndexer(cproject);
} catch ( CoreException e ) {
/*boo*/
}
if (project == null)
fail("Unable to create project"); //$NON-NLS-1$
assertTrue(CCorePlugin.getIndexManager().joinIndexer(10000, monitor));
}
}
public ContentAssistTests()
@ -125,7 +123,7 @@ public class ContentAssistTests extends BaseUITestCase {
closeAllEditors();
// wait for indexer before deleting project to avoid errors in the log
CCorePlugin.getIndexManager().joinIndexer(10000, monitor);
waitForIndexer(cproject);
IResource [] members = project.members();
for (IResource member : members) {

View file

@ -19,7 +19,6 @@ import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.text.contentassist.ContentAssistant;
@ -30,7 +29,6 @@ import org.eclipse.jface.text.templates.TemplateProposal;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
@ -55,7 +53,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
protected ICProject fCProject;
private IFile fCFile;
protected ITextEditor fEditor;
private boolean fIsCpp;
private final boolean fIsCpp;
public AbstractContentAssistTest(String name, boolean isCpp) {
super(name);
@ -73,7 +71,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
}
fCFile= setUpProjectContent(fCProject.getProject());
assertNotNull(fCFile);
CCorePlugin.getIndexManager().joinIndexer(8000, new NullProgressMonitor());
waitForIndexer(fCProject);
fEditor= (ITextEditor)EditorTestHelper.openInEditor(fCFile, true);
assertNotNull(fEditor);
CPPASTNameBase.sAllowNameComputation= true;
@ -129,22 +127,20 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println("Time (ms): " + (endTime-startTime));
for (int i = 0; i < resultStrings.length; i++) {
String proposal = resultStrings[i];
for (String proposal : resultStrings) {
System.out.println("Result: " + proposal);
}
}
boolean allFound = true ; // for the time being, let's be optimistic
for (int i = 0; i< expected.length; i++){
for (String element : expected) {
boolean found = false;
for(int j = 0; j< resultStrings.length; j++){
String proposal = resultStrings[j];
if(expected[i].equals(proposal)){
for (String proposal : resultStrings) {
if(element.equals(proposal)){
found = true;
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println("Lookup success for " + expected[i]);
System.out.println("Lookup success for " + element);
}
break;
}
@ -152,7 +148,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
if (!found) {
allFound = false ;
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println( "Lookup failed for " + expected[i]); //$NON-NLS-1$
System.out.println( "Lookup failed for " + element); //$NON-NLS-1$
}
}
}
@ -177,8 +173,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
*/
private Object[] filterResults(Object[] results, boolean isCodeCompletion) {
List<Object> filtered= new ArrayList<Object>();
for (int i = 0; i < results.length; i++) {
Object result = results[i];
for (Object result : results) {
if (result instanceof TemplateProposal) {
continue;
}
@ -206,8 +201,7 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
*/
private Object[] filterResultsKeepTemplates(Object[] results) {
List<Object> filtered= new ArrayList<Object>();
for (int i = 0; i < results.length; i++) {
Object result = results[i];
for (Object result : results) {
if (result instanceof TemplateProposal) {
filtered.add(result);
}
@ -248,8 +242,8 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
private String toString(String[] strings) {
StringBuffer buf= new StringBuffer();
for(int i=0; i< strings.length; i++){
buf.append(strings[i]).append('\n');
for (String string : strings) {
buf.append(string).append('\n');
}
return buf.toString();
}

View file

@ -26,7 +26,6 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.IDocument;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
@ -862,11 +861,11 @@ public class CompletionTests extends AbstractContentAssistTest {
};
String disturbContent= readTaggedComment(DISTURB_FILE_NAME);
IFile dfile= createFile(fProject, DISTURB_FILE_NAME, disturbContent);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm()));
waitForIndexer(fCProject);
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
dfile.delete(true, npm());
assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm()));
waitForIndexer(fCProject);
assertCompletionResults(fCursorOffset, expected2, AbstractContentAssistTest.COMPARE_REP_STRINGS);
}

View file

@ -17,7 +17,6 @@ import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.IDocument;
import org.eclipse.cdt.core.CCorePlugin;
@ -182,7 +181,7 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest {
IFile sourceFile= createFile(project, SOURCE_FILE_NAME, sourceContent.toString());
// re-indexing is necessary to parse the header in context of the source.
CCorePlugin.getIndexManager().reindex(fCProject);
CCorePlugin.getIndexManager().joinIndexer(4000, new NullProgressMonitor());
waitForIndexer(fCProject);
return sourceFile;
}
@ -232,11 +231,11 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest {
};
String disturbContent= readTaggedComment(DISTURB_FILE_NAME);
IFile dfile= createFile(fProject, DISTURB_FILE_NAME, disturbContent);
assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm()));
waitForIndexer(fCProject);
assertCompletionResults(expected);
dfile.delete(true, npm());
assertTrue(CCorePlugin.getIndexManager().joinIndexer(8000, npm()));
waitForIndexer(fCProject);
assertCompletionResults(expected2);
}

View file

@ -43,16 +43,13 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
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.testplugin.FileManager;
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.cdt.ui.testplugin.EditorTestHelper;
import org.eclipse.cdt.ui.tests.BaseUITestCase;
@ -89,14 +86,6 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
}
}
public void waitForIndex(int maxSec) throws Exception {
assertTrue(CCorePlugin.getIndexManager().joinIndexer(maxSec * 1000, new NullProgressMonitor()));
}
protected void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception {
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEXER_TIMEOUT_SEC * 1000);
}
protected String getMessage(IStatus status) {
StringBuffer message = new StringBuffer("["); //$NON-NLS-1$
message.append(status.getMessage());
@ -123,7 +112,7 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
fileManager.addFile(file);
waitForIndex(20); // only wait 20 seconds max.
waitForIndexer(fCProject);
return file;
}

View file

@ -834,7 +834,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
IFile hcppfile = importFile("cpp.h", hcppcode);
IFile cppfile = importFile("cpp.cpp", cppcode);
CCorePlugin.getIndexManager().reindex(fCProject);
waitForIndex(INDEXER_TIMEOUT_SEC * 1000);
waitForIndexer(fCProject);
IASTNode decl;
int offset0, offset1;

View file

@ -108,7 +108,7 @@ public class ResolveBindingTests extends BaseUITestCase {
public void testNamespaceVarBinding() throws Exception {
String content = readTaggedComment("namespace-var-test");
IFile file= createFile(fCProject.getProject(), "nsvar.cpp", content);
waitForIndexer(fIndex, file, WAIT_FOR_INDEXER);
waitUntilFileIsIndexed(fIndex, file);
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
@ -132,7 +132,7 @@ public class ResolveBindingTests extends BaseUITestCase {
public void testNamespaceVarBinding_156519() throws Exception {
String content = readTaggedComment("namespace-var-test");
IFile file= createFile(fCProject.getProject(), "nsvar.cpp", content);
waitForIndexer(fIndex, file, WAIT_FOR_INDEXER);
waitUntilFileIsIndexed(fIndex, file);
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();
@ -173,7 +173,7 @@ public class ResolveBindingTests extends BaseUITestCase {
IFile hfile= createFile(fCProject.getProject(), "testMethods.h", content);
content = readTaggedComment("testMethods.cpp");
IFile cppfile= createFile(fCProject.getProject(), "testMethods.cpp", content);
waitForIndexer(fIndex, hfile, WAIT_FOR_INDEXER);
waitUntilFileIsIndexed(fIndex, hfile);
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
index.acquireReadLock();

View file

@ -36,7 +36,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testEnumC() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enum.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item;
@ -72,7 +72,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testEnumCFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enummem.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item;
@ -108,7 +108,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testEnumCPP() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enum.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item;
@ -144,7 +144,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testEnumCPPFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enummem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item;
@ -188,7 +188,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testStructC() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "struct.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("S1"), 1);
@ -242,7 +242,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testStructCFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "structmem.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("a1"), 1);
@ -276,7 +276,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testStructCPP() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "struct.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("S1"), 1);
@ -331,7 +331,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testStructCPPFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "structmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("a1"), 1);
@ -365,7 +365,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testUnionC() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "union.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("U1"), 1);
@ -415,7 +415,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testUnionCFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "unionmem.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("a1"), 1);
@ -441,7 +441,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testUnionCPP() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "union.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("U1"), 1);
@ -500,7 +500,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testUnionCPPFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "unionmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("a1"), 1);

View file

@ -52,7 +52,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testSimpleInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "class.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
@ -145,7 +145,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testSimpleInheritanceFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "classmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
TreeItem item1, item2, item3, item4;
@ -238,7 +238,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testMultipleInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multi.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -349,7 +349,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testMultipleInheritanceFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multimem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -460,7 +460,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testDiamondInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamond.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -571,7 +571,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testDiamondInheritanceFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamondmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -679,7 +679,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testViaTypedefInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -770,7 +770,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testViaTypedefInheritanceFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -849,7 +849,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testTemplatesNoInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "simpleTemplate.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;

View file

@ -53,7 +53,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testSimpleInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "class.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -149,7 +149,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testSimpleInheritanceFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "classmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -231,7 +231,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testMultipleInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multi.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -342,7 +342,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testMultipleInheritanceFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multimem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -434,7 +434,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testDiamondInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamond.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -545,7 +545,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testDiamondInheritanceFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamondmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -632,7 +632,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testViaTypedefInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;
@ -726,7 +726,7 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
public void testViaTypedefInheritanceFromMember() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, file);
CEditor editor= openEditor(file);
Tree tree;

View file

@ -90,7 +90,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
String source = content[1].toString();
IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header);
IFile sourceFile= createFile(fCProject2.getProject(), "simple.cpp", source);
waitForIndexer(fIndex, sourceFile, TypeHierarchyBaseTest.INDEXER_WAIT_TIME);
waitUntilFileIsIndexed(fIndex, sourceFile);
CEditor editor= openEditor(sourceFile);
Tree tree;

View file

@ -56,7 +56,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
protected void setUp() throws Exception {
super.setUp();
fCProject= CProjectHelper.createCCProject("__thTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, npm());
waitForIndexer(fCProject);
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
}

View file

@ -580,20 +580,6 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
enableStopAtMain.fillIntoGrid(group1, 3);
addField(enableStopAtMain);
// final StringFieldEditor stopAtMainSymbol = new StringFieldEditor(
// IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL,
// "", group1); //$NON-NLS-1$
// stopAtMainSymbol.fillIntoGrid(group1, 2);
// addField(stopAtMainSymbol);
//
// enableStopAtMain.getChangeControl(group1).addSelectionListener(new SelectionAdapter() {
// @Override
// public void widgetSelected(SelectionEvent e) {
// boolean enabled = enableStopAtMain.getBooleanValue();
// stopAtMainSymbol.setEnabled(enabled, group1);
// }
// });
fCommandTimeoutField = new IntegerWithBooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT,
IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE,
@ -659,36 +645,30 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
// Need to set layout again.
group2.setLayout(groupLayout);
final ListenableBooleanFieldEditor enableGdbTracesField = new ListenableBooleanFieldEditor(
final IntegerWithBooleanFieldEditor enableGdbTracesField = new IntegerWithBooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE,
MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label,
SWT.NONE, group2);
enableGdbTracesField.fillIntoGrid(group2, 3);
addField(enableGdbTracesField);
final IntegerFieldEditor maxCharactersField = new IntegerFieldEditor(
IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES,
MessagesForPreferences.GdbDebugPreferencePage_maxGdbTraces_label,
MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label,
group2);
// Instead of using Integer.MAX_VALUE which is some obscure number,
// using 2 billion is nice and readable.
maxCharactersField.setValidRange(10000, 2000000000);
maxCharactersField.fillIntoGrid(group2, 3);
addField(maxCharactersField);
enableGdbTracesField.getChangeControl(group2).addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean enabled = enableGdbTracesField.getBooleanValue();
maxCharactersField.setEnabled(enabled, group2);
}
});
enableGdbTracesField.setValidRange(10000, 2000000000);
enableGdbTracesField.fillIntoGrid(group2, 2);
addField(enableGdbTracesField);
// Need to set layout again.
group2.setLayout(groupLayout);
boolField= new BooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_USE_RTTI,
MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label1 + "\n" //$NON-NLS-1$
+ MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label2,
group2);
boolField.fillIntoGrid(group2, 3);
addField(boolField);
// need to set layout again
group2.setLayout(groupLayout);
Group group = new Group(parent, SWT.NONE);
group.setText(MessagesForPreferences.GdbDebugPreferencePage_prettyPrinting_label);
groupLayout = new GridLayout(3, false);
@ -733,23 +713,6 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
}
});
group= new Group(parent, SWT.NONE);
group.setText(MessagesForPreferences.GdbDebugPreferencePage_rtti_label);
groupLayout= new GridLayout(3, false);
group.setLayout(groupLayout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
boolField= new BooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_USE_RTTI,
MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label1 + "\n" //$NON-NLS-1$
+ MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label2,
group);
boolField.fillIntoGrid(group, 3);
addField(boolField);
// need to set layout again
group.setLayout(groupLayout);
// need to set layouts again
indentHelper.setLayout(helperLayout);
group.setLayout(groupLayout);

View file

@ -29,8 +29,6 @@ class MessagesForPreferences extends NLS {
/** @since 2.3 */
public static String GdbDebugPreferencePage_general_behavior_label;
public static String GdbDebugPreferencePage_enableTraces_label;
/** @since 2.2 */
public static String GdbDebugPreferencePage_maxGdbTraces_label;
public static String GdbDebugPreferencePage_autoTerminateGdb_label;
public static String GdbDebugPreferencePage_Browse_button;
public static String GdbDebugPreferencePage_Command_column_name;
@ -58,8 +56,6 @@ class MessagesForPreferences extends NLS {
public static String GdbDebugPreferencePage_Non_stop_mode;
public static String GdbDebugPreferencePage_Timeout_column_name;
public static String GdbDebugPreferencePage_Timeout_value_can_not_be_negative;
/** @since 2.3 */
public static String GdbDebugPreferencePage_rtti_label;
public static String GdbDebugPreferencePage_Stop_on_startup_at;
/** @since 2.3 */
public static String GdbDebugPreferencePage_use_rtti_label1;

View file

@ -16,8 +16,7 @@ GdbDebugPreferencePage_Add_button=Add
GdbDebugPreferencePage_description=General settings for GDB Debugging
GdbDebugPreferencePage_general_behavior_label=General Behavior
GdbDebugPreferencePage_enableTraces_label=Enable GDB traces
GdbDebugPreferencePage_maxGdbTraces_label=Limit GDB traces output (number of characters):
GdbDebugPreferencePage_enableTraces_label=Enable GDB traces with character limit:
GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits
GdbDebugPreferencePage_Command_column_name=GDB/MI Command
GdbDebugPreferencePage_Command_field_can_not_be_empty='Command' field can not be empty
@ -29,12 +28,11 @@ GdbDebugPreferencePage_hideRunningThreads=Show only suspended threads in the Deb
GdbDebugPreferencePage_prettyPrinting_label=Pretty Printing
GdbDebugPreferencePage_enablePrettyPrinting_label1=Enable pretty printers in variable/expression tree
GdbDebugPreferencePage_enablePrettyPrinting_label2=(requires python-enabled GDB)
GdbDebugPreferencePage_enablePrettyPrinting_label2=(Note: requires python-enabled GDB)
GdbDebugPreferencePage_initialChildCountLimitForCollections_label=For collections, initially limit child count to
GdbDebugPreferencePage_rtti_label=Run-time type information
GdbDebugPreferencePage_use_rtti_label1=Display run-time type of variables
GdbDebugPreferencePage_use_rtti_label2=(requires GDB 7.5 or higher)
GdbDebugPreferencePage_use_rtti_label2=(Note: requires GDB 7.5 or higher)
GdbDebugPreferencePage_defaults_label=Debug Configurations Defaults
GdbDebugPreferencePage_Delete_button=Delete

View file

@ -431,8 +431,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// Even if the breakpoint is disabled when we start, the target filter
// can be accessed by the user through the breakpoint properties UI, so
// we must set it right now.
// This is the reason we don't do this in 'installBreakpoint', which is not
// called right away if the breakpoint is disabled.
// This is the reason we don't do this in 'installBreakpoint', which used to not
// be called right away if the breakpoint was disabled (this is no longer the case).
try {
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IContainerDMContext.class);
IDsfBreakpointExtension filterExt = getFilterExtension(breakpoint);
@ -444,14 +444,9 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
} catch (CoreException e) {
}
// Install only if the breakpoint is enabled at startup (Bug261082)
// Note that Tracepoints are not affected by "skip-all"
boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) &&
(breakpoint instanceof ICTracepoint || fBreakpointManager.isEnabled());
if (bpEnabled)
installBreakpoint(dmc, breakpoint, attributes, countingRm);
else
countingRm.done();
// Must install breakpoints right away, even if disabled, so that
// we can find out if they apply to this target (Bug 389070)
installBreakpoint(dmc, breakpoint, attributes, countingRm);
}
});
}
@ -646,6 +641,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// Convert the breakpoint attributes for the back-end
attributes.put(ATTR_THREAD_ID, thread);
Map<String,Object> targetAttributes = convertToTargetBreakpoint(breakpoint, attributes);
// Must install breakpoint right away, even if disabled, so that
// we can find out if it applies to this target (Bug 389070)
fBreakpoints.insertBreakpoint(dmc, targetAttributes, drm);
}
}
@ -855,15 +852,11 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
return;
}
// Check if the breakpoint is installed: it might not have been if it wasn't enabled at startup (Bug261082)
// Or the installation might have failed; in this case, we still try to install it again because
// Check if the breakpoint is installed:
// the installation might have failed; in this case, we try to install it again because
// some attribute might have changed which will make the install succeed.
if (!breakpointIDs.containsKey(breakpoint) && !targetBPs.containsValue(breakpoint)) {
// Install only if the breakpoint is enabled
// Note that Tracepoints are not affected by "skip-all"
boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) &&
(breakpoint instanceof ICTracepoint || fBreakpointManager.isEnabled());
if (!filtered && bpEnabled) {
if (!filtered) {
attributes.put(ATTR_DEBUGGER_PATH, NULL_STRING);
attributes.put(ATTR_THREAD_FILTER, extractThreads(dmc, breakpoint));
attributes.put(ATTR_THREAD_ID, NULL_STRING);

View file

@ -172,12 +172,17 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
public void consumeNewInitializer() {
IASTExpression expr;
if(astStack.peek() == null) { // if there is an empty set of parens
astStack.pop();
IASTExpression initializer = nodeFactory.newExpressionList();
setOffsetAndLength(initializer);
astStack.push(initializer);
expr = nodeFactory.newExpressionList();
setOffsetAndLength(expr);
} else {
expr = (IASTExpression) astStack.pop(); // may be null
}
ICPPASTConstructorInitializer initializer = nodeFactory.newConstructorInitializer(expr);
setOffsetAndLength(initializer);
astStack.push(initializer);
}
@ -189,13 +194,13 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
* | dcolon_opt 'new' new_placement_opt '(' type_id ')' <openscope-ast> new_array_expressions_op new_initializer_opt
*/
public void consumeExpressionNew(boolean isNewTypeId) {
IASTExpression initializer = (IASTExpression) astStack.pop(); // may be null
ICPPASTConstructorInitializer initializer = (ICPPASTConstructorInitializer) astStack.pop(); // may be null
List<Object> arrayExpressions = astStack.closeScope();
IASTTypeId typeId = (IASTTypeId) astStack.pop();
IASTExpression placement = (IASTExpression) astStack.pop(); // may be null
boolean hasDoubleColon = astStack.pop() != null;
ICPPASTNewExpression newExpression = nodeFactory.newNewExpression(placement, initializer, typeId);
ICPPASTNewExpression newExpression = nodeFactory.newNewExpression(new IASTExpression[] {placement}, initializer, typeId);
newExpression.setIsGlobal(hasDoubleColon);
newExpression.setIsNewTypeId(isNewTypeId);
setOffsetAndLength(newExpression);
@ -1635,9 +1640,30 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
* ::= mem_initializer_id '(' expression_list_opt ')'
*/
public void consumeConstructorChainInitializer() {
IASTExpression expr = (IASTExpression) astStack.pop();
IASTName name = (IASTName) astStack.pop();
ICPPASTConstructorChainInitializer initializer = nodeFactory.newConstructorChainInitializer(name, expr);
Object o = astStack.pop();
IASTName name = (IASTName) astStack.pop();
IASTInitializerClause[] initClauseList =null;
if(o instanceof IASTExpressionList){
initClauseList = ((IASTExpressionList) o).getExpressions();
}else if(o instanceof IASTInitializerClause){
initClauseList = new IASTInitializerClause[]{(IASTInitializerClause)o};
}
ICPPASTConstructorInitializer init = nodeFactory.newConstructorInitializer(initClauseList);
int rule_start_offset = stream.getLeftIToken().getStartOffset();
int initClauseList_offset = ParserUtil.offset(initClauseList[0]);
List<IToken> ruleTokens = stream.getRuleTokens();
int start_offset = -1;
for (int i = initClauseList_offset, n = rule_start_offset; i >= n; i--){
if(tokenMap.mapKind(ruleTokens.get(i).getKind()) == TK_LeftParen) {
start_offset = ruleTokens.get(i).getStartOffset();
break;
}
}
int ruleLength = stream.getRightIToken().getEndOffset() - start_offset;
ParserUtil.setOffsetAndLength(init, start_offset, ruleLength < 0 ? 0 : ruleLength);
ICPPASTConstructorChainInitializer initializer = nodeFactory.newConstructorChainInitializer(name, init);
setOffsetAndLength(initializer);
astStack.push(initializer);
}