From 250d34926bbc401169c64cf9ea8106838ffbd062 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Thu, 22 Mar 2007 18:50:26 +0000 Subject: [PATCH] 169668: add unit tests + fix bugs --- .../tests/GeneratePDOMApplicationTest.java | 283 ++++++++++++++++++ .../cdt/internal/pdom/tests/PDOMTests.java | 3 +- core/org.eclipse.cdt.core.tests/plugin.xml | 12 + .../project1/a/b/c/d e/this.h | 7 + .../generatePDOMTests/project1/this.cpp | 7 + .../org.eclipse.cdt.core/META-INF/MANIFEST.MF | 1 + .../export/ExternalExportProjectProvider.java | 42 ++- .../index/export/IExportProjectProvider.java | 3 +- .../cdt/internal/core/index/IndexFactory.java | 41 ++- .../core/pdom/export/GeneratePDOM.java | 27 +- .../pdom/export/GeneratePDOMApplication.java | 38 ++- .../internal/core/pdom/export/Messages.java | 2 + .../core/pdom/export/messages.properties | 4 +- 13 files changed, 419 insertions(+), 51 deletions(-) create mode 100644 core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java create mode 100644 core/org.eclipse.cdt.core.tests/resources/pdomtests/generatePDOMTests/project1/a/b/c/d e/this.h create mode 100644 core/org.eclipse.cdt.core.tests/resources/pdomtests/generatePDOMTests/project1/this.cpp diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java new file mode 100644 index 00000000000..a1d2b3a3859 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/GeneratePDOMApplicationTest.java @@ -0,0 +1,283 @@ +/******************************************************************************* + * Copyright (c) 2007 Symbian Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andrew Ferguson (Symbian) - Initial implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.pdom.tests; + +import java.io.File; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +import junit.framework.Test; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.IPDOMManager; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.index.IIndexLocationConverter; +import org.eclipse.cdt.core.index.IIndexerStateEvent; +import org.eclipse.cdt.core.index.IIndexerStateListener; +import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter; +import org.eclipse.cdt.core.index.URIRelativeLocationConverter; +import org.eclipse.cdt.core.index.export.ExternalExportProjectProvider; +import org.eclipse.cdt.core.index.export.IExportProjectProvider; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.core.testplugin.CTestPlugin; +import org.eclipse.cdt.internal.core.index.IIndexFragment; +import org.eclipse.cdt.internal.core.pdom.WritablePDOM; +import org.eclipse.cdt.internal.core.pdom.export.GeneratePDOMApplication; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.equinox.app.IApplicationContext; +import org.osgi.framework.Bundle; + +/** + * Tests the GeneratePDOMApplication + */ +public class GeneratePDOMApplicationTest extends PDOMTestBase { + private static final String SDK_VERSION = "com.acme.sdk.version"; + private static final String ACME_SDK_ID= "com.acme.sdk.4.0.1"; + private static List toDeleteOnTearDown= new ArrayList(); + private final static String s= "resources/pdomtests/generatePDOMTests/project1"; + private URI baseURI; + + public static Test suite() { + return suite(GeneratePDOMApplicationTest.class); + } + + protected void setUp() throws Exception { + toDeleteOnTearDown.clear(); + baseURI= new URI("file:///base/"); // unimportant what the value is + } + + protected void tearDown() throws Exception { + for(Iterator i= toDeleteOnTearDown.iterator(); i.hasNext(); ) { + ICProject cproject= (ICProject) i.next(); + cproject.getProject().delete(true, new NullProgressMonitor()); + } + } + + public void testBrokenExportProjectProvider1() throws Exception { + try { + File target= File.createTempFile("test", "pdom"); + doGenerate(new String[] { + GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(), + GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider1.class.getName() + }); + fail("Expected exception - IExportProjectProvider implementation returns null for createProject"); + } catch(CoreException ce) { + // correct behaviour + } + } + + public void testBrokenExportProjectProvider2() throws Exception { + try { + File target= File.createTempFile("test", "pdom"); + doGenerate(new String[] { + GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(), + GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider2.class.getName() + }); + fail("Expected exception - IExportProjectProvider implementation returns null for getLocationConverter"); + } catch(CoreException ce) { + // correct behaviour + } + } + + public void testSimpleExportProjectProvider1() throws Exception { + File target= File.createTempFile("test", "pdom"); + doGenerate(new String[] { + GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(), + GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider3.class.getName() + }); + assertTrue(target.exists()); + WritablePDOM wpdom= new WritablePDOM(target, new URIRelativeLocationConverter(baseURI)); + verifyProject1Content(wpdom); + + String fid= wpdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID); + assertNotNull(fid); + assertTrue(fid.startsWith("export")); // check for default export id + } + + public void testSimpleExportProjectProvider2() throws Exception { + File target= File.createTempFile("test", "pdom"); + doGenerate(new String[] { + GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(), + GeneratePDOMApplication.OPT_PROJECTPROVIDER, TestProjectProvider4.class.getName() + }); + assertTrue(target.exists()); + WritablePDOM wpdom= new WritablePDOM(target, new URIRelativeLocationConverter(baseURI)); + verifyProject1Content(wpdom); + + String fid= wpdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID); + assertNotNull(fid); + assertEquals(ACME_SDK_ID, fid); // check for default export id + + String sdkVer= wpdom.getProperty(SDK_VERSION); + assertNotNull(sdkVer); + assertEquals("4.0.1", sdkVer); // check for default export id + } + + public void testExternalExportProjectProvider_BadCmdLine1() throws Exception { + File target= File.createTempFile("test", "pdom"); + try { + doGenerate(new String[] { + GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(), + GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName() + }); + assertTrue(target.exists()); + fail("Expected failure: -source must be specified"); + } catch(CoreException ce) { + // correct behaviour + } + } + + public void testExternalExportProjectProvider_BadCmdLine2() throws Exception { + File target= File.createTempFile("test", "pdom"); + TestProjectProvider4 tpp4= new TestProjectProvider4(); + ICProject cproject= tpp4.createProject(); + try { + doGenerate(new String[] { + GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(), + GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName(), + ExternalExportProjectProvider.OPT_SOURCE, cproject.getProject().getLocation().toFile().getAbsolutePath() + }); + assertTrue(target.exists()); + fail("Expected failure: -id must be specified"); + } catch(CoreException ce) { + // correct behaviour + } + } + + public void testExternalExportProjectProvider() throws Exception { + File target= File.createTempFile("test", "pdom"); + + final int[] stateCount = new int[1]; + IIndexerStateListener listener= new IIndexerStateListener() { + public void indexChanged(IIndexerStateEvent event) { + stateCount[0]++; + } + }; + CCorePlugin.getIndexManager().addIndexerStateListener(listener); + + URL url= FileLocator.find(CTestPlugin.getDefault().getBundle(), new Path(s), null); + String baseDir= FileLocator.toFileURL(url).getFile(); + + doGenerate(new String[] { + GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(), + GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName(), + ExternalExportProjectProvider.OPT_SOURCE, baseDir, + ExternalExportProjectProvider.OPT_FRAGMENT_ID, "hello.world" + }); + assertTrue(target.exists()); + + WritablePDOM wpdom= new WritablePDOM(target, new URIRelativeLocationConverter(baseURI)); + verifyProject1Content(wpdom); + + String fid= wpdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID); + assertNotNull(fid); + assertEquals("hello.world", fid); // check for default export id + + assertTrue(stateCount[0] == 2); + } + + public void verifyProject1Content(WritablePDOM wpdom) throws CoreException { + IBinding[] bindings= wpdom.findBindings(Pattern.compile(".*foo.*"), false, IndexFilter.ALL, PROGRESS); + assertEquals(1, bindings.length); + + bindings= wpdom.findBindings(Pattern.compile(".*bar.*"), false, IndexFilter.ALL, PROGRESS); + assertEquals(1, bindings.length); + } + + + private void doGenerate(String[] args) throws CoreException { + GeneratePDOMApplication app = new GeneratePDOMApplication(); + IApplicationContext ac= new MockApplicationContext(args); + app.start(ac); + } + + /* + * IExportProjectProvider test implementations + */ + public static class TestProjectProvider1 implements IExportProjectProvider { + public ICProject createProject() throws CoreException {return null;} + public Map getExportProperties() {return null;} + public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;} + public void setApplicationArguments(String[] arguments) {} + } + + public static class TestProjectProvider2 implements IExportProjectProvider { + public ICProject createProject() throws CoreException { + ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); + toDeleteOnTearDown.add(cproject); + CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), s); + return cproject; + } + public Map getExportProperties() {return null;} + public IIndexLocationConverter getLocationConverter(ICProject cproject) {return null;} + public void setApplicationArguments(String[] arguments) {} + } + + public static class TestProjectProvider3 implements IExportProjectProvider { + public ICProject createProject() throws CoreException { + ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); + toDeleteOnTearDown.add(cproject); + CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), s); + return cproject; + } + public Map getExportProperties() {return null;} + public IIndexLocationConverter getLocationConverter(ICProject cproject) { + return new ResourceContainerRelativeLocationConverter(cproject.getProject()); + } + public void setApplicationArguments(String[] arguments) {} + } + + public static class TestProjectProvider4 implements IExportProjectProvider { + public ICProject createProject() throws CoreException { + ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER); + toDeleteOnTearDown.add(cproject); + CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), s); + return cproject; + } + public Map getExportProperties() { + Map map= new HashMap(); + map.put(SDK_VERSION, "4.0.1"); + map.put(IIndexFragment.PROPERTY_FRAGMENT_ID, ACME_SDK_ID); + return map; + } + public IIndexLocationConverter getLocationConverter(ICProject cproject) { + return new ResourceContainerRelativeLocationConverter(cproject.getProject()); + } + public void setApplicationArguments(String[] arguments) {} + } +} + +class MockApplicationContext implements IApplicationContext { + Map arguments; + MockApplicationContext(String[] appArgs) { + arguments= new HashMap(); + arguments.put(APPLICATION_ARGS, appArgs); + } + public void applicationRunning() {} + public Map getArguments() {return arguments;} + public String getBrandingApplication() {return null;} + public Bundle getBrandingBundle() {return null;} + public String getBrandingDescription() {return null;} + public String getBrandingId() {return null;} + public String getBrandingName() {return null;} + public String getBrandingProperty(String key) {return null;} +} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java index 0381ab9f479..0c86db7fac1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java @@ -39,7 +39,8 @@ public class PDOMTests extends TestSuite { suite.addTest(OverloadsWithinCommonHeaderTests.suite()); suite.addTest(BTreeTests.suite()); suite.addTest(FilesOnReindexTests.suite()); - + suite.addTest(GeneratePDOMApplicationTest.suite()); + suite.addTest(CPPFieldTests.suite()); suite.addTest(CPPFunctionTests.suite()); suite.addTest(CPPVariableTests.suite()); diff --git a/core/org.eclipse.cdt.core.tests/plugin.xml b/core/org.eclipse.cdt.core.tests/plugin.xml index 003e1c3e601..f7ac96e4f81 100644 --- a/core/org.eclipse.cdt.core.tests/plugin.xml +++ b/core/org.eclipse.cdt.core.tests/plugin.xml @@ -32,6 +32,18 @@ + + + + + + + + diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/generatePDOMTests/project1/a/b/c/d e/this.h b/core/org.eclipse.cdt.core.tests/resources/pdomtests/generatePDOMTests/project1/a/b/c/d e/this.h new file mode 100644 index 00000000000..703f161f014 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/generatePDOMTests/project1/a/b/c/d e/this.h @@ -0,0 +1,7 @@ +class A { + public: + class B {}; + int c; + A* foo(B b) {}; +}; + \ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/generatePDOMTests/project1/this.cpp b/core/org.eclipse.cdt.core.tests/resources/pdomtests/generatePDOMTests/project1/this.cpp new file mode 100644 index 00000000000..8447f0c9d84 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/generatePDOMTests/project1/this.cpp @@ -0,0 +1,7 @@ +#include "a/b/c/d e/this.h" + +void bar() { + A a; + a.foo(*new A::B()); +} + \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 8918170bccc..45747394448 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -65,6 +65,7 @@ Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.internal.core.pdom.dom;x-friends:="org.eclipse.cdt.ui", org.eclipse.cdt.internal.core.pdom.dom.c;x-internal:=true, org.eclipse.cdt.internal.core.pdom.dom.cpp;x-internal:=true, + org.eclipse.cdt.internal.core.pdom.export, org.eclipse.cdt.internal.core.pdom.indexer;x-friends:="org.eclipse.cdt.ui", org.eclipse.cdt.internal.core.pdom.indexer.fast;x-internal:=true, org.eclipse.cdt.internal.core.pdom.indexer.full;x-internal:=true, diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/ExternalExportProjectProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/ExternalExportProjectProvider.java index 603b733b5ad..29212e2fb37 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/ExternalExportProjectProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/ExternalExportProjectProvider.java @@ -31,6 +31,9 @@ import org.eclipse.cdt.core.index.ResourceContainerRelativeLocationConverter; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData; import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; import org.eclipse.core.resources.IFolder; @@ -58,9 +61,9 @@ import org.eclipse.core.runtime.Path; public class ExternalExportProjectProvider extends AbstractExportProjectProvider implements IExportProjectProvider { private static final String ORG_ECLIPSE_CDT_CORE_INDEX_EXPORT_DATESTAMP = "org.eclipse.cdt.core.index.export.datestamp"; //$NON-NLS-1$ private static final String CONTENT = "content"; //$NON-NLS-1$ - protected static final String ARG_SOURCE = "-source"; //$NON-NLS-1$ - protected static final String ARG_INCLUDE = "-include"; //$NON-NLS-1$ - protected static final String ARG_FRAGMENT_ID = "-id"; //$NON-NLS-1$ + public static final String OPT_SOURCE = "-source"; //$NON-NLS-1$ + public static final String OPT_INCLUDE = "-include"; //$NON-NLS-1$ + public static final String OPT_FRAGMENT_ID = "-id"; //$NON-NLS-1$ private IFolder content; private String fragmentId; @@ -75,21 +78,21 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider */ public ICProject createProject() throws CoreException { // -source - File source= new File(getSingleString(ARG_SOURCE)); + File source= new File(getSingleString(OPT_SOURCE)); if(!source.exists()) { fail(MessageFormat.format(Messages.ExternalContentPEM_LocationToIndexNonExistent, new Object[] {source})); } // -include List includeFiles= new ArrayList(); - if(isPresent(ARG_INCLUDE)) { - includeFiles.addAll(getParameters(ARG_INCLUDE)); + if(isPresent(OPT_INCLUDE)) { + includeFiles.addAll(getParameters(OPT_INCLUDE)); } // -id - fragmentId= getSingleString(ARG_FRAGMENT_ID); + fragmentId= getSingleString(OPT_FRAGMENT_ID); - return createCProject("__"+System.currentTimeMillis(), source, IPDOMManager.ID_FAST_INDEXER, includeFiles); //$NON-NLS-1$ + return createCCProject("__"+System.currentTimeMillis(), source, includeFiles); //$NON-NLS-1$ } /** @@ -109,10 +112,9 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider * @return a new project * @throws CoreException */ - private ICProject createCProject( + private ICProject createCCProject( final String projectName, final File location, - final String indexerID, final List includeFiles ) throws CoreException { final IWorkspace ws = ResourcesPlugin.getWorkspace(); @@ -158,19 +160,29 @@ public class ExternalExportProjectProvider extends AbstractExportProjectProvider (IPathEntry[]) entries.toArray(new IPathEntry[includeFiles.size()]), new NullProgressMonitor() ); + + ICProjectDescription pd= CoreModel.getDefault().createProjectDescription(cproject.getProject(), false); // create the description + newCfg(pd, project.getName(), "cfg1"); //$NON-NLS-1$ + CoreModel.getDefault().setProjectDescription(cproject.getProject(), pd, true, new NullProgressMonitor()); + newProject[0]= cproject; + + IndexerPreferences.set(newProject[0].getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, Boolean.TRUE.toString()); + IndexerPreferences.set(newProject[0].getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER); } }, null); - if (indexerID != null) { - IndexerPreferences.set(newProject[0].getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, Boolean.TRUE.toString()); - IndexerPreferences.set(newProject[0].getProject(), IndexerPreferences.KEY_INDEXER_ID, indexerID); - } - return newProject[0]; } + private ICConfigurationDescription newCfg(ICProjectDescription des, String project, String config) throws CoreException { + CDefaultConfigurationData data= new CDefaultConfigurationData(project+"."+config, project+" "+config+" name", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + data.initEmptyData(); + String ID= CCorePlugin.PLUGIN_ID + ".defaultConfigDataProvider"; //$NON-NLS-1$ + return des.createConfiguration(ID, data); + } + /* * This should be a platform/CDT API */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/IExportProjectProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/IExportProjectProvider.java index dcd8742817f..6d92f51aa48 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/IExportProjectProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/export/IExportProjectProvider.java @@ -41,7 +41,8 @@ public interface IExportProjectProvider { public void setApplicationArguments(String[] arguments); /** - * Creates, configures and returns a project for the indexer to index + * Creates, configures and returns a project for the indexer to index. This routine should + * not itself index the project, as a reindex will be performed by the framework. * May not return null. * @return */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java index 560d454f337..42d5f4e44e5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFactory.java @@ -29,6 +29,8 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.internal.core.CCoreInternals; import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager; import org.eclipse.cdt.internal.core.pdom.PDOMManager; import org.eclipse.core.resources.IProject; @@ -56,7 +58,7 @@ public class IndexFactory { boolean addDependent= (options & ADD_DEPENDENT) != 0; boolean skipProvided= (options & SKIP_PROVIDED) != 0; - IndexProviderManager m = ((PDOMManager)CCorePlugin.getPDOMManager()).getIndexProviderManager(); + IndexProviderManager m = CCoreInternals.getPDOMManager().getIndexProviderManager(); HashMap map= new HashMap(); Collection selectedProjects= getProjects(projects, addDependencies, addDependent, map, new Integer(1)); @@ -68,10 +70,13 @@ public class IndexFactory { fragments.put(pdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID), pdom); if(!skipProvided) { - ICConfigurationDescription activeCfg= CoreModel.getDefault().getProjectDescription(cproject.getProject()).getActiveConfiguration(); - IIndexFragment[] pFragments= m.getProvidedIndexFragments(activeCfg); - for(int i=0; i*/ projectInitializers; @@ -49,7 +51,8 @@ public class GeneratePDOMApplication implements IApplication { * Starts this application */ public Object start(IApplicationContext context) throws CoreException { - Map arguments= CLIUtil.parseToMap(Platform.getApplicationArgs()); + String[] appArgs= (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS); + Map arguments= CLIUtil.parseToMap(appArgs); output(Messages.GeneratePDOMApplication_Initializing); setupCLIProgressProvider(); @@ -64,6 +67,16 @@ public class GeneratePDOMApplication implements IApplication { String target= (String) CLIUtil.getArg(arguments, OPT_TARGET, 1).get(0); boolean quiet= arguments.get(OPT_QUIET)!=null; + String indexerID= IPDOMManager.ID_FAST_INDEXER; + String[] indexerIDs= (String[]) arguments.get(OPT_INDEXER_ID); + if(indexerIDs!=null) { + if(indexerIDs.length==1) { + indexerID= indexerIDs[0]; + } else if(indexerIDs.length>1) { + fail(MessageFormat.format(Messages.GeneratePDOMApplication_InvalidIndexerID, new Object[] {OPT_INDEXER_ID})); + } + } + if(!quiet) { System.setProperty(IPDOMIndexerTask.TRACE_ACTIVITY, Boolean.TRUE.toString()); System.setProperty(IPDOMIndexerTask.TRACE_PROBLEMS, Boolean.TRUE.toString()); @@ -72,12 +85,11 @@ public class GeneratePDOMApplication implements IApplication { IExportProjectProvider pprovider = getExportProjectProvider(pproviderFQN); if(pprovider==null) { - output(MessageFormat.format(Messages.GeneratePDOMApplication_CouldNotFindInitializer, new Object[]{pproviderFQN})); - return null; + fail(MessageFormat.format(Messages.GeneratePDOMApplication_CouldNotFindInitializer, new Object[]{pproviderFQN})); } File targetLocation = new File(target); - GeneratePDOM generate = new GeneratePDOM(pprovider, Platform.getApplicationArgs(), targetLocation); + GeneratePDOM generate = new GeneratePDOM(pprovider, appArgs, targetLocation, indexerID); output(Messages.GeneratePDOMApplication_GenerationStarts); generate.run(); output(Messages.GeneratePDOMApplication_GenerationEnds); @@ -92,6 +104,10 @@ public class GeneratePDOMApplication implements IApplication { // do nothing } + private void fail(String message) throws CoreException { + throw new CoreException(CCorePlugin.createStatus(message)); + } + /** * Returns the IExportProjectProvider registed in the plug-in registry under the * specified fully qualified class name @@ -109,20 +125,16 @@ public class GeneratePDOMApplication implements IApplication { IExtension extension = extensions[i]; IConfigurationElement[] ce = extension.getConfigurationElements(); - IExportProjectProvider pfem = null; for(int j=0; j