Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2018-11-20 16:20:39 -0500
committerJonah Graham2018-11-20 16:20:39 -0500
commit48d2271a58a68743e428d3096d2bca054d04e310 (patch)
tree235ba23e71c393ad22d1d57fc8fdfec14754c4ee /core/org.eclipse.cdt.core.tests
parent3cf0297769e5cfb91823e93ce570120a75fe01ce (diff)
downloadorg.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.gz
org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.xz
org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.zip
Bug 540373: Normalize newlines with .gitattributes
There is also a new script to verify completeness of .gitattributes: releng/scripts/verify_gitattributes.sh Change-Id: I2ce270852ab54b66b6c474a6ec94203fe5bba78b
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java64
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java604
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java1916
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java206
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h290
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/cfiles/TranslationUnits.c138
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/cfiles/included.h20
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/cmodel/DeclaratorsTests.cpp48
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/cmodel/IIncludeTest.h84
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/cmodel/IMacroTest.h8
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/cmodel/ITemplate.cpp144
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.cpp16
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.h16
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.cpp16
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.h16
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.cpp14
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.h16
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/Inc1.h14
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/a.h14
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/c.h10
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/dependency/d.h10
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/indexer/DocumentManager.cpp50
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/indexer/extramail.cpp224
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/indexer/reftest.cpp42
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.c86
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.h34
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.cpp74
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.h64
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/parser/LineNumberTest.h84
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp202
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/search/include.h70
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java992
32 files changed, 2793 insertions, 2793 deletions
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java
index 17039f287f6..0fde6d42f70 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/tests/filesystem/ram/MemoryEFSExtensionProvider.java
@@ -1,33 +1,33 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Andrew Gvozdev 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 Gvozdev - initial API and implementation
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Andrew Gvozdev 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 Gvozdev - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.core.internal.tests.filesystem.ram;
-
-import java.net.URI;
-
-import org.eclipse.cdt.core.EFSExtensionProvider;
-
-/**
- * Test stub to test EFSExtensionProvider mappings.
- *
- */
-public class MemoryEFSExtensionProvider extends EFSExtensionProvider {
-
- public String getMappedPath(URI locationURI) {
-
- String path = locationURI.getPath();
- if (path.contains("/BeingMappedFrom/Folder")) {
- return path.replaceFirst("/BeingMappedFrom/Folder", "/LocallyMappedTo/Folder");
- }
-
- return super.getMappedPath(locationURI);
- }
-
-}
+package org.eclipse.cdt.core.internal.tests.filesystem.ram;
+
+import java.net.URI;
+
+import org.eclipse.cdt.core.EFSExtensionProvider;
+
+/**
+ * Test stub to test EFSExtensionProvider mappings.
+ *
+ */
+public class MemoryEFSExtensionProvider extends EFSExtensionProvider {
+
+ public String getMappedPath(URI locationURI) {
+
+ String path = locationURI.getPath();
+ if (path.contains("/BeingMappedFrom/Folder")) {
+ return path.replaceFirst("/BeingMappedFrom/Folder", "/LocallyMappedTo/Folder");
+ }
+
+ return super.getMappedPath(locationURI);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java
index 7613f726fdb..a7c5811518d 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java
@@ -1,302 +1,302 @@
-/*******************************************************************************
- * Copyright (c) 2013 Andrew Gvozdev 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 Gvozdev - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.core.testplugin.ResourceHelper;
-import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
-import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Test cases testing ReferencedProjectsLanguageSettingsProvider functionality
- */
-public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCase {
- /**
- * Constructor.
- * @param name - name of the test.
- */
- public LanguageSettingsProviderReferencedProjectsTests(String name) {
- super(name);
-
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown(); // includes ResourceHelper cleanup
- }
-
- /**
- * @return - new TestSuite.
- */
- public static TestSuite suite() {
- return new TestSuite(LanguageSettingsProviderReferencedProjectsTests.class);
- }
-
- /**
- * main function of the class.
- *
- * @param args - arguments
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Helper method to fetch configuration descriptions.
- */
- private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
- CoreModel coreModel = CoreModel.getDefault();
- ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
- // project description
- ICProjectDescription projectDescription = mngr.getProjectDescription(project, false);
- assertNotNull(projectDescription);
- assertEquals(1, projectDescription.getConfigurations().length);
- // configuration description
- ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
- return cfgDescriptions;
- }
-
- /**
- * Helper method to set reference project.
- */
- private void setReference(IProject project, final IProject projectReferenced) throws CoreException {
- {
- CoreModel coreModel = CoreModel.getDefault();
- ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
- // project description
- ICProjectDescription projectDescription = mngr.getProjectDescription(project);
- assertNotNull(projectDescription);
- assertEquals(1, projectDescription.getConfigurations().length);
- // configuration description
- ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
- ICConfigurationDescription cfgDescription = cfgDescriptions[0];
-
- final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions(projectReferenced)[0];
- cfgDescription.setReferenceInfo(new HashMap<String, String>() {{ put(projectReferenced.getName(), cfgDescriptionReferenced.getId()); }});
- coreModel.setProjectDescription(project, projectDescription);
- }
-
- {
- // doublecheck that it's set as expected
- ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
- ICConfigurationDescription cfgDescription = cfgDescriptions[0];
- Map<String,String> refs = cfgDescription.getReferenceInfo();
- assertEquals(1, refs.size());
- Set<String> referencedProjectsNames = new LinkedHashSet<String>(refs.keySet());
- assertEquals(projectReferenced.getName(), referencedProjectsNames.toArray()[0]);
- }
-
- }
-
- /**
- * Test that null arguments don't crash the provider.
- */
- public void testNulls() throws Exception {
- ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
- assertNotNull(provider);
- List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
- assertEquals(null, entries);
- }
-
- /**
- * Test main functionality of ReferencedProjectsLanguageSettingsProvider.
- */
- public void testReferencedProjectProvider() throws Exception {
- // Create model project and accompanied descriptions
- String projectName = getName();
- IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
- IProject nonReferencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-non-referenced");
- IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-referenced");
- setReference(project, referencedProject);
-
- // get cfgDescription
- ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
- ICConfigurationDescription cfgDescription = cfgDescriptions[0];
-
- {
- // double-check that provider for referenced projects is set in the configuration
- ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
- assertNotNull(refProjectsProvider);
- List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
- assertTrue(providers.contains(refProjectsProvider));
- }
-
- // Check that no setting entries are set initially
- {
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
- assertEquals(0, entries.size());
- }
-
- // Add an entry into a non-referenced project
- CIncludePathEntry nonRefEntry = CDataUtil.createCIncludePathEntry("non-referenced-exported", ICSettingEntry.EXPORTED);
- {
- ICConfigurationDescription[] nonRefCfgDescriptions = getConfigurationDescriptions(nonReferencedProject);
- ICConfigurationDescription nonRefCfgDescription = nonRefCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersNonRef = ((ILanguageSettingsProvidersKeeper) nonRefCfgDescription).getLanguageSettingProviders();
- // get user provider which is the first one
- ILanguageSettingsProvider userProviderNonRef = providersNonRef.get(0);
- assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderNonRef.getId());
- assertTrue(userProviderNonRef instanceof LanguageSettingsGenericProvider);
- // add sample entries
- ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(nonRefEntry);
- ((LanguageSettingsGenericProvider) userProviderNonRef).setSettingEntries(null, null, null, entries);
- }
- // Confirm that that does not add entries to the main project
- {
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
- assertEquals(0, entries.size());
- }
-
- CIncludePathEntry refEntry = CDataUtil.createCIncludePathEntry("referenced-exported", ICSettingEntry.EXPORTED);
- // Add entries into a referenced project
- {
- ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(referencedProject);
- ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
- // get user provider which is the first one
- ILanguageSettingsProvider userProviderRef = providersRef.get(0);
- assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
- assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider);
- // add sample entries
- ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- CIncludePathEntry refEntryNotExported = CDataUtil.createCIncludePathEntry("referenced-not-exported", 0);
- entries.add(refEntry);
- entries.add(refEntryNotExported);
- ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
- List<ICLanguageSettingEntry> entriesActual = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, project, null, ICSettingEntry.ALL);
- assertEquals(entries, entriesActual);
- }
- // Check that the new entries from referenced project made it to the main project
- {
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
- assertEquals(CDataUtil.createCIncludePathEntry(refEntry.getName(), 0), entries.get(0));
- assertEquals(1, entries.size());
- }
- }
-
- /**
- * Test case when projects reference each other recursively.
- */
- public void testRecursiveReferences() throws Exception {
- // Create model projects that reference each other
- String projectName = getName();
- IProject projectA = ResourceHelper.createCDTProjectWithConfig(projectName + "-A");
- IProject projectB = ResourceHelper.createCDTProjectWithConfig(projectName + "-B");
- setReference(projectA, projectB);
- setReference(projectB, projectA);
-
- {
- // get cfgDescriptions to work with
- ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA);
- ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0];
- ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB);
- ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0];
- // double-check that provider for referenced projects is set in the configurations
- ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
- assertNotNull(refProjectsProvider);
- List<ILanguageSettingsProvider> providersA = ((ILanguageSettingsProvidersKeeper) cfgDescriptionA).getLanguageSettingProviders();
- assertTrue(providersA.contains(refProjectsProvider));
- List<ILanguageSettingsProvider> providersB = ((ILanguageSettingsProvidersKeeper) cfgDescriptionB).getLanguageSettingProviders();
- assertTrue(providersB.contains(refProjectsProvider));
-
- // Check that no setting entries are set initially
- List<ICLanguageSettingEntry> entriesA = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL);
- assertEquals(0, entriesA.size());
- List<ICLanguageSettingEntry> entriesB = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectB, null, ICSettingEntry.ALL);
- assertEquals(0, entriesB.size());
- }
-
- CIncludePathEntry entryExportedA = CDataUtil.createCIncludePathEntry("referenced-exported-A", ICSettingEntry.EXPORTED);
- CIncludePathEntry entryNotExportedA = CDataUtil.createCIncludePathEntry("referenced-not-exported-A", 0);
- // Add entries into a project A
- {
- ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectA);
- ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
- // get user provider which is the first one
- ILanguageSettingsProvider userProviderRef = providersRef.get(0);
- assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
- assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider);
- // add sample entries
- ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(entryExportedA);
- entries.add(entryNotExportedA);
- ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
- }
-
- CIncludePathEntry entryExportedB = CDataUtil.createCIncludePathEntry("referenced-exported-B", ICSettingEntry.EXPORTED);
- CIncludePathEntry entryNotExportedB = CDataUtil.createCIncludePathEntry("referenced-not-exported-B", 0);
- // Add entries into a project B
- {
- ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectB);
- ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
- List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
- // get user provider which is the first one
- ILanguageSettingsProvider userProviderRef = providersRef.get(0);
- assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
- assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider);
- // add sample entries
- ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(entryExportedB);
- entries.add(entryNotExportedB);
- ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
- }
-
- // Check that the new entries from projectB made it to projectA
- {
- ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA);
- ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0];
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL);
- assertEquals(entryExportedA, entries.get(0));
- assertEquals(entryNotExportedA, entries.get(1));
- assertEquals(CDataUtil.createCIncludePathEntry(entryExportedB.getName(), 0), entries.get(2));
- assertEquals(3, entries.size());
- }
- // Check that the new entries from projectA made it to projectB
- {
- ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB);
- ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0];
- List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionB, projectB, null, ICSettingEntry.ALL);
- assertEquals(entryExportedB, entries.get(0));
- assertEquals(entryNotExportedB, entries.get(1));
- assertEquals(CDataUtil.createCIncludePathEntry(entryExportedA.getName(), 0), entries.get(2));
- assertEquals(3, entries.size());
- }
-
- // Hopefully it gets here without stack overflow
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2013 Andrew Gvozdev 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 Gvozdev - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.language.settings.providers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.core.testplugin.ResourceHelper;
+import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
+import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Test cases testing ReferencedProjectsLanguageSettingsProvider functionality
+ */
+public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCase {
+ /**
+ * Constructor.
+ * @param name - name of the test.
+ */
+ public LanguageSettingsProviderReferencedProjectsTests(String name) {
+ super(name);
+
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown(); // includes ResourceHelper cleanup
+ }
+
+ /**
+ * @return - new TestSuite.
+ */
+ public static TestSuite suite() {
+ return new TestSuite(LanguageSettingsProviderReferencedProjectsTests.class);
+ }
+
+ /**
+ * main function of the class.
+ *
+ * @param args - arguments
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Helper method to fetch configuration descriptions.
+ */
+ private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
+ CoreModel coreModel = CoreModel.getDefault();
+ ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
+ // project description
+ ICProjectDescription projectDescription = mngr.getProjectDescription(project, false);
+ assertNotNull(projectDescription);
+ assertEquals(1, projectDescription.getConfigurations().length);
+ // configuration description
+ ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
+ return cfgDescriptions;
+ }
+
+ /**
+ * Helper method to set reference project.
+ */
+ private void setReference(IProject project, final IProject projectReferenced) throws CoreException {
+ {
+ CoreModel coreModel = CoreModel.getDefault();
+ ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
+ // project description
+ ICProjectDescription projectDescription = mngr.getProjectDescription(project);
+ assertNotNull(projectDescription);
+ assertEquals(1, projectDescription.getConfigurations().length);
+ // configuration description
+ ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
+ ICConfigurationDescription cfgDescription = cfgDescriptions[0];
+
+ final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions(projectReferenced)[0];
+ cfgDescription.setReferenceInfo(new HashMap<String, String>() {{ put(projectReferenced.getName(), cfgDescriptionReferenced.getId()); }});
+ coreModel.setProjectDescription(project, projectDescription);
+ }
+
+ {
+ // doublecheck that it's set as expected
+ ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
+ ICConfigurationDescription cfgDescription = cfgDescriptions[0];
+ Map<String,String> refs = cfgDescription.getReferenceInfo();
+ assertEquals(1, refs.size());
+ Set<String> referencedProjectsNames = new LinkedHashSet<String>(refs.keySet());
+ assertEquals(projectReferenced.getName(), referencedProjectsNames.toArray()[0]);
+ }
+
+ }
+
+ /**
+ * Test that null arguments don't crash the provider.
+ */
+ public void testNulls() throws Exception {
+ ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
+ assertNotNull(provider);
+ List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
+ assertEquals(null, entries);
+ }
+
+ /**
+ * Test main functionality of ReferencedProjectsLanguageSettingsProvider.
+ */
+ public void testReferencedProjectProvider() throws Exception {
+ // Create model project and accompanied descriptions
+ String projectName = getName();
+ IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
+ IProject nonReferencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-non-referenced");
+ IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-referenced");
+ setReference(project, referencedProject);
+
+ // get cfgDescription
+ ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
+ ICConfigurationDescription cfgDescription = cfgDescriptions[0];
+
+ {
+ // double-check that provider for referenced projects is set in the configuration
+ ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
+ assertNotNull(refProjectsProvider);
+ List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
+ assertTrue(providers.contains(refProjectsProvider));
+ }
+
+ // Check that no setting entries are set initially
+ {
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
+ assertEquals(0, entries.size());
+ }
+
+ // Add an entry into a non-referenced project
+ CIncludePathEntry nonRefEntry = CDataUtil.createCIncludePathEntry("non-referenced-exported", ICSettingEntry.EXPORTED);
+ {
+ ICConfigurationDescription[] nonRefCfgDescriptions = getConfigurationDescriptions(nonReferencedProject);
+ ICConfigurationDescription nonRefCfgDescription = nonRefCfgDescriptions[0];
+ List<ILanguageSettingsProvider> providersNonRef = ((ILanguageSettingsProvidersKeeper) nonRefCfgDescription).getLanguageSettingProviders();
+ // get user provider which is the first one
+ ILanguageSettingsProvider userProviderNonRef = providersNonRef.get(0);
+ assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderNonRef.getId());
+ assertTrue(userProviderNonRef instanceof LanguageSettingsGenericProvider);
+ // add sample entries
+ ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(nonRefEntry);
+ ((LanguageSettingsGenericProvider) userProviderNonRef).setSettingEntries(null, null, null, entries);
+ }
+ // Confirm that that does not add entries to the main project
+ {
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
+ assertEquals(0, entries.size());
+ }
+
+ CIncludePathEntry refEntry = CDataUtil.createCIncludePathEntry("referenced-exported", ICSettingEntry.EXPORTED);
+ // Add entries into a referenced project
+ {
+ ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(referencedProject);
+ ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
+ List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
+ // get user provider which is the first one
+ ILanguageSettingsProvider userProviderRef = providersRef.get(0);
+ assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
+ assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider);
+ // add sample entries
+ ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ CIncludePathEntry refEntryNotExported = CDataUtil.createCIncludePathEntry("referenced-not-exported", 0);
+ entries.add(refEntry);
+ entries.add(refEntryNotExported);
+ ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
+ List<ICLanguageSettingEntry> entriesActual = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, project, null, ICSettingEntry.ALL);
+ assertEquals(entries, entriesActual);
+ }
+ // Check that the new entries from referenced project made it to the main project
+ {
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL);
+ assertEquals(CDataUtil.createCIncludePathEntry(refEntry.getName(), 0), entries.get(0));
+ assertEquals(1, entries.size());
+ }
+ }
+
+ /**
+ * Test case when projects reference each other recursively.
+ */
+ public void testRecursiveReferences() throws Exception {
+ // Create model projects that reference each other
+ String projectName = getName();
+ IProject projectA = ResourceHelper.createCDTProjectWithConfig(projectName + "-A");
+ IProject projectB = ResourceHelper.createCDTProjectWithConfig(projectName + "-B");
+ setReference(projectA, projectB);
+ setReference(projectB, projectA);
+
+ {
+ // get cfgDescriptions to work with
+ ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA);
+ ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0];
+ ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB);
+ ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0];
+ // double-check that provider for referenced projects is set in the configurations
+ ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID);
+ assertNotNull(refProjectsProvider);
+ List<ILanguageSettingsProvider> providersA = ((ILanguageSettingsProvidersKeeper) cfgDescriptionA).getLanguageSettingProviders();
+ assertTrue(providersA.contains(refProjectsProvider));
+ List<ILanguageSettingsProvider> providersB = ((ILanguageSettingsProvidersKeeper) cfgDescriptionB).getLanguageSettingProviders();
+ assertTrue(providersB.contains(refProjectsProvider));
+
+ // Check that no setting entries are set initially
+ List<ICLanguageSettingEntry> entriesA = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL);
+ assertEquals(0, entriesA.size());
+ List<ICLanguageSettingEntry> entriesB = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectB, null, ICSettingEntry.ALL);
+ assertEquals(0, entriesB.size());
+ }
+
+ CIncludePathEntry entryExportedA = CDataUtil.createCIncludePathEntry("referenced-exported-A", ICSettingEntry.EXPORTED);
+ CIncludePathEntry entryNotExportedA = CDataUtil.createCIncludePathEntry("referenced-not-exported-A", 0);
+ // Add entries into a project A
+ {
+ ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectA);
+ ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
+ List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
+ // get user provider which is the first one
+ ILanguageSettingsProvider userProviderRef = providersRef.get(0);
+ assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
+ assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider);
+ // add sample entries
+ ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(entryExportedA);
+ entries.add(entryNotExportedA);
+ ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
+ }
+
+ CIncludePathEntry entryExportedB = CDataUtil.createCIncludePathEntry("referenced-exported-B", ICSettingEntry.EXPORTED);
+ CIncludePathEntry entryNotExportedB = CDataUtil.createCIncludePathEntry("referenced-not-exported-B", 0);
+ // Add entries into a project B
+ {
+ ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectB);
+ ICConfigurationDescription refCfgDescription = refCfgDescriptions[0];
+ List<ILanguageSettingsProvider> providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders();
+ // get user provider which is the first one
+ ILanguageSettingsProvider userProviderRef = providersRef.get(0);
+ assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId());
+ assertTrue(userProviderRef instanceof LanguageSettingsGenericProvider);
+ // add sample entries
+ ArrayList<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(entryExportedB);
+ entries.add(entryNotExportedB);
+ ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries);
+ }
+
+ // Check that the new entries from projectB made it to projectA
+ {
+ ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA);
+ ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0];
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL);
+ assertEquals(entryExportedA, entries.get(0));
+ assertEquals(entryNotExportedA, entries.get(1));
+ assertEquals(CDataUtil.createCIncludePathEntry(entryExportedB.getName(), 0), entries.get(2));
+ assertEquals(3, entries.size());
+ }
+ // Check that the new entries from projectA made it to projectB
+ {
+ ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB);
+ ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0];
+ List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionB, projectB, null, ICSettingEntry.ALL);
+ assertEquals(entryExportedB, entries.get(0));
+ assertEquals(entryNotExportedB, entries.get(1));
+ assertEquals(CDataUtil.createCIncludePathEntry(entryExportedA.getName(), 0), entries.get(2));
+ assertEquals(3, entries.size());
+ }
+
+ // Hopefully it gets here without stack overflow
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java
index 72ee4c50cfe..9d9bce06f51 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java
@@ -1,958 +1,958 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Andrew Gvozdev 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 Gvozdev - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.LanguageManager;
-import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
-import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
-import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
-import org.eclipse.cdt.core.settings.model.CMacroEntry;
-import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICFolderDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
-import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.testplugin.ResourceHelper;
-import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
-import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider;
-import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * Test cases testing LanguageSettingsProvider functionality
- */
-public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
- private static final IFile FAKE_FILE = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0"));
- private static final String PROVIDER_ID = "test.provider.id";
- private static final String PROVIDER_ID_2 = "test.provider.id.2";
- private static final String PROVIDER_NAME = "test.provider.name";
-
- // constants for getProjectDescription()
- private static final boolean READ_ONLY = false;
- private static final boolean WRITEABLE = true;
-
- private class MockProvider extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
- private final List<ICLanguageSettingEntry> entries;
-
- public MockProvider(String id, String name, List<ICLanguageSettingEntry> entries) {
- super(id, name);
- this.entries = entries;
- }
-
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- return entries;
- }
- }
-
- /**
- * Constructor.
- * @param name - name of the test.
- */
- public LanguageSettingsScannerInfoProviderTests(String name) {
- super(name);
-
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown(); // includes ResourceHelper cleanup
- }
-
- /**
- * @return - new TestSuite.
- */
- public static TestSuite suite() {
- return new TestSuite(LanguageSettingsScannerInfoProviderTests.class);
- }
-
- /**
- * main function of the class.
- *
- * @param args - arguments
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Sets build working directory for DefaultSettingConfiguration being tested.
- */
- private void setBuilderCWD(IProject project, IPath buildCWD) throws CoreException {
- CProjectDescriptionManager manager = CProjectDescriptionManager.getInstance();
- {
- ICProjectDescription prjDescription = manager.getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
-
- cfgDescription.getBuildSetting().setBuilderCWD(buildCWD);
- manager.setProjectDescription(project, prjDescription);
- // doublecheck builderCWD
- IPath actualBuildCWD = cfgDescription.getBuildSetting().getBuilderCWD();
- assertEquals(buildCWD, actualBuildCWD);
- }
- {
- // triplecheck builderCWD for different project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
-
- }
- }
-
- /**
- * Test cases when some objects are null.
- */
- public void testNulls() throws Exception {
- {
- // Handle project==null
- IResource root = ResourcesPlugin.getWorkspace().getRoot();
- assertNull(root.getProject());
-
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(root);
- assertEquals(0, info.getIncludePaths().length);
- assertEquals(0, info.getDefinedSymbols().size());
- assertEquals(0, info.getIncludeFiles().length);
- assertEquals(0, info.getMacroFiles().length);
- assertEquals(0, info.getLocalIncludePath().length);
- }
-
- {
- // Handle prjDescription==null
- IProject project = FAKE_FILE.getProject();
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
- assertNull(prjDescription);
-
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(FAKE_FILE);
- assertEquals(0, info.getIncludePaths().length);
- assertEquals(0, info.getDefinedSymbols().size());
- assertEquals(0, info.getIncludeFiles().length);
- assertEquals(0, info.getMacroFiles().length);
- assertEquals(0, info.getLocalIncludePath().length);
- }
-
- {
- // Handle language==null
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFile file = ResourceHelper.createFile(project, "file");
-
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
- assertNull(language);
-
- // AG FIXME - temporarily ignore the entry in the log
- setExpectedNumberOfLoggedNonOKStatusObjects(1);
-
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- assertEquals(0, info.getIncludePaths().length);
- assertEquals(0, info.getDefinedSymbols().size());
- assertEquals(0, info.getIncludeFiles().length);
- assertEquals(0, info.getMacroFiles().length);
- assertEquals(0, info.getLocalIncludePath().length);
- }
- }
-
- /**
- * Test empty scanner info.
- */
- public void testEmpty() throws Exception {
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // confirm that language==null
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
- assertNotNull(language);
-
- // test that the info is empty
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- assertEquals(0, info.getIncludePaths().length);
- assertEquals(0, info.getDefinedSymbols().size());
- assertEquals(0, info.getIncludeFiles().length);
- assertEquals(0, info.getMacroFiles().length);
- assertEquals(0, info.getLocalIncludePath().length);
- }
-
- /**
- * Test regular cases.
- */
- public void testRegular() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // sanity test of language
- ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
- assertNotNull(language);
-
- // contribute the entries
- IFolder includeFolder = ResourceHelper.createFolder(project, "/include-path");
- IFolder includeLocalFolder = ResourceHelper.createFolder(project, "/local-include-path");
- IFile macroFile = ResourceHelper.createFile(project, "macro-file");
- IFile includeFile = ResourceHelper.createFile(project, "include-file");
-
- CIncludePathEntry includePathEntry = new CIncludePathEntry(includeFolder, 0);
- CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(includeLocalFolder, ICSettingEntry.LOCAL); // #include "..."
- CMacroEntry macroEntry = new CMacroEntry("MACRO", "value",0);
- CIncludeFileEntry includeFileEntry = new CIncludeFileEntry(includeFile, 0);
- CMacroFileEntry macroFileEntry = new CMacroFileEntry(macroFile, 0);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(includePathEntry);
- entries.add(includeLocalPathEntry);
- entries.add(macroEntry);
- entries.add(includeFileEntry);
- entries.add(macroFileEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- Map<String, String> actualDefinedSymbols = info.getDefinedSymbols();
- String[] actualIncludeFiles = info.getIncludeFiles();
- String[] actualMacroFiles = info.getMacroFiles();
- String[] actualLocalIncludePath = info.getLocalIncludePath();
- // include paths
- assertEquals(includeFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- // macros
- assertEquals(macroEntry.getValue(), actualDefinedSymbols.get(macroEntry.getName()));
- assertEquals(1, actualDefinedSymbols.size());
- // include file
- assertEquals(includeFile.getLocation(), new Path(actualIncludeFiles[0]));
- assertEquals(1, actualIncludeFiles.length);
- // macro file
- assertEquals(macroFile.getLocation(), new Path(actualMacroFiles[0]));
- assertEquals(1, actualMacroFiles.length);
- // local include files
- assertEquals(includeLocalFolder.getLocation(), new Path(actualLocalIncludePath[0]));
- assertEquals(1, actualLocalIncludePath.length);
- }
-
- /**
- * Test "local" flag (#include "...").
- */
- public void testLocal() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- IFolder incFolder = ResourceHelper.createFolder(project, "include");
- IFolder incFolder2 = ResourceHelper.createFolder(project, "include2");
- CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
- CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
- CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder2, ICSettingEntry.LOCAL); // #include "..."
- CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder2, 0);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(includePathEntry);
- entries.add(includeLocalPathEntry);
- // reverse order for incPath2
- entries.add(includeLocalPathEntry2);
- entries.add(includePathEntry2);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- String[] actualLocalIncludePath = info.getLocalIncludePath();
- // include paths
- assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(incFolder2.getLocation(), new Path(actualIncludePaths[1]));
- assertEquals(2, actualIncludePaths.length);
- // local include files
- assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0]));
- assertEquals(incFolder2.getLocation(), new Path(actualLocalIncludePath[1]));
- assertEquals(2, actualLocalIncludePath.length);
- }
-
- /**
- * Test Mac frameworks.
- */
- public void testFramework() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- IFolder frameworkFolder = ResourceHelper.createFolder(project, "Fmwk");
- CIncludePathEntry frameworkPathEntry = new CIncludePathEntry(frameworkFolder, ICSettingEntry.FRAMEWORKS_MAC);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(frameworkPathEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- // include paths
- assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/Headers/__header__"),
- new Path(actualIncludePaths[0]));
- assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/PrivateHeaders/__header__"),
- new Path(actualIncludePaths[1]));
- assertEquals(2, actualIncludePaths.length);
- }
-
- /**
- * Test duplicate entries.
- */
- public void testDuplicate() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- IFolder incFolder = ResourceHelper.createFolder(project, "include");
- CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
- CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
- CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder, 0);
- CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(includePathEntry);
- entries.add(includeLocalPathEntry);
- entries.add(includePathEntry2);
- entries.add(includeLocalPathEntry2);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- String[] actualLocalIncludePath = info.getLocalIncludePath();
- // include paths
- assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- // local include files
- assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0]));
- assertEquals(1, actualLocalIncludePath.length);
- }
-
- /**
- * Test include path managed by eclipse as a workspace path.
- */
- public void testWorkspacePath() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
- // eclipse-managed folder in workspace
- IFolder incWorkspace_1 = ResourceHelper.createFolder(project, "include_1");
- IPath incWorkspaceLocation_1 = incWorkspace_1.getLocation();
- IFolder incWorkspace_2 = ResourceHelper.createFolder(project, "include_2");
- IPath incWorkspacePath_2 = incWorkspace_2.getFullPath();
- IPath incWorkspaceLocation_2 = incWorkspace_2.getLocation();
- IFolder incWorkspace_3 = ResourceHelper.createFolder(project, "include_3");
- // "relative" should make no difference for VALUE_WORKSPACE_PATH
- IPath incWorkspaceRelativePath_3 = incWorkspace_3.getFullPath().makeRelative();
- IPath incWorkspaceLocation_3 = incWorkspace_3.getLocation();
- // not having "RESOLVED" should make no difference for well formed path
- IFolder incWorkspace_4 = ResourceHelper.createFolder(project, "include_4");
- IPath incWorkspacePathNoResolved_4 = incWorkspace_4.getFullPath();
- IPath incWorkspaceLocation_4 = incWorkspace_4.getLocation();
- // folder defined by absolute path on the filesystem
- IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem");
-
- // contribute the entries
- CIncludePathEntry incWorkspaceEntry_1 = new CIncludePathEntry(incWorkspace_1, 0);
- CIncludePathEntry incWorkspaceEntry_2 = new CIncludePathEntry(incWorkspacePath_2, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
- CIncludePathEntry incWorkspaceEntry_3 = new CIncludePathEntry(incWorkspaceRelativePath_3, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
- CIncludePathEntry incWorkspaceEntry_4 = new CIncludePathEntry(incWorkspacePathNoResolved_4, ICSettingEntry.VALUE_WORKSPACE_PATH);
- CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incWorkspaceEntry_1);
- entries.add(incWorkspaceEntry_2);
- entries.add(incWorkspaceEntry_3);
- entries.add(incWorkspaceEntry_4);
- entries.add(incFilesystemEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- assertEquals(incWorkspaceLocation_1, new Path(actualIncludePaths[0]));
- assertEquals(incWorkspaceLocation_2, new Path(actualIncludePaths[1]));
- assertEquals(incWorkspaceLocation_3, new Path(actualIncludePaths[2]));
- assertEquals(incWorkspaceLocation_4, new Path(actualIncludePaths[3]));
- assertEquals(incFilesystem, new Path(actualIncludePaths[4]));
- assertEquals(5, actualIncludePaths.length);
-
- }
-
- /**
- * Confirm that device letter is prepended on filesystems that support that.
- */
- public void testFilesystemPathNoDriveLetter() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- // change drive on build working directory
- String buildCwdDevice = project.getLocation().getDevice();
-
-// // Test manually with a device which is different from project location device (path should exist)
-// IPath buildCWD = new Path("D:/build/path");
-// String buildCwdDevice = buildCWD.getDevice();
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- // no-drive-letter folder defined by absolute path on the filesystem
- IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem").setDevice(null);
- CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incFilesystemEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- IPath expectedInclude = incFilesystem.setDevice(buildCwdDevice);
- assertEquals(expectedInclude, new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- }
-
- /**
- * Test relative paths.
- */
- public void testRelativePath() throws Exception {
- // create a project
- String prjName = getName();
- IProject project = ResourceHelper.createCDTProjectWithConfig(prjName);
- String relativePath = "include";
- IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
- IFolder relativeFolder = ResourceHelper.createFolder(project, "buildDir/"+relativePath);
- IFolder relativeFolderProjName = ResourceHelper.createFolder(project, "buildDir/"+prjName);
- String markedResolved = "-MarkedResolved";
- IFolder relativeFolderProjNameResolved = ResourceHelper.createFolder(project, "buildDir/" + prjName+markedResolved);
- IPath buildCWD=buildFolder.getLocation();
- setBuilderCWD(project, buildCWD);
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- CIncludePathEntry incRelativeEntry = new CIncludePathEntry(new Path(relativePath), 0);
- CIncludePathEntry incProjNameEntry = new CIncludePathEntry(new Path("${ProjName}"), 0);
- CIncludePathEntry incProjNameMarkedResolvedEntry = new CIncludePathEntry(new Path("${ProjName}"+markedResolved), ICSettingEntry.RESOLVED);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incRelativeEntry);
- entries.add(incProjNameEntry);
- entries.add(incProjNameMarkedResolvedEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- // pair of entries, one from build dir another relative path
- assertEquals(relativeFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(new Path(relativePath), new Path(actualIncludePaths[1]));
-
- // pair of entries, one resolved from build dir another expanded relative path
- assertEquals(relativeFolderProjName.getLocation(), new Path(actualIncludePaths[2]));
- assertEquals(new Path(prjName), new Path(actualIncludePaths[3]));
-
- // if marked RESOLVED only that path stays
- assertEquals(new Path("${ProjName}"+markedResolved), new Path(actualIncludePaths[4]));
-
- assertEquals(5, actualIncludePaths.length);
- }
-
- /**
- * Test relative paths - some combinations of dot paths.
- */
- public void testRelativePathWithDots() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- // set build CWD
- IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
- IPath buildCWD=buildFolder.getLocation();
- setBuilderCWD(project, buildCWD);
-
- // define a few variations of paths
- String relativePath_dot = ".";
- String relativePath_dot_slash = "./";
- String relativePath_dot_slash_path = "./include";
- IFolder relativeFolder_dot_slash_path = ResourceHelper.createFolder(project, "buildDir/include");
- String relativePath_dotdot = "..";
- String relativePath_dotdot_slash = "../";
- String relativePath_dotdot_slash_path = "../include";
- IFolder relativeFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include");
- String locationPath_dotdot_path = buildCWD.toString()+"/../include2";
- IFolder incFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include2"); // "/ProjPath/buildDir/../include2"
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- CIncludePathEntry incRelativeEntry_dot = new CIncludePathEntry(new Path(relativePath_dot), 0);
- CIncludePathEntry incRelativeEntry_dot_slash_path = new CIncludePathEntry(new Path(relativePath_dot_slash_path), 0);
- CIncludePathEntry incRelativeEntry_dotdot = new CIncludePathEntry(new Path(relativePath_dotdot), 0);
- CIncludePathEntry incRelativeEntry_dotdot_slash_path = new CIncludePathEntry(new Path(relativePath_dotdot_slash_path), 0);
- CIncludePathEntry incEntry_dotdot_path = new CIncludePathEntry(locationPath_dotdot_path, 0);
- // use LOCAL flag not to clash with plain dot entries
- CIncludePathEntry incRelativeEntry_dotdot_slash = new CIncludePathEntry(new Path(relativePath_dotdot_slash), ICSettingEntry.LOCAL);
- CIncludePathEntry incRelativeEntry_dot_slash = new CIncludePathEntry(new Path(relativePath_dot_slash), ICSettingEntry.LOCAL);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incRelativeEntry_dot);
- entries.add(incRelativeEntry_dot_slash);
- entries.add(incRelativeEntry_dot_slash_path);
- entries.add(incRelativeEntry_dotdot);
- entries.add(incRelativeEntry_dotdot_slash);
- entries.add(incRelativeEntry_dotdot_slash_path);
- entries.add(incEntry_dotdot_path);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- String[] actualLocalIncludePaths = info.getLocalIncludePath();
-
- IPath expectedLocation_dot = buildFolder.getLocation();
- IPath expectedLocation_dot_slash = buildFolder.getLocation();
- IPath expectedLocation_dot_slash_path = relativeFolder_dot_slash_path.getLocation();
- IPath expectedLocation_dotdot = project.getLocation();
- IPath expectedLocation_dotdot_slash = project.getLocation();
- IPath expectedLocation_dotdot_slash_path = relativeFolder_dotdot_slash_path.getLocation();
-
- assertEquals(expectedLocation_dot, new Path(actualIncludePaths[0]));
- assertEquals(".", actualIncludePaths[1]);
- assertEquals(expectedLocation_dot_slash_path, new Path(actualIncludePaths[2]));
- assertEquals(new Path(relativePath_dot_slash_path), new Path(actualIncludePaths[3]));
-
- assertEquals(expectedLocation_dotdot, new Path(actualIncludePaths[4]));
- assertEquals("..", actualIncludePaths[5]);
- assertEquals(expectedLocation_dotdot_slash_path, new Path(actualIncludePaths[6]));
- assertEquals(new Path(relativePath_dotdot_slash_path), new Path(actualIncludePaths[7]));
- assertTrue(actualIncludePaths[7].startsWith(".."));
- assertEquals(new Path(locationPath_dotdot_path), new Path(actualIncludePaths[8]));
- assertTrue(actualIncludePaths[8].contains(".."));
- assertEquals(9, actualIncludePaths.length);
-
- assertEquals(expectedLocation_dot_slash, new Path(actualLocalIncludePaths[0]));
- assertEquals(new Path(relativePath_dot_slash), new Path(actualLocalIncludePaths[1]));
- assertTrue(actualLocalIncludePaths[1].startsWith("."));
- assertEquals(expectedLocation_dotdot_slash, new Path(actualLocalIncludePaths[2]));
- assertEquals(new Path(relativePath_dotdot_slash), new Path(actualLocalIncludePaths[3]));
- assertTrue(actualLocalIncludePaths[3].startsWith(".."));
- assertEquals(4, actualLocalIncludePaths.length);
- }
-
- /**
- * Test if build/environment variables are expanded
- */
- public void testEnvironmentVars() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFolder folder = ResourceHelper.createFolder(project, "Folder");
- String envPathStr = "${ProjDirPath}/Folder";
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, 0);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incRelativeEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- IPath expectedLocation = folder.getLocation();
- assertEquals(expectedLocation, new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- }
-
- /**
- * Test from parent folder's entries.
- */
- public void testParentFolder() throws Exception {
- class MockProviderForResource extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
- private IResource rc;
- private final List<ICLanguageSettingEntry> entries;
-
- public MockProviderForResource(IResource rc, List<ICLanguageSettingEntry> entries) {
- this.rc = rc;
- this.entries = entries;
- }
-
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (this.rc.equals(rc))
- return entries;
- return null;
- }
- }
-
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // sample file
- IFolder parentFolder = ResourceHelper.createFolder(project, "ParentFolder");
- IFile file = ResourceHelper.createFile(project, "ParentFolder/file.c");
-
- // contribute the entries
- IFolder incFolder = ResourceHelper.createFolder(project, "include");
- CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
-
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(includePathEntry);
-
- // add provider for parent folder
- ILanguageSettingsProvider provider = new MockProviderForResource(parentFolder, entries);
- assertNull(provider.getSettingEntries(cfgDescription, file, null));
- assertEquals(includePathEntry, provider.getSettingEntries(cfgDescription, parentFolder, null).get(0));
-
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test that the scannerInfoProvider gets the entries for
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
- // include paths
- assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- }
-
- /**
- * Test resolved paths.
- */
- public void testResolvedPath() throws Exception {
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFolder folder = ResourceHelper.createFolder(project, "Folder");
- String envPathStr = "${ProjDirPath}/Folder";
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // create sample file
- IFile file = ResourceHelper.createFile(project, "file.c");
-
- // contribute the entries
- CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, ICSettingEntry.RESOLVED);
- List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
- entries.add(incRelativeEntry);
-
- // add provider to the configuration
- ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
- String[] actualIncludePaths = info.getIncludePaths();
-
- // test that RESOLVED entries are not modified
- IPath expectedLocation = new Path(envPathStr);
- assertEquals(expectedLocation, new Path(actualIncludePaths[0]));
- assertEquals(1, actualIncludePaths.length);
- }
-
- /**
- * Get languages for the folder.
- */
- private List<String> getLanguages(IFolder folder, ICConfigurationDescription cfgDescription) {
- IPath rcPath = folder.getProjectRelativePath();
- ICFolderDescription rcDes = (ICFolderDescription) cfgDescription.getResourceDescription(rcPath, false);
- ICLanguageSetting[] langSettings = rcDes.getLanguageSettings();
- assertNotNull(langSettings);
-
- List<String> languageIds = new ArrayList<String>();
- for (ICLanguageSetting ls : langSettings) {
- String langId = ls.getLanguageId();
- if (langId!=null && !languageIds.contains(langId)) {
- languageIds.add(langId);
- }
- }
- return languageIds;
- }
-
- /**
- * Test composition of 2 languages.
- */
- public void testResourceLanguages() throws Exception {
- class MockProviderLang extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
- private final String langId;
- private final List<ICLanguageSettingEntry> entries;
-
- public MockProviderLang(String id, String name, String langId, List<ICLanguageSettingEntry> entries) {
- super(id, name);
- this.langId = langId;
- this.entries = entries;
- }
-
- @Override
- public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
- if (langId==null || langId.equals(languageId))
- return entries;
- return new ArrayList<ICLanguageSettingEntry>();
- }
- }
-
- // create a project
- IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
- IFolder folder = ResourceHelper.createFolder(project, "Folder");
-
- IFolder incFolderA = ResourceHelper.createFolder(project, "includeA");
- IFolder incFolderB = ResourceHelper.createFolder(project, "includeB");
- IFolder incFolderC = ResourceHelper.createFolder(project, "includeC");
-
- // get project/configuration descriptions
- ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
- assertNotNull(prjDescription);
- ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
- assertNotNull(cfgDescription);
- assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
-
- // find 2 languages applicable to the folder
- List<String> languageIds = getLanguages(folder, cfgDescription);
- assertTrue(languageIds.size() >= 2);
- String langId1 = languageIds.get(0);
- String langId2 = languageIds.get(1);
-
- // define overlapping entries
- CIncludePathEntry incEntryA = new CIncludePathEntry(incFolderA, 0);
- CIncludePathEntry incEntryB = new CIncludePathEntry(incFolderB, 0);
- CIncludePathEntry incEntryC = new CIncludePathEntry(incFolderC, 0);
- List<ICLanguageSettingEntry> entries1 = new ArrayList<ICLanguageSettingEntry>();
- entries1.add(incEntryA);
- entries1.add(incEntryB);
- List<ICLanguageSettingEntry> entries2 = new ArrayList<ICLanguageSettingEntry>();
- entries2.add(incEntryC);
- entries2.add(incEntryB);
-
- // add providers to the configuration
- ILanguageSettingsProvider provider1 = new MockProviderLang(PROVIDER_ID, PROVIDER_NAME, langId1, entries1);
- ILanguageSettingsProvider provider2 = new MockProviderLang(PROVIDER_ID_2, PROVIDER_NAME, langId2, entries2);
- List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
- providers.add(provider1);
- providers.add(provider2);
- ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
-
- // set project description
- CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
-
- // test the entries received from the scannerInfoProvider
- LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
- ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(folder);
- String[] actualIncludePaths = info.getIncludePaths();
-
- // Test that the result is the union of entries
- assertEquals(incFolderA.getLocation(), new Path(actualIncludePaths[0]));
- assertEquals(incFolderB.getLocation(), new Path(actualIncludePaths[1]));
- assertEquals(incFolderC.getLocation(), new Path(actualIncludePaths[2]));
- assertEquals(3, actualIncludePaths.length);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Andrew Gvozdev 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 Gvozdev - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.language.settings.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestSuite;
+
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.testplugin.ResourceHelper;
+import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
+import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider;
+import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * Test cases testing LanguageSettingsProvider functionality
+ */
+public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
+ private static final IFile FAKE_FILE = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0"));
+ private static final String PROVIDER_ID = "test.provider.id";
+ private static final String PROVIDER_ID_2 = "test.provider.id.2";
+ private static final String PROVIDER_NAME = "test.provider.name";
+
+ // constants for getProjectDescription()
+ private static final boolean READ_ONLY = false;
+ private static final boolean WRITEABLE = true;
+
+ private class MockProvider extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
+ private final List<ICLanguageSettingEntry> entries;
+
+ public MockProvider(String id, String name, List<ICLanguageSettingEntry> entries) {
+ super(id, name);
+ this.entries = entries;
+ }
+
+ @Override
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ return entries;
+ }
+ }
+
+ /**
+ * Constructor.
+ * @param name - name of the test.
+ */
+ public LanguageSettingsScannerInfoProviderTests(String name) {
+ super(name);
+
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown(); // includes ResourceHelper cleanup
+ }
+
+ /**
+ * @return - new TestSuite.
+ */
+ public static TestSuite suite() {
+ return new TestSuite(LanguageSettingsScannerInfoProviderTests.class);
+ }
+
+ /**
+ * main function of the class.
+ *
+ * @param args - arguments
+ */
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Sets build working directory for DefaultSettingConfiguration being tested.
+ */
+ private void setBuilderCWD(IProject project, IPath buildCWD) throws CoreException {
+ CProjectDescriptionManager manager = CProjectDescriptionManager.getInstance();
+ {
+ ICProjectDescription prjDescription = manager.getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+
+ cfgDescription.getBuildSetting().setBuilderCWD(buildCWD);
+ manager.setProjectDescription(project, prjDescription);
+ // doublecheck builderCWD
+ IPath actualBuildCWD = cfgDescription.getBuildSetting().getBuilderCWD();
+ assertEquals(buildCWD, actualBuildCWD);
+ }
+ {
+ // triplecheck builderCWD for different project/configuration descriptions
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+
+ }
+ }
+
+ /**
+ * Test cases when some objects are null.
+ */
+ public void testNulls() throws Exception {
+ {
+ // Handle project==null
+ IResource root = ResourcesPlugin.getWorkspace().getRoot();
+ assertNull(root.getProject());
+
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(root);
+ assertEquals(0, info.getIncludePaths().length);
+ assertEquals(0, info.getDefinedSymbols().size());
+ assertEquals(0, info.getIncludeFiles().length);
+ assertEquals(0, info.getMacroFiles().length);
+ assertEquals(0, info.getLocalIncludePath().length);
+ }
+
+ {
+ // Handle prjDescription==null
+ IProject project = FAKE_FILE.getProject();
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
+ assertNull(prjDescription);
+
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(FAKE_FILE);
+ assertEquals(0, info.getIncludePaths().length);
+ assertEquals(0, info.getDefinedSymbols().size());
+ assertEquals(0, info.getIncludeFiles().length);
+ assertEquals(0, info.getMacroFiles().length);
+ assertEquals(0, info.getLocalIncludePath().length);
+ }
+
+ {
+ // Handle language==null
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ IFile file = ResourceHelper.createFile(project, "file");
+
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
+ assertNull(language);
+
+ // AG FIXME - temporarily ignore the entry in the log
+ setExpectedNumberOfLoggedNonOKStatusObjects(1);
+
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ assertEquals(0, info.getIncludePaths().length);
+ assertEquals(0, info.getDefinedSymbols().size());
+ assertEquals(0, info.getIncludeFiles().length);
+ assertEquals(0, info.getMacroFiles().length);
+ assertEquals(0, info.getLocalIncludePath().length);
+ }
+ }
+
+ /**
+ * Test empty scanner info.
+ */
+ public void testEmpty() throws Exception {
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // confirm that language==null
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
+ assertNotNull(language);
+
+ // test that the info is empty
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ assertEquals(0, info.getIncludePaths().length);
+ assertEquals(0, info.getDefinedSymbols().size());
+ assertEquals(0, info.getIncludeFiles().length);
+ assertEquals(0, info.getMacroFiles().length);
+ assertEquals(0, info.getLocalIncludePath().length);
+ }
+
+ /**
+ * Test regular cases.
+ */
+ public void testRegular() throws Exception {
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // sanity test of language
+ ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
+ assertNotNull(language);
+
+ // contribute the entries
+ IFolder includeFolder = ResourceHelper.createFolder(project, "/include-path");
+ IFolder includeLocalFolder = ResourceHelper.createFolder(project, "/local-include-path");
+ IFile macroFile = ResourceHelper.createFile(project, "macro-file");
+ IFile includeFile = ResourceHelper.createFile(project, "include-file");
+
+ CIncludePathEntry includePathEntry = new CIncludePathEntry(includeFolder, 0);
+ CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(includeLocalFolder, ICSettingEntry.LOCAL); // #include "..."
+ CMacroEntry macroEntry = new CMacroEntry("MACRO", "value",0);
+ CIncludeFileEntry includeFileEntry = new CIncludeFileEntry(includeFile, 0);
+ CMacroFileEntry macroFileEntry = new CMacroFileEntry(macroFile, 0);
+
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(includePathEntry);
+ entries.add(includeLocalPathEntry);
+ entries.add(macroEntry);
+ entries.add(includeFileEntry);
+ entries.add(macroFileEntry);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test that the scannerInfoProvider gets the entries
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+ Map<String, String> actualDefinedSymbols = info.getDefinedSymbols();
+ String[] actualIncludeFiles = info.getIncludeFiles();
+ String[] actualMacroFiles = info.getMacroFiles();
+ String[] actualLocalIncludePath = info.getLocalIncludePath();
+ // include paths
+ assertEquals(includeFolder.getLocation(), new Path(actualIncludePaths[0]));
+ assertEquals(1, actualIncludePaths.length);
+ // macros
+ assertEquals(macroEntry.getValue(), actualDefinedSymbols.get(macroEntry.getName()));
+ assertEquals(1, actualDefinedSymbols.size());
+ // include file
+ assertEquals(includeFile.getLocation(), new Path(actualIncludeFiles[0]));
+ assertEquals(1, actualIncludeFiles.length);
+ // macro file
+ assertEquals(macroFile.getLocation(), new Path(actualMacroFiles[0]));
+ assertEquals(1, actualMacroFiles.length);
+ // local include files
+ assertEquals(includeLocalFolder.getLocation(), new Path(actualLocalIncludePath[0]));
+ assertEquals(1, actualLocalIncludePath.length);
+ }
+
+ /**
+ * Test "local" flag (#include "...").
+ */
+ public void testLocal() throws Exception {
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // contribute the entries
+ IFolder incFolder = ResourceHelper.createFolder(project, "include");
+ IFolder incFolder2 = ResourceHelper.createFolder(project, "include2");
+ CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
+ CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
+ CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder2, ICSettingEntry.LOCAL); // #include "..."
+ CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder2, 0);
+
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(includePathEntry);
+ entries.add(includeLocalPathEntry);
+ // reverse order for incPath2
+ entries.add(includeLocalPathEntry2);
+ entries.add(includePathEntry2);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test that the scannerInfoProvider gets the entries
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+ String[] actualLocalIncludePath = info.getLocalIncludePath();
+ // include paths
+ assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
+ assertEquals(incFolder2.getLocation(), new Path(actualIncludePaths[1]));
+ assertEquals(2, actualIncludePaths.length);
+ // local include files
+ assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0]));
+ assertEquals(incFolder2.getLocation(), new Path(actualLocalIncludePath[1]));
+ assertEquals(2, actualLocalIncludePath.length);
+ }
+
+ /**
+ * Test Mac frameworks.
+ */
+ public void testFramework() throws Exception {
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // contribute the entries
+ IFolder frameworkFolder = ResourceHelper.createFolder(project, "Fmwk");
+ CIncludePathEntry frameworkPathEntry = new CIncludePathEntry(frameworkFolder, ICSettingEntry.FRAMEWORKS_MAC);
+
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(frameworkPathEntry);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test that the scannerInfoProvider gets the entries
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+ // include paths
+ assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/Headers/__header__"),
+ new Path(actualIncludePaths[0]));
+ assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/PrivateHeaders/__header__"),
+ new Path(actualIncludePaths[1]));
+ assertEquals(2, actualIncludePaths.length);
+ }
+
+ /**
+ * Test duplicate entries.
+ */
+ public void testDuplicate() throws Exception {
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // contribute the entries
+ IFolder incFolder = ResourceHelper.createFolder(project, "include");
+ CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
+ CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
+ CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder, 0);
+ CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
+
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(includePathEntry);
+ entries.add(includeLocalPathEntry);
+ entries.add(includePathEntry2);
+ entries.add(includeLocalPathEntry2);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test that the scannerInfoProvider gets the entries
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+ String[] actualLocalIncludePath = info.getLocalIncludePath();
+ // include paths
+ assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
+ assertEquals(1, actualIncludePaths.length);
+ // local include files
+ assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0]));
+ assertEquals(1, actualLocalIncludePath.length);
+ }
+
+ /**
+ * Test include path managed by eclipse as a workspace path.
+ */
+ public void testWorkspacePath() throws Exception {
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // create sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+ // eclipse-managed folder in workspace
+ IFolder incWorkspace_1 = ResourceHelper.createFolder(project, "include_1");
+ IPath incWorkspaceLocation_1 = incWorkspace_1.getLocation();
+ IFolder incWorkspace_2 = ResourceHelper.createFolder(project, "include_2");
+ IPath incWorkspacePath_2 = incWorkspace_2.getFullPath();
+ IPath incWorkspaceLocation_2 = incWorkspace_2.getLocation();
+ IFolder incWorkspace_3 = ResourceHelper.createFolder(project, "include_3");
+ // "relative" should make no difference for VALUE_WORKSPACE_PATH
+ IPath incWorkspaceRelativePath_3 = incWorkspace_3.getFullPath().makeRelative();
+ IPath incWorkspaceLocation_3 = incWorkspace_3.getLocation();
+ // not having "RESOLVED" should make no difference for well formed path
+ IFolder incWorkspace_4 = ResourceHelper.createFolder(project, "include_4");
+ IPath incWorkspacePathNoResolved_4 = incWorkspace_4.getFullPath();
+ IPath incWorkspaceLocation_4 = incWorkspace_4.getLocation();
+ // folder defined by absolute path on the filesystem
+ IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem");
+
+ // contribute the entries
+ CIncludePathEntry incWorkspaceEntry_1 = new CIncludePathEntry(incWorkspace_1, 0);
+ CIncludePathEntry incWorkspaceEntry_2 = new CIncludePathEntry(incWorkspacePath_2, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
+ CIncludePathEntry incWorkspaceEntry_3 = new CIncludePathEntry(incWorkspaceRelativePath_3, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
+ CIncludePathEntry incWorkspaceEntry_4 = new CIncludePathEntry(incWorkspacePathNoResolved_4, ICSettingEntry.VALUE_WORKSPACE_PATH);
+ CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0);
+
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(incWorkspaceEntry_1);
+ entries.add(incWorkspaceEntry_2);
+ entries.add(incWorkspaceEntry_3);
+ entries.add(incWorkspaceEntry_4);
+ entries.add(incFilesystemEntry);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test the entries received from the scannerInfoProvider
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+
+ assertEquals(incWorkspaceLocation_1, new Path(actualIncludePaths[0]));
+ assertEquals(incWorkspaceLocation_2, new Path(actualIncludePaths[1]));
+ assertEquals(incWorkspaceLocation_3, new Path(actualIncludePaths[2]));
+ assertEquals(incWorkspaceLocation_4, new Path(actualIncludePaths[3]));
+ assertEquals(incFilesystem, new Path(actualIncludePaths[4]));
+ assertEquals(5, actualIncludePaths.length);
+
+ }
+
+ /**
+ * Confirm that device letter is prepended on filesystems that support that.
+ */
+ public void testFilesystemPathNoDriveLetter() throws Exception {
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ // change drive on build working directory
+ String buildCwdDevice = project.getLocation().getDevice();
+
+// // Test manually with a device which is different from project location device (path should exist)
+// IPath buildCWD = new Path("D:/build/path");
+// String buildCwdDevice = buildCWD.getDevice();
+
+ // get project/configuration descriptions
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // create sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // contribute the entries
+ // no-drive-letter folder defined by absolute path on the filesystem
+ IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem").setDevice(null);
+ CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0);
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(incFilesystemEntry);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test the entries received from the scannerInfoProvider
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+
+ IPath expectedInclude = incFilesystem.setDevice(buildCwdDevice);
+ assertEquals(expectedInclude, new Path(actualIncludePaths[0]));
+ assertEquals(1, actualIncludePaths.length);
+ }
+
+ /**
+ * Test relative paths.
+ */
+ public void testRelativePath() throws Exception {
+ // create a project
+ String prjName = getName();
+ IProject project = ResourceHelper.createCDTProjectWithConfig(prjName);
+ String relativePath = "include";
+ IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
+ IFolder relativeFolder = ResourceHelper.createFolder(project, "buildDir/"+relativePath);
+ IFolder relativeFolderProjName = ResourceHelper.createFolder(project, "buildDir/"+prjName);
+ String markedResolved = "-MarkedResolved";
+ IFolder relativeFolderProjNameResolved = ResourceHelper.createFolder(project, "buildDir/" + prjName+markedResolved);
+ IPath buildCWD=buildFolder.getLocation();
+ setBuilderCWD(project, buildCWD);
+
+ // get project/configuration descriptions
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // create sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // contribute the entries
+ CIncludePathEntry incRelativeEntry = new CIncludePathEntry(new Path(relativePath), 0);
+ CIncludePathEntry incProjNameEntry = new CIncludePathEntry(new Path("${ProjName}"), 0);
+ CIncludePathEntry incProjNameMarkedResolvedEntry = new CIncludePathEntry(new Path("${ProjName}"+markedResolved), ICSettingEntry.RESOLVED);
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(incRelativeEntry);
+ entries.add(incProjNameEntry);
+ entries.add(incProjNameMarkedResolvedEntry);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test the entries received from the scannerInfoProvider
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+
+ // pair of entries, one from build dir another relative path
+ assertEquals(relativeFolder.getLocation(), new Path(actualIncludePaths[0]));
+ assertEquals(new Path(relativePath), new Path(actualIncludePaths[1]));
+
+ // pair of entries, one resolved from build dir another expanded relative path
+ assertEquals(relativeFolderProjName.getLocation(), new Path(actualIncludePaths[2]));
+ assertEquals(new Path(prjName), new Path(actualIncludePaths[3]));
+
+ // if marked RESOLVED only that path stays
+ assertEquals(new Path("${ProjName}"+markedResolved), new Path(actualIncludePaths[4]));
+
+ assertEquals(5, actualIncludePaths.length);
+ }
+
+ /**
+ * Test relative paths - some combinations of dot paths.
+ */
+ public void testRelativePathWithDots() throws Exception {
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ // set build CWD
+ IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
+ IPath buildCWD=buildFolder.getLocation();
+ setBuilderCWD(project, buildCWD);
+
+ // define a few variations of paths
+ String relativePath_dot = ".";
+ String relativePath_dot_slash = "./";
+ String relativePath_dot_slash_path = "./include";
+ IFolder relativeFolder_dot_slash_path = ResourceHelper.createFolder(project, "buildDir/include");
+ String relativePath_dotdot = "..";
+ String relativePath_dotdot_slash = "../";
+ String relativePath_dotdot_slash_path = "../include";
+ IFolder relativeFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include");
+ String locationPath_dotdot_path = buildCWD.toString()+"/../include2";
+ IFolder incFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include2"); // "/ProjPath/buildDir/../include2"
+
+ // get project/configuration descriptions
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // create sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // contribute the entries
+ CIncludePathEntry incRelativeEntry_dot = new CIncludePathEntry(new Path(relativePath_dot), 0);
+ CIncludePathEntry incRelativeEntry_dot_slash_path = new CIncludePathEntry(new Path(relativePath_dot_slash_path), 0);
+ CIncludePathEntry incRelativeEntry_dotdot = new CIncludePathEntry(new Path(relativePath_dotdot), 0);
+ CIncludePathEntry incRelativeEntry_dotdot_slash_path = new CIncludePathEntry(new Path(relativePath_dotdot_slash_path), 0);
+ CIncludePathEntry incEntry_dotdot_path = new CIncludePathEntry(locationPath_dotdot_path, 0);
+ // use LOCAL flag not to clash with plain dot entries
+ CIncludePathEntry incRelativeEntry_dotdot_slash = new CIncludePathEntry(new Path(relativePath_dotdot_slash), ICSettingEntry.LOCAL);
+ CIncludePathEntry incRelativeEntry_dot_slash = new CIncludePathEntry(new Path(relativePath_dot_slash), ICSettingEntry.LOCAL);
+
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(incRelativeEntry_dot);
+ entries.add(incRelativeEntry_dot_slash);
+ entries.add(incRelativeEntry_dot_slash_path);
+ entries.add(incRelativeEntry_dotdot);
+ entries.add(incRelativeEntry_dotdot_slash);
+ entries.add(incRelativeEntry_dotdot_slash_path);
+ entries.add(incEntry_dotdot_path);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test the entries received from the scannerInfoProvider
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+ String[] actualLocalIncludePaths = info.getLocalIncludePath();
+
+ IPath expectedLocation_dot = buildFolder.getLocation();
+ IPath expectedLocation_dot_slash = buildFolder.getLocation();
+ IPath expectedLocation_dot_slash_path = relativeFolder_dot_slash_path.getLocation();
+ IPath expectedLocation_dotdot = project.getLocation();
+ IPath expectedLocation_dotdot_slash = project.getLocation();
+ IPath expectedLocation_dotdot_slash_path = relativeFolder_dotdot_slash_path.getLocation();
+
+ assertEquals(expectedLocation_dot, new Path(actualIncludePaths[0]));
+ assertEquals(".", actualIncludePaths[1]);
+ assertEquals(expectedLocation_dot_slash_path, new Path(actualIncludePaths[2]));
+ assertEquals(new Path(relativePath_dot_slash_path), new Path(actualIncludePaths[3]));
+
+ assertEquals(expectedLocation_dotdot, new Path(actualIncludePaths[4]));
+ assertEquals("..", actualIncludePaths[5]);
+ assertEquals(expectedLocation_dotdot_slash_path, new Path(actualIncludePaths[6]));
+ assertEquals(new Path(relativePath_dotdot_slash_path), new Path(actualIncludePaths[7]));
+ assertTrue(actualIncludePaths[7].startsWith(".."));
+ assertEquals(new Path(locationPath_dotdot_path), new Path(actualIncludePaths[8]));
+ assertTrue(actualIncludePaths[8].contains(".."));
+ assertEquals(9, actualIncludePaths.length);
+
+ assertEquals(expectedLocation_dot_slash, new Path(actualLocalIncludePaths[0]));
+ assertEquals(new Path(relativePath_dot_slash), new Path(actualLocalIncludePaths[1]));
+ assertTrue(actualLocalIncludePaths[1].startsWith("."));
+ assertEquals(expectedLocation_dotdot_slash, new Path(actualLocalIncludePaths[2]));
+ assertEquals(new Path(relativePath_dotdot_slash), new Path(actualLocalIncludePaths[3]));
+ assertTrue(actualLocalIncludePaths[3].startsWith(".."));
+ assertEquals(4, actualLocalIncludePaths.length);
+ }
+
+ /**
+ * Test if build/environment variables are expanded
+ */
+ public void testEnvironmentVars() throws Exception {
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ IFolder folder = ResourceHelper.createFolder(project, "Folder");
+ String envPathStr = "${ProjDirPath}/Folder";
+
+ // get project/configuration descriptions
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // create sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // contribute the entries
+ CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, 0);
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(incRelativeEntry);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test the entries received from the scannerInfoProvider
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+
+ IPath expectedLocation = folder.getLocation();
+ assertEquals(expectedLocation, new Path(actualIncludePaths[0]));
+ assertEquals(1, actualIncludePaths.length);
+ }
+
+ /**
+ * Test from parent folder's entries.
+ */
+ public void testParentFolder() throws Exception {
+ class MockProviderForResource extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
+ private IResource rc;
+ private final List<ICLanguageSettingEntry> entries;
+
+ public MockProviderForResource(IResource rc, List<ICLanguageSettingEntry> entries) {
+ this.rc = rc;
+ this.entries = entries;
+ }
+
+ @Override
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ if (this.rc.equals(rc))
+ return entries;
+ return null;
+ }
+ }
+
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // sample file
+ IFolder parentFolder = ResourceHelper.createFolder(project, "ParentFolder");
+ IFile file = ResourceHelper.createFile(project, "ParentFolder/file.c");
+
+ // contribute the entries
+ IFolder incFolder = ResourceHelper.createFolder(project, "include");
+ CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
+
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(includePathEntry);
+
+ // add provider for parent folder
+ ILanguageSettingsProvider provider = new MockProviderForResource(parentFolder, entries);
+ assertNull(provider.getSettingEntries(cfgDescription, file, null));
+ assertEquals(includePathEntry, provider.getSettingEntries(cfgDescription, parentFolder, null).get(0));
+
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test that the scannerInfoProvider gets the entries for
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+ // include paths
+ assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
+ assertEquals(1, actualIncludePaths.length);
+ }
+
+ /**
+ * Test resolved paths.
+ */
+ public void testResolvedPath() throws Exception {
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ IFolder folder = ResourceHelper.createFolder(project, "Folder");
+ String envPathStr = "${ProjDirPath}/Folder";
+
+ // get project/configuration descriptions
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // create sample file
+ IFile file = ResourceHelper.createFile(project, "file.c");
+
+ // contribute the entries
+ CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, ICSettingEntry.RESOLVED);
+ List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
+ entries.add(incRelativeEntry);
+
+ // add provider to the configuration
+ ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test the entries received from the scannerInfoProvider
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
+ String[] actualIncludePaths = info.getIncludePaths();
+
+ // test that RESOLVED entries are not modified
+ IPath expectedLocation = new Path(envPathStr);
+ assertEquals(expectedLocation, new Path(actualIncludePaths[0]));
+ assertEquals(1, actualIncludePaths.length);
+ }
+
+ /**
+ * Get languages for the folder.
+ */
+ private List<String> getLanguages(IFolder folder, ICConfigurationDescription cfgDescription) {
+ IPath rcPath = folder.getProjectRelativePath();
+ ICFolderDescription rcDes = (ICFolderDescription) cfgDescription.getResourceDescription(rcPath, false);
+ ICLanguageSetting[] langSettings = rcDes.getLanguageSettings();
+ assertNotNull(langSettings);
+
+ List<String> languageIds = new ArrayList<String>();
+ for (ICLanguageSetting ls : langSettings) {
+ String langId = ls.getLanguageId();
+ if (langId!=null && !languageIds.contains(langId)) {
+ languageIds.add(langId);
+ }
+ }
+ return languageIds;
+ }
+
+ /**
+ * Test composition of 2 languages.
+ */
+ public void testResourceLanguages() throws Exception {
+ class MockProviderLang extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
+ private final String langId;
+ private final List<ICLanguageSettingEntry> entries;
+
+ public MockProviderLang(String id, String name, String langId, List<ICLanguageSettingEntry> entries) {
+ super(id, name);
+ this.langId = langId;
+ this.entries = entries;
+ }
+
+ @Override
+ public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
+ if (langId==null || langId.equals(languageId))
+ return entries;
+ return new ArrayList<ICLanguageSettingEntry>();
+ }
+ }
+
+ // create a project
+ IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
+ IFolder folder = ResourceHelper.createFolder(project, "Folder");
+
+ IFolder incFolderA = ResourceHelper.createFolder(project, "includeA");
+ IFolder incFolderB = ResourceHelper.createFolder(project, "includeB");
+ IFolder incFolderC = ResourceHelper.createFolder(project, "includeC");
+
+ // get project/configuration descriptions
+ ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
+ assertNotNull(prjDescription);
+ ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+ assertNotNull(cfgDescription);
+ assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
+
+ // find 2 languages applicable to the folder
+ List<String> languageIds = getLanguages(folder, cfgDescription);
+ assertTrue(languageIds.size() >= 2);
+ String langId1 = languageIds.get(0);
+ String langId2 = languageIds.get(1);
+
+ // define overlapping entries
+ CIncludePathEntry incEntryA = new CIncludePathEntry(incFolderA, 0);
+ CIncludePathEntry incEntryB = new CIncludePathEntry(incFolderB, 0);
+ CIncludePathEntry incEntryC = new CIncludePathEntry(incFolderC, 0);
+ List<ICLanguageSettingEntry> entries1 = new ArrayList<ICLanguageSettingEntry>();
+ entries1.add(incEntryA);
+ entries1.add(incEntryB);
+ List<ICLanguageSettingEntry> entries2 = new ArrayList<ICLanguageSettingEntry>();
+ entries2.add(incEntryC);
+ entries2.add(incEntryB);
+
+ // add providers to the configuration
+ ILanguageSettingsProvider provider1 = new MockProviderLang(PROVIDER_ID, PROVIDER_NAME, langId1, entries1);
+ ILanguageSettingsProvider provider2 = new MockProviderLang(PROVIDER_ID_2, PROVIDER_NAME, langId2, entries2);
+ List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
+ providers.add(provider1);
+ providers.add(provider2);
+ ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
+
+ // set project description
+ CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
+
+ // test the entries received from the scannerInfoProvider
+ LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
+ ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(folder);
+ String[] actualIncludePaths = info.getIncludePaths();
+
+ // Test that the result is the union of entries
+ assertEquals(incFolderA.getLocation(), new Path(actualIncludePaths[0]));
+ assertEquals(incFolderB.getLocation(), new Path(actualIncludePaths[1]));
+ assertEquals(incFolderC.getLocation(), new Path(actualIncludePaths[2]));
+ assertEquals(3, actualIncludePaths.length);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java
index c39835629ec..d6887eb6e0a 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockListenerRegisterer.java
@@ -1,104 +1,104 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Andrew Gvozdev 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 Gvozdev - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.language.settings.providers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.core.runtime.Assert;
-
-/**
- * Mock Language Settings Provider that keeps count how many times it has been registered.
- */
-public class MockListenerRegisterer extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider, ICListenerAgent {
- private static MockListenerManager mockListenerManager = new MockListenerManager();
-
- private static class MockListenerManager {
- private class ListenerCount {
- private MockListenerRegisterer listener;
- private int count;
- public ListenerCount(MockListenerRegisterer l, int cnt) {
- listener = l;
- count = cnt;
- }
- }
- private List<ListenerCount> register = new ArrayList<ListenerCount>();
-
- public void registerListener(MockListenerRegisterer listener) {
- for (ListenerCount lc : register) {
- if (lc.listener == listener) {
- lc.count++;
- return;
- }
- }
-
- register.add(new ListenerCount(listener, 1));
- }
-
- public void unregisterListener(MockListenerRegisterer listener) {
- for (ListenerCount lc : register) {
- if (lc.listener == listener) {
- lc.count--;
- Assert.isTrue(lc.count>=0);
- return;
- }
- }
-
- // attempt to unregister non-registered listener
- Assert.isTrue(false);
- }
-
- /**
- * Note that that count includes all listeners with that id.
- */
- public int getCount(String id) {
- int count = 0;
-
- for (ListenerCount lc : register) {
- if (lc.listener.getId().equals(id)) {
- count = count + lc.count;
- }
- }
-
- return count;
- }
- }
-
- public MockListenerRegisterer() {
- super();
- }
- public MockListenerRegisterer(String id, String name) {
- super(id, name);
- }
- @Override
- public void registerListener(ICConfigurationDescription cfgDescription) {
- mockListenerManager.registerListener(this);
- }
-
- @Override
- public void unregisterListener() {
- mockListenerManager.unregisterListener(this);
- }
- @Override
- public MockListenerRegisterer cloneShallow() throws CloneNotSupportedException {
- return (MockListenerRegisterer) super.cloneShallow();
- }
- @Override
- public MockListenerRegisterer clone() throws CloneNotSupportedException {
- return (MockListenerRegisterer) super.clone();
- }
-
- public static int getCount(String id) {
- return mockListenerManager.getCount(id);
- }
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Andrew Gvozdev 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 Gvozdev - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.language.settings.providers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * Mock Language Settings Provider that keeps count how many times it has been registered.
+ */
+public class MockListenerRegisterer extends LanguageSettingsSerializableProvider implements ILanguageSettingsEditableProvider, ICListenerAgent {
+ private static MockListenerManager mockListenerManager = new MockListenerManager();
+
+ private static class MockListenerManager {
+ private class ListenerCount {
+ private MockListenerRegisterer listener;
+ private int count;
+ public ListenerCount(MockListenerRegisterer l, int cnt) {
+ listener = l;
+ count = cnt;
+ }
+ }
+ private List<ListenerCount> register = new ArrayList<ListenerCount>();
+
+ public void registerListener(MockListenerRegisterer listener) {
+ for (ListenerCount lc : register) {
+ if (lc.listener == listener) {
+ lc.count++;
+ return;
+ }
+ }
+
+ register.add(new ListenerCount(listener, 1));
+ }
+
+ public void unregisterListener(MockListenerRegisterer listener) {
+ for (ListenerCount lc : register) {
+ if (lc.listener == listener) {
+ lc.count--;
+ Assert.isTrue(lc.count>=0);
+ return;
+ }
+ }
+
+ // attempt to unregister non-registered listener
+ Assert.isTrue(false);
+ }
+
+ /**
+ * Note that that count includes all listeners with that id.
+ */
+ public int getCount(String id) {
+ int count = 0;
+
+ for (ListenerCount lc : register) {
+ if (lc.listener.getId().equals(id)) {
+ count = count + lc.count;
+ }
+ }
+
+ return count;
+ }
+ }
+
+ public MockListenerRegisterer() {
+ super();
+ }
+ public MockListenerRegisterer(String id, String name) {
+ super(id, name);
+ }
+ @Override
+ public void registerListener(ICConfigurationDescription cfgDescription) {
+ mockListenerManager.registerListener(this);
+ }
+
+ @Override
+ public void unregisterListener() {
+ mockListenerManager.unregisterListener(this);
+ }
+ @Override
+ public MockListenerRegisterer cloneShallow() throws CloneNotSupportedException {
+ return (MockListenerRegisterer) super.cloneShallow();
+ }
+ @Override
+ public MockListenerRegisterer clone() throws CloneNotSupportedException {
+ return (MockListenerRegisterer) super.clone();
+ }
+
+ public static int getCount(String id) {
+ return mockListenerManager.getCount(id);
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h b/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h
index df422c6e855..d9736eff1d3 100644
--- a/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h
+++ b/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h
@@ -1,146 +1,146 @@
-// include
-#include "included.h"
-
-// macro
-#define PRINT(string,msg) printf(string, msg)
-
-//namespace
-namespace MyPackage
-{
- // check class
- // class
- class Hello
- {
- // protected visibility
- protected:
- // field
- int x;
- // method
- inline void setX(int X)
- {
- x = X;
- };
- // check nested pachage
- // nested namespace
- namespace MyNestedPackage {
- // check parent nested class
- // nested class
- class Y
- { // public visibility
- public:
- // constructor
- Y();
- // virtual destructor
- virtual ~Y();
- };
- // check derived nested class
- // derived class
- class X : public Y {
- // private visibility
- private:
- // private field
- B b;
-
- public:
- // constructor chain
- X(int x) : Y(x) {
- cout << "In consturctor\n";
- }
- // method declaration
- int doNothing();
- };
- }
- };
-
- // check enums
- // enum without name
- enum {
- first = 1,
- second,
- third
- }
- ;
- // enum with name
- enum MyEnum {
- f,
- s,
- t };
-
- // check variables
- // variable
- int v;
- // unsigned long variable
- unsigned long vuLong;
- // unsigned short variable
- unsigned short vuShort;
-
- // check variable declarations
- // variable declaration
- extern int evar;
- // function pointer
- static void * (*orig_malloc_hook)(const char *file, int line, size_t size);
-
- // check functions
- // simple function declaration
- void foo();
- // function declaration with parameters
- char* foo(int& x,
- char**y);
- // simple function definition
- void boo(){
- int g = 0;
- };
- // check Structs
- // struct
- struct MyStruct{
- int sint;
- };
- // typedef and elaborated types
- typedef struct MyStruct myStruct;
- // typedef
- typedef struct{
- int ss;
- } myTypedef;
- // unions
- union U{
- int U1;
- };
-
-
- // check templates
- // template function
- template<class A, typename B=C>
- A aTemplatedFunction( B bInstance );
- // template method
- class enclosing {
- // public visibility
- public:
- template<class A, typename B=C>
- A aTemplatedMethod( B bInstance );
- };
- // template class
- template<class T, typename Tibor = junk>
- class myarray { /* */ };
- // template struct
- template<class T, typename Tibor = junk>
- struct mystruct { /* */ };
- // template variable
-// template <bool __threads, int __inst>
-// char* default_alloc_template<__threads, __inst>::_S_start_free = 0;
-};
- // check arrays
- // arrays
- int myArray [5][];
- int main(int argc, char * argv[])
- {
- }
-
-// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815
-struct bug180815 {
- int i,j;
-} bug180815_var0, bug180815_var1;
-
-// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350
-namespace {
- int bug352350;
+// include
+#include "included.h"
+
+// macro
+#define PRINT(string,msg) printf(string, msg)
+
+//namespace
+namespace MyPackage
+{
+ // check class
+ // class
+ class Hello
+ {
+ // protected visibility
+ protected:
+ // field
+ int x;
+ // method
+ inline void setX(int X)
+ {
+ x = X;
+ };
+ // check nested pachage
+ // nested namespace
+ namespace MyNestedPackage {
+ // check parent nested class
+ // nested class
+ class Y
+ { // public visibility
+ public:
+ // constructor
+ Y();
+ // virtual destructor
+ virtual ~Y();
+ };
+ // check derived nested class
+ // derived class
+ class X : public Y {
+ // private visibility
+ private:
+ // private field
+ B b;
+
+ public:
+ // constructor chain
+ X(int x) : Y(x) {
+ cout << "In consturctor\n";
+ }
+ // method declaration
+ int doNothing();
+ };
+ }
+ };
+
+ // check enums
+ // enum without name
+ enum {
+ first = 1,
+ second,
+ third
+ }
+ ;
+ // enum with name
+ enum MyEnum {
+ f,
+ s,
+ t };
+
+ // check variables
+ // variable
+ int v;
+ // unsigned long variable
+ unsigned long vuLong;
+ // unsigned short variable
+ unsigned short vuShort;
+
+ // check variable declarations
+ // variable declaration
+ extern int evar;
+ // function pointer
+ static void * (*orig_malloc_hook)(const char *file, int line, size_t size);
+
+ // check functions
+ // simple function declaration
+ void foo();
+ // function declaration with parameters
+ char* foo(int& x,
+ char**y);
+ // simple function definition
+ void boo(){
+ int g = 0;
+ };
+ // check Structs
+ // struct
+ struct MyStruct{
+ int sint;
+ };
+ // typedef and elaborated types
+ typedef struct MyStruct myStruct;
+ // typedef
+ typedef struct{
+ int ss;
+ } myTypedef;
+ // unions
+ union U{
+ int U1;
+ };
+
+
+ // check templates
+ // template function
+ template<class A, typename B=C>
+ A aTemplatedFunction( B bInstance );
+ // template method
+ class enclosing {
+ // public visibility
+ public:
+ template<class A, typename B=C>
+ A aTemplatedMethod( B bInstance );
+ };
+ // template class
+ template<class T, typename Tibor = junk>
+ class myarray { /* */ };
+ // template struct
+ template<class T, typename Tibor = junk>
+ struct mystruct { /* */ };
+ // template variable
+// template <bool __threads, int __inst>
+// char* default_alloc_template<__threads, __inst>::_S_start_free = 0;
+};
+ // check arrays
+ // arrays
+ int myArray [5][];
+ int main(int argc, char * argv[])
+ {
+ }
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815
+struct bug180815 {
+ int i,j;
+} bug180815_var0, bug180815_var1;
+
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350
+namespace {
+ int bug352350;
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/resources/cfiles/TranslationUnits.c b/core/org.eclipse.cdt.core.tests/resources/cfiles/TranslationUnits.c
index e258b183e56..2f7b355860a 100644
--- a/core/org.eclipse.cdt.core.tests/resources/cfiles/TranslationUnits.c
+++ b/core/org.eclipse.cdt.core.tests/resources/cfiles/TranslationUnits.c
@@ -1,70 +1,70 @@
-/*
- * (c) Copyright QNX Software Systems Ltd. 2002, 2003.
- * All Rights Reserved.
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002, 2003.
+ * All Rights Reserved.
*/
-/********
- * This is a sample C file that will be used in testing the TranslationUnit
- * class. It has a specific structure that will be looked for within the
- * test case.
- * This file is only ment to contain various C elements, and may not compile
- * into a running application (but should be valid C)
- */
-
-#include <stdio.h>
-#include <unistd.h>
-
-/* A function prototype */
-int func2p(void);
-
-/* A global variable */
-int globalvar;
-
-/* A enumeration */
-enum myenum {ENUM_A=1, ENUM_B=2, ENUM_C=3, ENUM_D=4};
-
-/* A structure. This also includes a typedef around the strcture def
- * which at the time of writing was not picked up.
- */
-typedef struct mystruct {
- int a;
- char b;
- long c;
-} mystruct_t;
-
-/* A union */
-union myunion {
- int x;
- char y;
- long z;
-};
-
-/* A typedef */
-typedef struct mystruct mytype;
-
-
-/* A couple functions */
-
-void * func1(void)
-{
- return(NULL);
-}
-
-
-int func2(void)
-{
- return(0);
-}
-
-int main(int argc, char ** argv)
-{
- int var1;
- printf("Hello world\n");
-}
-
-
-void func3()
-{
- printf("This is not really here\n");
-}
-
-
+/********
+ * This is a sample C file that will be used in testing the TranslationUnit
+ * class. It has a specific structure that will be looked for within the
+ * test case.
+ * This file is only ment to contain various C elements, and may not compile
+ * into a running application (but should be valid C)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+
+/* A function prototype */
+int func2p(void);
+
+/* A global variable */
+int globalvar;
+
+/* A enumeration */
+enum myenum {ENUM_A=1, ENUM_B=2, ENUM_C=3, ENUM_D=4};
+
+/* A structure. This also includes a typedef around the strcture def
+ * which at the time of writing was not picked up.
+ */
+typedef struct mystruct {
+ int a;
+ char b;
+ long c;
+} mystruct_t;
+
+/* A union */
+union myunion {
+ int x;
+ char y;
+ long z;
+};
+
+/* A typedef */
+typedef struct mystruct mytype;
+
+
+/* A couple functions */
+
+void * func1(void)
+{
+ return(NULL);
+}
+
+
+int func2(void)
+{
+ return(0);
+}
+
+int main(int argc, char ** argv)
+{
+ int var1;
+ printf("Hello world\n");
+}
+
+
+void func3()
+{
+ printf("This is not really here\n");
+}
+
+
diff --git a/core/org.eclipse.cdt.core.tests/resources/cfiles/included.h b/core/org.eclipse.cdt.core.tests/resources/cfiles/included.h
index b5b6d36ac65..53eae6898ac 100644
--- a/core/org.eclipse.cdt.core.tests/resources/cfiles/included.h
+++ b/core/org.eclipse.cdt.core.tests/resources/cfiles/included.h
@@ -1,10 +1,10 @@
-#define size_t int
-class A;
-
-class B;
-
-class C;
-
-class T;
-
-class junk;
+#define size_t int
+class A;
+
+class B;
+
+class C;
+
+class T;
+
+class junk;
diff --git a/core/org.eclipse.cdt.core.tests/resources/cmodel/DeclaratorsTests.cpp b/core/org.eclipse.cdt.core.tests/resources/cmodel/DeclaratorsTests.cpp
index f0d2c7e98c7..94df40c6076 100644
--- a/core/org.eclipse.cdt.core.tests/resources/cmodel/DeclaratorsTests.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/cmodel/DeclaratorsTests.cpp
@@ -1,24 +1,24 @@
-void decl_0001(char);
-void (decl_0002)(char);
-void ((decl_0003))(char);
-
-void *decl_0004(char);
-void (*decl_0005)(char);
-void (*(decl_0006))(char);
-void ((*decl_0007))(char);
-
-typedef void decl_0011(char);
-typedef void (decl_0012)(char);
-typedef void ((decl_0013))(char);
-
-typedef void *decl_0014(char);
-typedef void (*decl_0015)(char);
-typedef void (*(decl_0016))(char);
-typedef void ((*decl_0017))(char);
-
-typedef void decl_0021(char);
-void (*decl_0022)(char);
-void (*(*decl_0023(int a)))(char) { return &decl_0021; }
-void (*(*(*((decl_0024)))(int))(float))(char);
-
-int (*decl_0031)(char(*yyy)(bool));
+void decl_0001(char);
+void (decl_0002)(char);
+void ((decl_0003))(char);
+
+void *decl_0004(char);
+void (*decl_0005)(char);
+void (*(decl_0006))(char);
+void ((*decl_0007))(char);
+
+typedef void decl_0011(char);
+typedef void (decl_0012)(char);
+typedef void ((decl_0013))(char);
+
+typedef void *decl_0014(char);
+typedef void (*decl_0015)(char);
+typedef void (*(decl_0016))(char);
+typedef void ((*decl_0017))(char);
+
+typedef void decl_0021(char);
+void (*decl_0022)(char);
+void (*(*decl_0023(int a)))(char) { return &decl_0021; }
+void (*(*(*((decl_0024)))(int))(float))(char);
+
+int (*decl_0031)(char(*yyy)(bool));
diff --git a/core/org.eclipse.cdt.core.tests/resources/cmodel/IIncludeTest.h b/core/org.eclipse.cdt.core.tests/resources/cmodel/IIncludeTest.h
index 04b6e419a44..872c9f3d811 100644
--- a/core/org.eclipse.cdt.core.tests/resources/cmodel/IIncludeTest.h
+++ b/core/org.eclipse.cdt.core.tests/resources/cmodel/IIncludeTest.h
@@ -1,42 +1,42 @@
-// include
-#include <stdio.h>
-#include "whatever.h"
-#include <src/slash.h>
-#include <src\backslash.h>
-#include "Program Files/space.h"
-#include "../up1dir.h"
-#include "./samedir.h"
-#include "different_extension1.hpp"
-#include "different_extension2.hh"
-#include "different_extension3.x"
-#include <no_extension>
-# include "whitespace_after_hash"
- #include "whitespace_before_hash"
-
-// failure cases:
-#include garbage
-#include "resync_after_bad_parse_1"
-#include
-#include "resync_after_bad_parse_2"
-#include "one" "two" "three"
-#include "resync_after_bad_parse_3"
-
-// from the Spec:
-
-// from [C, 6.10.p8]
-// should fail
-#define EMPTY
-EMPTY #include "invalid.h"
-
-// from [C, 6.10.2.p8]:
-// should equal #include "myInclude1.h"
-#define MYINCFILE "myInclude1.h"
-#include MYINCFILE
-
-// from [C, 6.10.3.5.p6]:
-// should equal #include "vers2.h"
-#define INCFILE(x) vers ## x
-#define xstr(x) str(x)
-#define str(x) #x
-#include xstr(INCFILE(2).h)
-
+// include
+#include <stdio.h>
+#include "whatever.h"
+#include <src/slash.h>
+#include <src\backslash.h>
+#include "Program Files/space.h"
+#include "../up1dir.h"
+#include "./samedir.h"
+#include "different_extension1.hpp"
+#include "different_extension2.hh"
+#include "different_extension3.x"
+#include <no_extension>
+# include "whitespace_after_hash"
+ #include "whitespace_before_hash"
+
+// failure cases:
+#include garbage
+#include "resync_after_bad_parse_1"
+#include
+#include "resync_after_bad_parse_2"
+#include "one" "two" "three"
+#include "resync_after_bad_parse_3"
+
+// from the Spec:
+
+// from [C, 6.10.p8]
+// should fail
+#define EMPTY
+EMPTY #include "invalid.h"
+
+// from [C, 6.10.2.p8]:
+// should equal #include "myInclude1.h"
+#define MYINCFILE "myInclude1.h"
+#include MYINCFILE
+
+// from [C, 6.10.3.5.p6]:
+// should equal #include "vers2.h"
+#define INCFILE(x) vers ## x
+#define xstr(x) str(x)
+#define str(x) #x
+#include xstr(INCFILE(2).h)
+
diff --git a/core/org.eclipse.cdt.core.tests/resources/cmodel/IMacroTest.h b/core/org.eclipse.cdt.core.tests/resources/cmodel/IMacroTest.h
index a5bf320efab..34fdd295164 100644
--- a/core/org.eclipse.cdt.core.tests/resources/cmodel/IMacroTest.h
+++ b/core/org.eclipse.cdt.core.tests/resources/cmodel/IMacroTest.h
@@ -1,4 +1,4 @@
-// macro
-#define SINGLETON
-#define NUMBER 1
-#define PRINT(string,msg) printf(string, msg)
+// macro
+#define SINGLETON
+#define NUMBER 1
+#define PRINT(string,msg) printf(string, msg)
diff --git a/core/org.eclipse.cdt.core.tests/resources/cmodel/ITemplate.cpp b/core/org.eclipse.cdt.core.tests/resources/cmodel/ITemplate.cpp
index 9874a1f3fd4..a180890fd5a 100644
--- a/core/org.eclipse.cdt.core.tests/resources/cmodel/ITemplate.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/cmodel/ITemplate.cpp
@@ -1,72 +1,72 @@
-class Key;
-class Value;
-class SortAlgorithm;
-class DefaultSort;
-class T;
-class X;
-class Y;
-class Bar;
-class Foo {
- template<class Bar> void fum(int i);
-};
-
-// TEMPLATE_STRUCT
-template<class Key, class Value, class SortAlgorithm=DefaultSort>
-struct Map
-{
- Key* keys;
- Value* values;
- SortAlgorithm* sortAlgorithm;
- Map();
-};
-
-// TEMPLATE_CLASS
-template<class T> class nonVector {
- private:
- T* head;
-
- public:
- nonVector() { head =new T(); }
- int length() { return 1; }
- const T& first();
-};
-
-// TEMPLATE_UNION
-template<class X, class Y, int size=16>
-union ArrayOverlay {
- public:
- X x[size];
- Y y[size];
-
- static int<X,Y> numArrays;
-};
-
-
-// TEMPLATE_METHODS
-class TemplateContainer {
- // these are in an enclosing class
- template<class Bar> void fum(int i);
- template<int> void scrum(void) {};
-};
-
-// TEMPLATE_FUNCTION
-template<class T> const T& nonVector<T>::first() const
-{
- return *head;
-}
-
-template<class X> bool IsGreaterThan(X,X);
-
-template<class Bar> void Foo::fum(int i) {}
-
-// TEMPLATE_VARIABLES
-template <bool threads, int inst> char* default_alloc_template<threads, inst>::S_start_free = 0;
-
-// an instantiation, not a template:
-complex<float> cf(0,0);
-//template<class Language, class CharacterSet, class SortAlgorithm<CharacterSet> >
-//Dictionary* TheSpellCheckDictionary;
-
-int success;
-
-
+class Key;
+class Value;
+class SortAlgorithm;
+class DefaultSort;
+class T;
+class X;
+class Y;
+class Bar;
+class Foo {
+ template<class Bar> void fum(int i);
+};
+
+// TEMPLATE_STRUCT
+template<class Key, class Value, class SortAlgorithm=DefaultSort>
+struct Map
+{
+ Key* keys;
+ Value* values;
+ SortAlgorithm* sortAlgorithm;
+ Map();
+};
+
+// TEMPLATE_CLASS
+template<class T> class nonVector {
+ private:
+ T* head;
+
+ public:
+ nonVector() { head =new T(); }
+ int length() { return 1; }
+ const T& first();
+};
+
+// TEMPLATE_UNION
+template<class X, class Y, int size=16>
+union ArrayOverlay {
+ public:
+ X x[size];
+ Y y[size];
+
+ static int<X,Y> numArrays;
+};
+
+
+// TEMPLATE_METHODS
+class TemplateContainer {
+ // these are in an enclosing class
+ template<class Bar> void fum(int i);
+ template<int> void scrum(void) {};
+};
+
+// TEMPLATE_FUNCTION
+template<class T> const T& nonVector<T>::first() const
+{
+ return *head;
+}
+
+template<class X> bool IsGreaterThan(X,X);
+
+template<class Bar> void Foo::fum(int i) {}
+
+// TEMPLATE_VARIABLES
+template <bool threads, int inst> char* default_alloc_template<threads, inst>::S_start_free = 0;
+
+// an instantiation, not a template:
+complex<float> cf(0,0);
+//template<class Language, class CharacterSet, class SortAlgorithm<CharacterSet> >
+//Dictionary* TheSpellCheckDictionary;
+
+int success;
+
+
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.cpp b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.cpp
index 828a3aca6cf..4dbb7f4f9b3 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.cpp
@@ -1,8 +1,8 @@
-#include "DepTest.h"
-#include "d.h"
-
-DepTest::DepTest()
-{};
-DepTest::~DepTest()
-{};
-
+#include "DepTest.h"
+#include "d.h"
+
+DepTest::DepTest()
+{};
+DepTest::~DepTest()
+{};
+
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.h b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.h
index c008086c156..376c76f4891 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.h
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest.h
@@ -1,8 +1,8 @@
-#include "Inc1.h"
-#include "a.h"
-class DepTest{
-public:
-
- DepTest();
- ~DepTest();
-};
+#include "Inc1.h"
+#include "a.h"
+class DepTest{
+public:
+
+ DepTest();
+ ~DepTest();
+};
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.cpp b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.cpp
index 6f3000e6df3..55014b84d54 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.cpp
@@ -1,8 +1,8 @@
-#include "DepTest2.h"
-#include "d.h"
-
-DepTest2::DepTest2()
-{};
-DepTest2::~DepTest2()
-{};
-
+#include "DepTest2.h"
+#include "d.h"
+
+DepTest2::DepTest2()
+{};
+DepTest2::~DepTest2()
+{};
+
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.h b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.h
index 6f084a69b11..e3a8946e84e 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.h
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest2.h
@@ -1,8 +1,8 @@
-#include "d.h"
-
-class DepTest2{
-public:
-
- DepTest2();
- ~DepTest2();
-};
+#include "d.h"
+
+class DepTest2{
+public:
+
+ DepTest2();
+ ~DepTest2();
+};
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.cpp b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.cpp
index cc0d9ba24ee..e3e0086c56c 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.cpp
@@ -1,7 +1,7 @@
-#include "DepTest3.h"
-
-DepTest3::DepTest3()
-{};
-DepTest3::~DepTest3()
-{};
-
+#include "DepTest3.h"
+
+DepTest3::DepTest3()
+{};
+DepTest3::~DepTest3()
+{};
+
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.h b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.h
index b4b47ce40e4..1390e03a3cd 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.h
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/DepTest3.h
@@ -1,8 +1,8 @@
-#include "a.h"
-
-class DepTest3{
-public:
-
- DepTest3();
- ~DepTest3();
-};
+#include "a.h"
+
+class DepTest3{
+public:
+
+ DepTest3();
+ ~DepTest3();
+};
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/Inc1.h b/core/org.eclipse.cdt.core.tests/resources/dependency/Inc1.h
index 7bfbe592caa..71ea5574504 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/Inc1.h
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/Inc1.h
@@ -1,8 +1,8 @@
-#include "c.h"
-
-class X
-{
- public:
- X(){};
- ~X(){};
+#include "c.h"
+
+class X
+{
+ public:
+ X(){};
+ ~X(){};
}; \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/a.h b/core/org.eclipse.cdt.core.tests/resources/dependency/a.h
index 3c66f940fc1..ac18143ef8d 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/a.h
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/a.h
@@ -1,8 +1,8 @@
-#include "c.h"
-
-class Z
-{
- public:
- Z(){};
- ~Z(){};
+#include "c.h"
+
+class Z
+{
+ public:
+ Z(){};
+ ~Z(){};
}; \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/c.h b/core/org.eclipse.cdt.core.tests/resources/dependency/c.h
index bc82542a695..5c9fd01d7b2 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/c.h
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/c.h
@@ -1,6 +1,6 @@
-class Y
-{
- public:
- Y(){};
- ~Y(){};
+class Y
+{
+ public:
+ Y(){};
+ ~Y(){};
}; \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/resources/dependency/d.h b/core/org.eclipse.cdt.core.tests/resources/dependency/d.h
index 8dcf01a87d2..9f800e81d90 100644
--- a/core/org.eclipse.cdt.core.tests/resources/dependency/d.h
+++ b/core/org.eclipse.cdt.core.tests/resources/dependency/d.h
@@ -1,6 +1,6 @@
-class d
-{
- public:
- d(){};
- ~d(){};
+class d
+{
+ public:
+ d(){};
+ ~d(){};
}; \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/resources/indexer/DocumentManager.cpp b/core/org.eclipse.cdt.core.tests/resources/indexer/DocumentManager.cpp
index 5fb91b9ce50..155edfb47bd 100644
--- a/core/org.eclipse.cdt.core.tests/resources/indexer/DocumentManager.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/indexer/DocumentManager.cpp
@@ -1,25 +1,25 @@
-//#include "StdAfx.h"
-#include "DocumentManager.h"
-
-CDocumentManager::CDocumentManager(void)
-{
-}
-
-CDocumentManager::~CDocumentManager(void)
-{
-}
-
-void CDocumentManager::addToControlMap(UINT threadID, IUnknown * theControl)
-{
- _controlMap.insert(MUL2IUnk_Pair(threadID,theControl));
-}
-
-void CDocumentManager::getControl(ULONG threadID, IUnknown ** theControl)
-{
- if (_controlMap.find(threadID) != _controlMap.end())
- {
- theControl = &_controlMap[threadID];
- }
-
-
-}
+//#include "StdAfx.h"
+#include "DocumentManager.h"
+
+CDocumentManager::CDocumentManager(void)
+{
+}
+
+CDocumentManager::~CDocumentManager(void)
+{
+}
+
+void CDocumentManager::addToControlMap(UINT threadID, IUnknown * theControl)
+{
+ _controlMap.insert(MUL2IUnk_Pair(threadID,theControl));
+}
+
+void CDocumentManager::getControl(ULONG threadID, IUnknown ** theControl)
+{
+ if (_controlMap.find(threadID) != _controlMap.end())
+ {
+ theControl = &_controlMap[threadID];
+ }
+
+
+}
diff --git a/core/org.eclipse.cdt.core.tests/resources/indexer/extramail.cpp b/core/org.eclipse.cdt.core.tests/resources/indexer/extramail.cpp
index da47fd6b304..766afa6a80e 100644
--- a/core/org.eclipse.cdt.core.tests/resources/indexer/extramail.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/indexer/extramail.cpp
@@ -1,112 +1,112 @@
-#include <iostream.h>
-#include <stdlib.h>
-#include <alloc.h>
-#include <iomanip.h>
-
-#define PRINT(a,b) cout<<(a)<<(b)
-#define CASE break;case
-#define MAX(a,b) (((a)>(b))?(a):(b))
-
-typedef int int32;
-
-static void doSomething();
-
-namespace Z{
- int x;
- namespace X{
- namespace Y{
- enum test{cool,hi,bye,why};
- class Mail
- {
- public:
- Mail(){}
- virtual void print()=0; //Pure Virtual Function, forces redefinition
- protected:
- float postage;
- char *type;
- friend ostream& operator << (ostream& os, Mail *m);
- };
-
- class postcard : public Mail
- {
- public:
- postcard(): Mail(){postage = 0.20; type = "Postcard";}
- void print(){cout << type << ": $" << setiosflags(ios::fixed)
- <<setprecision(2) << postage <<endl;}
- };
-
- class first_class : public Mail
- {
- public:
- first_class() : Mail(){postage = 0.32; type = "First Class";}
- void print(){cout << type << ": $" <<setiosflags(ios::fixed)
- << setprecision(2) << postage <<endl;}
-
- };
-
- class Unknown : public postcard, first_class // ??? Multiple Inheritance
- {
- public:
- Unknown(): postcard(), first_class()
- {
- postcard::postage = 1.50; // MUST disambiguate
- postcard::type = "Unknown";
- }
- void print(){cout << postcard::type << ": $" <<setiosflags(ios::fixed)
- <<setprecision(2)<<postcard::postage <<endl;}
- };
-
- class container
- {
- private:
- Mail **array;
- int index;
- int sz;
- public:
- container(){array = 0;}
- ~container(){
- for(int x = 0; x <sz; x++)
- delete array[x];
- free(array);
- }
- int size() {return sz;}
- Mail* operator[](int index);
- Mail* operator = (Mail* mail);
- };
-
- main()
- {
- container PO_Box;
- PO_Box = new postcard;
- PO_Box = new first_class;
- PO_Box = new parcel_Post;
- //PO_Box = new Unknown;
- //one way of printing information
- for(int x =0; x <3; x++){
- PO_Box[x]->print();
- }
- //Overloaded <<
- for(int x =0; x <PO_Box.size(); x++){
- cout << PO_Box[x];
- }
- }
-
- ostream& operator << (ostream &os, Mail *m)
- {
- os <<setiosflags(ios::fixed) << setprecision(2)<< m->type
- << ": $" << m->postage <<endl;
-
- return os;
- }
- Mail* container::operator[](int index) {return array[index];}
- Mail* container::operator = (Mail* mail)
- {
- int size = sizeof(Mail*) * (++sz);
- int temp = sz -1;
- array = (Mail**)realloc(array, size);
- array[temp] = mail;
- return 0;
- }
- }
- }
-}
+#include <iostream.h>
+#include <stdlib.h>
+#include <alloc.h>
+#include <iomanip.h>
+
+#define PRINT(a,b) cout<<(a)<<(b)
+#define CASE break;case
+#define MAX(a,b) (((a)>(b))?(a):(b))
+
+typedef int int32;
+
+static void doSomething();
+
+namespace Z{
+ int x;
+ namespace X{
+ namespace Y{
+ enum test{cool,hi,bye,why};
+ class Mail
+ {
+ public:
+ Mail(){}
+ virtual void print()=0; //Pure Virtual Function, forces redefinition
+ protected:
+ float postage;
+ char *type;
+ friend ostream& operator << (ostream& os, Mail *m);
+ };
+
+ class postcard : public Mail
+ {
+ public:
+ postcard(): Mail(){postage = 0.20; type = "Postcard";}
+ void print(){cout << type << ": $" << setiosflags(ios::fixed)
+ <<setprecision(2) << postage <<endl;}
+ };
+
+ class first_class : public Mail
+ {
+ public:
+ first_class() : Mail(){postage = 0.32; type = "First Class";}
+ void print(){cout << type << ": $" <<setiosflags(ios::fixed)
+ << setprecision(2) << postage <<endl;}
+
+ };
+
+ class Unknown : public postcard, first_class // ??? Multiple Inheritance
+ {
+ public:
+ Unknown(): postcard(), first_class()
+ {
+ postcard::postage = 1.50; // MUST disambiguate
+ postcard::type = "Unknown";
+ }
+ void print(){cout << postcard::type << ": $" <<setiosflags(ios::fixed)
+ <<setprecision(2)<<postcard::postage <<endl;}
+ };
+
+ class container
+ {
+ private:
+ Mail **array;
+ int index;
+ int sz;
+ public:
+ container(){array = 0;}
+ ~container(){
+ for(int x = 0; x <sz; x++)
+ delete array[x];
+ free(array);
+ }
+ int size() {return sz;}
+ Mail* operator[](int index);
+ Mail* operator = (Mail* mail);
+ };
+
+ main()
+ {
+ container PO_Box;
+ PO_Box = new postcard;
+ PO_Box = new first_class;
+ PO_Box = new parcel_Post;
+ //PO_Box = new Unknown;
+ //one way of printing information
+ for(int x =0; x <3; x++){
+ PO_Box[x]->print();
+ }
+ //Overloaded <<
+ for(int x =0; x <PO_Box.size(); x++){
+ cout << PO_Box[x];
+ }
+ }
+
+ ostream& operator << (ostream &os, Mail *m)
+ {
+ os <<setiosflags(ios::fixed) << setprecision(2)<< m->type
+ << ": $" << m->postage <<endl;
+
+ return os;
+ }
+ Mail* container::operator[](int index) {return array[index];}
+ Mail* container::operator = (Mail* mail)
+ {
+ int size = sizeof(Mail*) * (++sz);
+ int temp = sz -1;
+ array = (Mail**)realloc(array, size);
+ array[temp] = mail;
+ return 0;
+ }
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core.tests/resources/indexer/reftest.cpp b/core/org.eclipse.cdt.core.tests/resources/indexer/reftest.cpp
index 8f65972886d..0c908b274ce 100644
--- a/core/org.eclipse.cdt.core.tests/resources/indexer/reftest.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/indexer/reftest.cpp
@@ -1,22 +1,22 @@
-namespace A
-{
- class ForwardA;
- ForwardA * tmp;
- int something(void);
- namespace B
- {
- enum e1{dude1,dude2};
- int x;
- class C
- { static int y = 5;
- static int bar(void);
- };
- }
-}
-using namespace A::B;
-using A::B::x;
-using A::B::C;
-using A::B::C::y;
-using A::B::C::bar;
-using A::something;
+namespace A
+{
+ class ForwardA;
+ ForwardA * tmp;
+ int something(void);
+ namespace B
+ {
+ enum e1{dude1,dude2};
+ int x;
+ class C
+ { static int y = 5;
+ static int bar(void);
+ };
+ }
+}
+using namespace A::B;
+using A::B::x;
+using A::B::C;
+using A::B::C::y;
+using A::B::C::bar;
+using A::something;
using A::B::e1; \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.c b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.c
index e7d2a2e016f..16bc625fe55 100644
--- a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.c
+++ b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.c
@@ -1,43 +1,43 @@
-#include <Simple.h>
-
-const SimpleStruct simpleStruct =
-{
- 1
- , "mySimple"
- , 0.1232
-};
-
-#define SIZEOF( A, B ) sizeof( A.B )
-
-const OtherStruct array[] =
-{
- {
-#if FOO
- "foo"
-#else
- "bar"
-#endif
- , SIZEOF( simpleStruct, num )
- , &t_int
- , 0
- }
- , {
- "name"
- , SIZEOF( simpleStruct, floatnum )
- , &t_float
- , 1
- }
-};
-
-
-void SimpleStruct_construct( struct SimpleStruct * const this )
-{
- this->num = 1;
- this->name = "boo";
- this->floatNum = 1.5;
-}
-
-int ConnectParams_doSomething( const struct SimpleStruct * const this )
-{
- return 1;
-}
+#include <Simple.h>
+
+const SimpleStruct simpleStruct =
+{
+ 1
+ , "mySimple"
+ , 0.1232
+};
+
+#define SIZEOF( A, B ) sizeof( A.B )
+
+const OtherStruct array[] =
+{
+ {
+#if FOO
+ "foo"
+#else
+ "bar"
+#endif
+ , SIZEOF( simpleStruct, num )
+ , &t_int
+ , 0
+ }
+ , {
+ "name"
+ , SIZEOF( simpleStruct, floatnum )
+ , &t_float
+ , 1
+ }
+};
+
+
+void SimpleStruct_construct( struct SimpleStruct * const this )
+{
+ this->num = 1;
+ this->name = "boo";
+ this->floatNum = 1.5;
+}
+
+int ConnectParams_doSomething( const struct SimpleStruct * const this )
+{
+ return 1;
+}
diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.h b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.h
index 96e8ef0a741..b5012c10f5b 100644
--- a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.h
+++ b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultC/Simple.h
@@ -1,17 +1,17 @@
-#ifndef SIMPLE_H
-#define SIMPLE_H
-
-struct SimpleStruct
-{
- int num;
- char name[ ];
- float floatNum;
-};
-
-
-void SimpleStruct_construct( struct SimpleStruct * const this );
-
-int SimpleStruct_doSomething( const struct SimpleStruct * const this );
-
-#endif /* SIMPLE_H */
-
+#ifndef SIMPLE_H
+#define SIMPLE_H
+
+struct SimpleStruct
+{
+ int num;
+ char name[ ];
+ float floatNum;
+};
+
+
+void SimpleStruct_construct( struct SimpleStruct * const this );
+
+int SimpleStruct_doSomething( const struct SimpleStruct * const this );
+
+#endif /* SIMPLE_H */
+
diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.cpp b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.cpp
index 4b4055ade2d..471f78e6c91 100644
--- a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.cpp
@@ -1,37 +1,37 @@
-#include <Simple.h>
-
-#include <iostream>
-
-#define NULL (void *)0
-
-SimpleClass::SimpleClass( void )
-{
- init( NULL );
-}
-
-SimpleClass::~SimpleClass( void )
-{
-}
-
-SimpleClass::SimpleClass( const SimpleClass & arg )
-{
- //TODO: copy constructor
-}
-
-SimpleClass & SimpleClass::operator=( const SimpleClass & arg )
-{
- if( this != &arg )
- {
- }
- return *this;
-}
-
-
-void SimpleClass::init( void * foo)
-{
-}
-
-InnerStruct & SimpleClass::getInner( void )
-{
- return inner;
-}
+#include <Simple.h>
+
+#include <iostream>
+
+#define NULL (void *)0
+
+SimpleClass::SimpleClass( void )
+{
+ init( NULL );
+}
+
+SimpleClass::~SimpleClass( void )
+{
+}
+
+SimpleClass::SimpleClass( const SimpleClass & arg )
+{
+ //TODO: copy constructor
+}
+
+SimpleClass & SimpleClass::operator=( const SimpleClass & arg )
+{
+ if( this != &arg )
+ {
+ }
+ return *this;
+}
+
+
+void SimpleClass::init( void * foo)
+{
+}
+
+InnerStruct & SimpleClass::getInner( void )
+{
+ return inner;
+}
diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.h b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.h
index e22c5eefbd0..b385fcd46ff 100644
--- a/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.h
+++ b/core/org.eclipse.cdt.core.tests/resources/parser/AutomatedTest/defaultCpp/Simple.h
@@ -1,32 +1,32 @@
-#ifndef SIMPLE_H
-#define SIMPLE_H
-
-class OtherClass;
-
-class SimpleClass
-{
-public:
- SimpleClass( void );
- SimpleClass( const SimpleClass & arg );
-
- virtual ~SimpleClass( void );
-
- SimpleClass & operator=( const SimpleClass & arg );
-
-private:
- struct InnerStruct
- {
- inline InnerStruct( int a ){ _a = a; }
- inline ~InnerStruct( void ){}
- unsigned int _a;
- };
-
- InnerStruct inner;
-
- void init( void * );
-
-public:
- InnerStruct & getInner( void );
-};
-
-#endif /* SIMPLE_H */
+#ifndef SIMPLE_H
+#define SIMPLE_H
+
+class OtherClass;
+
+class SimpleClass
+{
+public:
+ SimpleClass( void );
+ SimpleClass( const SimpleClass & arg );
+
+ virtual ~SimpleClass( void );
+
+ SimpleClass & operator=( const SimpleClass & arg );
+
+private:
+ struct InnerStruct
+ {
+ inline InnerStruct( int a ){ _a = a; }
+ inline ~InnerStruct( void ){}
+ unsigned int _a;
+ };
+
+ InnerStruct inner;
+
+ void init( void * );
+
+public:
+ InnerStruct & getInner( void );
+};
+
+#endif /* SIMPLE_H */
diff --git a/core/org.eclipse.cdt.core.tests/resources/parser/LineNumberTest.h b/core/org.eclipse.cdt.core.tests/resources/parser/LineNumberTest.h
index 16b506364f0..6660b4e9898 100644
--- a/core/org.eclipse.cdt.core.tests/resources/parser/LineNumberTest.h
+++ b/core/org.eclipse.cdt.core.tests/resources/parser/LineNumberTest.h
@@ -1,43 +1,43 @@
-// inclusion begins and ends on line 2
-#include <stdio.h>
-
-// simple macro begins and ends on line 5; ANOTHER on line 6
-#define SIMPLE_MACRO simple
-#define ANOTHER
-// namespace begins on line 7, ends on line 22
-namespace MyPackage{
- // class specification begins on line 10, ends on line 21
- class Hello{
- protected:
- // simple declaration begins and ends on line 13
- int x;
- // simple declaration begins and ends on line 15
- void setX(int X);
- public:
- // simple declaration begins on line 18 and ends on line 20
- Hello( void ) : x
- ( 5 ) {
- }
- };
-}
-
-// simple declaration begins on line 25 and ends on line 27
-int *
- y =
- 0;
-
-// complex macro begins on line 30 and ends on line 31
-#define COMPLEX_MACRO 33 \
- + 44
-
-// template declaration begins on line 34 and ends on line 35
-template <class A >
- A createA( void );
-
-// enumeration begins on line 38 and ends on line 43
-enum {
- one, // enumerator begins and ends on line 39
- two, // enumerator begins and ends on line 40
- three // enumerator begins on line 41, ends on line 42
- = 4
+// inclusion begins and ends on line 2
+#include <stdio.h>
+
+// simple macro begins and ends on line 5; ANOTHER on line 6
+#define SIMPLE_MACRO simple
+#define ANOTHER
+// namespace begins on line 7, ends on line 22
+namespace MyPackage{
+ // class specification begins on line 10, ends on line 21
+ class Hello{
+ protected:
+ // simple declaration begins and ends on line 13
+ int x;
+ // simple declaration begins and ends on line 15
+ void setX(int X);
+ public:
+ // simple declaration begins on line 18 and ends on line 20
+ Hello( void ) : x
+ ( 5 ) {
+ }
+ };
+}
+
+// simple declaration begins on line 25 and ends on line 27
+int *
+ y =
+ 0;
+
+// complex macro begins on line 30 and ends on line 31
+#define COMPLEX_MACRO 33 \
+ + 44
+
+// template declaration begins on line 34 and ends on line 35
+template <class A >
+ A createA( void );
+
+// enumeration begins on line 38 and ends on line 43
+enum {
+ one, // enumerator begins and ends on line 39
+ two, // enumerator begins and ends on line 40
+ three // enumerator begins on line 41, ends on line 42
+ = 4
}; \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp b/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp
index f2fa14f0168..94a7173c70e 100644
--- a/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp
@@ -1,102 +1,102 @@
-#include "include.h"
-
-#define FOO bar
-
-class Heal{};
-
-class A {
- A() {}
- ~A(){}
- class B {
- void f( A );
- void f( A & );
- void f( A* );
- void f( int &, const char [], A ** );
- };
-};
-
-namespace NS {
- namespace NS2{
- struct a{};
- }
- class B: public A {
- public:
- struct AA {};
- enum e {
- One,
- Two,
- Three
- };
-
- void f(){
- using namespace NS2;
- a aStruct;
- }
-
-
-
- AA anotherStruct;
- };
- union u{ } ;
-}
-
-namespace NS3{
- class C : public NS::B {
- e eE = One;
- };
-}
-
-A::B b1;
-
-typedef NS::B NS_B;
-NS_B b2;
-
-union u{
-};
-
-class AClassForFoo {};
-
-AClassForFoo foo( AClassForFoo ){
- AClassForFoo b;
- return b;
-}
-
-Head * Head::operator *= ( int index ){
- return array[ index ];
-}
-
-Head * Head::operator += ( int index ){
- return array[ index ];
-}
-
-extern int externalInt;
-extern int externalIntWithInitializer = 2;
-extern "C" int externCInt;
-extern "C" int externCIntWithInitializer = 3;
-
-void forwardFunction() { }
-void normalFunction() { }
-
-void DeclsAndDefns::forwardMethod(){ }
-
-int DeclsAndDefns::staticField = 5;
-
-
-namespace bug68235{
- struct xTag {
- int x;
- };
- typedef xTag xType;
-
- typedef struct yTag {
- int x;
- } yType;
-
- class C1{
- public:
- xType x;
- yType y;
- C1();
- ~C1();
- };
+#include "include.h"
+
+#define FOO bar
+
+class Heal{};
+
+class A {
+ A() {}
+ ~A(){}
+ class B {
+ void f( A );
+ void f( A & );
+ void f( A* );
+ void f( int &, const char [], A ** );
+ };
+};
+
+namespace NS {
+ namespace NS2{
+ struct a{};
+ }
+ class B: public A {
+ public:
+ struct AA {};
+ enum e {
+ One,
+ Two,
+ Three
+ };
+
+ void f(){
+ using namespace NS2;
+ a aStruct;
+ }
+
+
+
+ AA anotherStruct;
+ };
+ union u{ } ;
+}
+
+namespace NS3{
+ class C : public NS::B {
+ e eE = One;
+ };
+}
+
+A::B b1;
+
+typedef NS::B NS_B;
+NS_B b2;
+
+union u{
+};
+
+class AClassForFoo {};
+
+AClassForFoo foo( AClassForFoo ){
+ AClassForFoo b;
+ return b;
+}
+
+Head * Head::operator *= ( int index ){
+ return array[ index ];
+}
+
+Head * Head::operator += ( int index ){
+ return array[ index ];
+}
+
+extern int externalInt;
+extern int externalIntWithInitializer = 2;
+extern "C" int externCInt;
+extern "C" int externCIntWithInitializer = 3;
+
+void forwardFunction() { }
+void normalFunction() { }
+
+void DeclsAndDefns::forwardMethod(){ }
+
+int DeclsAndDefns::staticField = 5;
+
+
+namespace bug68235{
+ struct xTag {
+ int x;
+ };
+ typedef xTag xType;
+
+ typedef struct yTag {
+ int x;
+ } yType;
+
+ class C1{
+ public:
+ xType x;
+ yType y;
+ C1();
+ ~C1();
+ };
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/resources/search/include.h b/core/org.eclipse.cdt.core.tests/resources/search/include.h
index f9c3d75956e..bb0b00ad594 100644
--- a/core/org.eclipse.cdt.core.tests/resources/search/include.h
+++ b/core/org.eclipse.cdt.core.tests/resources/search/include.h
@@ -1,36 +1,36 @@
-#ifndef INCLUDE_H
-#define INCLUDE_H
-
-class Head {
- Head ** array;
-
- Head * operator *= ( int index );
- Head * operator * ( int index ){ return array[ index ]; }
- Head * operator += ( int index );
-
- operator const short & ();
- operator short ();
- operator short int ();
-
-};
-
-class DeclsAndDefns{
- static int staticField;
- int nonStaticField;
-
- void forwardMethod();
- void inlineMethod() {}
-};
-
-void forwardFunction();
-
-
-class Direction{
- void turn();
- void turn(int);
- void turnAgain(void);
-};
-class Right : public Direction {
- void turn() { }
-};
+#ifndef INCLUDE_H
+#define INCLUDE_H
+
+class Head {
+ Head ** array;
+
+ Head * operator *= ( int index );
+ Head * operator * ( int index ){ return array[ index ]; }
+ Head * operator += ( int index );
+
+ operator const short & ();
+ operator short ();
+ operator short int ();
+
+};
+
+class DeclsAndDefns{
+ static int staticField;
+ int nonStaticField;
+
+ void forwardMethod();
+ void inlineMethod() {}
+};
+
+void forwardFunction();
+
+
+class Direction{
+ void turn();
+ void turn(int);
+ void turnAgain(void);
+};
+class Right : public Direction {
+ void turn() { }
+};
#endif \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java
index db644fd1d62..8483e7d1163 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java
@@ -1,496 +1,496 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Andrew Gvozdev 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 Gvozdev - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.core.testplugin;
-
-import java.util.Map;
-
-import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
-import org.eclipse.cdt.core.settings.model.CConfigurationStatus;
-import org.eclipse.cdt.core.settings.model.ICBuildSetting;
-import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICExternalSetting;
-import org.eclipse.cdt.core.settings.model.ICFileDescription;
-import org.eclipse.cdt.core.settings.model.ICFolderDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICResourceDescription;
-import org.eclipse.cdt.core.settings.model.ICSettingContainer;
-import org.eclipse.cdt.core.settings.model.ICSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICSettingObject;
-import org.eclipse.cdt.core.settings.model.ICSourceEntry;
-import org.eclipse.cdt.core.settings.model.ICStorageElement;
-import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
-import org.eclipse.cdt.core.settings.model.WriteAccessException;
-import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.QualifiedName;
-
-/**
- * Collection of mock classes for testing
- */
-public class CModelMock {
- /**
- * Dummy implementation of ICProjectDescription for testing.
- * Feel free to override the methods you are interested to mock.
- */
- public static class DummyCProjectDescription implements ICProjectDescription {
-
- @Override
- public ICSettingObject[] getChildSettings() {
- return null;
- }
-
- @Override
- public String getId() {
- return null;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public int getType() {
- return 0;
- }
-
- @Override
- public boolean isValid() {
- return false;
- }
-
- @Override
- public ICConfigurationDescription getConfiguration() {
- return null;
- }
-
- @Override
- public ICSettingContainer getParent() {
- return null;
- }
-
- @Override
- public boolean isReadOnly() {
- return false;
- }
-
- @Override
- public ICStorageElement getStorage(String id, boolean create)
- throws CoreException {
- return null;
- }
-
- @Override
- public void removeStorage(String id) throws CoreException {
- }
-
- @Override
- public ICStorageElement importStorage(String id, ICStorageElement el)
- throws UnsupportedOperationException, CoreException {
- return null;
- }
-
- @Override
- public void setReadOnly(boolean readOnly, boolean keepModify) {
- }
-
- @Override
- public int getConfigurationRelations() {
- return 0;
- }
-
- @Override
- public void setConfigurationRelations(int status) {
- }
-
- @Override
- public void useDefaultConfigurationRelations() {
- }
-
- @Override
- public boolean isDefaultConfigurationRelations() {
- return false;
- }
-
- @Override
- public ICConfigurationDescription[] getConfigurations() {
- return null;
- }
-
- @Override
- public ICConfigurationDescription getActiveConfiguration() {
- return null;
- }
-
- @Override
- public void setActiveConfiguration(ICConfigurationDescription cfg)
- throws WriteAccessException {
- }
-
- @Override
- public ICConfigurationDescription createConfiguration(String id,
- String name, ICConfigurationDescription base)
- throws CoreException, WriteAccessException {
- return null;
- }
-
- @Override
- public ICConfigurationDescription createConfiguration(
- String buildSystemId, CConfigurationData data)
- throws CoreException, WriteAccessException {
- return null;
- }
-
- @Override
- public ICConfigurationDescription getConfigurationByName(String name) {
- return null;
- }
-
- @Override
- public ICConfigurationDescription getConfigurationById(String id) {
- return null;
- }
-
- @Override
- public void removeConfiguration(String name)
- throws WriteAccessException {
- }
-
- @Override
- public void removeConfiguration(ICConfigurationDescription cfg)
- throws WriteAccessException {
- }
-
- @Override
- public IProject getProject() {
- return null;
- }
-
- @Override
- public boolean isModified() {
- return false;
- }
-
- @Override
- public Object getSessionProperty(QualifiedName name) {
- return null;
- }
-
- @Override
- public void setSessionProperty(QualifiedName name, Object value) {
-
- }
-
- @Override
- public ICConfigurationDescription getDefaultSettingConfiguration() {
- return null;
- }
-
- @Override
- public void setDefaultSettingConfiguration(
- ICConfigurationDescription cfg) {
- }
-
- @Override
- public boolean isCdtProjectCreating() {
- return false;
- }
-
- @Override
- public void setCdtProjectCreated() {
- }
-
- }
-
- /**
- * Dummy implementation of ICConfigurationDescription for testing.
- * Feel free to override the methods you are interested to mock.
- */
- public static class DummyCConfigurationDescription implements ICConfigurationDescription {
- private String id;
- private ICProjectDescription projectDescription;
-
- public DummyCConfigurationDescription(String id) {
- this.id = id;
- this.projectDescription = new DummyCProjectDescription();
- }
-
- @Override
- public ICSettingObject[] getChildSettings() {
- return null;
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public int getType() {
- return 0;
- }
-
- @Override
- public boolean isValid() {
- return false;
- }
-
- @Override
- public ICConfigurationDescription getConfiguration() {
- return null;
- }
-
- @Override
- public ICSettingContainer getParent() {
- return null;
- }
-
- @Override
- public boolean isReadOnly() {
- return false;
- }
-
- @Override
- public ICStorageElement getStorage(String id, boolean create)
- throws CoreException {
- return null;
- }
-
- @Override
- public void removeStorage(String id) throws CoreException {
- }
-
- @Override
- public ICStorageElement importStorage(String id, ICStorageElement el)
- throws UnsupportedOperationException, CoreException {
- return null;
- }
-
- @Override
- public void setReadOnly(boolean readOnly, boolean keepModify) {
- }
-
- @Override
- public boolean isActive() {
- return false;
- }
-
- @Override
- public String getDescription() {
- return null;
- }
-
- @Override
- public void setDescription(String des) throws WriteAccessException {
- }
-
- @Override
- public ICProjectDescription getProjectDescription() {
- return projectDescription;
- }
-
- @Override
- public ICFolderDescription getRootFolderDescription() {
- return null;
- }
-
- @Override
- public ICFolderDescription[] getFolderDescriptions() {
- return null;
- }
-
- @Override
- public ICFileDescription[] getFileDescriptions() {
- return null;
- }
-
- @Override
- public ICResourceDescription[] getResourceDescriptions() {
- return null;
- }
-
- @Override
- public ICResourceDescription getResourceDescription(IPath path,
- boolean exactPath) {
- return null;
- }
-
- @Override
- public void removeResourceDescription(ICResourceDescription des)
- throws CoreException, WriteAccessException {
- }
-
- @Override
- public ICFileDescription createFileDescription(IPath path,
- ICResourceDescription base) throws CoreException,
- WriteAccessException {
- return null;
- }
-
- @Override
- public ICFolderDescription createFolderDescription(IPath path,
- ICFolderDescription base) throws CoreException,
- WriteAccessException {
- return null;
- }
-
- @Override
- public String getBuildSystemId() {
- return null;
- }
-
- @Override
- public CConfigurationData getConfigurationData() {
- return null;
- }
-
- @Override
- public void setActive() throws WriteAccessException {
- }
-
- @Override
- public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException {
- }
-
- @Override
- public boolean isModified() {
- return false;
- }
-
- @Override
- public ICTargetPlatformSetting getTargetPlatformSetting() {
- return null;
- }
-
- @Override
- public ICSourceEntry[] getSourceEntries() {
- return null;
- }
-
- @Override
- public ICSourceEntry[] getResolvedSourceEntries() {
- return null;
- }
-
- @Override
- public void setSourceEntries(ICSourceEntry[] entries) throws CoreException, WriteAccessException {
- }
-
- @Override
- public Map<String, String> getReferenceInfo() {
- return null;
- }
-
- @Override
- public void setReferenceInfo(Map<String, String> refs) throws WriteAccessException {
- }
-
- @Override
- public ICExternalSetting[] getExternalSettings() {
- return null;
- }
-
- @Override
- public ICExternalSetting createExternalSetting(String[] languageIDs,
- String[] contentTypeIds, String[] extensions,
- ICSettingEntry[] entries) throws WriteAccessException {
- return null;
- }
-
- @Override
- public void removeExternalSetting(ICExternalSetting setting) throws WriteAccessException {
- }
-
- @Override
- public void removeExternalSettings() throws WriteAccessException {
- }
-
- @Override
- public ICBuildSetting getBuildSetting() {
- return null;
- }
-
- @Override
- public ICdtVariablesContributor getBuildVariablesContributor() {
- return null;
- }
-
- @Override
- public Object getSessionProperty(QualifiedName name) {
- return null;
- }
-
- @Override
- public void setSessionProperty(QualifiedName name, Object value) {
- }
-
- @Override
- public void setName(String name) throws WriteAccessException {
- }
-
- @Override
- public ICConfigExtensionReference[] get(String extensionPointID) {
- return null;
- }
-
- @Override
- public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException {
- return null;
- }
-
- @Override
- public void remove(ICConfigExtensionReference ext) throws CoreException {
- }
-
- @Override
- public void remove(String extensionPoint) throws CoreException {
- }
-
- @Override
- public boolean isPreferenceConfiguration() {
- return false;
- }
-
- @Override
- public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExludeStatus) {
- return null;
- }
-
- @Override
- public void setExternalSettingsProviderIds(String[] ids) {
- }
-
- @Override
- public String[] getExternalSettingsProviderIds() {
- return null;
- }
-
- @Override
- public void updateExternalSettingsProviders(String[] ids) throws WriteAccessException {
- }
-
- @Override
- public CConfigurationStatus getConfigurationStatus() {
- return null;
- }
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Andrew Gvozdev 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 Gvozdev - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.core.testplugin;
+
+import java.util.Map;
+
+import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
+import org.eclipse.cdt.core.settings.model.CConfigurationStatus;
+import org.eclipse.cdt.core.settings.model.ICBuildSetting;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.QualifiedName;
+
+/**
+ * Collection of mock classes for testing
+ */
+public class CModelMock {
+ /**
+ * Dummy implementation of ICProjectDescription for testing.
+ * Feel free to override the methods you are interested to mock.
+ */
+ public static class DummyCProjectDescription implements ICProjectDescription {
+
+ @Override
+ public ICSettingObject[] getChildSettings() {
+ return null;
+ }
+
+ @Override
+ public String getId() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public int getType() {
+ return 0;
+ }
+
+ @Override
+ public boolean isValid() {
+ return false;
+ }
+
+ @Override
+ public ICConfigurationDescription getConfiguration() {
+ return null;
+ }
+
+ @Override
+ public ICSettingContainer getParent() {
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ @Override
+ public ICStorageElement getStorage(String id, boolean create)
+ throws CoreException {
+ return null;
+ }
+
+ @Override
+ public void removeStorage(String id) throws CoreException {
+ }
+
+ @Override
+ public ICStorageElement importStorage(String id, ICStorageElement el)
+ throws UnsupportedOperationException, CoreException {
+ return null;
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly, boolean keepModify) {
+ }
+
+ @Override
+ public int getConfigurationRelations() {
+ return 0;
+ }
+
+ @Override
+ public void setConfigurationRelations(int status) {
+ }
+
+ @Override
+ public void useDefaultConfigurationRelations() {
+ }
+
+ @Override
+ public boolean isDefaultConfigurationRelations() {
+ return false;
+ }
+
+ @Override
+ public ICConfigurationDescription[] getConfigurations() {
+ return null;
+ }
+
+ @Override
+ public ICConfigurationDescription getActiveConfiguration() {
+ return null;
+ }
+
+ @Override
+ public void setActiveConfiguration(ICConfigurationDescription cfg)
+ throws WriteAccessException {
+ }
+
+ @Override
+ public ICConfigurationDescription createConfiguration(String id,
+ String name, ICConfigurationDescription base)
+ throws CoreException, WriteAccessException {
+ return null;
+ }
+
+ @Override
+ public ICConfigurationDescription createConfiguration(
+ String buildSystemId, CConfigurationData data)
+ throws CoreException, WriteAccessException {
+ return null;
+ }
+
+ @Override
+ public ICConfigurationDescription getConfigurationByName(String name) {
+ return null;
+ }
+
+ @Override
+ public ICConfigurationDescription getConfigurationById(String id) {
+ return null;
+ }
+
+ @Override
+ public void removeConfiguration(String name)
+ throws WriteAccessException {
+ }
+
+ @Override
+ public void removeConfiguration(ICConfigurationDescription cfg)
+ throws WriteAccessException {
+ }
+
+ @Override
+ public IProject getProject() {
+ return null;
+ }
+
+ @Override
+ public boolean isModified() {
+ return false;
+ }
+
+ @Override
+ public Object getSessionProperty(QualifiedName name) {
+ return null;
+ }
+
+ @Override
+ public void setSessionProperty(QualifiedName name, Object value) {
+
+ }
+
+ @Override
+ public ICConfigurationDescription getDefaultSettingConfiguration() {
+ return null;
+ }
+
+ @Override
+ public void setDefaultSettingConfiguration(
+ ICConfigurationDescription cfg) {
+ }
+
+ @Override
+ public boolean isCdtProjectCreating() {
+ return false;
+ }
+
+ @Override
+ public void setCdtProjectCreated() {
+ }
+
+ }
+
+ /**
+ * Dummy implementation of ICConfigurationDescription for testing.
+ * Feel free to override the methods you are interested to mock.
+ */
+ public static class DummyCConfigurationDescription implements ICConfigurationDescription {
+ private String id;
+ private ICProjectDescription projectDescription;
+
+ public DummyCConfigurationDescription(String id) {
+ this.id = id;
+ this.projectDescription = new DummyCProjectDescription();
+ }
+
+ @Override
+ public ICSettingObject[] getChildSettings() {
+ return null;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public int getType() {
+ return 0;
+ }
+
+ @Override
+ public boolean isValid() {
+ return false;
+ }
+
+ @Override
+ public ICConfigurationDescription getConfiguration() {
+ return null;
+ }
+
+ @Override
+ public ICSettingContainer getParent() {
+ return null;
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ @Override
+ public ICStorageElement getStorage(String id, boolean create)
+ throws CoreException {
+ return null;
+ }
+
+ @Override
+ public void removeStorage(String id) throws CoreException {
+ }
+
+ @Override
+ public ICStorageElement importStorage(String id, ICStorageElement el)
+ throws UnsupportedOperationException, CoreException {
+ return null;
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly, boolean keepModify) {
+ }
+
+ @Override
+ public boolean isActive() {
+ return false;
+ }
+
+ @Override
+ public String getDescription() {
+ return null;
+ }
+
+ @Override
+ public void setDescription(String des) throws WriteAccessException {
+ }
+
+ @Override
+ public ICProjectDescription getProjectDescription() {
+ return projectDescription;
+ }
+
+ @Override
+ public ICFolderDescription getRootFolderDescription() {
+ return null;
+ }
+
+ @Override
+ public ICFolderDescription[] getFolderDescriptions() {
+ return null;
+ }
+
+ @Override
+ public ICFileDescription[] getFileDescriptions() {
+ return null;
+ }
+
+ @Override
+ public ICResourceDescription[] getResourceDescriptions() {
+ return null;
+ }
+
+ @Override
+ public ICResourceDescription getResourceDescription(IPath path,
+ boolean exactPath) {
+ return null;
+ }
+
+ @Override
+ public void removeResourceDescription(ICResourceDescription des)
+ throws CoreException, WriteAccessException {
+ }
+
+ @Override
+ public ICFileDescription createFileDescription(IPath path,
+ ICResourceDescription base) throws CoreException,
+ WriteAccessException {
+ return null;
+ }
+
+ @Override
+ public ICFolderDescription createFolderDescription(IPath path,
+ ICFolderDescription base) throws CoreException,
+ WriteAccessException {
+ return null;
+ }
+
+ @Override
+ public String getBuildSystemId() {
+ return null;
+ }
+
+ @Override
+ public CConfigurationData getConfigurationData() {
+ return null;
+ }
+
+ @Override
+ public void setActive() throws WriteAccessException {
+ }
+
+ @Override
+ public void setConfigurationData(String buildSystemId, CConfigurationData data) throws WriteAccessException {
+ }
+
+ @Override
+ public boolean isModified() {
+ return false;
+ }
+
+ @Override
+ public ICTargetPlatformSetting getTargetPlatformSetting() {
+ return null;
+ }
+
+ @Override
+ public ICSourceEntry[] getSourceEntries() {
+ return null;
+ }
+
+ @Override
+ public ICSourceEntry[] getResolvedSourceEntries() {
+ return null;
+ }
+
+ @Override
+ public void setSourceEntries(ICSourceEntry[] entries) throws CoreException, WriteAccessException {
+ }
+
+ @Override
+ public Map<String, String> getReferenceInfo() {
+ return null;
+ }
+
+ @Override
+ public void setReferenceInfo(Map<String, String> refs) throws WriteAccessException {
+ }
+
+ @Override
+ public ICExternalSetting[] getExternalSettings() {
+ return null;
+ }
+
+ @Override
+ public ICExternalSetting createExternalSetting(String[] languageIDs,
+ String[] contentTypeIds, String[] extensions,
+ ICSettingEntry[] entries) throws WriteAccessException {
+ return null;
+ }
+
+ @Override
+ public void removeExternalSetting(ICExternalSetting setting) throws WriteAccessException {
+ }
+
+ @Override
+ public void removeExternalSettings() throws WriteAccessException {
+ }
+
+ @Override
+ public ICBuildSetting getBuildSetting() {
+ return null;
+ }
+
+ @Override
+ public ICdtVariablesContributor getBuildVariablesContributor() {
+ return null;
+ }
+
+ @Override
+ public Object getSessionProperty(QualifiedName name) {
+ return null;
+ }
+
+ @Override
+ public void setSessionProperty(QualifiedName name, Object value) {
+ }
+
+ @Override
+ public void setName(String name) throws WriteAccessException {
+ }
+
+ @Override
+ public ICConfigExtensionReference[] get(String extensionPointID) {
+ return null;
+ }
+
+ @Override
+ public ICConfigExtensionReference create(String extensionPoint, String extension) throws CoreException {
+ return null;
+ }
+
+ @Override
+ public void remove(ICConfigExtensionReference ext) throws CoreException {
+ }
+
+ @Override
+ public void remove(String extensionPoint) throws CoreException {
+ }
+
+ @Override
+ public boolean isPreferenceConfiguration() {
+ return false;
+ }
+
+ @Override
+ public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExludeStatus) {
+ return null;
+ }
+
+ @Override
+ public void setExternalSettingsProviderIds(String[] ids) {
+ }
+
+ @Override
+ public String[] getExternalSettingsProviderIds() {
+ return null;
+ }
+
+ @Override
+ public void updateExternalSettingsProviders(String[] ids) throws WriteAccessException {
+ }
+
+ @Override
+ public CConfigurationStatus getConfigurationStatus() {
+ return null;
+ }
+
+ }
+}

Back to the top