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

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

This commit is contained in:
Andrew Gvozdev 2012-05-24 14:44:41 -04:00
commit 500ee54268
49 changed files with 1144 additions and 191 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2010 QNX Software Systems and others.
* Copyright (c) 2000, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -11,6 +11,7 @@
* Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
* Save build output (bug 294106)
* Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.make.core;
@ -279,7 +280,7 @@ public class MakeBuilder extends ACBuilder {
*/
protected void refreshProject(IProject project) {
if (buildRunnerHelper != null) {
buildRunnerHelper.refreshProject(null);
buildRunnerHelper.refreshProject(null, null);
}
}

View file

@ -9,6 +9,7 @@
* Wind River Systems - Initial API and implementation
* James Blackburn (Broadcom Corp.)
* Andrew Gvozdev
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
@ -129,7 +130,7 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
buildRunnerHelper.goodbye();
if (state != ICommandLauncher.ILLEGAL_COMMAND) {
buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
buildRunnerHelper.refreshProject(cfgName, new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
}
} else {
String msg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.undefined.build.command", builder.getId()); //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2011 Wind River Systems and others.
* Copyright (c) 2010, 2012 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors:
* Wind River Systems - Initial API and implementation
* James Blackburn (Broadcom Corp.)
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.core;
@ -136,7 +137,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
buildRunnerHelper.goodbye();
if (status != ICommandLauncher.ILLEGAL_COMMAND) {
buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
buildRunnerHelper.refreshProject(cfgName, new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
}
} catch (Exception e) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2010 Intel Corporation and others.
* Copyright (c) 2007, 2012 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -1211,7 +1211,7 @@ public class CommonBuilder extends ACBuilder {
buildRunnerHelper.goodbye();
if (status != ICommandLauncher.ILLEGAL_COMMAND) {
buildRunnerHelper.refreshProject(new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT));
buildRunnerHelper.refreshProject(cfgName, new SubProgressMonitor(monitor, TICKS_REFRESH_PROJECT));
}
//Throw a core exception indicating that the clean command failed

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2011 IBM Corporation and others.
* Copyright (c) 2002, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -1118,7 +1118,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
// use the refresh scope manager to refresh
RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project, cfg.getName());
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
monitor.subTask(ManagedMakeMessages

View file

@ -10,11 +10,14 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector;
import org.eclipse.cdt.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
@ -32,6 +35,8 @@ import org.eclipse.swt.widgets.Text;
/**
* Options page for {@link AbstractBuiltinSpecsDetector}.
*
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettingProviderOptionPage {
private boolean fEditable;
@ -152,4 +157,18 @@ public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettin
});
}
@Override
public void performApply(IProgressMonitor monitor) throws CoreException {
ILanguageSettingsProvider provider = providerTab.getProvider(providerId);
if ((provider instanceof AbstractBuiltinSpecsDetector)) { // basically check for working copy
ILanguageSettingsProvider initialProvider = providerTab.getInitialProvider(providerId);
if (!(initialProvider instanceof AbstractBuiltinSpecsDetector) || !((AbstractBuiltinSpecsDetector) initialProvider).getCommand().equals(((AbstractBuiltinSpecsDetector) provider).getCommand())) {
// clear and reset isExecuted flag
((AbstractBuiltinSpecsDetector) provider).clear();
}
}
super.performApply(monitor);
}
}

View file

@ -144,8 +144,7 @@ public class RefreshPolicyTab extends AbstractCBuildPropertyTab {
private void loadInfo() {
HashMap<String, HashMap<IResource, List<RefreshExclusion>>> configMap = fManager.getConfigurationToResourcesMap(fProject);
if (configMap != null)
fConfigurationToResourcesToExclusionsMap = copyHashMap(configMap);
fConfigurationToResourcesToExclusionsMap = copyHashMap(configMap);
}
private List<RefreshExclusion> getExclusions(String configName, IResource resource) {

View file

@ -486,7 +486,7 @@ public class RefreshScopeTests extends TestCase {
createTestFile(path);
// now refresh
IWorkspaceRunnable runnable = manager.getRefreshRunnable(fProject);
IWorkspaceRunnable runnable = manager.getRefreshRunnable(fProject, conf_name);
try {
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.core.language.settings.providers;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import junit.framework.TestSuite;
@ -25,7 +26,10 @@ import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
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.runtime.jobs.Job;
/**
@ -1131,5 +1135,371 @@ public class LanguageSettingsListenersTests extends BaseTestCase {
assertEquals(cfgDescriptionId, event.getConfigurationDescriptionIds()[0]);
}
}
/**
* Test case when a project is present in the list of resources in delta.
*/
public void testDelta_AffectedResources_Project() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
// create a mock provider and add to cfgDescription
{
// get project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
}
// register mock listener to inspect the notifications
{
LanguageSettingsManager.registerLanguageSettingsChangeListener(mockLseListener);
assertEquals(0, mockLseListener.getCount());
assertEquals(null, mockLseListener.getLastEvent());
}
// trigger an event on the project
ICConfigurationDescription cfgDescription;
{
// get project descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
mockProvider.setSettingEntries(cfgDescription, project, null, entries);
mockProvider.serializeLanguageSettings(cfgDescription);
}
// inspect event
{
assertEquals(1, mockLseListener.getCount());
ILanguageSettingsChangeEvent event = mockLseListener.getLastEvent();
assertNotNull(event);
assertEquals(event.getProjectName(), project.getName());
Set<IResource> resources = event.getAffectedResources(cfgDescription.getId());
assertNotNull(resources);
assertEquals(project, resources.toArray()[0]);
assertEquals(1, resources.size());
}
}
/**
* Test case when a default resource (null) is represented in the list of resources in delta.
*/
public void testDelta_AffectedResources_DefaultResource() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
// create a mock provider and add to cfgDescription
{
// get project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
}
// register mock listener to inspect the notifications
{
LanguageSettingsManager.registerLanguageSettingsChangeListener(mockLseListener);
assertEquals(0, mockLseListener.getCount());
assertEquals(null, mockLseListener.getLastEvent());
}
// trigger an event on the project
ICConfigurationDescription cfgDescription;
{
// get project descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
mockProvider.setSettingEntries(cfgDescription, null, null, entries);
mockProvider.serializeLanguageSettings(cfgDescription);
}
// inspect event
{
assertEquals(1, mockLseListener.getCount());
ILanguageSettingsChangeEvent event = mockLseListener.getLastEvent();
assertNotNull(event);
assertEquals(event.getProjectName(), project.getName());
Set<IResource> resources = event.getAffectedResources(cfgDescription.getId());
assertNotNull(resources);
assertEquals(project, resources.toArray()[0]);
assertEquals(1, resources.size());
}
}
/**
* Test case when a folder is present in the list of resources in delta.
*/
public void testDelta_AffectedResources_Folder() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFolder folder = ResourceHelper.createFolder(project, "Folder");
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
// create a mock provider and add to cfgDescription
{
// get project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
}
// register mock listener to inspect the notifications
{
LanguageSettingsManager.registerLanguageSettingsChangeListener(mockLseListener);
assertEquals(0, mockLseListener.getCount());
assertEquals(null, mockLseListener.getLastEvent());
}
// trigger an event on the project
ICConfigurationDescription cfgDescription;
{
// get project descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
mockProvider.setSettingEntries(cfgDescription, folder, null, entries);
mockProvider.serializeLanguageSettings(cfgDescription);
}
// inspect event
{
assertEquals(1, mockLseListener.getCount());
ILanguageSettingsChangeEvent event = mockLseListener.getLastEvent();
assertNotNull(event);
assertEquals(event.getProjectName(), project.getName());
Set<IResource> resources = event.getAffectedResources(cfgDescription.getId());
assertNotNull(resources);
assertEquals(folder, resources.toArray()[0]);
assertEquals(1, resources.size());
}
}
/**
* Test case when a file is present in the list of resources in delta.
*/
public void testDelta_AffectedResources_File() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFile file = ResourceHelper.createFile(project, "file.cpp");
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
// create a mock provider and add to cfgDescription
{
// get project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
}
// register mock listener to inspect the notifications
{
LanguageSettingsManager.registerLanguageSettingsChangeListener(mockLseListener);
assertEquals(0, mockLseListener.getCount());
assertEquals(null, mockLseListener.getLastEvent());
}
// trigger an event on the project
ICConfigurationDescription cfgDescription;
{
// get project descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
mockProvider.setSettingEntries(cfgDescription, file, null, entries);
mockProvider.serializeLanguageSettings(cfgDescription);
}
// inspect event
{
assertEquals(1, mockLseListener.getCount());
ILanguageSettingsChangeEvent event = mockLseListener.getLastEvent();
assertNotNull(event);
assertEquals(event.getProjectName(), project.getName());
Set<IResource> resources = event.getAffectedResources(cfgDescription.getId());
assertNotNull(resources);
assertEquals(file, resources.toArray()[0]);
assertEquals(1, resources.size());
}
}
/**
* Test case when a mix of files and folders is present in the list of resources in delta.
*/
public void testDelta_AffectedResources_Mix() throws Exception {
// create project
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFolder folder = ResourceHelper.createFolder(project, "Folder");
IFile file1 = ResourceHelper.createFile(project, "file1.cpp");
IFile file2 = ResourceHelper.createFile(project, "file2.cpp");
IFile file3 = ResourceHelper.createFile(project, "file3.cpp");
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
// create a mock provider and add to cfgDescription
{
// get project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// add mock provider to cfgDescription
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
CoreModel.getDefault().setProjectDescription(project, prjDescriptionWritable);
}
// register mock listener to inspect the notifications
{
LanguageSettingsManager.registerLanguageSettingsChangeListener(mockLseListener);
assertEquals(0, mockLseListener.getCount());
assertEquals(null, mockLseListener.getLastEvent());
}
// trigger an event on the project
ICConfigurationDescription cfgDescription;
{
// get project descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
assertEquals(1, cfgDescriptions.length);
cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size());
MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(SAMPLE_LSE);
mockProvider.setSettingEntries(cfgDescription, folder, null, entries);
mockProvider.setSettingEntries(cfgDescription, file1, null, entries);
mockProvider.setSettingEntries(cfgDescription, file2, null, entries);
mockProvider.serializeLanguageSettings(cfgDescription);
}
// inspect event
{
assertEquals(1, mockLseListener.getCount());
ILanguageSettingsChangeEvent event = mockLseListener.getLastEvent();
assertNotNull(event);
assertEquals(event.getProjectName(), project.getName());
Set<IResource> resources = event.getAffectedResources(cfgDescription.getId());
assertNotNull(resources);
assertTrue(resources.contains(folder));
assertTrue(resources.contains(file1));
assertTrue(resources.contains(file2));
assertFalse(resources.contains(file3));
assertEquals(3, resources.size());
}
}
}

View file

@ -27,6 +27,7 @@ import java.util.Iterator;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
@ -9684,4 +9685,13 @@ public class AST2CPPTests extends AST2BaseTest {
f= bh.assertNonProblem("f( 0 )", 1);
assertEquals("void (int)", ASTTypeUtil.getType(f.getType()));
}
// void foo(struct S s);
public void testParameterForwardDeclaration_379511() throws Exception {
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
ICPPClassType struct= bh.assertNonProblem("S", 1, ICPPClassType.class);
IName[] declarations= bh.getTranslationUnit().getDeclarations(struct);
assertEquals(1, declarations.length);
assertEquals(bh.findName("S", 1), declarations[0]);
}
}

View file

@ -10,7 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.core.language.settings.providers;
import java.util.Set;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.core.resources.IResource;
/**
* Contains the details of changes that occurred as a result of modifying
@ -21,7 +24,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
* <p>
* <strong>EXPERIMENTAL</strong>. This class interface is not stable yet as
* it is not currently clear how it may need to be used in future. Only bare
* minimum is provided here at this point (CDT 9.0, Juno).
* minimum is provided here at this point (CDT 8.1, Juno).
* There is no guarantee that this API will work or that it will remain the same.
* Please do not use this API without consulting with the CDT team.
* </p>
@ -38,8 +41,12 @@ public interface ILanguageSettingsChangeEvent {
public String getProjectName();
/**
* @return configuration IDs which are affected by the language settings changes.
* @return configuration IDs which are affected by the language settings entries changes.
*/
public String[] getConfigurationDescriptionIds();
/**
* @return list of resources affected by the language settings entries changes.
*/
public Set<IResource> getAffectedResources(String cfgId);
}

View file

@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -91,8 +92,10 @@ public class LanguageSettingsStorage implements Cloneable {
/**
* Sets language settings entries for the resource and language.
*
* @param rcProjectPath - path to the resource relative to the project.
* @param languageId - language id.
* @param rcProjectPath - path to the resource relative to the project. If {@code null} the entries are
* considered to be being defined as default entries for resources.
* @param languageId - language id. If {@code null}, then entries are considered
* to be defined for the language scope.
* @param entries - language settings entries to set.
*/
public void setSettingEntries(String rcProjectPath, String languageId, List<ICLanguageSettingEntry> entries) {
@ -134,6 +137,31 @@ public class LanguageSettingsStorage implements Cloneable {
}
}
/**
* @return set of all languages associated with the entries.
* Note that the storage can keep default entries for the language scope
* of the provider, so the set can contain {@code null}.
*/
public Set<String> getLanguages() {
return new HashSet<String>(fStorage.keySet());
}
/**
* Returns set of paths for all resources associated with entries for given language.
* The paths are project relative.
*
* @param languageId - language ID.
* @return the set of resource paths associated with entries for the given language or empty set.
* Note that the storage can keep default entries for resources, so the set can contain {@code null}.
*/
public Set<String> getResourcePaths(String languageId) {
Map<String, List<ICLanguageSettingEntry>> rcPathsMap = fStorage.get(languageId);
if (rcPathsMap == null) {
return new HashSet<String>();
}
return new HashSet<String>(rcPathsMap.keySet());
}
/**
* Find and return the equal list of entries from the pool.
*

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.internal.core.language.settings.providers;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
@ -24,7 +27,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
* <p>
* <strong>EXPERIMENTAL</strong>. This class interface is not stable yet as
* it is not currently clear how it may need to be used in future. Only bare
* minimum is provided here at this point (CDT 9.0, Juno).
* minimum is provided here at this point (CDT 8.1, Juno).
* There is no guarantee that this API will work or that it will remain the same.
* Please do not use this API without consulting with the CDT team.
* </p>
@ -33,12 +36,12 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class LanguageSettingsDelta {
// maps need to be ordered by providers
@SuppressWarnings("unused")
// maps are ordered by providers
private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> oldLanguageSettingsState;
@SuppressWarnings("unused")
private LinkedHashMap<String/*providerId*/, LanguageSettingsStorage> newLanguageSettingsState;
private Set<String> paths = null;
/**
* Constructor.
*
@ -50,4 +53,64 @@ public class LanguageSettingsDelta {
newLanguageSettingsState = newState;
}
/**
* @return resource paths affected by changes represented by this delta.
*/
public Set<String> getAffectedResourcePaths() {
if (paths != null) {
return paths;
}
paths = new TreeSet<String>();
LanguageSettingsStorage oldCombinedStorage = combineStorage(oldLanguageSettingsState);
LanguageSettingsStorage newCombinedStorage = combineStorage(newLanguageSettingsState);
for (String lang : oldCombinedStorage.getLanguages()) {
for (String path : oldCombinedStorage.getResourcePaths(lang)) {
if (oldCombinedStorage.getSettingEntries(path, lang) != newCombinedStorage.getSettingEntries(path, lang)) {
if (path == null) {
// add path of the project
path = ""; //$NON-NLS-1$
}
paths.add(path);
}
}
}
for (String lang : newCombinedStorage.getLanguages()) {
for (String path : newCombinedStorage.getResourcePaths(lang)) {
if (newCombinedStorage.getSettingEntries(path, lang) != oldCombinedStorage.getSettingEntries(path, lang)) {
if (path == null) {
// add path of the project
path = ""; //$NON-NLS-1$
}
paths.add(path);
}
}
}
return paths;
}
/**
* Language settings entries from different providers can overlap. This method resolves all overlapping
* ones combining entries into one aggregate storage.
*/
private LanguageSettingsStorage combineStorage(LinkedHashMap<String, LanguageSettingsStorage> state) {
LanguageSettingsStorage combinedStore = new LanguageSettingsStorage();
for (LanguageSettingsStorage providerStore : state.values()) {
for (String lang : providerStore.getLanguages()) {
for (String path : providerStore.getResourcePaths(lang)) {
// provider (store) higher on the list overrides others below
if (combinedStore.getSettingEntries(path, lang) == null) {
List<ICLanguageSettingEntry> entries = providerStore.getSettingEntries(path, lang);
combinedStore.setSettingEntries(path, lang, entries);
}
}
}
}
return combinedStore;
}
}

View file

@ -14,8 +14,10 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ICListenerAgent;
@ -305,6 +307,26 @@ public class LanguageSettingsProvidersSerializer {
return "LanguageSettingsChangeEvent for project=[" + getProjectName() + "]"
+ ", configurations=" + deltaMap.keySet();
}
@Override
public Set<IResource> getAffectedResources(String cfgId) {
LanguageSettingsDelta delta = deltaMap.get(cfgId);
if (delta != null) {
Set<String> paths = delta.getAffectedResourcePaths();
if (!paths.isEmpty()) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
Set<IResource> resources = new HashSet<IResource>();
for (String path : paths) {
IResource rc = project.findMember(path);
if (rc != null) {
resources.add(rc);
}
}
return resources;
}
}
return null;
}
}
/** static initializer */

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
* John Camelon (IBM Rational Software) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;

View file

@ -13,7 +13,11 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
import java.util.ArrayList;
import java.util.Arrays;
@ -1468,8 +1472,9 @@ public class CPPVisitor extends ASTQueries {
break;
} else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
IASTNode p = name.getParent().getParent();
if (p instanceof IASTSimpleDeclaration &&
((IASTSimpleDeclaration) p).getDeclarators().length == 0) {
if (p instanceof IASTParameterDeclaration ||
(p instanceof IASTSimpleDeclaration &&
((IASTSimpleDeclaration) p).getDeclarators().length == 0)) {
break;
}
} else if (prop == IASTDeclarator.DECLARATOR_NAME) {

View file

@ -10,15 +10,23 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsChangeEvent;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsChangeListener;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
/**
* This class handles changes in language settings for the PDOM.
@ -43,16 +51,36 @@ public class LanguageSettingsChangeListener implements ILanguageSettingsChangeLi
if (project != null) {
ICProjectDescription prjDescription = CCorePlugin.getDefault().getProjectDescription(project);
if (prjDescription != null) {
ICConfigurationDescription indexedCfgDescription = prjDescription.getDefaultSettingConfiguration();
String indexedCfgId = indexedCfgDescription.getId();
// cfgDescription being indexed
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
String indexedId = cfgDescription.getId();
for (String cfgId : event.getConfigurationDescriptionIds()) {
if (cfgId.equals(indexedCfgId)) {
fManager.reindex(CoreModel.getDefault().getCModel().getCProject(project.getName()));
for (String id : event.getConfigurationDescriptionIds()) {
if (id.equals(indexedId)) {
reindex(id, event);
return;
}
}
}
}
}
private void reindex(String cfgId, ILanguageSettingsChangeEvent event) {
CModelManager manager = CModelManager.getDefault();
ICProject cProject = manager.getCModel().getCProject(event.getProjectName());
Set<ICElement> tuSelection = new HashSet<ICElement>();
Set<IResource> resources = event.getAffectedResources(cfgId);
if (resources != null && !resources.isEmpty()) {
for (IResource rc : resources) {
tuSelection.add(manager.create(rc, cProject));
}
try {
fManager.update(tuSelection.toArray(new ICElement[tuSelection.size()]), IIndexManager.UPDATE_ALL);
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
}
}

View file

@ -11,11 +11,11 @@
package org.eclipse.cdt.core.resources;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -97,6 +97,7 @@ public class RefreshScopeManager {
private boolean fIsLoaded = false;
private boolean fIsLoading = false;
private boolean fIsNewProject = false;
private HashMap<IProject,HashMap<String,HashMap<IResource, List<RefreshExclusion>>>> fProjToConfToResToExcluMap;
private int fVersion = 2;
@ -214,9 +215,7 @@ public class RefreshScopeManager {
}
private synchronized void clearDataForProject(IProject project) {
HashMap<String,HashMap<IResource, List<RefreshExclusion>>> configMap = fProjToConfToResToExcluMap.get(project);
if (configMap != null)
configMap.clear();
fProjToConfToResToExcluMap.remove(project);
}
/**
@ -286,7 +285,8 @@ public class RefreshScopeManager {
if (resourceMap == null) {
resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
resourceMap.put(project, new LinkedList<RefreshExclusion>());
if (!fIsLoading)
resourceMap.put(project, new LinkedList<RefreshExclusion>());
configMap.put(configName, resourceMap);
}
@ -317,9 +317,24 @@ public class RefreshScopeManager {
return fProjToConfToResToExcluMap;
}
/**
* Refresh the given project using the refresh setting for the active configuration
* @param project
* @return the refresh runnable for the given project
*/
public IWorkspaceRunnable getRefreshRunnable(final IProject project) {
return getRefreshRunnable(project, null);
}
/**
* Refresh the given project using the refresh setting for the configuration with the given name
* @param project
* @param configName
* @return the refresh runnable for the given project
* @since 5.4
*/
public IWorkspaceRunnable getRefreshRunnable(final IProject project, final String configName) {
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
/**
@ -345,13 +360,14 @@ public class RefreshScopeManager {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager
.getInstance();
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
ICConfigurationDescription active_conf = projectDescription.getActiveConfiguration();
String name = active_conf.getName();
String name = configName;
if (name == null) {
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager
.getInstance();
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
ICConfigurationDescription active_conf = projectDescription.getActiveConfiguration();
name = active_conf.getName();
}
List<IResource> resourcesToRefresh = getResourcesToRefresh(project,name);
for (IResource resource : resourcesToRefresh) {
List<RefreshExclusion> exclusions = getExclusions(project,name,resource);
@ -473,7 +489,7 @@ public class RefreshScopeManager {
// walk the tree and load the settings
String str = storageElement.getAttribute(VERSION_NUMBER_ATTRIBUTE_NAME);
if ((str == null) || (str.equals("1"))) { //$NON-NLS-1$
if ( (children.length != 0) && ((str == null) || (str.equals("1")))) { //$NON-NLS-1$
ICConfigurationDescription cfgDescs[] = projectDescription.getConfigurations();
for (ICConfigurationDescription cfgDesc : cfgDescs)
loadResourceData(workspaceRoot, project, cfgDesc.getName(), children);
@ -488,7 +504,9 @@ public class RefreshScopeManager {
// else there are no children, and this is a "new" project.
// so initialize it.
if (children.length == 0) {
fIsNewProject = true;
getConfigurationToResourcesMap(project); // this will initialize the config map.
fIsNewProject = false;
}
}
}
@ -506,7 +524,7 @@ public class RefreshScopeManager {
for (ICConfigurationDescription cfgDesc : cfgDescs) {
String configName = cfgDesc.getName();
HashMap<IResource, List<RefreshExclusion>> resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
if (!fIsLoading)
if (!fIsLoading || fIsNewProject) //config settings could be loading and detects a new project and if so, add the default refresh setting
resourceMap.put(project, new LinkedList<RefreshExclusion>());
configMap.put(configName, resourceMap);
}
@ -520,76 +538,80 @@ public class RefreshScopeManager {
*/
public synchronized void loadResourceData(IWorkspaceRoot workspaceRoot, IProject project, String configName, ICStorageElement[] children) {
for (ICStorageElement child : children) {
if (child.getName().equals(RESOURCE_ELEMENT_NAME)) {
// get the resource path
String resourcePath = child.getAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME);
if (resourcePath == null) {
// error... skip this resource
continue;
}
else {
String resourceTypeString = child
.getAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME);
if (resourceTypeString == null) {
// we'll do our best, but we won't be able to create handles to non-existent
// resources
resourceTypeString = OTHER_VALUE;
}
// find the resource
IResource resource = null;
if (resourceTypeString.equals(PROJECT_VALUE)) {
resource = workspaceRoot.getProject(resourcePath);
}
else if (resourceTypeString.equals(FILE_VALUE)) {
resource = workspaceRoot.getFile(new Path(resourcePath));
}
else if (resourceTypeString.equals(FOLDER_VALUE)) {
resource = workspaceRoot.getFolder(new Path(resourcePath));
}
else {
// Find arbitrary resource.
// The only way to do this is to ask the workspace root to find
// it, if it exists. If it doesn't exist, we have no way of
// creating a handle to the right type of object, so we must
// give up. In practice, this would likely happen if we had
// a virtual group resource that has been deleted somehow since
// the settings were created, and since the resource is virtual,
// it's impossible to refresh it if it doesn't exist anyway.
resource = workspaceRoot.findMember(resourcePath);
}
if (resource == null) {
// error.. skip this resource
if (children.length == 0) {
// we have an empty config to resource map. This call will create an empty resource set for the config name.
getResourcesToExclusionsMap(project,configName);
} else {
for (ICStorageElement child : children) {
if (child.getName().equals(RESOURCE_ELEMENT_NAME)) {
// get the resource path
String resourcePath = child.getAttribute(WORKSPACE_PATH_ATTRIBUTE_NAME);
if (resourcePath == null) {
// error... skip this resource
continue;
}
else {
addResourceToRefresh(project,configName, resource);
String resourceTypeString = child
.getAttribute(RESOURCE_TYPE_ATTRIBUTE_NAME);
if (resourceTypeString == null) {
// we'll do our best, but we won't be able to create handles to non-existent
// resources
resourceTypeString = OTHER_VALUE;
}
// find the resource
IResource resource = null;
if (resourceTypeString.equals(PROJECT_VALUE)) {
resource = workspaceRoot.getProject(resourcePath);
}
else if (resourceTypeString.equals(FILE_VALUE)) {
resource = workspaceRoot.getFile(new Path(resourcePath));
}
else if (resourceTypeString.equals(FOLDER_VALUE)) {
resource = workspaceRoot.getFolder(new Path(resourcePath));
}
else {
// Find arbitrary resource.
// The only way to do this is to ask the workspace root to find
// it, if it exists. If it doesn't exist, we have no way of
// creating a handle to the right type of object, so we must
// give up. In practice, this would likely happen if we had
// a virtual group resource that has been deleted somehow since
// the settings were created, and since the resource is virtual,
// it's impossible to refresh it if it doesn't exist anyway.
resource = workspaceRoot.findMember(resourcePath);
}
if (resource == null) {
// error.. skip this resource
continue;
}
else {
addResourceToRefresh(project,configName, resource);
// load any exclusions
List<RefreshExclusion> exclusions;
try {
exclusions = RefreshExclusion.loadData(
child, null, resource, this);
// load any exclusions
List<RefreshExclusion> exclusions;
try {
exclusions = RefreshExclusion.loadData(
child, null, resource, this);
// add them
for (RefreshExclusion exclusion : exclusions) {
addExclusion(project, configName, resource, exclusion);
// add them
for (RefreshExclusion exclusion : exclusions) {
addExclusion(project, configName, resource, exclusion);
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2012 Andrew Gvozdev and others.
* Copyright (c) 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
@ -7,6 +7,7 @@
*
* Contributors:
* Andrew Gvozdev - initial API and implementation
* IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core;
@ -313,10 +314,11 @@ public class BuildRunnerHelper implements Closeable {
/**
* Refresh project in the workspace.
*
* @param configName - the configuration to refresh
* @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
* has not been called yet.
*/
public void refreshProject(IProgressMonitor monitor) {
public void refreshProject(String configName, IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
@ -328,7 +330,7 @@ public class BuildRunnerHelper implements Closeable {
// The caveat is for huge projects, it may take sometimes at every build.
// Use the refresh scope manager to refresh
RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project, configName);
ResourcesPlugin.getWorkspace().run(runnable, null, IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
// ignore exceptions

View file

@ -25,7 +25,6 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterOptions;
import org.eclipse.cdt.ui.tests.BaseUITestCase;
import org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant;
import org.eclipse.cdt.internal.ui.editor.IndentUtil;
@ -979,4 +978,27 @@ public class CIndenterTest extends BaseUITestCase {
public void testIndentationAfterFunctionHeaderWithPointerReturnType_Bug334805() throws Exception {
assertIndenterResult();
}
//void test(int arg1, int arg2) {
//if (BooleanFunction1(arg1,
//arg2) ||
//BooleanFunction2(arg1, arg2)) {
//x++;
//}
//}
//void test(int arg1, int arg2) {
// if (BooleanFunction1(arg1,
// arg2) ||
// BooleanFunction2(arg1, arg2)) {
// x++;
// }
//}
public void testMultilineFunctionCall_Bug380490() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_COMPACT,
DefaultCodeFormatterConstants.INDENT_ON_COLUMN));
assertIndenterResult();
}
}

View file

@ -107,7 +107,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
*/
private List<ILanguageSettingsProvider> presentedProviders = null;
private final Map<String, ICOptionPage> optionsPageMap = new HashMap<String, ICOptionPage>();
private Map<String, List<ILanguageSettingsProvider>> initialProvidersByCfg = new HashMap<String, List<ILanguageSettingsProvider>>();
private Map<String/*cfgId*/, List<ILanguageSettingsProvider>> initialProvidersByCfg = new HashMap<String, List<ILanguageSettingsProvider>>();
/**
* Label provider for language settings providers displayed by this tab.
@ -169,6 +169,27 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
return findProvider(id, presentedProviders);
}
/**
* Returns the provider equal to provider at the point from which editing started.
* Used by option pages when there is a need.
* @param id - id of the provider.
*
* @return the initial provider.
*/
public ILanguageSettingsProvider getInitialProvider(String id) {
ILanguageSettingsProvider initialProvider = null;
if (page.isForPrefs()) {
initialProvider = LanguageSettingsManager.getWorkspaceProvider(id);
} else {
ICConfigurationDescription cfgDescription = getConfigurationDescription();
List<ILanguageSettingsProvider> initialProviders = initialProvidersByCfg.get(cfgDescription.getId());
if (initialProviders != null) {
initialProvider = findProvider(id, initialProviders);
}
}
return initialProvider;
}
/**
* Check if the provider is a working copy and can be modified.
*/
@ -508,6 +529,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
*/
private void createProjectStorageCheckBox(Composite parent) {
projectStorageCheckBox = new Button(parent, SWT.CHECK);
projectStorageCheckBox.setLayoutData(new GridData(SWT.END, SWT.NONE, false, false));
projectStorageCheckBox.setText(Messages.LanguageSettingsProviderTab_StoreEntriesInsideProject);
projectStorageCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
@ -561,7 +583,14 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
createLinkToPreferences(groupOptionsPage, 2);
}
compositeOptionsPage = new Composite(groupOptionsPage, SWT.NONE);
// composite to span over 2 columns
Composite comp = new Composite(groupOptionsPage, SWT.NONE);
comp.setLayout(new GridLayout());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.horizontalSpan = 2;
comp.setLayoutData(gd);
compositeOptionsPage = new Composite(comp, SWT.NONE);
compositeOptionsPage.setLayout(new TabFolderLayout());
}
@ -940,6 +969,7 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
optionsPage.setContainer(page);
optionsPage.createControl(compositeOptionsPage);
optionsPage.setVisible(false);
compositeOptionsPage.setBounds(compositeOptionsPage.getParent().getClientArea());
compositeOptionsPage.layout(true);
}
}
@ -985,6 +1015,8 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
boolean isEditable = isEditableForProject || isEditableForPrefs;
currentOptionsPage.getControl().setEnabled(isEditable);
compositeOptionsPage.setEnabled(isEditable);
compositeOptionsPage.setBounds(compositeOptionsPage.getParent().getClientArea());
compositeOptionsPage.layout(true);
}
}
@ -1136,7 +1168,16 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
@Override
protected void performOK() {
// Build Settings page
// give option pages a chance for provider-specific pre-apply actions
Collection<ICOptionPage> optionPages = optionsPageMap.values();
for (ICOptionPage op : optionPages) {
try {
op.performApply(null);
} catch (CoreException e) {
CUIPlugin.log("Error applying options page", e); //$NON-NLS-1$
}
}
if (page.isForPrefs()) {
try {
LanguageSettingsManager.setWorkspaceProviders(presentedProviders);
@ -1149,15 +1190,6 @@ public class LanguageSettingsProviderTab extends AbstractCPropertyTab {
if (masterPropertyPage != null && enableProvidersCheckBox.getEnabled()) {
masterPropertyPage.applyLanguageSettingsProvidersEnabled();
}
Collection<ICOptionPage> optionPages = optionsPageMap.values();
for (ICOptionPage op : optionPages) {
try {
op.performApply(null);
} catch (CoreException e) {
CUIPlugin.log("Error applying options page", e); //$NON-NLS-1$
}
}
}
@Override

View file

@ -202,7 +202,7 @@ LanguageSettingsProviderTab_ProviderOptions=Language Settings Provider Options
LanguageSettingsProviderTab_SettingEntries=Setting Entries
LanguageSettingsProviderTab_SettingEntriesTooltip=Setting Entries
LanguageSettingsProviderTab_ShareProviders=Share setting entries between projects (global provider)
LanguageSettingsProviderTab_StoreEntriesInsideProject=Store entries in project settings folder (easing project miration)
LanguageSettingsProviderTab_StoreEntriesInsideProject=Store entries in project settings folder (easing project migration)
LanguageSettingsProviderTab_TitleResetProviders=Reset Language Settings Providers
LanguageSettingsProviderTab_WorkspaceSettings=Workspace Settings

View file

@ -39,7 +39,6 @@ import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
* </p>
*/
public final class CIndenter {
/**
* The CDT Core preferences.
*/
@ -1588,6 +1587,7 @@ public final class CIndenter {
private int skipToPreviousListItemOrListStart() {
int startLine= fLine;
int startPosition= fPosition;
int linesSkippedInsideScopes = 0;
boolean continuationLineCandidate =
fToken == Symbols.TokenEQUAL || fToken == Symbols.TokenSHIFTLEFT ||
fToken == Symbols.TokenRPAREN;
@ -1596,7 +1596,7 @@ public final class CIndenter {
nextToken();
// If any line item comes with its own indentation, adapt to it
if (fLine < startLine) {
if (fLine < startLine - linesSkippedInsideScopes) {
try {
int lineOffset= fDocument.getLineOffset(startLine);
int bound= Math.min(fDocument.getLength(), startPosition + 1);
@ -1617,6 +1617,7 @@ public final class CIndenter {
return startPosition;
}
int line = fLine;
switch (fToken) {
// scopes: skip them
case Symbols.TokenRPAREN:
@ -1625,6 +1626,7 @@ public final class CIndenter {
case Symbols.TokenRBRACKET:
case Symbols.TokenRBRACE:
skipScope();
linesSkippedInsideScopes = line - fLine;
break;
// scope introduction: special treat who special is

View file

@ -22,12 +22,13 @@ import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsP
/**
* Abstract class to implement language settings providers Options page.
* @noextend This class is not intended to be subclassed by clients, only internally by CDT.
*
* @since 5.4
*/
public abstract class AbstractLanguageSettingProviderOptionPage extends AbstractCOptionPage {
private LanguageSettingsProviderTab providerTab;
private String providerId;
protected LanguageSettingsProviderTab providerTab;
protected String providerId;
/**
* Initialize the options page with the owning tab and provider ID.

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.cdt</groupId>
<artifactId>cdt-parent</artifactId>
<version>8.1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<version>2.2.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.tests.dsf.gdb</artifactId>
<packaging>eclipse-test-plugin</packaging>
<!-- Uncommenting this is useful when the repo is built first then you want to run tests on this plugin only -->
<!-- <repositories>
<repository>
<id>cdt.repo</id>
<url>file:/${basedir}/../../releng/org.eclipse.cdt.repo/target/repository</url>
<layout>p2</layout>
</repository>
</repositories>-->
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>true</useUIHarness>
<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
<includes>
<include>**/AutomatedSuite.*</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
<dependencies>
<dependency>
<artifactId>org.eclipse.platform.feature.group</artifactId>
<version>3.7.0</version>
<type>p2-installable-unit</type>
</dependency>
<dependency>
<artifactId>org.eclipse.cdt.feature.group</artifactId>
<version>8.1.0.${buildQualifier}</version>
<type>p2-installable-unit</type>
</dependency>
</dependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.tests.dsf.gdb.framework;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
@ -39,6 +40,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
@ -356,6 +358,22 @@ public class BaseTestCase {
protected void setGdbVersion() {
// Leave empty for the base class
}
/**
* This method will verify that the GDB binary is available, and if it is not, the test will
* be ignored. This method should be called by a Suite that specifies a specific GDB version.
*/
public static void ignoreIfGDBMissing() {
try {
// See if we can find GDB by actually running it.
String gdb = (String)globalLaunchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME);
Process process = ProcessFactory.getFactory().exec(gdb + " --version");
process.destroy();
} catch (IOException e) {
// If we cannot run GDB, just ignore the test case.
Assume.assumeNoException(e);
}
}
/**
* In some tests we need to start a gdbserver session without starting gdbserver.

View file

@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2012 Ericsson 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:
* Marc Khouzam (Ericsson) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests;
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4.Suite_7_4;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
/**
* This suite runs all suites that are part of the tests
* automatically run with each CDT build.
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
Suite_7_4.class,
// Can't run the Remote test just yet because they
// have the same names on the local tests, which is
// not handled by JUnit (https://bugs.eclipse.org/172256)
})
public class AutomatedSuite {}

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -43,5 +46,11 @@ import org.junit.runners.Suite;
/* Add your test class here */
})
public class Suite_6_6 {}
public class Suite_6_6 {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -12,6 +12,9 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -43,4 +46,9 @@ import org.junit.runners.Suite;
})
public class Suite_Remote_6_6 extends BaseRemoteSuite {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -43,4 +46,10 @@ import org.junit.runners.Suite;
/* Add your test class here */
})
public class Suite_6_7 {}
public class Suite_6_7 {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_7);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -12,6 +12,9 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -43,4 +46,9 @@ import org.junit.runners.Suite;
})
public class Suite_Remote_6_7 extends BaseRemoteSuite {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_7);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -43,4 +46,10 @@ import org.junit.runners.Suite;
/* Add your test class here */
})
public class Suite_6_8 {}
public class Suite_6_8 {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_8);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -12,6 +12,9 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -43,4 +46,9 @@ import org.junit.runners.Suite;
})
public class Suite_Remote_6_8 extends BaseRemoteSuite {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_8);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -46,4 +49,10 @@ import org.junit.runners.Suite;
/* Add your test class here */
})
public class Suite_7_0 {}
public class Suite_7_0 {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_0);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -12,6 +12,9 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -47,4 +50,9 @@ import org.junit.runners.Suite;
})
public class Suite_Remote_7_0 extends BaseRemoteSuite {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_0);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -46,4 +49,10 @@ import org.junit.runners.Suite;
/* Add your test class here */
})
public class Suite_7_1 {}
public class Suite_7_1 {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_1);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -12,6 +12,9 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -47,4 +50,9 @@ import org.junit.runners.Suite;
})
public class Suite_Remote_7_1 extends BaseRemoteSuite {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_1);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -46,4 +49,10 @@ import org.junit.runners.Suite;
/* Add your test class here */
})
public class Suite_7_2 {}
public class Suite_7_2 {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -12,6 +12,9 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -47,4 +50,9 @@ import org.junit.runners.Suite;
})
public class Suite_Remote_7_2 extends BaseRemoteSuite {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -46,4 +49,10 @@ import org.junit.runners.Suite;
/* Add your test class here */
})
public class Suite_7_3 {}
public class Suite_7_3 {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_3);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -12,6 +12,9 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_3;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -47,4 +50,9 @@ import org.junit.runners.Suite;
})
public class Suite_Remote_7_3 extends BaseRemoteSuite {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_3);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -46,4 +49,10 @@ import org.junit.runners.Suite;
/* Add your test class here */
})
public class Suite_7_4 {}
public class Suite_7_4 {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_4);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -12,6 +12,9 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_4;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -47,4 +50,9 @@ import org.junit.runners.Suite;
})
public class Suite_Remote_7_4 extends BaseRemoteSuite {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_4);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -11,6 +11,9 @@
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -46,4 +49,10 @@ import org.junit.runners.Suite;
/* Add your test class here */
})
public class Suite_7_5 {}
public class Suite_7_5 {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_5);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -12,6 +12,9 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_5;
import org.eclipse.cdt.dsf.mi.service.command.commands.Suite_Sessionless_Tests;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseRemoteSuite;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@ -47,4 +50,9 @@ import org.junit.runners.Suite;
})
public class Suite_Remote_7_5 extends BaseRemoteSuite {
@BeforeClass
public static void beforeClassMethod() {
BaseTestCase.setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_5);
BaseTestCase.ignoreIfGDBMissing();
}
}

View file

@ -1134,7 +1134,15 @@ public class FindReplaceDialog extends SelectionDialog
{
try
{
fMemoryBlock.setValue(currentPosition.subtract(fMemoryBlock.getBigBaseAddress()), replaceData);
if ((searchPhrase instanceof BigIntegerSearchPhrase) && (bytes.length > 0) && bytes[0].isEndianessKnown() && !bytes[0].isBigEndian())
{
// swap the bytes when replacing an integer on little-endian targets
fMemoryBlock.setValue(currentPosition.subtract(fMemoryBlock.getBigBaseAddress()), swapBytes(replaceData));
}
else
{
fMemoryBlock.setValue(currentPosition.subtract(fMemoryBlock.getBigBaseAddress()), replaceData);
}
}
catch(DebugException de)
{
@ -1376,9 +1384,18 @@ public class FindReplaceDialog extends SelectionDialog
byte[] targetBytes = new byte[bytes.length + 1];
targetBytes[0] = 0;
for(int i = 0; i < bytes.length; i++)
targetBytes[i + 1] = bytes[i].getValue();
{
if (bytes[i].isEndianessKnown() && !bytes[i].isBigEndian())
{
// swap the bytes when matching an integer on little-endian targets
targetBytes[i + 1] = bytes[bytes.length - i - 1].getValue();
}
else
{
targetBytes[i + 1] = bytes[i].getValue();
}
}
// TODO endian?
BigInteger targetBigInteger = new BigInteger(targetBytes);
return fPhrase.equals(targetBigInteger);
@ -1395,6 +1412,14 @@ public class FindReplaceDialog extends SelectionDialog
return processedBytes;
}
private byte[] swapBytes(byte[] bytes)
{
byte[] processedBytes = new byte[bytes.length];
for (int i = 0; i < bytes.length; i++)
processedBytes[i] = bytes[bytes.length - i - 1];
return processedBytes;
}
interface IMemorySearchQuery extends ISearchQuery
{
public IMemoryRenderingSite getMemoryView();

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -66,7 +66,6 @@ public class SRecordExporter implements IMemoryExporter
Composite composite = new Composite(parent, SWT.NONE)
{
@Override
public void dispose()
{
fProperties.put(TRANSFER_FILE, fFileText.getText());
@ -192,27 +191,25 @@ public class SRecordExporter implements IMemoryExporter
fStartText.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
boolean valid = true;
try
{
getStartAddress();
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger actualLength = getEndAddress().subtract(getStartAddress());
String lengthString = actualLength.toString();
if(!fLengthText.getText().equals(lengthString)) {
if ( ! actualLength.equals( BigInteger.ZERO ) ) {
fLengthText.setText(lengthString);
}
}
validate();
}
catch(Exception ex)
{
valid = false;
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
validate();
//fParentDialog.setValid(false);
}
fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) :
Display.getDefault().getSystemColor(SWT.COLOR_RED));
//
BigInteger endAddress = getEndAddress();
BigInteger startAddress = getStartAddress();
fLengthText.setText(endAddress.subtract(startAddress).toString());
validate();
}
public void keyPressed(KeyEvent e) {}
@ -222,23 +219,25 @@ public class SRecordExporter implements IMemoryExporter
public void keyReleased(KeyEvent e) {
try
{
getEndAddress();
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger endAddress = getEndAddress();
BigInteger startAddress = getStartAddress();
String lengthString = endAddress.subtract(startAddress).toString();
BigInteger actualLength = getEndAddress().subtract(getStartAddress());
String lengthString = actualLength.toString();
if(!fLengthText.getText().equals(lengthString))
fLengthText.setText(lengthString);
if(!fLengthText.getText().equals(lengthString)) {
if ( ! actualLength.equals( BigInteger.ZERO ) ) {
fLengthText.setText(lengthString);
}
}
validate();
}
catch(Exception ex)
{
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
validate();
//fParentDialog.setValid(false);
}
validate();
}
public void keyPressed(KeyEvent e) {}
@ -251,20 +250,22 @@ public class SRecordExporter implements IMemoryExporter
{
BigInteger length = getLength();
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
BigInteger startAddress = getStartAddress();
String endString = "0x" + startAddress.add(length).toString(16); //$NON-NLS-1$
if(!fEndText.getText().equals(endString))
String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$
if(!fEndText.getText().equals(endString)) {
if ( ! length.equals( BigInteger.ZERO ) ) {
fLengthText.setText(endString);
}
fEndText.setText(endString);
}
validate();
}
catch(Exception ex)
{
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
validate();
//fParentDialog.setValid(false);
}
validate();
}
public void keyPressed(KeyEvent e) {
@ -309,6 +310,10 @@ public class SRecordExporter implements IMemoryExporter
BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10);
if ( endAddress.bitLength() > 32 ) {
throw(new NumberFormatException("End Address is larger than 32 bits"));
}
return endAddress;
}
@ -319,6 +324,10 @@ public class SRecordExporter implements IMemoryExporter
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10);
if ( startAddress.bitLength() > 32 ) {
throw(new NumberFormatException("Start Address is larger than 32 bits"));
}
return startAddress;
}
@ -329,6 +338,7 @@ public class SRecordExporter implements IMemoryExporter
BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10);
return lengthAddress;
}
@ -377,7 +387,6 @@ public class SRecordExporter implements IMemoryExporter
public void exportMemory()
{
Job job = new Job("Memory Export to S-Record File"){ //$NON-NLS-1$
@Override
public IStatus run(IProgressMonitor monitor) {
try
{

View file

@ -28,6 +28,8 @@ import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
@ -73,7 +75,6 @@ public class SRecordImporter implements IMemoryImporter {
Composite composite = new Composite(parent, SWT.NONE)
{
@Override
public void dispose()
{
fProperties.put(TRANSFER_FILE, fFileText.getText());
@ -131,7 +132,17 @@ public class SRecordImporter implements IMemoryImporter {
public void widgetDefaultSelected(SelectionEvent e) {}
public void widgetSelected(SelectionEvent e) {
validate();
try
{
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
getStartAddress();
validate();
}
catch(Exception ex)
{
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
fParentDialog.setValid(false);
}
}
});
@ -190,27 +201,38 @@ public class SRecordImporter implements IMemoryImporter {
});
fStartText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
boolean valid = true;
fStartText.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
try
{
getStartAddress();
boolean restoreToAddress = fComboRestoreToThisAddress.getSelection();
if ( restoreToAddress ) {
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
getStartAddress();
validate();
}
else {
try
{
getStartAddress();
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
}
catch(Exception ex)
{
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
}
}
catch(Exception ex)
{
valid = false;
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
validate();
}
fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) :
Display.getDefault().getSystemColor(SWT.COLOR_RED));
//
validate();
}
public void keyPressed(KeyEvent e) {}
});
fFileText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validate();
@ -276,6 +298,11 @@ public class SRecordImporter implements IMemoryImporter {
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
hex ? 16 : 10);
if ( startAddress.bitLength() > 32 ) {
throw(new NumberFormatException("Start Address is larger than 32 bits"));
}
return startAddress;
}
@ -297,7 +324,6 @@ public class SRecordImporter implements IMemoryImporter {
public void importMemory() {
Job job = new Job("Memory Import from S-Record File"){ //$NON-NLS-1$
@Override
public IStatus run(IProgressMonitor monitor) {
try

View file

@ -162,6 +162,7 @@
<module>codan/org.eclipse.cdt.codan.core.test</module>
<module>build/org.eclipse.cdt.managedbuilder.core.tests</module>
<module>build/org.eclipse.cdt.managedbuilder.ui.tests</module>
<module>dsf-gdb/org.eclipse.cdt.tests.dsf.gdb</module>
<module>build/org.eclipse.cdt.autotools.core</module>
<module>build/org.eclipse.cdt.autotools.docs</module>