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-04-30 20:56:40 -04:00
commit b00af18d9b
91 changed files with 8285 additions and 767 deletions

View file

@ -494,11 +494,11 @@
<and>
` <instanceof value="org.eclipse.core.resources.IFile"/>
<test property="org.eclipse.cdt.ui.isSource" value="" />
<test property="org.eclipse.cdt.ui.isSource"/>
</and>
<and>
<instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/>
<test property="org.eclipse.cdt.ui.isSource" value="" />
<test property="org.eclipse.cdt.ui.isSource"/>
</and>
</or>

View file

@ -25,6 +25,7 @@ public class AllLanguageSettingsProvidersMBSTests extends TestSuite {
public AllLanguageSettingsProvidersMBSTests() {
super(AllLanguageSettingsProvidersMBSTests.class.getName());
addTestSuite(LanguageSettingsProvidersMBSTest.class);
addTestSuite(GCCBuildCommandParserTest.class);
addTestSuite(BuiltinSpecsDetectorTest.class);
addTestSuite(GCCBuiltinSpecsDetectorTest.class);

View file

@ -14,16 +14,23 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
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.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.internal.core.Cygwin;
import org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin;
import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
* Test cases to test GCC built-in specs detector.
@ -45,6 +52,20 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
}
}
/**
* Mock GCCBuiltinSpecsDetectorCygwin to gain access to protected methods.
*/
class MockGCCBuiltinSpecsDetectorCygwin extends GCCBuiltinSpecsDetectorCygwin {
@Override
public void startupForLanguage(String languageId) throws CoreException {
super.startupForLanguage(languageId);
}
@Override
public void shutdownForLanguage() {
super.shutdownForLanguage();
}
}
@Override
protected void setUp() throws Exception {
super.setUp();
@ -55,6 +76,21 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
super.tearDown();
}
/**
* 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);
assertNotNull(projectDescription);
assertEquals(1, projectDescription.getConfigurations().length);
// configuration description
ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
return cfgDescriptions;
}
/**
* Test expansion of variables in build command.
*/
@ -363,4 +399,68 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
assertEquals(1, entries.size());
}
/**
* Test parsing of include directives for Cygwin for global provider.
*/
public void testGCCBuiltinSpecsDetector_Cygwin_NoProject() throws Exception {
if (!Cygwin.isAvailable()) {
// Skip the test if Cygwin is not available.
return;
}
String cygwinLocation = "/usr/include";
String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
assertTrue("windowsLocation=["+windowsLocation+"]", new Path(windowsLocation).getDevice()!=null);
MockGCCBuiltinSpecsDetectorCygwin detector = new MockGCCBuiltinSpecsDetectorCygwin();
detector.startup(null, null);
detector.startupForLanguage(null);
detector.processLine("#include <...> search starts here:");
detector.processLine(" /usr/include");
detector.processLine("End of search list.");
detector.shutdownForLanguage();
detector.shutdown();
// check populated entries
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CIncludePathEntry(new Path(windowsLocation), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
/**
* Test parsing of include directives for Cygwin for provider running for a configuration.
*/
public void testGCCBuiltinSpecsDetector_Cygwin_Configuration() throws Exception {
if (!Cygwin.isAvailable()) {
// Skip the test if Cygwin is not available.
return;
}
String cygwinLocation = "/usr/include";
String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
assertTrue("windowsLocation=["+windowsLocation+"]", new Path(windowsLocation).getDevice()!=null);
// Create model project and folders to test
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
MockGCCBuiltinSpecsDetectorCygwin detector = new MockGCCBuiltinSpecsDetectorCygwin();
detector.startup(cfgDescription, null);
detector.startupForLanguage(null);
detector.processLine("#include <...> search starts here:");
detector.processLine(" /usr/include");
detector.processLine("End of search list.");
detector.shutdownForLanguage();
detector.shutdown();
// check populated entries
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CIncludePathEntry(new Path(windowsLocation), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
}

View file

@ -0,0 +1,190 @@
/*******************************************************************************
* 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.managedbuilder.language.settings.providers.tests;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsPersistenceProjectTests;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
/**
* Test creation of a new project in respect with language settings providers.
*/
public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
private static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID;
private static final String USER_LANGUAGE_SETTINGS_PROVIDER_ID = ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID;
private static final String GCC_SPECS_DETECTOR_ID = "org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector";
private static final String PROJECT_TYPE_EXECUTABLE_GNU = "cdt.managedbuild.target.gnu.exe";
private static final String LANGUAGE_SETTINGS_PROJECT_XML = LanguageSettingsPersistenceProjectTests.LANGUAGE_SETTINGS_PROJECT_XML;
private static final String LANGUAGE_SETTINGS_WORKSPACE_XML = LanguageSettingsPersistenceProjectTests.LANGUAGE_SETTINGS_WORKSPACE_XML;
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected void tearDown() throws Exception {
ManagedBuildTestHelper.removeProject(this.getName());
super.tearDown();
}
/**
* Imitate a new Project Wizard. New Project Wizards really do these things in CDT.
*/
private static IProject imitateNewProjectWizard(String name, String projectTypeId) throws CoreException {
IProject project = ManagedBuildTestHelper.createProject(name, projectTypeId);
ManagedBuildTestHelper.addManagedBuildNature(project);
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, true);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true);
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDescription);
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(cfg, cfgDescription);
assertTrue(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders().size() > 0);
}
CoreModel.getDefault().setProjectDescription(project, prjDescription);
return project;
}
/**
* Test new GNU Executable project.
*/
public void testGnuToolchainProviders() throws Exception {
// create a new project imitating wizard
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
// check that the language settings providers are in place.
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
{
ILanguageSettingsProvider provider = providers.get(0);
String id = provider.getId();
assertEquals(USER_LANGUAGE_SETTINGS_PROVIDER_ID, id);
assertEquals(false, LanguageSettingsManager.isPreferShared(id));
assertEquals(false, LanguageSettingsManager.isWorkspaceProvider(provider));
}
{
ILanguageSettingsProvider provider = providers.get(1);
String id = provider.getId();
assertEquals(MBS_LANGUAGE_SETTINGS_PROVIDER_ID, id);
assertEquals(true, LanguageSettingsManager.isPreferShared(id));
assertEquals(true, LanguageSettingsManager.isWorkspaceProvider(provider));
}
{
ILanguageSettingsProvider provider = providers.get(2);
String id = provider.getId();
assertEquals(GCC_SPECS_DETECTOR_ID, id);
assertEquals(true, LanguageSettingsManager.isPreferShared(id));
assertEquals(true, LanguageSettingsManager.isWorkspaceProvider(provider));
}
assertEquals(3, providers.size());
}
}
/**
* Test that no unnecessary storage file is created for language settings for default set
* of language settings providers.
*/
public void testProjectPersistence_Defaults() throws Exception {
// create a new project imitating wizard
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
// double-check that the project contains language settings providers
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds();
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(defaultIds.length, providers.size());
for (int i = 0; i < defaultIds.length; i++) {
assertEquals(providers.get(i).getId(), defaultIds[i]);
}
assertTrue(defaultIds.length > 0);
}
// no settings file in project area
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertEquals(false, xmlStorageFile.exists());
assertEquals(false, xmlStorageFile.getParent().exists()); // .settings folder
// no settings file in workspace area
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
assertEquals(false, xmlStorageFilePrjWsp.exists());
}
/**
* Test that storage file is created for language settings for empty set of language settings providers.
*/
public void testProjectPersistence_NoProviders() throws Exception {
// create a new project imitating wizard
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
// remove language settings providers from the project
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, true);
assertNotNull(prjDescription);
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
assertTrue(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders().size() == 0);
}
CoreModel.getDefault().setProjectDescription(project, prjDescription);
// settings file appears in project area
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertEquals(true, xmlStorageFile.exists());
// no settings file in workspace area
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
assertEquals(false, xmlStorageFilePrjWsp.exists());
}
}

View file

@ -308,13 +308,14 @@
</managedBuildRevision>
<configuration
id="org.eclipse.cdt.build.core.emptycfg"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;${Toolchain}"
name="%cfg1_empty">
</configuration>
<configuration
id="org.eclipse.cdt.build.core.prefbase.cfg"
name="%cfg1_base"
>
id="org.eclipse.cdt.build.core.prefbase.cfg"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;${Toolchain}"
name="%cfg1_base">
<toolChain
id="org.eclipse.cdt.build.core.prefbase.toolchain"
name="%toolChain.name"
@ -612,6 +613,14 @@
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider
class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin"
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin"
name="CDT GCC Builtin Compiler Settings Cygwin"
parameter="${COMMAND} -E -P -v -dD ${INPUTS}">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider
class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser"
id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"

View file

@ -263,7 +263,16 @@ Specifying this attribute is fully equivalent to specifying the &quot;org.eclips
<attribute name="errorParsers" type="string">
<annotation>
<documentation>
The semi-colon separated list of the default error parsers to be used with this configuration. The list is ordered with the first error parser on the list invoked first, the second error parser second, and so on. The list may contain the error parsers defined by CDT and/or other installed error parser extensions. The list of error parsers to be used may be changed by the user on a per-configuration basis. When specified, this overrides the tool-chain errorParsers attribute.
The semi-colon separated list of the default error parsers to be used with this configuration. The list is ordered with the first error parser on the list invoked first, the second error parser second, and so on. The list may contain the error parsers defined by CDT and/or other installed error parser extensions. The list of error parsers to be used may be changed by the user on a per-configuration basis. When specified, this overrides the tool-chain errorParsers attribute.
</documentation>
</annotation>
</attribute>
<attribute name="languageSettingsProviders" type="string">
<annotation>
<documentation>
Semicolon-separated list of providers ID implementing ILanguageSettingProvider interface.
This field could be amended with toolchain-level providers list by using ${Toolchain} keyword. Provider ID can be prefixed with &quot;*&quot;, in this case shared instance of the provider defined on workspace level is used. Also provider ID can be prefixed with &quot;-&quot; which will cause id to be removed from the preceeding list including providers defined with ${Toolchain} keyword.
If this field is not specified, &quot;*org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider&quot; (MBS Language Settings Provider) is used by default.
</documentation>
</annotation>
</attribute>
@ -405,7 +414,15 @@ Specifying this attribute is fully equivalent to specifying the &quot;org.eclips
<attribute name="errorParsers" type="string">
<annotation>
<documentation>
The semi-colon separated list of the default error parsers to be used with this tool-chain. The list is ordered with the first error parser on the list invoked first, the second error parser second, and so on. The list may contain the error parsers defined by CDT and/or other installed error parser extensions. When specified, this overrides the tool errorParsers attributes of the tool children of the tool-chain and the builder child of the tool-chain.
The semi-colon separated list of the default error parsers to be used with this tool-chain. The list is ordered with the first error parser on the list invoked first, the second error parser second, and so on. The list may contain the error parsers defined by CDT and/or other installed error parser extensions. When specified, this overrides the tool errorParsers attributes of the tool children of the tool-chain and the builder child of the tool-chain.
</documentation>
</annotation>
</attribute>
<attribute name="languageSettingsProviders" type="string">
<annotation>
<documentation>
Semicolon-separated list of providers ID implementing ILanguageSettingProvider interface. Provider ID can be prefixed with &quot;*&quot;, in this case shared instance of the provider defined on workspace level is used.
This list could be adjusted on configuration level in the corresponding attribute.
</documentation>
</annotation>
</attribute>
@ -732,14 +749,14 @@ The pathConverter of a toolchain applies for all tools of the toolchain except i
<attribute name="customBuildStep" type="boolean">
<annotation>
<documentation>
Specifies whether this Tool represents a user-define custom build step. The default is false. When True, the default value of the commandLinePattern attribute changes to “$(command)”.
Specifies whether this Tool represents a user-define custom build step. The default is false. When True, the default value of the commandLinePattern attribute changes to “$(command)�.
</documentation>
</annotation>
</attribute>
<attribute name="announcement" type="string">
<annotation>
<documentation>
Specifies a string that is written to the build output prior to each invocation of the tool. The default value is “Invoking tool-name (tool-id)…”
Specifies a string that is written to the build output prior to each invocation of the tool. The default value is “Invoking tool-name (tool-id)…�
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
@ -1066,7 +1083,7 @@ Overrides language id specified with the languageId attribute.
<attribute name="primaryInputType" type="string">
<annotation>
<documentation>
The id of the input type that is used in determining the build “rules” for the output type and for the default name of the output file. The default is the input type with primaryInput == true.
The id of the input type that is used in determining the build “rules� for the output type and for the default name of the output file. The default is the input type with primaryInput == true.
</documentation>
</annotation>
</attribute>
@ -1080,7 +1097,7 @@ Overrides language id specified with the languageId attribute.
<attribute name="outputPrefix" type="string">
<annotation>
<documentation>
Some tools produce files with a special prefix that must be specified. For example, a librarian on POSIX systems expects the output to be libtarget.a, so &apos;lib&apos; would be the prefix. The default is to use the Tool “outputPrefix” attribute if primaryOutput is True, otherwise the default is an empty string. This attribute supports MBS configuration context macros.
Some tools produce files with a special prefix that must be specified. For example, a librarian on POSIX systems expects the output to be libtarget.a, so &apos;lib&apos; would be the prefix. The default is to use the Tool “outputPrefix� attribute if primaryOutput is True, otherwise the default is an empty string. This attribute supports MBS configuration context macros.
</documentation>
</annotation>
</attribute>
@ -2035,11 +2052,11 @@ If the &quot;buildPathResolver&quot; attribute is specified, the &quot;pathDelim
<documentation>
Represents the applicability type for this enablement.
Can contain the following values:
UI_VISIBILITY the given enablement expression specifies whether the option is to be visible in UI,
UI_ENABLEMENT the given enablement expression specifies the enable state of the controls that represent the option in UI,
CMD_USAGE the given enablement expression specifies whether the option is to be used in command line
UI_VISIBILITY – the given enablement expression specifies whether the option is to be visible in UI,
UI_ENABLEMENT – the given enablement expression specifies the enable state of the controls that represent the option in UI,
CMD_USAGE – the given enablement expression specifies whether the option is to be used in command line
CONTAINER_ATTRIBUTE - the given enablement expressions specifies thecontainer attribute value
ALL this value means the combination of all the above values.
ALL – this value means the combination of all the above values.
Several types could be specified simultaneously using the &quot;|&quot; as a delimiter, e.g.:
type=&quot;UI_VISIBILITY|CMD_USAGE&quot;
@ -2173,7 +2190,7 @@ Default value is true.
<attribute name="value" type="string">
<annotation>
<documentation>
Specifies the expected value. If the current option value matches the value specified in this attribute, the checkOption element is treated as true, otherwise as false.
Specifies the expected value. If the current option value matches the value specified in this attribute, the checkOption element is treated as true, otherwise – as false.
The expected value could be specified either as a string that may contain build macros or as a regular expression. During the comparison, the build macros are resolved and the option value is checked to match the resulting string or regular expression. The way the expected value is specified and treated depends on the value of the isRegex attribute
</documentation>
</annotation>
@ -2188,14 +2205,14 @@ The expected value could be specified either as a string that may contain build
<attribute name="otherOptionId" type="string">
<annotation>
<documentation>
The id of the option which is to be compared with the option specified with the “optionId” attribute. The default is the id of the option that holds this expression. If the “value” attribute is specified, both the “otherOptionId” and the “otherHolderId” attributes are ignored. When searching for the option to be checked, MBS will examine all the options the holder contains along with all superclasses of each option to find the option with the specified id.
The id of the option which is to be compared with the option specified with the “optionId� attribute. The default is the id of the option that holds this expression. If the “value� attribute is specified, both the “otherOptionId� and the “otherHolderId� attributes are ignored. When searching for the option to be checked, MBS will examine all the options the holder contains along with all superclasses of each option to find the option with the specified id.
</documentation>
</annotation>
</attribute>
<attribute name="otherHolderId" type="string">
<annotation>
<documentation>
The option holder id that holds the option specified with the “otherOptionId” attribute. The default is the id of the holder that holds the container of this expression. If the “value” attribute is specified, both the “otherOptionId” and the “otherHolderId” attributes are ingnored. When searching for the needed holder, MBS will examine all the holders the current configuration contains along with all superclasses of each holder in order to find the holder with the specified id.
The option holder id that holds the option specified with the “otherOptionId� attribute. The default is the id of the holder that holds the container of this expression. If the “value� attribute is specified, both the “otherOptionId� and the “otherHolderId� attributes are ingnored. When searching for the needed holder, MBS will examine all the holders the current configuration contains along with all superclasses of each holder in order to find the holder with the specified id.
</documentation>
</annotation>
</attribute>
@ -2219,7 +2236,7 @@ The expected value could be specified either as a string that may contain build
<attribute name="value" type="string" use="required">
<annotation>
<documentation>
Specifies the expected value. If the current string specified in the “string” attribute matches the value specified in this attribute, the checkString element is treated as true, otherwise as false.
Specifies the expected value. If the current string specified in the “string� attribute matches the value specified in this attribute, the checkString element is treated as true, otherwise – as false.
The expected value could be specified either as a string that might contain the build macros or as a regular expression.
The way the value is specified and treated depends on the value of the isRegex attribute.
</documentation>

View file

@ -159,7 +159,12 @@ public class CfgScannerConfigUtil {
Set<String> profiles = new TreeSet<String>();
if (toolchain!=null) {
String toolchainProfileId = toolchain.getScannerConfigDiscoveryProfileId();
String toolchainProfileId = null;
if (toolchain instanceof ToolChain) {
toolchainProfileId = ((ToolChain) toolchain).getLegacyScannerConfigDiscoveryProfileId();
} else {
toolchainProfileId = toolchain.getScannerConfigDiscoveryProfileId();
}
if (toolchainProfileId!=null && toolchainProfileId.length()>0) {
profiles.add(toolchainProfileId);
}
@ -227,7 +232,7 @@ public class CfgScannerConfigUtil {
Set<String> profiles = new TreeSet<String>();
String attribute = ((InputType) inputType).getDiscoveryProfileIdAttribute();
String attribute = ((InputType) inputType).getLegacyDiscoveryProfileIdAttribute();
if (attribute!=null) {
// FIXME: temporary; we should add new method to IInputType instead of that
for (String profileId : attribute.split("\\|")) { //$NON-NLS-1$

View file

@ -46,6 +46,8 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont
// Schema element names
public static final String CONFIGURATION_ELEMENT_NAME = "configuration"; //$NON-NLS-1$
public static final String ERROR_PARSERS = "errorParsers"; //$NON-NLS-1$
/** @since 8.1 */
public static final String LANGUAGE_SETTINGS_PROVIDERS = "languageSettingsProviders";
public static final String EXTENSION = "artifactExtension"; //$NON-NLS-1$
public static final String PARENT = "parent"; //$NON-NLS-1$
@ -170,6 +172,14 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont
*/
public String[] getErrorParserList();
/**
* Returns default language settings providers IDs specified for the configuration.
* @return default language settings providers IDs.
*
* @since 8.1
*/
public String[] getDefaultLanguageSettingsProvidersIds();
/**
* Projects have C or CC natures. Tools can specify a filter so they are not
* misapplied to a project. This method allows the caller to retrieve a list

View file

@ -53,6 +53,9 @@ public interface IToolChain extends IBuildObject, IHoldsOptions {
// The attribute name for the scanner info collector
public static final String SCANNER_CONFIG_PROFILE_ID = "scannerConfigDiscoveryProfileId"; //$NON-NLS-1$
/** @since 8.1 */
public static final String LANGUAGE_SETTINGS_PROVIDERS = "languageSettingsProviders";
/**
* Returns the configuration that is the parent of this tool-chain.
*
@ -261,6 +264,15 @@ public interface IToolChain extends IBuildObject, IHoldsOptions {
*/
public void setErrorParserIds(String ids);
/**
* Returns the default language settings providers IDs.
*
* @return the default language settings providers IDs separated by semicolon or {@code null} if none.
*
* @since 8.1
*/
public String getDefaultLanguageSettingsProvidersIds();
/**
* Returns the scanner config discovery profile id or <code>null</code> if none.
*

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2011 IBM Corporation and others.
* Copyright (c) 2003, 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
@ -26,6 +26,7 @@ import java.util.Vector;
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -83,8 +84,10 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Version;
@ -92,6 +95,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private static final String EMPTY_CFG_ID = "org.eclipse.cdt.build.core.emptycfg"; //$NON-NLS-1$
private static final String LANGUAGE_SETTINGS_PROVIDER_DELIMITER = ";"; //$NON-NLS-1$
// Parent and children
private String parentId;
@ -102,6 +106,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
private String cleanCommand;
private String artifactExtension;
private String errorParserIds;
private String defaultLanguageSettingsProvidersAttribute;
private String[] defaultLanguageSettingsProvidersIds;
private String prebuildStep;
private String postbuildStep;
private String preannouncebuildStep;
@ -781,6 +787,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
// Get the semicolon separated list of IDs of the error parsers
errorParserIds = SafeStringInterner.safeIntern(element.getAttribute(ERROR_PARSERS));
// Get the initial/default language setttings providers IDs
defaultLanguageSettingsProvidersAttribute = SafeStringInterner.safeIntern(element.getAttribute(LANGUAGE_SETTINGS_PROVIDERS));
// Get the artifact extension
artifactExtension = SafeStringInterner.safeIntern(element.getAttribute(EXTENSION));
@ -1453,6 +1462,55 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return set;
}
private String getDefaultLanguageSettingsProvidersAttribute() {
if (defaultLanguageSettingsProvidersAttribute == null && parent instanceof Configuration) {
defaultLanguageSettingsProvidersAttribute = ((Configuration) parent).getDefaultLanguageSettingsProvidersAttribute();
}
return defaultLanguageSettingsProvidersAttribute;
}
@Override
public String[] getDefaultLanguageSettingsProvidersIds() {
defaultLanguageSettingsProvidersIds = null;
if (defaultLanguageSettingsProvidersIds == null) {
getDefaultLanguageSettingsProvidersAttribute();
if (defaultLanguageSettingsProvidersAttribute != null) {
List<String> ids = new ArrayList<String>();
String[] defaultIds = defaultLanguageSettingsProvidersAttribute.split(LANGUAGE_SETTINGS_PROVIDER_DELIMITER);
for (String id : defaultIds) {
if (id != null && !id.isEmpty()) {
if (id.startsWith("-")) {
id = id.substring(1);
ids.remove(id);
} else if (!ids.contains(id)){
if (id.contains("${Toolchain}")) {
IToolChain toolchain = getToolChain();
if (toolchain != null) {
String toolchainProvidersIds = toolchain.getDefaultLanguageSettingsProvidersIds();
if (toolchainProvidersIds != null) {
ids.addAll(Arrays.asList(toolchainProvidersIds.split(LANGUAGE_SETTINGS_PROVIDER_DELIMITER)));
} else {
String message = "Invalid use of ${Toolchain} tag, toolchain does not specify language settings providers. cfg=" + getId();
ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.ERROR, message, new Exception()));
}
}
} else {
ids.add(id);
}
}
}
}
defaultLanguageSettingsProvidersIds = ids.toArray(new String[ids.size()]);
} else if (parent != null) {
defaultLanguageSettingsProvidersIds = parent.getDefaultLanguageSettingsProvidersIds();
}
}
return defaultLanguageSettingsProvidersIds;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactExtension(java.lang.String)
*/

View file

@ -17,6 +17,7 @@ import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
@ -24,6 +25,7 @@ import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.internal.core.SafeStringInterner;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IInputOrder;
import org.eclipse.cdt.managedbuilder.core.IInputType;
@ -37,6 +39,7 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
@ -1838,9 +1841,56 @@ public class InputType extends BuildObject implements IInputType {
return id;
}
/**
* Temporary method to support compatibility during SD transition.
*/
private boolean isLanguageSettingsProvidersFunctionalityEnabled() {
boolean isLanguageSettingsProvidersEnabled = false;
ITool tool = getParent();
if (tool!=null) {
IBuildObject bo = tool.getParent();
if (bo instanceof IToolChain) {
IConfiguration cfg = ((IToolChain) bo).getParent();
if (cfg!=null) {
IResource rc = cfg.getOwner();
if (rc!=null) {
IProject project = rc.getProject();
isLanguageSettingsProvidersEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project);
}
}
}
}
return isLanguageSettingsProvidersEnabled;
}
/**
* Temporary method to support compatibility during SD transition.
* @noreference This method is not intended to be referenced by clients.
*/
public String getLegacyDiscoveryProfileIdAttribute(){
String profileId = buildInfoDicsoveryProfileId;
if (profileId == null) {
profileId = ScannerDiscoveryLegacySupport.getDeprecatedLegacyProfiles(id);
if (profileId == null && superClass instanceof InputType) {
profileId = ((InputType)superClass).getLegacyDiscoveryProfileIdAttribute();
}
}
return profileId;
}
public String getDiscoveryProfileIdAttribute(){
if(buildInfoDicsoveryProfileId == null && superClass != null)
return ((InputType)superClass).getDiscoveryProfileIdAttribute();
if (!isLanguageSettingsProvidersFunctionalityEnabled())
return getLegacyDiscoveryProfileIdAttribute();
return getDiscoveryProfileIdAttributeInternal();
}
/**
* Method extracted temporarily to support compatibility during SD transition.
*/
private String getDiscoveryProfileIdAttributeInternal(){
if(buildInfoDicsoveryProfileId == null && superClass instanceof InputType)
return ((InputType)superClass).getDiscoveryProfileIdAttributeInternal();
return buildInfoDicsoveryProfileId;
}

View file

@ -440,6 +440,12 @@ public class MultiConfiguration extends MultiItemsHolder implements
return s;
}
@Override
public String[] getDefaultLanguageSettingsProvidersIds() {
ManagedBuilderCorePlugin.error("Default Language Settings Providers are not supported in multiconfiguration mode");
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getFilteredTools()
*/

View file

@ -24,6 +24,7 @@ import java.util.SortedMap;
import java.util.StringTokenizer;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
@ -50,6 +51,8 @@ import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSu
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@ -85,6 +88,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
private String targetToolIds;
private String secondaryOutputIds;
private Boolean isAbstract;
private String defaultLanguageSettingsProvidersIds;
private String scannerConfigDiscoveryProfileId;
private String versionsSupported;
private String convertToId;
@ -554,6 +558,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
// Get the target tool id
targetToolIds = SafeStringInterner.safeIntern(element.getAttribute(TARGET_TOOL));
// Get the initial/default language setttings providers IDs
defaultLanguageSettingsProvidersIds = element.getAttribute(LANGUAGE_SETTINGS_PROVIDERS);
// Get the scanner config discovery profile id
scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID));
String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
@ -1529,18 +1536,72 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
setDirty(true);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getScannerConfigDiscoveryProfileId()
*/
@Override
@Override
public String getDefaultLanguageSettingsProvidersIds() {
if (defaultLanguageSettingsProvidersIds == null) {
if (superClass instanceof IToolChain) {
defaultLanguageSettingsProvidersIds = ((IToolChain) superClass).getDefaultLanguageSettingsProvidersIds();
}
}
return defaultLanguageSettingsProvidersIds;
}
/**
* Temporary method to support compatibility during SD transition.
*/
private boolean isLanguageSettingsProvidersFunctionalityEnabled() {
boolean isLanguageSettingsProvidersEnabled = false;
IConfiguration cfg = getParent();
if (cfg!=null) {
IResource rc = cfg.getOwner();
if (rc!=null) {
IProject project = rc.getProject();
isLanguageSettingsProvidersEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project);
}
}
return isLanguageSettingsProvidersEnabled;
}
/**
* Temporary method to support compatibility during SD transition.
* @noreference This method is not intended to be referenced by clients.
*/
public String getLegacyScannerConfigDiscoveryProfileId() {
String profileId = scannerConfigDiscoveryProfileId;
if (profileId==null) {
profileId = ScannerDiscoveryLegacySupport.getDeprecatedLegacyProfiles(id);
if (profileId == null) {
IToolChain superClass = getSuperClass();
if (superClass instanceof ToolChain) {
profileId = ((ToolChain) superClass).getLegacyScannerConfigDiscoveryProfileId();
}
}
}
return profileId;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getScannerConfigDiscoveryProfileId()
*/
@Override
public String getScannerConfigDiscoveryProfileId() {
if (scannerConfigDiscoveryProfileId == null) {
if (getSuperClass() != null) {
return getSuperClass().getScannerConfigDiscoveryProfileId();
}
}
return scannerConfigDiscoveryProfileId;
}
if (!isLanguageSettingsProvidersFunctionalityEnabled())
return getLegacyScannerConfigDiscoveryProfileId();
return getScannerConfigDiscoveryProfileIdInternal();
}
/**
* Method extracted temporarily to support compatibility during SD transition.
*/
private String getScannerConfigDiscoveryProfileIdInternal() {
if (scannerConfigDiscoveryProfileId == null && superClass instanceof ToolChain) {
return ((ToolChain) getSuperClass()).getScannerConfigDiscoveryProfileIdInternal();
}
return scannerConfigDiscoveryProfileId;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setScannerConfigDiscoveryProfileId(java.lang.String)

View file

@ -20,6 +20,10 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigInfoFactory2;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.ILanguageDescriptor;
import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -492,9 +496,7 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
}
@Override
public CConfigurationData loadConfiguration(ICConfigurationDescription cfgDescription,
IProgressMonitor monitor)
throws CoreException {
public CConfigurationData loadConfiguration(ICConfigurationDescription cfgDescription, IProgressMonitor monitor) throws CoreException {
if(cfgDescription.isPreferenceConfiguration())
return loadPreferences(cfgDescription);
@ -509,11 +511,56 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
// Update the ManagedBuildInfo in the ManagedBuildManager map. Doing this creates a barrier for subsequent
// ManagedBuildManager#getBuildInfo(...) see Bug 305146 for more
ManagedBuildManager.setLoaddedBuildInfo(cfgDescription.getProjectDescription().getProject(), info);
setDefaultLanguageSettingsProvidersIds(cfg, cfgDescription);
return cfg.getConfigurationData();
}
return null;
}
private static List<ILanguageSettingsProvider> getDefaultLanguageSettingsProviders(IConfiguration cfg) {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
String[] ids = cfg.getDefaultLanguageSettingsProvidersIds();
if (ids != null) {
for (String id : ids) {
ILanguageSettingsProvider provider = null;
if (!LanguageSettingsManager.isPreferShared(id)) {
provider = LanguageSettingsManager.getExtensionProviderCopy(id, false);
}
if (provider == null) {
provider = LanguageSettingsManager.getWorkspaceProvider(id);
}
providers.add(provider);
}
}
// AG TODO - should it be when empty or when ids==null?
if (providers.isEmpty()) {
providers = ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy();
}
return providers;
}
private static void setDefaultLanguageSettingsProvidersIds(IConfiguration cfg, ICConfigurationDescription cfgDescription) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
List<ILanguageSettingsProvider> providers = getDefaultLanguageSettingsProviders(cfg);
String[] ids = new String[providers.size()];
for (int i = 0; i < ids.length; i++) {
ILanguageSettingsProvider provider = providers.get(i);
ids[i] = provider.getId();
}
((ILanguageSettingsProvidersKeeper) cfgDescription).setDefaultLanguageSettingsProvidersIds(ids);
}
}
public static void setDefaultLanguageSettingsProviders(IConfiguration cfg, ICConfigurationDescription cfgDescription) {
setDefaultLanguageSettingsProvidersIds(cfg, cfgDescription);
List<ILanguageSettingsProvider> providers = getDefaultLanguageSettingsProviders(cfg);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
}
private boolean isPersistedCfg(ICConfigurationDescription cfgDescription){
return cfgDescription.getSessionProperty(CFG_PERSISTED_PROPERTY) != null;
}

View file

@ -0,0 +1,68 @@
/*******************************************************************************
* 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.managedbuilder.internal.language.settings.providers;
import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
import org.eclipse.core.resources.IResource;
/**
* Class to detect built-in compiler settings.
* The paths are converted to cygwin "file-system" representation.
*
*/
public class GCCBuiltinSpecsDetectorCygwin extends GCCBuiltinSpecsDetector {
private static final URI CYGWIN_ROOT;
static {
try {
CYGWIN_ROOT = new URI("cygwin:/"); //$NON-NLS-1$
} catch (URISyntaxException e) {
// hey we know this works
throw new IllegalStateException(e);
}
}
@Override
protected URI getMappedRootURI(IResource sourceFile, String parsedResourceName) {
if (mappedRootURI == null) {
mappedRootURI = super.getMappedRootURI(sourceFile, parsedResourceName);
if (mappedRootURI == null) {
mappedRootURI = CYGWIN_ROOT;
}
}
return mappedRootURI;
}
@Override
protected URI getBuildDirURI(URI mappedRootURI) {
if (buildDirURI == null) {
buildDirURI = super.getBuildDirURI(mappedRootURI);
if (buildDirURI == null) {
buildDirURI = CYGWIN_ROOT;
}
}
return buildDirURI;
}
@Override
public GCCBuiltinSpecsDetectorCygwin cloneShallow() throws CloneNotSupportedException {
return (GCCBuiltinSpecsDetectorCygwin) super.cloneShallow();
}
@Override
public GCCBuiltinSpecsDetectorCygwin clone() throws CloneNotSupportedException {
return (GCCBuiltinSpecsDetectorCygwin) super.clone();
}
}

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.core.errorparsers.RegexErrorPattern;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@ -167,6 +168,11 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
}
setSettingEntries(currentCfgDescription, rc, currentLanguageId, entries);
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logInfo(getPrefixForLog()
+ getClass().getSimpleName() + " collected " + (entries!=null ? ("" + entries.size()) : "null") + " entries for " + rc);
}
/**

View file

@ -37,6 +37,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.internal.core.BuildRunnerHelper;
import org.eclipse.cdt.internal.core.XmlUtil;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.utils.CommandLineUtil;
@ -317,12 +318,17 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
@Override
public void registerListener(ICConfigurationDescription cfgDescription) {
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logInfo(getPrefixForLog() + "registerListener [" + System.identityHashCode(this) + "] " + this);
currentCfgDescription = cfgDescription;
execute();
}
@Override
public void unregisterListener() {
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logInfo(getPrefixForLog() + "unregisterListener [" + System.identityHashCode(this) + "] " + this);
}
@Override
@ -347,6 +353,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
*/
protected void execute() {
if (isExecuted) {
// AG FIXME - temporary log to remove before CDT Juno release
// LanguageSettingsLogger.logInfo(getPrefixForLog() + "Already executed [" + System.identityHashCode(this) + "] " + this);
return;
}
isExecuted = true;
@ -385,6 +393,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
}
job.setRule(rule);
job.schedule();
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logInfo(getPrefixForLog() + "Execution scheduled [" + System.identityHashCode(this) + "] " + this);
}
/**
@ -481,6 +492,11 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
protected void shutdownForLanguage() {
if (detectedSettingEntries != null && detectedSettingEntries.size() > 0) {
collected = detectedSettingEntries.size();
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logInfo(getPrefixForLog()
+ getClass().getSimpleName() + " collected " + detectedSettingEntries.size() + " entries" + " for language " + currentLanguageId);
setSettingEntries(currentCfgDescription, currentResource, currentLanguageId, detectedSettingEntries);
}
detectedSettingEntries = null;

View file

@ -38,6 +38,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.internal.core.XmlUtil;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.filesystem.EFS;
@ -556,6 +557,19 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
return buildDirURI;
}
// AG FIXME - temporary, remove me
@Deprecated
protected String getPrefixForLog() {
String str;
if (currentCfgDescription!= null) {
IProject ownerProject = currentCfgDescription.getProjectDescription().getProject();
str = ownerProject + ":" + currentCfgDescription.getName();
} else {
str = "[global]";
}
return str + ": ";
}
/**
* Sets language settings entries for current configuration description, current resource
* and current language ID.
@ -564,6 +578,10 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
*/
protected void setSettingEntries(List<ICLanguageSettingEntry> entries) {
setSettingEntries(currentCfgDescription, currentResource, currentLanguageId, entries);
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logInfo(getPrefixForLog()
+ getClass().getSimpleName() + " collected " + (entries!=null ? ("" + entries.size()) : "null") + " entries for " + currentResource);
}
/**

View file

@ -1269,7 +1269,6 @@
dependencyExtensions="h"
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator2"
id="cdt.managedbuild.tool.gnu.c.compiler.input"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"
languageId="org.eclipse.cdt.core.gcc">
</inputType>
<outputType
@ -1591,7 +1590,6 @@
dependencyExtensions="h,H,hpp"
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator2"
id="cdt.managedbuild.tool.gnu.cpp.compiler.input"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"
languageId="org.eclipse.cdt.core.g++">
</inputType>
<outputType
@ -1658,7 +1656,7 @@
<inputType
id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"
superClass="cdt.managedbuild.tool.gnu.c.compiler.input"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
/>
</tool>
<tool
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin"
@ -1672,7 +1670,7 @@
<inputType
id="cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin"
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"/>
/>
</tool>
<builder
@ -1705,10 +1703,11 @@
<toolChain
archList="all"
osList="linux,hpux,aix,qnx"
id="cdt.managedbuild.toolchain.gnu.base"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser;org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"
name="%ToolChainName.Linux"
targetTool="cdt.managedbuild.tool.gnu.c.linker;cdt.managedbuild.tool.gnu.cpp.linker;cdt.managedbuild.tool.gnu.archiver"
id="cdt.managedbuild.toolchain.gnu.base">
osList="linux,hpux,aix,qnx"
targetTool="cdt.managedbuild.tool.gnu.c.linker;cdt.managedbuild.tool.gnu.cpp.linker;cdt.managedbuild.tool.gnu.archiver">
<targetPlatform
id="cdt.managedbuild.target.gnu.platform.base"
name="%PlatformName.Dbg"
@ -1773,6 +1772,7 @@
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
id="cdt.managedbuild.toolchain.gnu.cygwin.base"
isToolChainSupported="org.eclipse.cdt.managedbuilder.gnu.cygwin.IsGnuCygwinToolChainSupported"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser;org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin"
name="%ToolChainName.Cygwin"
osList="win32"
targetTool="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base;cdt.managedbuild.tool.gnu.c.linker.cygwin.base;cdt.managedbuild.tool.gnu.archiver">
@ -1842,6 +1842,7 @@
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.gnu.mingw.MingwEnvironmentVariableSupplier"
id="cdt.managedbuild.toolchain.gnu.mingw.base"
isToolChainSupported="org.eclipse.cdt.managedbuilder.gnu.mingw.MingwIsToolChainSupported"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser;org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"
name="%ToolChainName.MinGW"
osList="win32"
targetTool="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base;cdt.managedbuild.tool.gnu.c.linker.mingw.base;cdt.managedbuild.tool.gnu.archiver">
@ -2083,9 +2084,9 @@
</toolChain>
<configuration
id="cdt.managedbuild.config.gnu.base"
cleanCommand="rm -rf"
>
id="cdt.managedbuild.config.gnu.base"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;${Toolchain};-org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser">
<enablement type="CONTAINER_ATTRIBUTE"
attribute="artifactExtension"
value="so"
@ -2480,10 +2481,10 @@
</projectType>
<configuration
id="cdt.managedbuild.config.gnu.cygwin.base"
cleanCommand="rm -rf"
artifactExtension="exe"
>
cleanCommand="rm -rf"
id="cdt.managedbuild.config.gnu.cygwin.base"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;${Toolchain};-org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser">
<enablement type="CONTAINER_ATTRIBUTE"
attribute="artifactExtension"
value="dll"
@ -2878,10 +2879,10 @@
</projectType>
<configuration
id="cdt.managedbuild.config.gnu.mingw.base"
cleanCommand="rm -rf"
artifactExtension="exe"
>
cleanCommand="rm -rf"
id="cdt.managedbuild.config.gnu.mingw.base"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;${Toolchain};-org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser">
<enablement type="CONTAINER_ATTRIBUTE"
attribute="artifactExtension"
value="dll"

View file

@ -207,6 +207,12 @@ public class TestConfiguration implements IConfiguration {
return null;
}
@Override
public String[] getDefaultLanguageSettingsProvidersIds() {
// TODO Auto-generated method stub
return null;
}
@Override
public ITool[] getFilteredTools() {
// TODO Auto-generated method stub

View file

@ -364,6 +364,10 @@ public class TestToolchain extends HoldsOptions implements IToolChain {
return false;
}
@Override
public String getDefaultLanguageSettingsProvidersIds() {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -14,6 +14,7 @@ Export-Package: org.eclipse.cdt.managedbuilder.ui.preferences,
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.console;bundle-version="[3.5.100,4.0.0)",
org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)",
org.eclipse.cdt.ui;bundle-version="[5.0.0,6.0.0)",
org.eclipse.cdt.managedbuilder.core;bundle-version="[8.1.0,9.0.0)",

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

View file

@ -92,6 +92,9 @@ Source.location=Source Location
Output.location=Output Location
Binary.parsers=Binary Parsers
Error.parsers=Error Parsers
Language.settings.providers=Discovery
LanguageSettingsProvidersTab.name=Discovery
LanguageSettingsProvidersTab.tooltip=Language settings providers
Data.hierarchy=Data Hierarchy
Preferred.toolchains=Preferred Toolchains
Wizard.defaults=Wizard Defaults

View file

@ -456,6 +456,15 @@
helpId="cdt_u_pref_multi_cfg"
parent="org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_MultiConfig">
</tab>
<!-- AG FIXME - rather use managedbuilder page ??? -->
<tab
class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab"
icon="icons/obj16/search.gif"
name="%LanguageSettingsProvidersTab.name"
parent="org.eclipse.cdt.make.internal.ui.preferences.BuildSettingsPreferencePage"
tooltip="%LanguageSettingsProvidersTab.tooltip"
weight="000">
</tab>
</extension>
<extension
@ -534,7 +543,7 @@
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
</adapt>
<test property="org.eclipse.cdt.ui.pageEnabled" value="export" />
<test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.export.page.enable=true"/>
</and>
</enabledWhen>
</page>
@ -564,7 +573,7 @@
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
</adapt>
<test property="org.eclipse.cdt.ui.pageEnabled" value="toolEdit" />
<test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.toolchain.modification.disable=false"/>
</and>
</enabledWhen>
</page>
@ -625,6 +634,7 @@
name="%MBSPerProjectProfile.name"
profileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"/>
</extension>
<extension
point="org.eclipse.cdt.ui.workingSetConfigurations">
<projectConfigurationFactory
@ -648,6 +658,45 @@
</description>
</wizard>
</extension>
<extension
point="org.eclipse.cdt.ui.LanguageSettingsProviderAssociation">
<id-association
id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"
icon="icons/obj16/mbs.gif"
ui-clear-entries="false"
ui-edit-entries="false">
</id-association>
<class-association
class="org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser"
icon="icons/obj16/log_obj.gif"
page="org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers.GCCBuildCommandParserOptionPage"
ui-clear-entries="true"
ui-edit-entries="false">
</class-association>
<class-association
class="org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector"
icon="icons/obj16/inspect_system.gif"
page="org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers.BuiltinSpecsDetectorOptionPage"
ui-clear-entries="true"
ui-edit-entries="false">
</class-association>
</extension>
<extension
point="org.eclipse.cdt.core.CBuildConsole">
<CBuildConsole
id="org.eclipse.cdt.managedbuilder.ScannerDiscoveryConsole"
class="org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers.ScannerDiscoveryConsole">
</CBuildConsole>
</extension>
<extension
point="org.eclipse.cdt.core.CBuildConsole">
<CBuildConsole
id="org.eclipse.cdt.managedbuilder.ScannerDiscoveryGlobalConsole"
class="org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers.ScannerDiscoveryGlobalConsole">
</CBuildConsole>
</extension>
<extension
point="org.eclipse.cdt.ui.projectTypePages">
<projectTypePage

View file

@ -61,6 +61,10 @@ public class Messages extends NLS {
public static String BuildToolSettingsPage_tool_advancedSettings;
public static String BuildToolSettingsPage_tool_command;
public static String BuildToolSettingsPage_tool_commandLinePattern;
public static String BuiltinSpecsDetectorOptionPage_AllocateConsole;
public static String BuiltinSpecsDetectorOptionPage_Browse;
public static String BuiltinSpecsDetectorOptionPage_ChooseFile;
public static String BuiltinSpecsDetectorOptionPage_CompilerSpecsCommand;
public static String CConfigWizardPage_0;
public static String CConfigWizardPage_1;
public static String CConfigWizardPage_10;
@ -105,6 +109,12 @@ public class Messages extends NLS {
public static String DiscoveryTab_ErrorClearingEntries;
public static String EnvironmentTab_15;
public static String EnvironmentTab_23;
public static String GCCBuildCommandParserOptionPage_CompilerPattern;
public static String GCCBuildCommandParserOptionPage_ContainerForDiscoveredEntries;
public static String GCCBuildCommandParserOptionPage_File;
public static String GCCBuildCommandParserOptionPage_Folder;
public static String GCCBuildCommandParserOptionPage_Project;
public static String GCCBuildCommandParserOptionPage_ResolvePaths;
public static String MacrosBlock_label_delete_all_confirm_message;
public static String MacrosBlock_label_delete_all_confirm_title;
public static String MacrosBlock_label_delete_confirm_message;
@ -212,6 +222,7 @@ public class Messages extends NLS {
public static String PropertyPageDefsTab_8;
public static String PropertyPageDefsTab_9;
public static String PropertyPageDefsTab_showIncludeFileTab;
public static String PropertyPageDefsTab_showProvidersTab;
public static String RefreshPolicyExceptionDialog_addDialogLabel;
public static String RefreshPolicyExceptionDialog_AddExceptionInfoDialog_message;
public static String RefreshPolicyExceptionDialog_AddExceptionInfoDialog_title;

View file

@ -274,6 +274,7 @@ PropertyPageDefsTab_7=Show disc. page names if they are unique. Else show profil
PropertyPageDefsTab_8=Always show names + profile IDs
PropertyPageDefsTab_9=Always show profile IDs only
PropertyPageDefsTab_showIncludeFileTab=Display "Include Files" tab
PropertyPageDefsTab_showProvidersTab=Display "Preprocessor Include Paths" tabs
ProjectConvert_convertersList=Converters List
AbstractPrefPage_0=\ Preference settings will be applied to new projects \n only when there were no toolchains selected.
@ -303,3 +304,15 @@ NewCfgDialog_5=Import predefined
ToolChainSelectionPage_Description=Select the initial toolchain for this project.
ToolChainSelectionPage_Title=Select Tool Chain
# Language Settings Providers
BuiltinSpecsDetectorOptionPage_AllocateConsole=Allocate console in the Console View
BuiltinSpecsDetectorOptionPage_Browse=Browse...
BuiltinSpecsDetectorOptionPage_ChooseFile=Choose file
BuiltinSpecsDetectorOptionPage_CompilerSpecsCommand=Command to get compiler specs:
GCCBuildCommandParserOptionPage_CompilerPattern=Compiler command pattern:
GCCBuildCommandParserOptionPage_ContainerForDiscoveredEntries=Container to keep discovered entries
GCCBuildCommandParserOptionPage_File=File (use when settings vary for different files)
GCCBuildCommandParserOptionPage_Folder=Folder (use when settings are the same for all files in each folder)
GCCBuildCommandParserOptionPage_Project=Project (use when settings are the same for all files in the project)
GCCBuildCommandParserOptionPage_ResolvePaths=Use heuristics to resolve paths

View file

@ -0,0 +1,155 @@
/*******************************************************************************
* 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.managedbuilder.internal.ui.language.settings.providers;
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.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
* Options page for {@link AbstractBuiltinSpecsDetector}.
*/
public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettingProviderOptionPage {
private boolean fEditable;
private Text inputCommand;
private Button allocateConsoleCheckBox;
@Override
public void createControl(Composite parent) {
fEditable = parent.isEnabled();
AbstractBuiltinSpecsDetector provider = (AbstractBuiltinSpecsDetector) getProvider();
Composite composite = createCompositeForPageArea(parent);
createCompilerCommandInputControl(composite, provider);
createBrowseButton(composite);
createConsoleCheckbox(composite, provider);
setControl(composite);
}
/**
* Create composite for the page.
*/
private Composite createCompositeForPageArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 1;
layout.marginHeight = 1;
layout.marginRight = 1;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Dialog.applyDialogFont(composite);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
composite.setLayoutData(gd);
return composite;
}
/**
* Create input control for compiler command.
*/
private void createCompilerCommandInputControl(Composite composite, AbstractBuiltinSpecsDetector provider) {
Label label = ControlFactory.createLabel(composite, Messages.BuiltinSpecsDetectorOptionPage_CompilerSpecsCommand);
GridData gd = new GridData();
gd.horizontalSpan = 2;
label.setLayoutData(gd);
label.setEnabled(fEditable);
inputCommand = ControlFactory.createTextField(composite, SWT.SINGLE | SWT.BORDER);
String command = provider.getCommand();
inputCommand.setText(command!=null ? command : ""); //$NON-NLS-1$
inputCommand.setEnabled(fEditable);
inputCommand.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String text = inputCommand.getText();
AbstractBuiltinSpecsDetector provider = (AbstractBuiltinSpecsDetector) getProvider();
if (!text.equals(provider.getCommand())) {
AbstractBuiltinSpecsDetector selectedProvider = (AbstractBuiltinSpecsDetector) getProviderWorkingCopy();
selectedProvider.setCommand(text);
refreshItem(selectedProvider);
}
}
});
}
/**
* Create "Browse" button.
*/
private void createBrowseButton(Composite composite) {
Button button = ControlFactory.createPushButton(composite, Messages.BuiltinSpecsDetectorOptionPage_Browse);
button.setEnabled(fEditable);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
dialog.setText(Messages.BuiltinSpecsDetectorOptionPage_ChooseFile);
String fileName = inputCommand.getText();
// taking chance that the first word is a compiler path
int space = fileName.indexOf(' ');
if (space > 0) {
fileName = fileName.substring(0, space);
}
IPath folder = new Path(fileName).removeLastSegments(1);
dialog.setFilterPath(folder.toOSString());
String chosenFile = dialog.open();
if (chosenFile != null) {
inputCommand.insert(chosenFile);
}
}
});
}
/**
* Create check-box for console.
*/
private void createConsoleCheckbox(Composite composite, AbstractBuiltinSpecsDetector provider) {
allocateConsoleCheckBox = new Button(composite, SWT.CHECK);
allocateConsoleCheckBox.setText(Messages.BuiltinSpecsDetectorOptionPage_AllocateConsole);
allocateConsoleCheckBox.setSelection(provider.isConsoleEnabled());
allocateConsoleCheckBox.setEnabled(fEditable);
allocateConsoleCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean enabled = allocateConsoleCheckBox.getSelection();
AbstractBuiltinSpecsDetector provider = (AbstractBuiltinSpecsDetector) getProvider();
if (enabled != provider.isConsoleEnabled()) {
AbstractBuiltinSpecsDetector selectedProvider = (AbstractBuiltinSpecsDetector) getProviderWorkingCopy();
selectedProvider.setConsoleEnabled(enabled);
refreshItem(selectedProvider);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
}
}

View file

@ -0,0 +1,231 @@
/*******************************************************************************
* 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.managedbuilder.internal.ui.language.settings.providers;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser;
import org.eclipse.cdt.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
* Options page for {@link AbstractBuildCommandParser}.
*
*/
public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSettingProviderOptionPage {
private boolean fEditable;
private Text inputCommand;
private Button expandRelativePathCheckBox;
private Button scopeProjectRadioButton;
private Button scopeFolderRadioButton;
private Button scopeFileRadioButton;
@Override
public void createControl(Composite parent) {
fEditable = parent.isEnabled();
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
Composite composite = new Composite(parent, SWT.NONE);
createCompositeForPageArea(composite);
createCompilerPatternInputControl(provider, composite);
createResourceScopeGroup(provider, composite);
createResolvePathsCheckbox(composite, provider);
setControl(composite);
}
/**
* Create composite for the page.
*/
private void createCompositeForPageArea(final Composite composite) {
{
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 1;
layout.marginHeight = 1;
layout.marginRight = 1;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Dialog.applyDialogFont(composite);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
composite.setLayoutData(gd);
}
}
/**
* Create input control for compiler pattern.
*/
private void createCompilerPatternInputControl(AbstractBuildCommandParser provider, Composite composite) {
Label label = ControlFactory.createLabel(composite, Messages.GCCBuildCommandParserOptionPage_CompilerPattern);
GridData gd = new GridData();
gd.horizontalSpan = 1;
label.setLayoutData(gd);
label.setEnabled(fEditable);
inputCommand = ControlFactory.createTextField(composite, SWT.SINGLE | SWT.BORDER);
String compilerPattern = provider.getCompilerPattern();
inputCommand.setText(compilerPattern!=null ? compilerPattern : ""); //$NON-NLS-1$
gd = new GridData();
gd.horizontalSpan = 1;
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
inputCommand.setLayoutData(gd);
inputCommand.setEnabled(fEditable);
inputCommand.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String text = inputCommand.getText();
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
if (!text.equals(provider.getCompilerPattern())) {
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
selectedProvider.setCompilerPattern(text);
refreshItem(selectedProvider);
}
}
});
}
/**
* Create check-box for resolving paths.
*/
private void createResolvePathsCheckbox(Composite composite, AbstractBuildCommandParser provider) {
expandRelativePathCheckBox = new Button(composite, SWT.CHECK);
expandRelativePathCheckBox.setText(Messages.GCCBuildCommandParserOptionPage_ResolvePaths);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
expandRelativePathCheckBox.setLayoutData(gd);
expandRelativePathCheckBox.setSelection(provider.isResolvingPaths());
expandRelativePathCheckBox.setEnabled(fEditable);
expandRelativePathCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean enabled = expandRelativePathCheckBox.getSelection();
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
if (enabled != provider.isResolvingPaths()) {
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
selectedProvider.setResolvingPaths(enabled);
refreshItem(selectedProvider);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
}
/**
* Create group and radio buttons for container to keep discovered entries.
*/
private void createResourceScopeGroup(AbstractBuildCommandParser provider, Composite composite) {
Group resourceScopeGroup = new Group(composite, SWT.NONE);
resourceScopeGroup.setText(Messages.GCCBuildCommandParserOptionPage_ContainerForDiscoveredEntries);
resourceScopeGroup.setLayout(new GridLayout(2, false));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
resourceScopeGroup.setLayoutData(gd);
scopeFileRadioButton = new Button(resourceScopeGroup, SWT.RADIO);
scopeFileRadioButton.setText(Messages.GCCBuildCommandParserOptionPage_File);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
scopeFileRadioButton.setLayoutData(gd);
scopeFileRadioButton.setSelection(provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.FILE);
scopeFileRadioButton.setEnabled(fEditable);
scopeFileRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean enabled = scopeFileRadioButton.getSelection();
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
if (enabled != (provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.FILE)) {
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.FILE);
refreshItem(selectedProvider);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
scopeFolderRadioButton = new Button(resourceScopeGroup, SWT.RADIO);
scopeFolderRadioButton.setText(Messages.GCCBuildCommandParserOptionPage_Folder);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
scopeFolderRadioButton.setLayoutData(gd);
scopeFolderRadioButton.setSelection(provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.FOLDER);
scopeFolderRadioButton.setEnabled(fEditable);
scopeFolderRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean enabled = scopeFolderRadioButton.getSelection();
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
if (enabled != (provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.FOLDER)) {
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.FOLDER);
refreshItem(selectedProvider);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
scopeProjectRadioButton = new Button(resourceScopeGroup, SWT.RADIO);
scopeProjectRadioButton.setText(Messages.GCCBuildCommandParserOptionPage_Project);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
scopeProjectRadioButton.setLayoutData(gd);
scopeProjectRadioButton.setSelection(provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.PROJECT);
scopeProjectRadioButton.setEnabled(fEditable);
scopeProjectRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean enabled = scopeProjectRadioButton.getSelection();
AbstractBuildCommandParser provider = (AbstractBuildCommandParser) getProvider();
if (enabled != (provider.getResourceScope() == AbstractBuildCommandParser.ResourceScope.PROJECT)) {
AbstractBuildCommandParser selectedProvider = (AbstractBuildCommandParser) getProviderWorkingCopy();
selectedProvider.setResourceScope(AbstractBuildCommandParser.ResourceScope.PROJECT);
refreshItem(selectedProvider);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
}
}

View file

@ -0,0 +1,39 @@
/*******************************************************************************
* 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.managedbuilder.internal.ui.language.settings.providers;
import java.net.URL;
import org.eclipse.cdt.internal.ui.buildconsole.CBuildConsole;
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector;
import org.eclipse.cdt.ui.language.settings.providers.LanguageSettingsProvidersImages;
/**
* Console adapter for {@link AbstractBuiltinSpecsDetector}.
*/
public class ScannerDiscoveryConsole extends CBuildConsole {
/**
* {@inheritDoc}
* @param consoleId - a console ID is expected here which then is used as menu context ID.
* @param defaultIconUrl - if {@code LanguageSettingsProviderAssociation} extension point
* defines URL by provider id, {@code defaultIconUrl} will be ignored and the URL from the extension
* point will be used. If not, supplied {@code defaultIconUrl} will be used.
*/
@Override
public void init(String consoleId, String name, URL defaultIconUrl) {
URL iconUrl = LanguageSettingsProvidersImages.getImageUrl(consoleId);
if (iconUrl == null) {
iconUrl = defaultIconUrl;
}
super.init(consoleId, name, iconUrl);
}
}

View file

@ -0,0 +1,117 @@
/*******************************************************************************
* 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.managedbuilder.internal.ui.language.settings.providers;
import java.io.IOException;
import java.net.URL;
import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.internal.core.ICConsole;
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.language.settings.providers.LanguageSettingsProvidersImages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;
/**
* Console adapter for global {@link AbstractBuiltinSpecsDetector}.
*
* Note that this console is not colored.
*/
public class ScannerDiscoveryGlobalConsole implements ICConsole {
private MessageConsole console;
private class ConsoleOutputStreamAdapter extends ConsoleOutputStream {
private MessageConsoleStream fConsoleStream;
public ConsoleOutputStreamAdapter(MessageConsoleStream stream) {
fConsoleStream = stream;
}
@Override
public void write(int arg0) throws IOException {
fConsoleStream.write(arg0);
}
@Override
public synchronized void write(byte[] b, int off, int len) throws IOException {
fConsoleStream.write(b, off, len);
}
@Override
public void flush() throws IOException {
fConsoleStream.flush();
}
@Override
public void close() throws IOException {
fConsoleStream.close();
}
}
@Override
public void start(IProject project) {
Assert.isTrue(project == null);
}
@Override
public ConsoleOutputStream getOutputStream() throws CoreException {
return new ConsoleOutputStreamAdapter(console.newMessageStream());
}
@Override
public ConsoleOutputStream getInfoStream() throws CoreException {
return new ConsoleOutputStreamAdapter(console.newMessageStream());
}
@Override
public ConsoleOutputStream getErrorStream() throws CoreException {
return new ConsoleOutputStreamAdapter(console.newMessageStream());
}
@Override
public void init(String consoleId, String name, URL defaultIconUrl) {
console = null;
IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
IConsole[] allConsoles = consoleManager.getConsoles();
for (IConsole con : allConsoles) {
if (name.equals(con.getName()) && con instanceof MessageConsole) {
console = (MessageConsole) con;
console.clearConsole();
break;
}
}
if (console==null) {
URL iconUrl = LanguageSettingsProvidersImages.getImageUrl(consoleId);
if (iconUrl == null) {
iconUrl = defaultIconUrl;
}
ImageDescriptor imageDescriptor;
if (iconUrl != null) {
imageDescriptor = CDTSharedImages.getImageDescriptor(iconUrl.toString());
} else {
imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
}
console = new MessageConsole(name, imageDescriptor);
console.activate();
consoleManager.addConsoles(new IConsole[]{ console });
}
}
}

View file

@ -12,9 +12,10 @@
package org.eclipse.cdt.managedbuilder.ui.preferences;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
@ -38,6 +39,7 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
private Button show_mng;
private Button show_tool;
private Button show_exp;
private Button show_providers_tab; // temporary checkbox for scanner discovery Providers tab
private Button show_tipbox;
private Button b_0;
@ -74,6 +76,10 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
show_exp.setText(Messages.PropertyPageDefsTab_10);
show_exp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
show_providers_tab = new Button(usercomp, SWT.CHECK);
show_providers_tab.setText(Messages.PropertyPageDefsTab_showProvidersTab);
show_providers_tab.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
show_tipbox = new Button(usercomp, SWT.CHECK);
show_tipbox.setText(Messages.PropertyPageDefsTab_16);
show_tipbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@ -117,6 +123,7 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
show_mng.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG));
show_tool.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOTOOLM));
show_exp.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_EXPORT));
show_providers_tab.setSelection(!CDTPrefUtil.getBool(LanguageSettingsProvidersPage.KEY_NO_SHOW_PROVIDERS));
show_tipbox.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_TIPBOX));
switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_DISC_NAMES)) {
@ -140,6 +147,7 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOMNG, !show_mng.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOTOOLM, !show_tool.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_EXPORT, show_exp.getSelection());
CDTPrefUtil.setBool(LanguageSettingsProvidersPage.KEY_NO_SHOW_PROVIDERS, !show_providers_tab.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_TIPBOX, show_tipbox.getSelection());
int x = 0;
if (b_1.getSelection()) x = 1;
@ -160,6 +168,7 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
show_mng.setSelection(true);
show_tool.setSelection(true);
show_exp.setSelection(false);
show_providers_tab.setSelection(false);
show_tipbox.setSelection(false);
b_0.setSelection(true);
b_1.setSelection(false);

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.managedbuilder.ui.preferences;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
@ -30,6 +31,7 @@ public class WizardDefaultsTab extends AbstractCPropertyTab {
private Button show_sup;
private Button show_oth;
private Button checkBoxTryNewSD;
@Override
public void createControls(Composite parent) {
@ -44,20 +46,27 @@ public class WizardDefaultsTab extends AbstractCPropertyTab {
show_oth.setText(Messages.WizardDefaultsTab_1);
show_oth.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
checkBoxTryNewSD = new Button(usercomp, SWT.CHECK);
checkBoxTryNewSD.setText(org.eclipse.cdt.internal.ui.newui.Messages.CDTMainWizardPage_TrySD90);
checkBoxTryNewSD.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
show_sup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP));
show_oth.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_OTHERS));
checkBoxTryNewSD.setSelection(CDTPrefUtil.getBool(LanguageSettingsProvidersPage.KEY_NEWSD));
}
@Override
protected void performOK() {
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOSUPP, !show_sup.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_OTHERS, show_oth.getSelection());
CDTPrefUtil.setBool(LanguageSettingsProvidersPage.KEY_NEWSD, checkBoxTryNewSD.getSelection());
}
@Override
protected void performDefaults() {
show_sup.setSelection(true);
show_oth.setSelection(false);
checkBoxTryNewSD.setSelection(true);
}
@Override

View file

@ -24,10 +24,13 @@ import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgScannerConfigUtil;
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.util.CDTListComparator;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2Set;
@ -46,7 +49,9 @@ import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
@ -103,6 +108,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
private Button reportProblemsCheckBox;
private Combo profileComboBox;
private Composite profileOptionsComposite;
private Button clearButton;
private ICfgScannerConfigBuilderInfo2Set cbi;
private Map<InfoContext, IScannerConfigBuilderInfo2> baseInfoMap;
@ -116,6 +122,8 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
private DiscoveryPageWrapper wrapper = null;
private StatusMessageLine fStatusLine;
/*
* (non-Javadoc)
*
@ -184,6 +192,9 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
profileOptionsComposite.setLayoutData(gd);
profileOptionsComposite.setLayout(new TabFolderLayout());
fStatusLine = new StatusMessageLine(usercomp, SWT.LEFT, 2);
setEnablement();
sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
}
@ -236,7 +247,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
Label clearLabel = ControlFactory.createLabel(autoDiscoveryGroup, Messages.DiscoveryTab_ClearDisoveredEntries);
// "Clear" button
Button clearButton = ControlFactory.createPushButton(autoDiscoveryGroup, Messages.DiscoveryTab_Clear);
clearButton = ControlFactory.createPushButton(autoDiscoveryGroup, Messages.DiscoveryTab_Clear);
GridData gd = (GridData) clearButton.getLayoutData();
gd.grabExcessHorizontalSpace = true;
//Bug 331783 - NLS: "Clear" button label in Makefile Project preferences truncated
@ -334,6 +345,27 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} else {
setVisibility(Messages.DiscoveryTab_6);
}
setEnablement();
}
private void setEnablement() {
IStatus status = null;
ICConfigurationDescription cfgDescription = page.getResDesc().getConfiguration();
boolean isEnabled = !LanguageSettingsProvidersPage.isLanguageSettingsProvidersEnabled(getProject()) || ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
if (!isEnabled) {
status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, "Managed Build language settings provider is not enabled.");
}
scopeComboBox.setEnabled(isEnabled);
resTable.setEnabled(isEnabled);
boolean isSCDEnabled = autoDiscoveryCheckBox.getSelection();
reportProblemsCheckBox.setEnabled(isEnabled && isSCDEnabled);
autoDiscoveryCheckBox.setEnabled(isEnabled);
autoDiscoveryGroup.setEnabled(isEnabled);
clearButton.setEnabled(isEnabled);
fStatusLine.setErrorStatus(status);
}
private void setVisibility(String errMsg) {
@ -372,7 +404,13 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
buildInfo = (IScannerConfigBuilderInfo2) ti.getData("info"); //$NON-NLS-1$
String selectedProfileId = buildInfo.getSelectedProfileId();
iContext = (CfgInfoContext) ti.getData("cont"); //$NON-NLS-1$
autoDiscoveryCheckBox.setSelection(buildInfo.isAutoDiscoveryEnabled()
boolean autodiscoveryEnabled2 = buildInfo.isAutoDiscoveryEnabled();
if (autodiscoveryEnabled2) {
IConfiguration cfg = iContext.getConfiguration();
ICConfigurationDescription cfgDescription = ManagedBuildManager.getDescriptionForConfiguration(cfg);
autodiscoveryEnabled2 = ScannerDiscoveryLegacySupport.isLegacyScannerDiscoveryOn(cfgDescription);
}
autoDiscoveryCheckBox.setSelection(autodiscoveryEnabled2
&& !selectedProfileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID));
reportProblemsCheckBox.setSelection(buildInfo.isProblemReportingEnabled());

View file

@ -23,6 +23,9 @@ import java.util.SortedMap;
import java.util.TreeMap;
import java.util.TreeSet;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
@ -41,8 +44,9 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
import org.eclipse.cdt.ui.templateengine.IWizardDataPage;
import org.eclipse.cdt.ui.templateengine.Template;
@ -87,6 +91,7 @@ public class MBSWizardHandler extends CWizardHandler {
private static final String PROPERTY = "org.eclipse.cdt.build.core.buildType"; //$NON-NLS-1$
private static final String PROP_VAL = PROPERTY + ".debug"; //$NON-NLS-1$
private static final String tooltip =
Messages.CWizardHandler_1 +
Messages.CWizardHandler_2 +
@ -591,6 +596,27 @@ public class MBSWizardHandler extends CWizardHandler {
cfgDebug = cfgDes;
if (cfgFirst == null) // select at least first configuration
cfgFirst = cfgDes;
if (cfgDes instanceof ILanguageSettingsProvidersKeeper) {
boolean isTryingNewSD = false;
IWizardPage page = getStartingPage();
if (page instanceof CDTMainWizardPage) {
isTryingNewSD = ((CDTMainWizardPage)page).isTryingNewSD();
}
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD);
List<ILanguageSettingsProvider> providers;
if (isTryingNewSD) {
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(config, cfgDes);
} else {
if (cfgDes instanceof ILanguageSettingsProvidersKeeper) {
((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy());
}
}
} else {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false);
}
monitor.worked(work);
}
mngr.setProjectDescription(project, des);
@ -607,7 +633,7 @@ public class MBSWizardHandler extends CWizardHandler {
List<IConfiguration> configs = new ArrayList<IConfiguration>();
for (CfgHolder cfg : cfgs) {
configs.add((IConfiguration)cfg.getConfiguration());
configs.add(cfg.getConfiguration());
}
template.getTemplateInfo().setConfigurations(configs);
@ -834,5 +860,4 @@ public class MBSWizardHandler extends CWizardHandler {
return super.canFinish();
}
}

View file

@ -14,7 +14,10 @@ import java.lang.reflect.InvocationTargetException;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
@ -25,6 +28,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
import org.eclipse.core.resources.IProject;
@ -69,6 +73,7 @@ public class NewMakeProjFromExisting extends Wizard implements IImportWizard, IN
final String locationStr = page.getLocation();
final boolean isCPP = page.isCPP();
final IToolChain toolChain = page.getToolChain();
final boolean isTryingNewSD = page.isTryingNewSD();
IRunnableWithProgress op = new WorkspaceModifyOperation() {
@Override
@ -110,7 +115,21 @@ public class NewMakeProjFromExisting extends Wizard implements IImportWizard, IN
IBuilder builder = config.getEditableBuilder();
builder.setManagedBuildOn(false);
CConfigurationData data = config.getConfigurationData();
projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
ICConfigurationDescription cfgDes = projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
if (cfgDes instanceof ILanguageSettingsProvidersKeeper) {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD);
if (isTryingNewSD) {
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(config, cfgDes);
} else {
if (cfgDes instanceof ILanguageSettingsProvidersKeeper) {
((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy());
}
}
} else {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false);
}
monitor.worked(1);
pdMgr.setProjectDescription(project, projDesc);

View file

@ -16,9 +16,12 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@ -68,6 +71,9 @@ public class NewMakeProjFromExistingPage extends WizardPage {
*/
boolean projectNameSetByUser;
private Button checkBoxTryNewSD;
protected NewMakeProjFromExistingPage() {
super(Messages.NewMakeProjFromExistingPage_0);
setTitle(Messages.NewMakeProjFromExistingPage_1);
@ -87,6 +93,22 @@ public class NewMakeProjFromExistingPage extends WizardPage {
addSourceSelector(comp);
addLanguageSelector(comp);
addToolchainSelector(comp);
checkBoxTryNewSD = new Button(comp, SWT.CHECK);
checkBoxTryNewSD.setText(org.eclipse.cdt.internal.ui.newui.Messages.CDTMainWizardPage_TrySD90);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
checkBoxTryNewSD.setLayoutData(gd);
// restore settings from preferences
boolean isTryNewSD = true;
boolean contains = CUIPlugin.getDefault().getPreferenceStore().contains(LanguageSettingsProvidersPage.KEY_NEWSD);
if (contains) {
isTryNewSD = CDTPrefUtil.getBool(LanguageSettingsProvidersPage.KEY_NEWSD);
}
checkBoxTryNewSD.setSelection(isTryNewSD);
setControl(comp);
}
@ -342,4 +364,11 @@ public class NewMakeProjFromExistingPage extends WizardPage {
return selection.length != 0 ? tcMap.get(selection[0]) : null;
}
/**
* AG FIXME temporary method to be removed before CDT Juno release.
* @since 8.1
*/
public boolean isTryingNewSD() {
return checkBoxTryNewSD.getSelection();
}
}

View file

@ -11,7 +11,10 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.wizards;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
@ -23,11 +26,14 @@ import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.ConfigurationDataProvider;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.ui.wizards.CDTMainWizardPage;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.widgets.Composite;
/**
@ -71,6 +77,7 @@ public class STDWizardHandler extends MBSWizardHandler {
private void setProjectDescription(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor)
throws CoreException {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
ICProjectDescription des = mngr.createProjectDescription(project, false, !onFinish);
ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
@ -99,12 +106,35 @@ public class STDWizardHandler extends MBSWizardHandler {
}
cfg.setArtifactName(mProj.getDefaultArtifactName());
CConfigurationData data = cfg.getConfigurationData();
des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
ICConfigurationDescription cfgDes = des.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data);
if (cfgDes instanceof ILanguageSettingsProvidersKeeper) {
boolean isTryingNewSD = false;
IWizardPage page = getStartingPage();
if (page instanceof CDTMainWizardPage) {
isTryingNewSD = ((CDTMainWizardPage)page).isTryingNewSD();
}
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, isTryingNewSD);
if (isTryingNewSD) {
ConfigurationDataProvider.setDefaultLanguageSettingsProviders(cfg, cfgDes);
} else {
if (cfgDes instanceof ILanguageSettingsProvidersKeeper) {
((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(ScannerDiscoveryLegacySupport.getDefaultProvidersLegacy());
}
}
} else {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false);
}
monitor.worked(work);
}
mngr.setProjectDescription(project, des);
}
public boolean canCreateWithoutToolchain() { return true; }
public boolean canCreateWithoutToolchain() {
return true;
}
@Override
public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException {

View file

@ -17,6 +17,7 @@ import java.util.List;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -55,6 +56,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
private static final String PROVIDER_NAME_2 = "test.provider.2.name";
private static final String CFG_ID = "test.configuration.id";
private static final String LANG_ID = "test.lang.id";
private static final String LANG_CPP = GPPLanguage.ID;
private static final IFile FILE_0 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0"));
/**
@ -805,4 +807,156 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
assertSame(provider, providers.get(0));
}
/**
* TODO - YAGNI?
*/
public void testBuildResourceTree_FileInFolder() throws Exception {
// sample entries
CMacroEntry entry = new CMacroEntry("MACRO", null, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(entry);
// create resources
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFile file = ResourceHelper.createFile(project, "file.cpp");
assertNotNull(file);
// create a provider and set the entries
LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
provider.setSettingEntries(null, file, null, entries);
// build the hierarchy
LanguageSettingsProvidersSerializer.buildResourceTree(provider, null, null, project);
// check that entries go to highest possible level
assertEquals(entries, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file, null));
assertEquals(entries, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, project, null));
}
/**
* TODO - YAGNI?
*/
public void testBuildResourceTree_FileInSubFolder() throws Exception {
// sample entries
CMacroEntry entry = new CMacroEntry("MACRO", null, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(entry);
// create resources
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFolder folder = ResourceHelper.createFolder(project, "Folder");
IFile file = ResourceHelper.createFile(project, "Folder/file.cpp");
// create a provider and set the entries
LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
provider.setSettingEntries(null, file, null, entries);
// build the hierarchy
LanguageSettingsProvidersSerializer.buildResourceTree(provider, null, null, project);
// check that entries go to highest possible level
assertEquals(entries, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file, null));
assertEquals(entries, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, folder, null));
assertEquals(entries, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, project, null));
}
/**
* TODO - YAGNI?
*/
public void testBuildResourceTree_TwoSubFolders() throws Exception {
// sample entries
List<ICLanguageSettingEntry> entries1 = new ArrayList<ICLanguageSettingEntry>();
entries1.add(new CMacroEntry("MACRO_1", null, 0));
List<ICLanguageSettingEntry> entries2 = new ArrayList<ICLanguageSettingEntry>();
entries2.add(new CMacroEntry("MACRO_2", null, 0));
// create resources
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFolder folder1 = ResourceHelper.createFolder(project, "Folder1");
IFolder folder2 = ResourceHelper.createFolder(project, "Folder2");
IFile file1 = ResourceHelper.createFile(project, "Folder1/file1.cpp");
IFile file2 = ResourceHelper.createFile(project, "Folder2/file2.cpp");
// create a provider and set the entries
LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
provider.setSettingEntries(null, file1, null, entries1);
provider.setSettingEntries(null, file2, null, entries2);
// build the hierarchy
LanguageSettingsProvidersSerializer.buildResourceTree(provider, null, null, project);
// check that entries go to highest possible level
assertEquals(entries1, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file1, null));
assertEquals(entries1, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, folder1, null));
assertEquals(entries2, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file2, null));
assertEquals(entries2, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, folder2, null));
assertEquals(0, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, project, null).size());
}
/**
* TODO - YAGNI?
*/
public void testBuildResourceTree_FlippingSettings() throws Exception {
// sample entries
List<ICLanguageSettingEntry> entries1 = new ArrayList<ICLanguageSettingEntry>();
entries1.add(new CMacroEntry("MACRO_1", null, 0));
List<ICLanguageSettingEntry> entries2 = new ArrayList<ICLanguageSettingEntry>();
entries2.add(new CMacroEntry("MACRO_2", null, 0));
// create resources
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFile file1 = ResourceHelper.createFile(project, "file1.cpp");
IFile file2 = ResourceHelper.createFile(project, "file2.cpp");
IFile file3 = ResourceHelper.createFile(project, "file3.cpp");
// create a provider
LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
// set the entries for the first 2 files
provider.setSettingEntries(null, file1, null, entries1);
provider.setSettingEntries(null, file2, null, entries1);
// build the hierarchy
LanguageSettingsProvidersSerializer.buildResourceTree(provider, null, null, project);
// double-check where the entries go
assertEquals(entries1, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file1, null));
assertEquals(entries1, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file2, null));
assertEquals(entries1, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, project, null));
// set the entries for the second+third files (second file flips the settings)
provider.setSettingEntries(null, file2, null, entries2);
provider.setSettingEntries(null, file3, null, entries2);
// build the hierarchy
LanguageSettingsProvidersSerializer.buildResourceTree(provider, null, null, project);
// check where the entries go, it should not lose entries for the first file
assertEquals(entries1, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file1, null));
assertEquals(entries2, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file2, null));
assertEquals(entries2, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file3, null));
assertEquals(entries2, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, project, null));
}
/**
* TODO - YAGNI?
*/
public void testBuildResourceTree_WithLanguage() throws Exception {
// sample entries
CMacroEntry entry = new CMacroEntry("MACRO", null, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(entry);
// create resources
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFolder folder = ResourceHelper.createFolder(project, "Folder");
IFile file = ResourceHelper.createFile(project, "Folder/file.cpp");
// create a provider and set the entries
LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
provider.setSettingEntries(null, file, LANG_CPP, entries);
// build the hierarchy
LanguageSettingsProvidersSerializer.buildResourceTree(provider, null, LANG_CPP, project);
// check that entries go to highest possible level
assertEquals(entries, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, file, LANG_CPP));
assertEquals(entries, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, folder, LANG_CPP));
assertEquals(entries, LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, null, project, LANG_CPP));
}
}

View file

@ -12,7 +12,9 @@
package org.eclipse.cdt.core.language.settings.providers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
@ -47,11 +49,18 @@ public class ScannerDiscoveryLegacySupport {
private static final String PREFERENCES_QUALIFIER = CCorePlugin.PLUGIN_ID;
private static final String LANGUAGE_SETTINGS_PROVIDERS_NODE = "languageSettingsProviders"; //$NON-NLS-1$
private static Map<String, String> legacyProfiles = null;
/**
* Get preferences node for org.eclipse.cdt.core.
*/
private static Preferences getPreferences(IProject project) {
if (project == null)
if (project == null) {
return InstanceScope.INSTANCE.getNode(PREFERENCES_QUALIFIER).node(LANGUAGE_SETTINGS_PROVIDERS_NODE);
else
} else {
return new LocalProjectScope(project).getNode(PREFERENCES_QUALIFIER).node(LANGUAGE_SETTINGS_PROVIDERS_NODE);
}
}
/**
@ -87,8 +96,10 @@ public class ScannerDiscoveryLegacySupport {
/**
* Check if legacy Scanner Discovery in MBS should be active.
* @noreference This is internal helper method to support compatibility with previous versions
* which is not intended to be referenced by clients.
*/
private static boolean isMbsLanguageSettingsProviderOn(ICConfigurationDescription cfgDescription) {
public static boolean isMbsLanguageSettingsProviderOn(ICConfigurationDescription cfgDescription) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
for (ILanguageSettingsProvider lsp : lsProviders) {
@ -141,4 +152,37 @@ public class ScannerDiscoveryLegacySupport {
return providers;
}
/**
* Returns the values of scanner discovery profiles (scannerConfigDiscoveryProfileId) which were deprecated
* and replaced with language settings providers in plugin.xml.
* This (temporary) function serves as fail-safe switch during the transition.
*
* @param id - can be id of either org.eclipse.cdt.managedbuilder.internal.core.InputType
* or org.eclipse.cdt.managedbuilder.internal.core.ToolChain.
* @return legacy scannerConfigDiscoveryProfileId.
*/
@SuppressWarnings("nls")
public static String getDeprecatedLegacyProfiles(String id) {
if (legacyProfiles == null) {
legacyProfiles = new HashMap<String, String>();
// InputTypes
// TODO -doublecheck
// legacyProfiles.put(inputTypeId, scannerConfigDiscoveryProfileId);
legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC");
legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input.cygwin", "org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP");
legacyProfiles.put("cdt.managedbuild.tool.xlc.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile");
legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.c.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile");
legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP");
// Toolchains
// TODO -doublecheck
// legacyProfiles.put(toolchainId, scannerConfigDiscoveryProfileId);
}
return legacyProfiles.get(id);
}
}

View file

@ -64,6 +64,7 @@ import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.cdtvariables.CoreVariableSubstitutor;
import org.eclipse.cdt.internal.core.cdtvariables.DefaultVariableContextInfo;
import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.internal.core.model.APathEntry;
import org.eclipse.cdt.internal.core.model.CModelStatus;
@ -2016,6 +2017,9 @@ public class PathEntryTranslator {
public boolean visit(PathSettingsContainer container) {
CResourceData rcData = (CResourceData)container.getValue();
if (rcData != null) {
// AG FIXME - temporary log to remove before CDT Juno release
temporaryLog(cfgDescription, kinds, rcData);
PathEntryCollector child = collector.createChild(container.getPath());
for (int kind : kinds) {
List<ICLanguageSettingEntry> list = new ArrayList<ICLanguageSettingEntry>();
@ -2027,6 +2031,24 @@ public class PathEntryTranslator {
}
return true;
}
// AG FIXME - temporary log to remove before CDT Juno release
@Deprecated
private void temporaryLog(final ICConfigurationDescription cfgDescription, final int[] kinds, CResourceData rcData) {
String kindsStr="";
for (int kind : kinds) {
String kstr = LanguageSettingEntriesSerializer.kindToString(kind);
if (kindsStr.length()==0) {
kindsStr = kstr;
} else {
kindsStr += "|" + kstr;
}
}
final IProject prj = cfgDescription.getProjectDescription().getProject();
String log_msg = "path="+prj+"/"+rcData.getPath()+", kind=["+kindsStr+"]"+" (PathEntryTranslator.collectEntries())";
LanguageSettingsLogger.logInfo(log_msg);
}
});
return collector;
}

View file

@ -0,0 +1,79 @@
package org.eclipse.cdt.internal.core.language.settings.providers;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* AG FIXME -Temporary class for logging language settings providers development.
* To remove before CDT Juno release
*
*/
@Deprecated
public class LanguageSettingsLogger {
private static boolean isEnabled() {
return false;
// return true;
}
/**
* @param msg
* @noreference This method is not intended to be referenced by clients.
*/
@Deprecated
public static void logInfo(String msg) {
if (isEnabled()) {
Exception e = new Exception(msg);
IStatus status = new Status(IStatus.INFO, CCorePlugin.PLUGIN_ID, msg, e);
CCorePlugin.log(status);
}
}
/**
* @param msg
* @noreference This method is not intended to be referenced by clients.
*/
@Deprecated
public static void logWarning(String msg) {
if (isEnabled()) {
Exception e = new Exception(msg);
IStatus status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, msg, e);
CCorePlugin.log(status);
}
}
/**
* @param msg
* @noreference This method is not intended to be referenced by clients.
*/
@Deprecated
public static void logError(String msg) {
if (isEnabled()) {
Exception e = new Exception(msg);
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, msg, e);
CCorePlugin.log(status);
}
}
/**
* @param rc
* @param who - pass "this" (calling class instance) here
* @noreference This method is not intended to be referenced by clients.
*/
@Deprecated
public static void logScannerInfoProvider(IResource rc, Object who) {
if (isEnabled()) {
String msg = "rc="+rc+" <-- "+who.getClass().getSimpleName(); //$NON-NLS-1$ //$NON-NLS-2$
if (rc instanceof IFile) {
LanguageSettingsLogger.logInfo(msg);
} else if (rc instanceof IProject) {
LanguageSettingsLogger.logWarning(msg);
} else {
LanguageSettingsLogger.logError(msg);
}
}
}
}

View file

@ -28,6 +28,8 @@ import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
@ -498,6 +500,9 @@ public class LanguageSettingsProvidersSerializer {
* @throws CoreException
*/
public static void serializeLanguageSettingsWorkspace() throws CoreException {
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logWarning("LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspace()");
URI uriStoreWsp = getStoreInWorkspaceArea(STORAGE_WORKSPACE_LANGUAGE_SETTINGS);
List<LanguageSettingsSerializableProvider> serializableWorkspaceProviders = new ArrayList<LanguageSettingsSerializableProvider>();
for (ILanguageSettingsProvider provider : rawGlobalWorkspaceProviders.values()) {
@ -804,6 +809,9 @@ public class LanguageSettingsProvidersSerializer {
*/
public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException {
IProject project = prjDescription.getProject();
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logWarning("LanguageSettingsProvidersSerializer.serializeLanguageSettings() for " + project);
try {
// Using side effect of adding the module to the storage
prjDescription.getStorage(CPROJECT_STORAGE_MODULE, true);
@ -1229,6 +1237,35 @@ public class LanguageSettingsProvidersSerializer {
return provider instanceof LanguageSettingsWorkspaceProvider;
}
/**
* Reports inconsistency in log.
* AG FIXME - temporary method to remove before CDT Juno release
*/
@SuppressWarnings("nls")
@Deprecated
public static void assertConsistency(ICProjectDescription prjDescription) {
if (prjDescription != null) {
List<ILanguageSettingsProvider> prjProviders = new ArrayList<ILanguageSettingsProvider>();
for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) {
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
for (ILanguageSettingsProvider provider : providers) {
if (!LanguageSettingsManager.isWorkspaceProvider(provider)) {
if (isInList(prjProviders, provider)) {
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Inconsistent state, duplicate LSP in project description "
+ "[" + System.identityHashCode(provider) + "] "
+ provider);
CoreException e = new CoreException(status);
CCorePlugin.log(e);
}
prjProviders.add(provider);
}
}
}
}
}
}
/**
* Check that this particular element is in the list.
*/
@ -1320,9 +1357,13 @@ public class LanguageSettingsProvidersSerializer {
*/
public static void reRegisterListeners(ICProjectDescription oldPrjDescription, ICProjectDescription newPrjDescription) {
if (oldPrjDescription == newPrjDescription) {
assertConsistency(oldPrjDescription);
return;
}
assertConsistency(oldPrjDescription);
assertConsistency(newPrjDescription);
List<ICListenerAgent> oldListeners = getListeners(oldPrjDescription);
List<ListenerAssociation> newAssociations = getListenersAssociations(newPrjDescription);
@ -1389,6 +1430,9 @@ public class LanguageSettingsProvidersSerializer {
* @param event - the {@link ILanguageSettingsChangeEvent} event to be broadcast.
*/
private static void notifyLanguageSettingsChangeListeners(ILanguageSettingsChangeEvent event) {
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logWarning("Firing " + event);
for (Object listener : fLanguageSettingsChangeListeners.getListeners()) {
((ILanguageSettingsChangeListener) listener).handleEvent(event);
}
@ -1592,4 +1636,109 @@ public class LanguageSettingsProvidersSerializer {
return new ArrayList<ILanguageSettingsProvider>(newProviders);
}
/**
* Check if the language is applicable for the file.
*/
private static boolean isLanguageInScope(IResource rc, ICConfigurationDescription cfgDescription, String languageId) {
if (rc instanceof IFile) {
ILanguage lang = null;
try {
lang = LanguageManager.getInstance().getLanguageForFile((IFile) rc, cfgDescription);
} catch (CoreException e) {
CCorePlugin.log("Error while determining language for a file", e); //$NON-NLS-1$
}
if (lang == null || (languageId != null && !languageId.equals(lang.getId()))) {
return false;
}
}
return true;
}
/**
* Builds for the provider a nicer-looking resource tree to present hierarchical view to the user.
*
* Note that it is not advisable to "compact" the tree because of potential loss of information
* which is especially important during partial or incremental builds.
*
* Note also that after using this method for a while for BOP parsers it appears that disadvantages
* outweigh benefits. In particular, it doesn't result in saving memory as the language settings
* (and the lists itself) are not duplicated in memory anyway but optimized with using WeakHashSet
* and SafeStringInterner.
*
* This method is a candidate for removal.
*
* @param provider - language settings provider to build the tree for.
* @param cfgDescription - configuration description.
* @param languageId - language ID.
* @param folder - container where the tree roots.
*/
public static void buildResourceTree(LanguageSettingsSerializableProvider provider,
ICConfigurationDescription cfgDescription, String languageId, IContainer folder) {
IResource[] members = null;
try {
members = folder.members();
} catch (Exception e) {
CCorePlugin.log(e);
}
if (members==null)
return;
for (IResource rc : members) {
if (rc instanceof IContainer) {
buildResourceTree(provider, cfgDescription, languageId, (IContainer) rc);
}
}
int rcNumber = members.length;
Map<List<ICLanguageSettingEntry>, Integer> listMap = new HashMap<List<ICLanguageSettingEntry>, Integer>();
// on the first pass find majority entry list, i.e. list present most often
List<ICLanguageSettingEntry> majorityEntries = null;
List<ICLanguageSettingEntry> candidate = null;
int candidateCount = 0;
for (IResource rc : members) {
if (!isLanguageInScope(rc, cfgDescription, languageId)) {
rcNumber--;
} else {
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, rc, languageId);
if (entries==null && rc instanceof IContainer) {
rcNumber--;
} else {
Integer count = listMap.get(entries);
if (count==null) {
count = 0;
}
count++;
if (count>candidateCount) {
candidateCount = count;
candidate = entries;
}
listMap.put(entries, count);
}
}
if (candidateCount > rcNumber/2) {
majorityEntries = candidate;
break;
}
}
if (majorityEntries!=null) {
provider.setSettingEntries(cfgDescription, folder, languageId, majorityEntries);
}
// second pass - assign the entries to the folders
for (IResource rc : members) {
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, rc, languageId);
if (entries!=null && entries==majorityEntries) {
if (!(rc instanceof IFile)) { // preserve information which files were collected
provider.setSettingEntries(cfgDescription, rc, languageId, null);
}
}
}
}
}

View file

@ -64,6 +64,9 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider
@Override
public ExtendedScannerInfo getScannerInformation(IResource rc) {
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logScannerInfoProvider(rc, this);
IProject project = rc.getProject();
if (project==null)
return DUMMY_SCANNER_INFO;

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@ -77,6 +78,9 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP
@Override
public IScannerInfo getScannerInformation(IResource resource) {
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logScannerInfoProvider(resource, this);
if(!fInited)
updateProjCfgInfo(CProjectDescriptionManager.getInstance().getProjectDescription(fProject, false));

View file

@ -782,5 +782,12 @@
factoryClass="org.eclipse.cdt.internal.core.resources.ResourceExclusionFactory">
</exclusionFactory>
</extension>
<extension
point="org.eclipse.cdt.core.EFSExtensionProvider">
<EFSExtensionProvider
class="org.eclipse.cdt.internal.core.resources.CygwinEFSExtensionProvider"
scheme="cygwin">
</EFSExtensionProvider>
</extension>
</plugin>

View file

@ -226,7 +226,7 @@ The value &quot;true&quot; of this attribute is meaningful only for providers ca
<meta.section type="since"/>
</appInfo>
<documentation>
CDT 9.0
CDT 8.1
</documentation>
</annotation>

View file

@ -29,8 +29,10 @@ import org.eclipse.cdt.core.model.IMacroFileEntry;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
import org.eclipse.cdt.internal.core.model.PathEntryManager;
import org.eclipse.cdt.internal.core.settings.model.ScannerInfoProviderProxy;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
@ -96,6 +98,13 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP
*/
@Override
public IScannerInfo getScannerInformation(IResource resource) {
// AG FIXME - temporary log to remove before CDT Juno release
if (resource instanceof IFile) {
LanguageSettingsLogger.logInfo("rc="+resource+" (ScannerProvider.getScannerInformation())");
} else {
LanguageSettingsLogger.logWarning("rc="+resource+" (ScannerProvider.getScannerInformation())");
}
IPath resPath = resource.getFullPath();
try {

View file

@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2011, 2011 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.internal.core.resources;
import java.net.URI;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.EFSExtensionProvider;
import org.eclipse.cdt.internal.core.Cygwin;
public class CygwinEFSExtensionProvider extends EFSExtensionProvider {
@Override
public String getMappedPath(URI locationURI) {
String cygwinPath = getPathFromURI(locationURI);
String windowsPath = null;
try {
windowsPath = Cygwin.cygwinToWindowsPath(cygwinPath);
} catch (Exception e) {
CCorePlugin.log(e);
}
return windowsPath;
}
}

View file

@ -29,6 +29,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.internal.ui.includebrowser;x-internal:=true,
org.eclipse.cdt.internal.ui.indexview;x-internal:=true,
org.eclipse.cdt.internal.ui.language;x-internal:=true,
org.eclipse.cdt.internal.ui.language.settings.providers;x-internal:=true,
org.eclipse.cdt.internal.ui.navigator;x-internal:=true,
org.eclipse.cdt.internal.ui.newui;x-internal:=true,
org.eclipse.cdt.internal.ui.preferences;x-internal:=true,
@ -75,6 +76,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.ui.browser.typeinfo,
org.eclipse.cdt.ui.dialogs,
org.eclipse.cdt.ui.internal.templateengine.wizard;x-internal:=true,
org.eclipse.cdt.ui.language.settings.providers,
org.eclipse.cdt.ui.newui,
org.eclipse.cdt.ui.refactoring,
org.eclipse.cdt.ui.refactoring.actions,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

View file

@ -607,9 +607,11 @@ includeFolderDecorator.description = Decorates missing include folders with erro
templatesViewName= Templates
AllLanguageSettingEntries.name=Providers
AllLanguageSettingEntries.tooltip=Language Setting Entries Providers
deleteConfigsCommand.name = Reset to Default
excludeCommand.name = Exclude from Build
ActionDefinition.selectEnclosing.description = Expand the selection to enclosing C/C++ element
excludeCommand.name = Exclude from BuildActionDefinition.selectEnclosing.description = Expand the selection to enclosing C/C++ element
ActionDefinition.selectEnclosing.name = Select Enclosing C/C++ Element
ActionDefinition.selectNext.description = Expand the selection to next C/C++ element
ActionDefinition.selectNext.name = Select Next C/C++ Element
@ -617,6 +619,8 @@ ActionDefinition.selectPrevious.description = Expand the selection to enclosing
ActionDefinition.selectPrevious.name = Select Previous C/C++ Element
ActionDefinition.selectLast.description = Restore last selection in C/C++ editor
ActionDefinition.selectLast.name = Restore Last C/C++ Selection
LanguageSettingsProviderUIExtensionPoint=Language Settings Provider UI
LanguageSettingsProviderAssociationExtensionPoint=Language Settings Provider UI
overrideAnnotation.label = C/C++ Override indicators
transfer.EditorAppearance.name = C/C++ Editor Appearance

View file

@ -26,6 +26,7 @@
<extension-point id="quickAssistProcessors" name="%quickAssistProcessorExtensionPoint" schema="schema/quickAssistProcessors.exsd"/>
<extension-point id="DocCommentOwner" name="%DocCommentOwner.name" schema="schema/DocCommentOwner.exsd"/>
<extension-point id="workingSetConfigurations" name="%workingSetConfigurationsExtensionPoint" schema="schema/workingSetConfigurations.exsd"/>
<extension-point id="LanguageSettingsProviderAssociation" name="%LanguageSettingsProviderAssociationExtensionPoint" schema="schema/LanguageSettingsProviderAssociation.exsd"/>
<extension-point id="RefreshExclusionContributor" name="%extension-point.name" schema="schema/RefreshExclusionContributor.exsd"/>
<extension-point id="projectTypePages" name="%ProjectTypePages" schema="schema/projectTypePages.exsd"/>
@ -3368,6 +3369,20 @@
</adapt>
</enabledWhen>
</page>
<page
name="Preprocessor Include Paths, Macros etc."
id="org.eclipse.cdt.ui.language.settings"
class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage"
category="org.eclipse.cdt.ui.newui.Page_head_general">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IResource">
<and>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
<test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.providers.tab.disable=false"/>
</and>
</adapt>
</enabledWhen>
</page>
</extension>
<extension
@ -3928,10 +3943,10 @@
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
id="org.eclipse.cdt.Tester3"
id="org.eclipse.cdt.ui.preferenceTester"
class="org.eclipse.cdt.ui.newui.PropertyTester"
namespace="org.eclipse.cdt.ui"
properties="pageEnabled"
properties="checkPreference"
type="java.lang.Object"/>
<propertyTester
id="org.eclipse.cdt.Tester1"
@ -4302,6 +4317,40 @@
</complexArray>
</processType>
</extension>
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider
class="org.eclipse.cdt.core.language.settings.providers.LanguageSettingsGenericProvider"
id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"
name="CDT User Setting Entries"
prefer-non-shared="true">
</provider>
</extension>
<extension point="org.eclipse.cdt.ui.LanguageSettingsProviderAssociation">
<id-association
id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"
icon="icons/obj16/person-me.gif"
ui-clear-entries="true"
ui-edit-entries="true">
</id-association>
</extension>
<extension point="org.eclipse.cdt.ui.cPropertyTab">
<tab
class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsEntriesTab"
icon="icons/obj16/ls_entries.gif"
name="Entries"
weight="010"
helpId="FIXME cdt_u_prop_pns_inc"
parent="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage"
tooltip="%AllLanguageSettingEntries.tooltip"/>
<tab
class="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab"
icon="icons/obj16/extension_obj.gif"
name="Providers"
weight="020"
helpId="FIXME cdt_u_prop_pns_inc"
parent="org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage"
tooltip="%AllLanguageSettingEntries.tooltip"/>
</extension>
<extension
point="org.eclipse.ui.commands">
<command

View file

@ -0,0 +1,200 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.ui" id="LanguageSettingsProviderAssociation" name="Language Settings Provider UI Associations"/>
</appInfo>
<documentation>
This extension point defines appearance and behavior of UI controls for Language Settings Providers defined with extension point &lt;samp&gt;org.eclipse.cdt.core.LanguageSettingsProvider&lt;/samp&gt;.
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
<documentation>
This extension point is used to define appearance and behavior of Language Settings Providers in user interface.
</documentation>
</annotation>
<complexType>
<sequence>
<element ref="id-association" minOccurs="0" maxOccurs="unbounded"/>
<element ref="class-association" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
ID of the extension point, not used
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
Name of the extension point, not used
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="id-association">
<annotation>
<documentation>
The definition of UI elements associated with ID of language settings provider.
</documentation>
</annotation>
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
ID of language settings provider for which appearance is being defined.
</documentation>
</annotation>
</attribute>
<attribute name="icon" type="string">
<annotation>
<documentation>
The path to the provider icon in the defining plugin, for example icons/obj16/picture.gif.
</documentation>
<appInfo>
<meta.attribute kind="resource"/>
</appInfo>
</annotation>
</attribute>
<attribute name="page" type="string">
<annotation>
<documentation>
Options page for the provider to appear in preferences in Providers tab.
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.dialogs.ICOptionPage"/>
</appInfo>
</annotation>
</attribute>
<attribute name="ui-edit-entries" type="boolean">
<annotation>
<documentation>
Defines if user is allowed to edit provider&apos;s entries in UI.
</documentation>
</annotation>
</attribute>
<attribute name="ui-clear-entries" type="boolean">
<annotation>
<documentation>
Defines if user is allowed to clear provider&apos;s entries in UI. For some providers like compiler specs detectors that may trigger automatic rerun.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="class-association">
<annotation>
<documentation>
The definition of UI elements associated with type of language settings provider. Providers subclassed from this type will inherit characteristics from closest super-type (unless exact ID association is defined).
</documentation>
</annotation>
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
Class of language settings provider for which appearance is being defined.
</documentation>
<appInfo>
<meta.attribute kind="java"/>
</appInfo>
</annotation>
</attribute>
<attribute name="icon" type="string">
<annotation>
<documentation>
The path to the provider icon in the defining plugin, for example icons/obj16/picture.gif.
</documentation>
<appInfo>
<meta.attribute kind="resource"/>
</appInfo>
</annotation>
</attribute>
<attribute name="page" type="string">
<annotation>
<documentation>
Options page for the provider to appear in preferences in Providers tab.
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.dialogs.ICOptionPage"/>
</appInfo>
</annotation>
</attribute>
<attribute name="ui-edit-entries" type="boolean">
<annotation>
<documentation>
Defines if user is allowed to edit provider&apos;s entries in UI.
</documentation>
</annotation>
</attribute>
<attribute name="ui-clear-entries" type="boolean">
<annotation>
<documentation>
Defines if user is allowed to clear provider&apos;s entries in UI. For some providers like compiler specs detectors that may trigger automatic rerun.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
CDT 8.1
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
For an example see definition for org.eclipse.cdt.ui.UserLanguageSettingsProvider.
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiinfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
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
</documentation>
</annotation>
</schema>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,615 @@
/*******************************************************************************
* 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.internal.ui.language.settings.providers;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.AbstractPropertyDialog;
import org.eclipse.cdt.internal.ui.ImageCombo;
import org.eclipse.cdt.internal.ui.newui.LanguageSettingsImages;
import org.eclipse.cdt.internal.ui.newui.Messages;
/**
* @noextend This class is not intended to be subclassed by clients.
*/
public class LanguageSettingEntryDialog extends AbstractPropertyDialog {
private static final String SLASH = "/"; //$NON-NLS-1$
private ICConfigurationDescription cfgDescription;
private IProject project;
private ICLanguageSettingEntry entry;
private boolean clearValue;
private int kind;
private Composite compositeArea;
private Label iconComboKind;
private ImageCombo comboKind;
private ImageCombo comboPathCategory;
private Label labelInput;
public Text inputName;
private Label checkBoxValue;
public Text inputValue;
private Button buttonBrowse;
private Button buttonVars;
private Button checkBoxBuiltIn;
private Button checkBoxFramework;
private Button buttonOk;
private Button buttonCancel;
private static final int COMBO_INDEX_INCLUDE_PATH = 0;
private static final int COMBO_INDEX_MACRO = 1;
private static final int COMBO_INDEX_INCLUDE_FILE = 2;
private static final int COMBO_INDEX_MACRO_FILE = 3;
private static final int COMBO_INDEX_LIBRARY_PATH = 4;
private static final int COMBO_INDEX_LIBRARY_FILE = 5;
final private String [] comboKindItems = {
Messages.LanguageSettingEntryDialog_IncludeDirectory,
Messages.LanguageSettingEntryDialog_PreporocessorMacro,
Messages.LanguageSettingEntryDialog_IncludeFile,
Messages.LanguageSettingEntryDialog_PreprocessorMacroFile,
Messages.LanguageSettingEntryDialog_LibraryPath,
Messages.LanguageSettingEntryDialog_Library,
};
final private Image[] comboKindImages = {
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TUNIT_HEADER),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACROS_FILE),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY_FOLDER),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY),
};
private static final int COMBO_PATH_INDEX_PROJECT = 0;
private static final int COMBO_PATH_INDEX_WORKSPACE = 1;
private static final int COMBO_PATH_INDEX_FILESYSTEM = 2;
final private String [] pathCategories = {
Messages.LanguageSettingEntryDialog_ProjectRelative,
Messages.LanguageSettingEntryDialog_WorkspacePath,
Messages.LanguageSettingEntryDialog_Filesystem,
};
final private Image[] pathCategoryImages = {
CDTSharedImages.getImage(CDTSharedImages.IMG_ETOOL_PROJECT),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE),
CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM),
};
private ICLanguageSettingEntry[] entries;
public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, int kind) {
super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject();
this.entry = null;
this.clearValue = true;
this.kind = kind;
}
/**
* This constructor is intended to be used with {@code clearValue=true} for "Add" dialogs
* where provided entry is used as a template.
*/
public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, ICLanguageSettingEntry entry, boolean clearValue) {
super(parent, ""); //$NON-NLS-1$
this.cfgDescription = cfgDescription;
this.project = cfgDescription.getProjectDescription().getProject();
this.entry = entry;
this.kind = entry!=null ? entry.getKind() : ICSettingEntry.INCLUDE_PATH;
this.clearValue = clearValue;
}
/**
* This constructor is used for "Edit" dialogs to edit provided entry
*/
public LanguageSettingEntryDialog(Shell parent, ICConfigurationDescription cfgDescription, ICLanguageSettingEntry entry) {
this(parent, cfgDescription, entry, false);
}
private int comboIndexToKind(int index) {
int kind=0;
switch (index) {
case COMBO_INDEX_INCLUDE_PATH:
kind = ICSettingEntry.INCLUDE_PATH;
break;
case COMBO_INDEX_MACRO:
kind = ICSettingEntry.MACRO;
break;
case COMBO_INDEX_INCLUDE_FILE:
kind = ICSettingEntry.INCLUDE_FILE;
break;
case COMBO_INDEX_MACRO_FILE:
kind = ICSettingEntry.MACRO_FILE;
break;
case COMBO_INDEX_LIBRARY_PATH:
kind = ICSettingEntry.LIBRARY_PATH;
break;
case COMBO_INDEX_LIBRARY_FILE:
kind = ICSettingEntry.LIBRARY_FILE;
break;
}
return kind;
}
private int kindToComboIndex(int kind) {
int index=0;
switch (kind) {
case ICSettingEntry.INCLUDE_PATH:
index = COMBO_INDEX_INCLUDE_PATH;
break;
case ICSettingEntry.MACRO:
index = COMBO_INDEX_MACRO;
break;
case ICSettingEntry.INCLUDE_FILE:
index = COMBO_INDEX_INCLUDE_FILE;
break;
case ICSettingEntry.MACRO_FILE:
index = COMBO_INDEX_MACRO_FILE;
break;
case ICSettingEntry.LIBRARY_PATH:
index = COMBO_INDEX_LIBRARY_PATH;
break;
case ICSettingEntry.LIBRARY_FILE:
index = COMBO_INDEX_LIBRARY_FILE;
break;
}
return index;
}
@Override
protected Control createDialogArea(Composite parent) {
parent.setLayout(new GridLayout(4, false));
GridData gd;
// Composite for the dialog area
compositeArea = new Composite (parent, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = SWT.TOP;
gd.horizontalSpan = 7;
compositeArea.setLayoutData(gd);
compositeArea.setLayout(new GridLayout(7, false));
// Icon for kind
iconComboKind = new Label (compositeArea, SWT.NONE);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.RIGHT;
iconComboKind.setLayoutData(gd);
iconComboKind.setText(Messages.LanguageSettingEntryDialog_SelectKind);
int kindToComboIndex = kindToComboIndex(kind);
iconComboKind.setImage(comboKindImages[kindToComboIndex]);
// Combo for the setting entry kind
comboKind = new ImageCombo(compositeArea, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
for (int i = 0; i < comboKindItems.length; i++) {
comboKind.add(comboKindItems[i], comboKindImages[i]);
}
comboKind.setText(comboKindItems[kindToComboIndex]);
comboKind.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateImages();
setButtons();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
comboKind.setEnabled(clearValue);
// Icon for path category
final Label comboPathCategoryIcon = new Label (compositeArea, SWT.NONE);
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END);
gd.verticalAlignment = SWT.TOP;
gd.widthHint = 15;
comboPathCategoryIcon.setLayoutData(gd);
comboPathCategoryIcon.setText(""); //$NON-NLS-1$
// Combo for path category
comboPathCategory = new ImageCombo(compositeArea, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
for (int i = 0; i < pathCategories.length; i++) {
comboPathCategory.add(pathCategories[i], pathCategoryImages[i]);
}
int pcindex = COMBO_PATH_INDEX_PROJECT;
if (entry != null) {
if ((entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) == 0) {
pcindex = COMBO_PATH_INDEX_FILESYSTEM;
} else {
if (entry.getName().startsWith(SLASH)) {
pcindex = COMBO_PATH_INDEX_WORKSPACE;
} else {
pcindex = COMBO_PATH_INDEX_PROJECT;
}
}
}
comboPathCategory.setText(pathCategories[pcindex]);
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
gd.verticalAlignment = SWT.TOP;
gd.horizontalSpan = 4;
comboPathCategory.setLayoutData(gd);
comboPathCategory.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateImages();
setButtons();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
// Dir/File/Name label
labelInput = new Label(compositeArea, SWT.NONE);
labelInput.setText(Messages.LanguageSettingEntryDialog_Directory);
gd = new GridData();
labelInput.setLayoutData(gd);
// Dir/File/Name input
inputName = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry!=null && !clearValue) {
inputName.setText(entry.getName());
}
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan = 2;
gd.widthHint = 200;
inputName.setLayoutData(gd);
inputName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
setButtons();
}});
inputName.setFocus();
inputName.setSelection(0, inputName.getText().length());
// Value label
checkBoxValue = new Label(compositeArea, SWT.NONE);
checkBoxValue.setText(Messages.LanguageSettingEntryDialog_Value);
gd = new GridData();
checkBoxValue.setLayoutData(gd);
// Path button
buttonBrowse = new Button(compositeArea, SWT.PUSH);
buttonBrowse.setText("..."); //$NON-NLS-1$
buttonBrowse.setImage(pathCategoryImages[0]);
buttonBrowse.setLayoutData(new GridData());
buttonBrowse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
buttonPressed(event);
}
});
// Variables button
buttonVars = new Button(compositeArea, SWT.PUSH);
buttonVars.setText(AbstractCPropertyTab.VARIABLESBUTTON_NAME);
buttonVars.setLayoutData(new GridData());
buttonVars.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
buttonPressed(event);
}
});
// Value input. Located after the other controls to get sufficient width
int comboPathWidth = comboPathCategory.computeSize(SWT.DEFAULT, SWT.NONE).x;
inputValue = new Text(compositeArea, SWT.SINGLE | SWT.BORDER);
if (entry != null && !clearValue) {
inputValue.setText(entry.getValue());
}
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
gd.widthHint = comboPathWidth;
inputValue.setLayoutData(gd);
if (entry != null && kind == ICSettingEntry.MACRO && !clearValue) {
inputValue.setFocus();
inputValue.setSelection(0, inputValue.getText().length());
}
// Checkboxes
Composite compCheckboxes = new Composite (parent, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = SWT.TOP;
gd.horizontalSpan = 4;
compCheckboxes.setLayoutData(gd);
compCheckboxes.setLayout(new GridLayout(1, false));
// Checkbox "Built-In"
checkBoxBuiltIn = new Button(compCheckboxes, SWT.CHECK);
checkBoxBuiltIn.setText(Messages.LanguageSettingEntryDialog_BuiltInFlag);
checkBoxBuiltIn.setSelection(entry!=null && (entry.getFlags()&ICSettingEntry.BUILTIN)!=0);
gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxBuiltIn.setLayoutData(gd);
checkBoxBuiltIn.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateImages();
setButtons();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
// Checkbox "Framework"
checkBoxFramework = new Button(compCheckboxes, SWT.CHECK);
checkBoxFramework.setText(Messages.LanguageSettingEntryDialog_FrameworkFolder);
checkBoxFramework.setSelection(entry!=null && (entry.getFlags()&ICSettingEntry.FRAMEWORKS_MAC)!=0);
gd = new GridData(GridData.FILL_HORIZONTAL);
checkBoxFramework.setLayoutData(gd);
checkBoxFramework.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateImages();
setButtons();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
// Buttons
Composite compButtons = new Composite (parent, SWT.FILL);
gd = new GridData(SWT.RIGHT, SWT.BOTTOM, false, false);
gd.horizontalSpan = 4;
gd.grabExcessVerticalSpace = true;
compButtons.setLayoutData(gd);
compButtons.setLayout(new GridLayout(4, false));
// placeholder
Label placeholder = new Label(compButtons, 0);
placeholder.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
// Button OK
buttonOk = new Button(compButtons, SWT.PUSH);
buttonOk.setText(IDialogConstants.OK_LABEL);
gd = new GridData();
gd.widthHint = buttonVars.computeSize(SWT.DEFAULT,SWT.NONE).x;
buttonOk.setLayoutData(gd);
buttonOk.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
buttonPressed(event);
}
});
// Button Cancel
buttonCancel = new Button(compButtons, SWT.PUSH);
buttonCancel.setText(IDialogConstants.CANCEL_LABEL);
gd = new GridData();
gd.widthHint = buttonVars.computeSize(SWT.DEFAULT, SWT.NONE).x;
buttonCancel.setLayoutData(gd);
buttonCancel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
buttonPressed(event);
}
});
parent.getShell().setDefaultButton(buttonOk);
parent.pack();
updateImages();
setButtons();
return parent;
}
private void setButtons() {
int kindSelectionIndex = comboKind.getSelectionIndex();
boolean isMacroSelected = (kindSelectionIndex == COMBO_INDEX_MACRO);
comboPathCategory.setVisible(!isMacroSelected);
buttonBrowse.setVisible(!isMacroSelected);
buttonVars.setVisible(!isMacroSelected);
checkBoxValue.setVisible(isMacroSelected);
inputValue.setVisible(isMacroSelected);
((GridData)checkBoxValue.getLayoutData()).exclude = !isMacroSelected;
((GridData)inputValue.getLayoutData()).exclude = !isMacroSelected;
((GridData)buttonBrowse.getLayoutData()).exclude = isMacroSelected;
((GridData)buttonVars.getLayoutData()).exclude = isMacroSelected;
switch (kindSelectionIndex) {
case COMBO_INDEX_INCLUDE_PATH:
case COMBO_INDEX_LIBRARY_PATH:
labelInput.setText(Messages.LanguageSettingEntryDialog_Path);
break;
case COMBO_INDEX_INCLUDE_FILE:
case COMBO_INDEX_MACRO_FILE:
case COMBO_INDEX_LIBRARY_FILE:
labelInput.setText(Messages.LanguageSettingEntryDialog_File);
break;
case COMBO_INDEX_MACRO:
default:
labelInput.setText(Messages.LanguageSettingEntryDialog_Name);
}
inputValue.setEnabled(isMacroSelected);
int indexPathKind = comboPathCategory.getSelectionIndex();
boolean isProjectSelected = (indexPathKind == COMBO_PATH_INDEX_PROJECT);
boolean isWorkspaceSelected = (indexPathKind == COMBO_PATH_INDEX_WORKSPACE);
boolean isFilesystemSelected = (indexPathKind == COMBO_PATH_INDEX_FILESYSTEM);
String path = inputName.getText();
if (path.trim().length() == 0) {
buttonOk.setEnabled(false);
} else {
buttonOk.setEnabled((isProjectSelected && !path.startsWith(SLASH)) ||
(isWorkspaceSelected && path.startsWith(SLASH)) || isFilesystemSelected);
}
buttonVars.setEnabled(isFilesystemSelected);
compositeArea.layout(true);
}
@Override
public void buttonPressed(SelectionEvent e) {
String str = null;
if (e.widget.equals(buttonOk)) {
String name = inputName.getText();
text1 = name;
String value = inputValue.getText();
result = true;
int flagBuiltIn = checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;
int flagFramework = checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
int indexPathKind = comboPathCategory.getSelectionIndex();
int kind = comboKind.getSelectionIndex();
boolean isProjectPath = indexPathKind==COMBO_PATH_INDEX_PROJECT;
boolean isWorkspacePath = (kind!=COMBO_INDEX_MACRO) && (isProjectPath || indexPathKind==COMBO_PATH_INDEX_WORKSPACE);
int flagWorkspace = isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED : 0;
int flags = flagBuiltIn | flagWorkspace | flagFramework;
ICLanguageSettingEntry entry=null;
switch (comboKind.getSelectionIndex()) {
case COMBO_INDEX_INCLUDE_PATH:
entry = CDataUtil.createCIncludePathEntry(name, flags);
break;
case COMBO_INDEX_MACRO:
// note that value=null is not supported by CMacroEntry
entry = CDataUtil.createCMacroEntry(name, value, flags);
break;
case COMBO_INDEX_INCLUDE_FILE:
entry = CDataUtil.createCIncludeFileEntry(name, flags);
break;
case COMBO_INDEX_MACRO_FILE:
entry = CDataUtil.createCMacroFileEntry(name, flags);
break;
case COMBO_INDEX_LIBRARY_PATH:
entry = CDataUtil.createCLibraryPathEntry(name, flags);
break;
case COMBO_INDEX_LIBRARY_FILE:
entry = CDataUtil.createCLibraryFileEntry(name, flags);
break;
default:
result = false;
}
entries = new ICLanguageSettingEntry[] {entry};
shell.dispose();
} else if (e.widget.equals(buttonCancel)) {
shell.dispose();
} else if (e.widget.equals(buttonBrowse)) {
boolean isDirectory = false;
boolean isFile = false;
switch (comboKind.getSelectionIndex()) {
case COMBO_INDEX_INCLUDE_PATH:
case COMBO_INDEX_LIBRARY_PATH:
isDirectory = true;
break;
case COMBO_INDEX_INCLUDE_FILE:
case COMBO_INDEX_MACRO_FILE:
case COMBO_INDEX_LIBRARY_FILE:
isFile = true;
break;
case COMBO_INDEX_MACRO:
break;
}
if (isDirectory) {
switch (comboPathCategory.getSelectionIndex()) {
case COMBO_PATH_INDEX_WORKSPACE:
str = AbstractCPropertyTab.getWorkspaceDirDialog(shell, inputName.getText());
break;
case COMBO_PATH_INDEX_PROJECT:
str = AbstractCPropertyTab.getProjectDirDialog(shell, inputName.getText(), project);
break;
case COMBO_PATH_INDEX_FILESYSTEM:
str = AbstractCPropertyTab.getFileSystemDirDialog(shell, inputName.getText());
break;
}
} else if (isFile) {
switch (comboPathCategory.getSelectionIndex()) {
case COMBO_PATH_INDEX_WORKSPACE:
str = AbstractCPropertyTab.getWorkspaceFileDialog(shell, inputName.getText());
break;
case COMBO_PATH_INDEX_PROJECT:
str = AbstractCPropertyTab.getProjectFileDialog(shell, inputName.getText(), project);
break;
case COMBO_PATH_INDEX_FILESYSTEM:
str = AbstractCPropertyTab.getFileSystemFileDialog(shell, inputName.getText());
break;
}
}
if (str != null) {
str = strip_wsp(str);
if (comboPathCategory.getSelectionIndex()==COMBO_PATH_INDEX_PROJECT && str.startsWith(SLASH+project.getName()+SLASH)) {
str=str.substring(project.getName().length()+2);
}
inputName.setText(str);
}
} else if (e.widget.equals(buttonVars)) {
str = AbstractCPropertyTab.getVariableDialog(shell, cfgDescription);
if (str != null) inputName.insert(str);
}
}
public ICLanguageSettingEntry[] getEntries() {
return entries;
}
private void updateImages() {
int indexEntryKind = comboKind.getSelectionIndex();
int indexPathKind = comboPathCategory.getSelectionIndex();
shell.setText(Messages.LanguageSettingEntryDialog_Add + comboKindItems[indexEntryKind]);
int kind = comboIndexToKind(indexEntryKind);
int flagBuiltin = checkBoxBuiltIn.getSelection() ? ICSettingEntry.BUILTIN : 0;
int flagFramework = checkBoxFramework.getSelection() ? ICSettingEntry.FRAMEWORKS_MAC : 0;
boolean isWorkspacePath = indexPathKind==COMBO_PATH_INDEX_PROJECT || indexPathKind==COMBO_PATH_INDEX_WORKSPACE;
int flagWorkspace = isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED : 0;
int flags = flagBuiltin | flagWorkspace | flagFramework;
Image image = LanguageSettingsImages.getImage(kind, flags, indexPathKind==COMBO_PATH_INDEX_PROJECT);
iconComboKind.setImage(image);
shell.setImage(image);
buttonBrowse.setImage(pathCategoryImages[indexPathKind]);
}
}

View file

@ -0,0 +1,361 @@
/*******************************************************************************
* 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.internal.ui.language.settings.providers;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
/**
* This class manages extensions of extension point org.eclipse.cdt.core.LanguageSettingsProvider
* which defines appearance and behavior of UI controls for Language Settings Providers.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class LanguageSettingsProviderAssociationManager {
/** Name of the extension point for contributing language settings provider associations */
private static final String PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID = "LanguageSettingsProviderAssociation"; //$NON-NLS-1$
private static final String ELEM_ID_ASSOCIATION = "id-association"; //$NON-NLS-1$
private static final String ELEM_CLASS_ASSOCIATION = "class-association"; //$NON-NLS-1$
private static final String ATTR_ID = "id"; //$NON-NLS-1$
private static final String ATTR_CLASS = "class"; //$NON-NLS-1$
private static final String ATTR_ICON = "icon"; //$NON-NLS-1$
private static final String ATTR_PAGE = "page"; //$NON-NLS-1$
private static final String ATTR_UI_CLEAR_ENTRIES = "ui-clear-entries"; //$NON-NLS-1$
private static final String ATTR_UI_EDIT_ENTRIES = "ui-edit-entries"; //$NON-NLS-1$
private static boolean isLoaded = false;
private static List<URL> loadedIcons = new ArrayList<URL>();
private static Map<String, URL> fImagesUrlById = new HashMap<String, URL>();
private static Map<String, URL> fImagesUrlByClass = new HashMap<String, URL>();
private static List<String> fRegirestedIds = new ArrayList<String>();
private static List<String> fRegisteredClasses = new ArrayList<String>();
private static Map<String, Map<String, String>> fAssociationsById = new HashMap<String, Map<String, String>>();
private static Map<String, Map<String, String>> fAssociationsByClass = new HashMap<String, Map<String, String>>();
/**
* Load extensions into memory maps.
*/
private static void loadExtensions() {
if (isLoaded) {
return;
}
isLoaded = true;
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
if (extension != null) {
IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) {
@SuppressWarnings("unused")
String extensionID = ext.getUniqueIdentifier();
for (IConfigurationElement cfgEl : ext.getConfigurationElements()) {
if (cfgEl.getName().equals(ELEM_ID_ASSOCIATION)) {
String id = cfgEl.getAttribute(ATTR_ID);
URL url = getIconUrl(cfgEl);
fImagesUrlById.put(id, url);
fRegirestedIds.add(id);
Map<String, String> properties = new HashMap<String, String>();
putNotEmpty(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
fAssociationsById.put(id, properties);
} else if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) {
String className = cfgEl.getAttribute(ATTR_CLASS);
URL url = getIconUrl(cfgEl);
fImagesUrlByClass.put(className, url);
String pageClass = cfgEl.getAttribute(ATTR_PAGE);
if (pageClass != null && pageClass.length() > 0) {
fRegisteredClasses.add(className);
}
Map<String, String> properties = new HashMap<String, String>();
putNotEmpty(properties, ATTR_PAGE, cfgEl.getAttribute(ATTR_PAGE));
putNotEmpty(properties, ATTR_UI_CLEAR_ENTRIES, cfgEl.getAttribute(ATTR_UI_CLEAR_ENTRIES));
putNotEmpty(properties, ATTR_UI_EDIT_ENTRIES, cfgEl.getAttribute(ATTR_UI_EDIT_ENTRIES));
fAssociationsByClass.put(className, properties);
}
}
}
}
}
/**
* Put value into properties ignoring nulls.
*/
private static void putNotEmpty(Map<String, String> properties, String key, String value) {
if (value != null)
properties.put(key, value);
}
/**
* Find icon URL in its bundle.
*/
private static URL getIconUrl(IConfigurationElement config) {
URL url = null;
try {
String iconName = config.getAttribute(ATTR_ICON);
if (iconName != null) {
URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$
url = new URL(pluginInstallUrl, iconName);
if (loadedIcons.contains(url)) {
return url;
}
}
} catch (MalformedURLException e) {
CUIPlugin.log(e);
}
loadedIcons.add(url);
if (url != null) {
CDTSharedImages.register(url);
}
return url;
}
/**
* Get image URL for language settings provider with the given ID.
*
* @param providerId - ID of language settings provider.
* @return image URL or {@code null}.
*/
public static URL getImageUrl(String providerId) {
loadExtensions();
return fImagesUrlById.get(providerId);
}
/**
* Create an Options page for language settings provider with given ID.
*/
private static ICOptionPage createOptionsPageById(String providerId) {
loadExtensions();
if (fRegirestedIds.contains(providerId)) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
if (extension != null) {
IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) {
try {
@SuppressWarnings("unused")
String extensionID = ext.getUniqueIdentifier();
for (IConfigurationElement cfgEl : ext.getConfigurationElements()) {
if (cfgEl.getName().equals(ELEM_ID_ASSOCIATION)) {
String id = cfgEl.getAttribute(ATTR_ID);
if (providerId.equals(id)) {
String pageClass = cfgEl.getAttribute(ATTR_PAGE);
if (pageClass != null && pageClass.trim().length() > 0) {
ICOptionPage page = (ICOptionPage) cfgEl.createExecutableExtension(ATTR_PAGE);
return page;
}
}
}
}
} catch (Exception e) {
CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " + ext.getUniqueIdentifier(), e); //$NON-NLS-1$
}
}
}
}
return null;
}
/**
* Create an Options page for language settings provider class by its name.
*/
private static ICOptionPage createOptionsPageByClass(String providerClassName) {
loadExtensions();
if (fRegisteredClasses.contains(providerClassName)) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extension = registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, PROVIDER_ASSOCIATION_EXTENSION_POINT_SIMPLE_ID);
if (extension != null) {
IExtension[] extensions = extension.getExtensions();
for (IExtension ext : extensions) {
try {
@SuppressWarnings("unused")
String extensionID = ext.getUniqueIdentifier();
for (IConfigurationElement cfgEl : ext.getConfigurationElements()) {
if (cfgEl.getName().equals(ELEM_CLASS_ASSOCIATION)) {
String className = cfgEl.getAttribute(ATTR_CLASS);
if (providerClassName.equals(className)) {
String pageClass = cfgEl.getAttribute(ATTR_PAGE);
if (pageClass!=null && pageClass.trim().length()>0) {
ICOptionPage page = (ICOptionPage) cfgEl.createExecutableExtension(ATTR_PAGE);
return page;
}
}
}
}
} catch (Exception e) {
CUIPlugin.log("Cannot load LanguageSettingsProviderAssociation extension " + ext.getUniqueIdentifier(), e); //$NON-NLS-1$
}
}
}
}
return null;
}
/**
* Returns Language Settings Provider image registered for closest superclass
* or interface.
*
* @param providerClass - class to find Language Settings Provider image.
* @return image or {@code null}
*/
public static URL getImage(Class<? extends ILanguageSettingsProvider> providerClass) {
URL url = null;
outer: for (Class<?> c = providerClass; c != null; c = c.getSuperclass()) {
url = getImageURL(c);
if (url != null) {
break;
}
// this does not check for super-interfaces, feel free to implement as needed
for (Class<?> i : c.getInterfaces()) {
url = getImageURL(i);
if (url != null) {
break outer;
}
}
}
return url;
}
/**
* Return image URL registered for the given class.
*/
private static URL getImageURL(Class<?> clazz) {
String className = clazz.getCanonicalName();
for (Entry<String, URL> entry : fImagesUrlByClass.entrySet()) {
if (entry.getKey().equals(className)) {
return entry.getValue();
}
}
return null;
}
/**
* Returns language settings provider Options page registered for closest superclass.
*
* @param provider - instance of provider to create Options page for.
* @return image or {@code null}.
*/
public static ICOptionPage createOptionsPage(ILanguageSettingsProvider provider) {
String id = provider.getId();
ICOptionPage optionsPage = createOptionsPageById(id);
if (optionsPage != null) {
return optionsPage;
}
Class<? extends ILanguageSettingsProvider> clazz = provider.getClass();
outer: for (Class<?> c = clazz ;c != null; c = c.getSuperclass()) {
optionsPage = createOptionsPageByClass(c);
if (optionsPage != null) {
break;
}
// this does not check for super-interfaces, feel free to implement as needed
for (Class<?> i : c.getInterfaces()) {
optionsPage = createOptionsPageByClass(i);
if (optionsPage != null) {
break outer;
}
}
}
return optionsPage;
}
/**
* Create an Options page for language settings provider class.
*/
private static ICOptionPage createOptionsPageByClass(Class<?> clazz) {
ICOptionPage optionsPage = null;
String className = clazz.getCanonicalName();
if (fRegisteredClasses.contains(className)) {
optionsPage = createOptionsPageByClass(className);
}
return optionsPage;
}
/**
* Returns value of the attribute of the provider by id or closest superclass.
*/
private static boolean getBooleanAttribute(ILanguageSettingsProvider provider, String attr) {
loadExtensions();
String id = provider.getId();
Map<String, String> properties = fAssociationsById.get(id);
if (properties != null) {
return Boolean.parseBoolean(properties.get(attr));
}
for (Class<?> c = provider.getClass();c != null; c = c.getSuperclass()) {
String className = c.getCanonicalName();
properties = fAssociationsByClass.get(className);
if (properties != null) {
return Boolean.parseBoolean(properties.get(attr));
}
// this does not check for superinterfaces, feel free to implement as needed
for (Class<?> i : c.getInterfaces()) {
String interfaceName = i.getCanonicalName();
properties = fAssociationsByClass.get(interfaceName);
if (properties != null) {
return Boolean.parseBoolean(properties.get(attr));
}
}
}
return false;
}
/**
* Check if the user is allowed to edit language settings provider entries in UI.
* @param provider - language settings provider.
* @return {@code true} if editing is allowed or {@code false} if not.
*/
public static boolean isAllowedToEditEntries(ILanguageSettingsProvider provider) {
return getBooleanAttribute(provider, ATTR_UI_EDIT_ENTRIES);
}
/**
* Check if the user is allowed to clear language settings provider entries in UI.
* @param provider - language settings provider.
* @return {@code true} if clearing is allowed or {@code false} if not.
*/
public static boolean isAllowedToClear(ILanguageSettingsProvider provider) {
return getBooleanAttribute(provider, ATTR_UI_CLEAR_ENTRIES);
}
}

View file

@ -0,0 +1,96 @@
/*******************************************************************************
* 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.internal.ui.language.settings.providers;
import java.net.URL;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.cdt.internal.ui.newui.Messages;
/**
* Label provider for language settings providers.
*
*/
public class LanguageSettingsProvidersLabelProvider extends LabelProvider {
private static final String TEST_PLUGIN_ID_PATTERN = "org.eclipse.cdt.*.tests.*"; //$NON-NLS-1$
private static final String OOPS = "OOPS"; //$NON-NLS-1$
/**
* Returns base image key (for image without overlay).
*/
protected String getBaseKey(ILanguageSettingsProvider provider) {
String imageKey = null;
// try id-association
String id = provider.getId();
URL url = LanguageSettingsProviderAssociationManager.getImageUrl(id);
// try class-association
if (url == null) {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider);
if (rawProvider != null) {
url = LanguageSettingsProviderAssociationManager.getImage(rawProvider.getClass());
}
}
if (url != null) {
imageKey = url.toString();
}
if (imageKey == null) {
if (id.matches(TEST_PLUGIN_ID_PATTERN)) {
imageKey = CDTSharedImages.IMG_OBJS_CDT_TESTING;
} else {
imageKey = CDTSharedImages.IMG_OBJS_EXTENSION;
}
}
return imageKey;
}
/**
* Returns keys for image overlays. Returning {@code null} is not allowed.
*/
protected String[] getOverlayKeys(ILanguageSettingsProvider provider) {
return new String[5];
}
@Override
public Image getImage(Object element) {
if (element instanceof ILanguageSettingsProvider) {
ILanguageSettingsProvider provider = (ILanguageSettingsProvider)element;
String imageKey = getBaseKey(provider);
String[] overlayKeys = getOverlayKeys(provider);
return CDTSharedImages.getImageOverlaid(imageKey, overlayKeys);
}
return null;
}
@Override
public String getText(Object element) {
if (element instanceof ILanguageSettingsProvider) {
ILanguageSettingsProvider provider = (ILanguageSettingsProvider) element;
String name = provider.getName();
if (name != null) {
if (LanguageSettingsManager.isWorkspaceProvider(provider)) {
name = name + Messages.LanguageSettingsProvidersLabelProvider_TextDecorator_Shared;
}
return name;
}
return NLS.bind(Messages.GeneralMessages_NonAccessibleID, provider.getId());
}
return OOPS;
}
}

View file

@ -0,0 +1,104 @@
/*******************************************************************************
* 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.internal.ui.language.settings.providers;
import org.eclipse.core.resources.IProject;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.ui.newui.AbstractPage;
import org.eclipse.cdt.ui.newui.ICPropertyTab;
/**
* Property page for language settings providers tabs.
* The handling of isLanguageSettingsProvidersEnabled is temporary, this control is to be removed.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class LanguageSettingsProvidersPage extends AbstractPage {
/** @since 5.4 */ // temporary key, subject to removal
public static final String KEY_NO_SHOW_PROVIDERS = "properties.providers.tab.disable"; //$NON-NLS-1$
/** @since 5.4 */ // temporary key, subject to removal
public static final String KEY_NEWSD = "wizard.try.new.sd.enable"; //$NON-NLS-1$
private static boolean isLanguageSettingsProvidersEnabled = false;
private static IProject project = null;
@Override
protected boolean isSingle() {
return false;
}
/**
* Check if language settings providers functionality is enabled for the project.
* Need this method as another page could be inquiring before this page gets initialized.
*
* @noreference This method is temporary and not intended to be referenced by clients.
*/
public static boolean isLanguageSettingsProvidersEnabled(IProject prj) {
if (prj != null) {
if (prj.equals(project)) {
return isLanguageSettingsProvidersEnabled;
} else {
return ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project);
}
}
return false;
}
/**
* Check if language settings providers functionality is enabled for the current project.
*
* @noreference This method is temporary and not intended to be referenced by clients.
*/
public boolean isLanguageSettingsProvidersEnabled() {
IProject prj = getProject();
if (prj != null) {
if (!prj.equals(project)) {
project = prj;
isLanguageSettingsProvidersEnabled = ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project);
}
return isLanguageSettingsProvidersEnabled;
}
return false;
}
/**
* Enable or disable language settings providers functionality for the current project.
* Triggers update of all the property pages.
*
* Note that this method only sets property for the current editing session.
* Use {@link #applyLanguageSettingsProvidersEnabled()} to apply to the project.
*
* @noreference This method is temporary and not intended to be referenced by clients.
*/
public void setLanguageSettingsProvidersEnabled(boolean enable) {
isLanguageSettingsProvidersEnabled = enable;
project = getProject();
forEach(ICPropertyTab.UPDATE,getResDesc());
}
/**
* Apply enablement of language settings providers functionality to the current project.
*
* @noreference This method is temporary and not intended to be referenced by clients.
*/
public void applyLanguageSettingsProvidersEnabled() {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(getProject(), isLanguageSettingsProvidersEnabled);
}
@Override
public void dispose() {
isLanguageSettingsProvidersEnabled = false;
project = null;
super.dispose();
}
}

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.ui.newui;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
@ -23,6 +24,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.settings.model.ACPathEntry;
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.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.ui.CDTSharedImages;
@ -32,6 +34,38 @@ import org.eclipse.cdt.ui.CUIPlugin;
* Helper class to provide unified images for {@link ICLanguageSettingEntry}.
*/
public class LanguageSettingsImages {
public static Image getImage(int kind, int flags, boolean isProjectRelative) {
String imageKey = getImageKey(kind, flags, isProjectRelative);
if (imageKey != null) {
return CDTSharedImages.getImage(imageKey);
}
return null;
}
/**
* Returns image for the given entry from internally managed repository including
* necessary overlays for given configuration description.
*
* @param entry - language settings entry to get an image for.
* @param cfgDescription - configuration description of the entry.
* @return the image for the entry with appropriate overlays.
*/
public static Image getImage(ICLanguageSettingEntry entry, ICConfigurationDescription cfgDescription) {
String projectName = null;
if (cfgDescription != null) {
ICProjectDescription prjDescription = cfgDescription.getProjectDescription();
if (prjDescription != null) {
IProject project = prjDescription.getProject();
if (project != null) {
projectName = project.getName();
}
}
}
return getImage(entry, projectName, cfgDescription);
}
/**
* @return the base key for the image.
*/
@ -89,7 +123,7 @@ public class LanguageSettingsImages {
* @param cfgDescription - configuration description of the entry.
* @return the image for the entry with appropriate overlays.
*/
public static Image getImage(ICLanguageSettingEntry entry, String projectName, ICConfigurationDescription cfgDescription) {
private static Image getImage(ICLanguageSettingEntry entry, String projectName, ICConfigurationDescription cfgDescription) {
int kind = entry.getKind();
int flags = entry.getFlags();
boolean isWorkspacePath = (flags & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;

View file

@ -84,6 +84,7 @@ public class Messages extends NLS {
public static String CDTCommonProjectWizard_creatingProject;
public static String CDTMainWizardPage_0;
public static String CDTMainWizardPage_1;
public static String CDTMainWizardPage_TrySD90;
public static String CLocationOutputTab_0;
public static String CLocationSourceTab_0;
public static String CLocationTab_0;
@ -138,7 +139,6 @@ public class Messages extends NLS {
public static String EnvironmentTab_8;
public static String EnvironmentTab_9;
public static String ErrorParsTab_error_IllegalCharacter;
public static String ErrorParsTab_error_NonAccessibleID;
public static String ErrorParsTab_error_NonEmptyName;
public static String ErrorParsTab_error_NonUniqueID;
public static String ErrorParsTab_error_OnApplyingSettings;
@ -174,6 +174,8 @@ public class Messages extends NLS {
public static String FileListControl_editdialog_title;
public static String FileListControl_movedown;
public static String FileListControl_moveup;
public static String GeneralMessages_InternalError_ReportLogToCdtTeam;
public static String GeneralMessages_NonAccessibleID;
public static String IncludeDialog_0;
public static String IncludeDialog_1;
public static String IncludeDialog_2;
@ -186,9 +188,42 @@ public class Messages extends NLS {
public static String IncludeTab_2;
public static String IncludeTab_export;
public static String IncludeTab_import;
public static String LanguageSettingEntryDialog_Add;
public static String LanguageSettingEntryDialog_BuiltInFlag;
public static String LanguageSettingEntryDialog_Directory;
public static String LanguageSettingEntryDialog_File;
public static String LanguageSettingEntryDialog_Filesystem;
public static String LanguageSettingEntryDialog_FrameworkFolder;
public static String LanguageSettingEntryDialog_IncludeDirectory;
public static String LanguageSettingEntryDialog_IncludeFile;
public static String LanguageSettingEntryDialog_Library;
public static String LanguageSettingEntryDialog_LibraryPath;
public static String LanguageSettingEntryDialog_Name;
public static String LanguageSettingEntryDialog_Path;
public static String LanguageSettingEntryDialog_PreporocessorMacro;
public static String LanguageSettingEntryDialog_PreprocessorMacroFile;
public static String LanguageSettingEntryDialog_ProjectRelative;
public static String LanguageSettingEntryDialog_SelectKind;
public static String LanguageSettingEntryDialog_Value;
public static String LanguageSettingEntryDialog_WorkspacePath;
public static String LanguageSettingsEntriesTab_Cannot_Determine_Languages;
public static String LanguageSettingsEntriesTab_Entries_Not_Editable;
public static String LanguageSettingsImages_FileDoesNotExist;
public static String LanguageSettingsImages_FolderDoesNotExist;
public static String LanguageSettingsImages_UsingRelativePathsNotRecommended;
public static String LanguageSettingsProvidersLabelProvider_TextDecorator_Shared;
public static String LanguageSettingsProviderTab_AreYouSureToResetProviders;
public static String LanguageSettingsProviderTab_Clear;
public static String LanguageSettingsProviderTab_LanguageSettingsProvidersOptions;
public static String LanguageSettingsProviderTab_OptionsCanBeChangedInPreferencesDiscoveryTab;
public static String LanguageSettingsProviderTab_ProviderOptions;
public static String LanguageSettingsProviderTab_Reset;
public static String LanguageSettingsProviderTab_SettingEntries;
public static String LanguageSettingsProviderTab_SettingEntriesTooltip;
public static String LanguageSettingsProviderTab_ShareProviders;
public static String LanguageSettingsProviderTab_StoreEntriesInsideProject;
public static String LanguageSettingsProviderTab_TitleResetProviders;
public static String LanguageSettingsProviderTab_WorkspaceSettings;
public static String LanguagesTab_0;
public static String LanguagesTab_1;
public static String LibraryPathTab_1;

View file

@ -166,9 +166,42 @@ IncludeDialog_0=Directory:
IncludeDialog_1=File:
IncludeDialog_2=Add to all configurations
IncludeDialog_3=Add to all languages
LanguageSettingEntryDialog_Add=Add
LanguageSettingEntryDialog_BuiltInFlag=Treat as Built-In (Ignore during build)
LanguageSettingEntryDialog_Directory=Dir:
LanguageSettingEntryDialog_File=File:
LanguageSettingEntryDialog_Filesystem=Filesystem
LanguageSettingEntryDialog_FrameworkFolder=Framework folder (Mac only)
LanguageSettingEntryDialog_IncludeDirectory=Include Directory
LanguageSettingEntryDialog_IncludeFile=Include File
LanguageSettingEntryDialog_Library=Library
LanguageSettingEntryDialog_LibraryPath=Library Path
LanguageSettingEntryDialog_Name=Name:
LanguageSettingEntryDialog_Path=Path:
LanguageSettingEntryDialog_PreporocessorMacro=Preprocessor Macro
LanguageSettingEntryDialog_PreprocessorMacroFile=Preprocessor Macros File
LanguageSettingEntryDialog_ProjectRelative=Project-Relative
LanguageSettingEntryDialog_SelectKind=Select Kind:
LanguageSettingEntryDialog_Value=Value:
LanguageSettingEntryDialog_WorkspacePath=Workspace Path
LanguageSettingsEntriesTab_Cannot_Determine_Languages=Cannot determine toolchain languages.
LanguageSettingsEntriesTab_Entries_Not_Editable=Setting entries for this provider are supplied by the system and are not editable.
LanguageSettingsImages_FileDoesNotExist=The selected file does not exist or not accessible.
LanguageSettingsImages_FolderDoesNotExist=The selected folder does not exist or not accessible.
LanguageSettingsImages_UsingRelativePathsNotRecommended=Using relative paths is ambiguous and not recommended. It can cause unexpected effects.
LanguageSettingsProvidersLabelProvider_TextDecorator_Shared=\ \ \ [ Shared ]
LanguageSettingsProviderTab_AreYouSureToResetProviders=Are you sure you want to reset all customized language settings providers?\nPlease note that providers may regain entries on their own schedule.
LanguageSettingsProviderTab_Clear=Clear Entries
LanguageSettingsProviderTab_LanguageSettingsProvidersOptions=Language Settings Provider Options
LanguageSettingsProviderTab_OptionsCanBeChangedInPreferencesDiscoveryTab=Options of global providers below can be changed in {0}, Discovery Tab.
LanguageSettingsProviderTab_Reset=Reset
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_TitleResetProviders=Reset Language Settings Providers
LanguageSettingsProviderTab_WorkspaceSettings=Workspace Settings
LanguagesTab_0=Content type
LanguagesTab_1=Language
LibraryPathTab_1=Add...
@ -207,7 +240,6 @@ ErrorParsTab_error_NonEmptyName=Specify non empty name
ErrorParsTab_error_NonUniqueID=Error parser ID is not unique, specify different name
ErrorParsTab_error_OnApplyingSettings=Error applying Error Parser Tab settings
ErrorParsTab_error_OnRestoring=Error restoring default Error Parser Tab settings
ErrorParsTab_error_NonAccessibleID=[ Not accessible id={0} ]
ErrorParsTab_error_IllegalCharacter=Special character ''{0}'' is not allowed
ErrorParsTab_label_EnterName=Enter name of new error parser:
ErrorParsTab_label_DefaultRegexErrorParserName=Regex Error Parser
@ -272,8 +304,11 @@ StringVariableSelectionDialog_message=&Choose a variable (? = any character, * =
StringVariableSelectionDialog_columnDescription=&Variable Description:
CDTMainWizardPage_0=Project name cannot contain '\#' symbol
CDTMainWizardPage_1=Project category is selected. Expand the category and select a concrete project type.
CDTMainWizardPage_TrySD90=I want to try new upcoming version of Scanner Discovery in CDT 9.0 (sd90 v.0.9.0)
CProjectWizard_0=Add C Project Nature
CCProjectWizard_0=Add CC Project Nature
GeneralMessages_InternalError_ReportLogToCdtTeam=Internal error happened, report application log to CDT team.
GeneralMessages_NonAccessibleID=[ Not accessible id={0} ]
WorkingSetConfigAction_21=Building project
WorkingSetConfigAction_22=Build error
IncludeTab_export=Export Settings...

View file

@ -10,12 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
import java.util.List;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IBaseLabelProvider;
@ -29,6 +30,10 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
@ -36,6 +41,7 @@ import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
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.ICResourceDescription;
import org.eclipse.cdt.ui.CElementImageDescriptor;
@ -379,6 +385,31 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
}
}
public static boolean isCustomizedResource(ICConfigurationDescription cfgDescription, IResource rc) {
if (rc instanceof IProject)
return false;
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(rc.getProject())) {
ICResourceDescription rcDescription = cfgDescription.getResourceDescription(rc.getProjectRelativePath(), true);
return rcDescription != null;
}
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
for (ILanguageSettingsProvider provider: ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()) {
for (String languageId : LanguageSettingsManager.getLanguages(rc, cfgDescription)) {
List<ICLanguageSettingEntry> list = provider.getSettingEntries(cfgDescription, rc, languageId);
if (list!=null) {
List<ICLanguageSettingEntry> listDefault = provider.getSettingEntries(cfgDescription, rc.getParent(), languageId);
// != is OK here due as the equal lists will have the same reference in WeakHashSet
if (list != listDefault)
return true;
}
}
}
}
return false;
}
/**
* @param rc - resource to check
* @return flags {@link TICK_CONFIGURATION} if the resource has custom settings and possibly needs
@ -393,9 +424,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
if (prjDescription != null) {
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
if (cfgDescription != null) {
IPath path = rc.getProjectRelativePath();
ICResourceDescription rcDescription = cfgDescription.getResourceDescription(path, true);
if (rcDescription != null)
if (isCustomizedResource(cfgDescription, rc))
result |= TICK_CONFIGURATION;
}
}

View file

@ -210,6 +210,39 @@ public class CDTSharedImages {
public static final String IMG_VIEW_PIN_ACTION_B = "icons/obj16/toolbar_pinned_b.gif"; //$NON-NLS-1$
public static final String IMG_VIEW_PIN_ACTION_MULTI = "icons/obj16/toolbar_pinned_multi.gif"; //$NON-NLS-1$
// Language Settings Images
/** @since 5.4 */
public static final String IMG_OBJS_LANG_SETTINGS_PROVIDER = "icons/obj16/ls_entries_provider.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_ETOOL_PROJECT = "icons/etool16/prj_obj.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_GLOBAL = "icons/ovr16/global_ovr.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_IMPORT = "icons/ovr16/import_co.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_LINK = "icons/ovr16/link_ovr.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_CONFIGURATION = "icons/ovr16/cfg_ovr.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_PARENT = "icons/ovr16/path_inherit_co.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_INDEXED = "icons/ovr16/indexedFile.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_REFERENCE = "icons/ovr16/referencedby_co.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_PROJECT = "icons/ovr16/project_co.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_CONTEXT = "icons/ovr16/overlay-has-context.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_LOCK = "icons/ovr16/lock_ovr.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_EDITED = "icons/ovr16/edited_ov.gif"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_EMPTY = "icons/ovr16/empty_ovr.png"; //$NON-NLS-1$
/** @since 5.4 */
public static final String IMG_OVR_USER = "icons/ovr16/person_ovr.gif"; //$NON-NLS-1$
/**
* The method finds URL of the image corresponding to the key which could be project-relative path
* of the image in org.eclipse.cdt.ui plugin or a (previously registered) string representation of URL

View file

@ -0,0 +1,79 @@
/*******************************************************************************
* 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.ui.language.settings.providers;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderTab;
/**
* Abstract class to implement language settings providers Options page.
*
* @since 5.4
*/
public abstract class AbstractLanguageSettingProviderOptionPage extends AbstractCOptionPage {
private LanguageSettingsProviderTab providerTab;
private String providerId;
/**
* Initialize the options page with the owning tab and provider ID.
*
* @param providerTab - provider tab which owns the options page.
* @param providerId - ID of the provider the options page is for.
*/
public void init(AbstractCPropertyTab providerTab, String providerId) {
this.providerTab = (LanguageSettingsProviderTab) providerTab;
this.providerId = providerId;
}
/**
* Get provider being displayed on this Options Page.
* @return provider.
*/
public ILanguageSettingsProvider getProvider() {
return LanguageSettingsManager.getRawProvider(providerTab.getProvider(providerId));
}
/**
* Get working copy of the provider to allow its options to be modified.
* @return working copy of the provider.
*/
public ILanguageSettingsProvider getProviderWorkingCopy() {
return providerTab.getWorkingCopy(providerId);
}
/**
* Refresh provider item in the table and update buttons.
* This method is intended for use by an Options Page of the provider.
*
* @param provider - provider item in the table to refresh.
*/
public void refreshItem(ILanguageSettingsProvider provider) {
providerTab.refreshItem(provider);
}
@Override
public void performApply(IProgressMonitor monitor) throws CoreException {
// normally should be handled by LanguageSettingsProviderTab
}
@Override
public void performDefaults() {
// normally should be handled by LanguageSettingsProviderTab
}
}

View file

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2012, 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.ui.language.settings.providers;
import java.net.URL;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderAssociationManager;
/**
* Utility class to provide API for language settings providers images.
*
* @since 5.4
*/
public class LanguageSettingsProvidersImages {
/**
* Get image URL for language settings provider with the given ID.
*
* @param providerId - ID of language settings provider.
* @return image URL or {@code null}.
*/
public static URL getImageUrl(String providerId) {
return LanguageSettingsProviderAssociationManager.getImageUrl(providerId);
}
}

View file

@ -94,6 +94,8 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
public static final String EDIT_STR = Messages.FileListControl_edit;
public static final String MOVEUP_STR = Messages.FileListControl_moveup;
public static final String MOVEDOWN_STR = Messages.FileListControl_movedown;
/** @since 5.4 */
public static final String PROJECTBUTTON_NAME = "Project...";
public static final String WORKSPACEBUTTON_NAME = Messages.FileListControl_button_workspace;
public static final String FILESYSTEMBUTTON_NAME = Messages.FileListControl_button_fs;
public static final String VARIABLESBUTTON_NAME = Messages.AbstractCPropertyTab_1;
@ -453,6 +455,18 @@ public abstract class AbstractCPropertyTab implements ICPropertyTab {
public static String getWorkspaceFileDialog(Shell shell, String text) {
return getWorkspaceDialog(shell, text, false, null);
}
/**
* @since 5.4
*/
public static String getProjectDirDialog(Shell shell, String text, IProject prj) {
return getWorkspaceDialog(shell, text, true, prj);
}
/**
* @since 5.4
*/
public static String getProjectFileDialog(Shell shell, String text, IProject prj) {
return getWorkspaceDialog(shell, text, false, prj);
}
private static String getWorkspaceDialog(Shell shell, String text, boolean dir, IProject prj) {
String currentPathText;

View file

@ -19,7 +19,6 @@ import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
@ -730,8 +729,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex==0 && (element instanceof ICLanguageSettingEntry)) {
ICConfigurationDescription cfg = getResDesc().getConfiguration();
IProject project = cfg.getProjectDescription().getProject();
return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, project.getName(), cfg);
return LanguageSettingsImages.getImage((ICLanguageSettingEntry) element, cfg);
}
return null;
}

View file

@ -166,7 +166,7 @@ public class ErrorParsTab extends AbstractCPropertyTab {
return name;
}
}
return NLS.bind(Messages.ErrorParsTab_error_NonAccessibleID, id);
return NLS.bind(Messages.GeneralMessages_NonAccessibleID, id);
}
return OOPS;
}

View file

@ -10,39 +10,63 @@
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.service.prefs.BackingStoreException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin;
/**
* Checks whether given object is a source file.
* Property tester to test expressions in plugin.xml. Tests following expressions:
* 1. Checks whether given object is a source file. Usage:
* <test property="org.eclipse.cdt.ui.isSource"/>
* 2. Checks value of a preference. Usage:
* <test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.export.page.enable=true"/>
*
* @noextend This class is not intended to be subclassed by clients.
*/
public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
private static final String KEY_SRC = "isSource"; //$NON-NLS-1$
private static final String KEY_PAGE = "pageEnabled"; //$NON-NLS-1$
private static final String VAL_EXP = "export"; //$NON-NLS-1$
private static final String VAL_TOOL = "toolEdit"; //$NON-NLS-1$
private static final String KEY_SRC = "isSource"; //$NON-NLS-1$
private static final String KEY_PREF = "checkPreference"; //$NON-NLS-1$
@Override
public boolean test(Object receiver, String property, Object[] args,
Object expectedValue) {
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (KEY_SRC.equals(property)) {
if (receiver instanceof ITranslationUnit) {
return ((ITranslationUnit)receiver).isSourceUnit();
}
else if (receiver instanceof IFile) {
IFile file = (IFile)receiver;
return ((ITranslationUnit) receiver).isSourceUnit();
} else if (receiver instanceof IFile) {
IFile file = (IFile) receiver;
return CoreModel.isValidSourceUnitName(file.getProject(), file.getName());
}
} else if (KEY_PAGE.equals(property)
&& expectedValue instanceof String) {
String s = (String) expectedValue;
if (VAL_EXP.equalsIgnoreCase(s))
return CDTPrefUtil.getBool(CDTPrefUtil.KEY_EXPORT);
if (VAL_TOOL.equalsIgnoreCase(s))
return !CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOTOOLM);
} else if (KEY_PREF.equals(property) && expectedValue instanceof String) {
boolean result = false;
final Pattern pat = Pattern.compile("(.*):(.*)=(.*)"); //$NON-NLS-1$
Matcher matcher = pat.matcher((String) expectedValue);
if (matcher.matches()) {
String pluginId = matcher.group(1);
String preference = matcher.group(2);
String wantedValue = matcher.group(3);
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(pluginId);
if (wantedValue != null) {
String actualValue = node.get(preference, ""); //$NON-NLS-1$
result = wantedValue.equals(actualValue) || (wantedValue.equals("false") && actualValue.isEmpty()); //$NON-NLS-1$
} else {
try {
result = Arrays.asList(node.keys()).contains(preference);
} catch (BackingStoreException e) {
CUIPlugin.log(e);
}
}
}
return result;
}
return false;
}

View file

@ -50,6 +50,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
import org.eclipse.cdt.ui.newui.PageLayout;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProvidersPage;
import org.eclipse.cdt.internal.ui.newui.Messages;
public class CDTMainWizardPage extends WizardNewProjectCreationPage implements IWizardItemsListListener {
@ -67,6 +68,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
private Tree tree;
private Composite right;
private Button show_sup;
private Button checkBoxTryNewSD;
private Label right_label;
public CWizardHandler h_selected = null;
@ -154,6 +156,20 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
// restore settings from preferences
show_sup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP));
checkBoxTryNewSD = new Button(c, SWT.CHECK);
checkBoxTryNewSD.setText(Messages.CDTMainWizardPage_TrySD90);
/* GridData */gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
checkBoxTryNewSD.setLayoutData(gd);
// restore settings from preferences
boolean isTryNewSD = true;
boolean contains = CUIPlugin.getDefault().getPreferenceStore().contains(LanguageSettingsProvidersPage.KEY_NEWSD);
if (contains) {
isTryNewSD = CDTPrefUtil.getBool(LanguageSettingsProvidersPage.KEY_NEWSD);
}
checkBoxTryNewSD.setSelection(isTryNewSD);
}
@Override
@ -481,5 +497,13 @@ import org.eclipse.cdt.internal.ui.newui.Messages;
public List filterItems(List items) {
return items;
}
/**
* AG FIXME - remove before CDT Juno release.
* @since 5.4
*/
public boolean isTryingNewSD() {
return checkBoxTryNewSD.getSelection();
}
}

View file

@ -522,18 +522,19 @@
name="%TargetName.xlc.exe"
projectMacroSupplier="org.eclipse.cdt.managedbuilder.xlc.ui.XLCProjectMacroSupplier">
<configuration
name="%ConfigName.Dbg"
artifactExtension="exe"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
id="cdt.managedbuild.config.xlc.exe.debug">
artifactExtension="exe"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
id="cdt.managedbuild.config.xlc.exe.debug"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;${Toolchain};-org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser"
name="%ConfigName.Dbg">
<toolChain
archList="all"
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.xlc.aix.AixConfigurationEnvironmentSupplier"
id="cdt.managedbuild.toolchain.xlc.exe.debug"
name="%ToolChainName.Dbg"
osList="all"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser;org.eclipse.cdt.managedbuilder.xlc.core.XlcBuiltinSpecsDetector"
targetTool="cdt.managedbuild.tool.xlc.c.linker.exe.debug;cdt.managedbuild.tool.xlc.cpp.linker.exe.debug">
<targetPlatform
id="cdt.managedbuild.target.xlc.platform.exe.debug"
@ -588,17 +589,18 @@
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
artifactExtension="exe"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
id="cdt.managedbuild.config.xlc.exe.release">
name="%ConfigName.Rel"
artifactExtension="exe"
cleanCommand="rm -rf"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;${Toolchain};-org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser"
id="cdt.managedbuild.config.xlc.exe.release">
<toolChain
archList="all"
id="cdt.managedbuild.toolchain.xlc.exe.release"
name="%ToolChainName.Rel"
osList="all"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser;org.eclipse.cdt.managedbuilder.xlc.core.XlcBuiltinSpecsDetector"
targetTool="cdt.managedbuild.tool.xlc.c.linker.exe.release;cdt.managedbuild.tool.xlc.cpp.linker.exe.release">
<targetPlatform
id="cdt.managedbuild.target.xlc.platform.exe.release"
@ -661,15 +663,17 @@
name="%TargetName.xlc.so"
projectMacroSupplier="org.eclipse.cdt.managedbuilder.xlc.ui.XLCProjectMacroSupplier">
<configuration
name="%ConfigName.Dbg"
cleanCommand="rm -rf"
artifactExtension="so"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
id="cdt.managedbuild.config.xlc.so.debug">
name="%ConfigName.Dbg"
cleanCommand="rm -rf"
artifactExtension="so"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;${Toolchain};-org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser"
id="cdt.managedbuild.config.xlc.so.debug">
<toolChain
name="%ToolChainName.Dbg"
targetTool="cdt.managedbuild.tool.xlc.c.linker.so.debug;cdt.managedbuild.tool.xlc.cpp.linker.so.debug"
id="cdt.managedbuild.toolchain.xlc.so.debug">
id="cdt.managedbuild.toolchain.xlc.so.debug"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser;org.eclipse.cdt.managedbuilder.xlc.core.XlcBuiltinSpecsDetector"
name="%ToolChainName.Dbg"
targetTool="cdt.managedbuild.tool.xlc.c.linker.so.debug;cdt.managedbuild.tool.xlc.cpp.linker.so.debug">
<targetPlatform
id="cdt.managedbuild.target.xlc.platform.so.debug"
name="%PlatformName.Dbg"
@ -723,15 +727,17 @@
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
cleanCommand="rm -rf"
artifactExtension="so"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
id="cdt.managedbuild.config.xlc.so.release">
name="%ConfigName.Rel"
cleanCommand="rm -rf"
artifactExtension="so"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;${Toolchain};-org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser"
id="cdt.managedbuild.config.xlc.so.release">
<toolChain
name="%ToolChainName.Rel"
targetTool="cdt.managedbuild.tool.xlc.c.linker.so.release;cdt.managedbuild.tool.xlc.cpp.linker.so.release"
id="cdt.managedbuild.toolchain.xlc.so.release">
id="cdt.managedbuild.toolchain.xlc.so.release"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser;org.eclipse.cdt.managedbuilder.xlc.core.XlcBuiltinSpecsDetector"
name="%ToolChainName.Rel"
targetTool="cdt.managedbuild.tool.xlc.c.linker.so.release;cdt.managedbuild.tool.xlc.cpp.linker.so.release">
<targetPlatform
id="cdt.managedbuild.target.xlc.platform.so.release"
name="%PlatformName.Rel"
@ -793,15 +799,17 @@
name="%TargetName.xlc.lib"
projectMacroSupplier="org.eclipse.cdt.managedbuilder.xlc.ui.XLCProjectMacroSupplier">
<configuration
name="%ConfigName.Dbg"
cleanCommand="rm -rf"
artifactExtension="lib"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
id="cdt.managedbuild.config.xlc.lib.debug">
name="%ConfigName.Dbg"
cleanCommand="rm -rf"
artifactExtension="lib"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;${Toolchain};-org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser"
id="cdt.managedbuild.config.xlc.lib.debug">
<toolChain
name="%ToolChainName.Dbg"
targetTool="cdt.managedbuild.tool.xlc.archiver.lib.debug"
id="cdt.managedbuild.toolchain.xlc.lib.debug">
id="cdt.managedbuild.toolchain.xlc.lib.debug"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser;org.eclipse.cdt.managedbuilder.xlc.core.XlcBuiltinSpecsDetector"
name="%ToolChainName.Dbg"
targetTool="cdt.managedbuild.tool.xlc.archiver.lib.debug">
<targetPlatform
id="cdt.managedbuild.target.xlc.platform.lib.debug"
name="%PlatformName.Dbg"
@ -851,15 +859,17 @@
</toolChain>
</configuration>
<configuration
name="%ConfigName.Rel"
cleanCommand="rm -rf"
artifactExtension="lib"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
id="cdt.managedbuild.config.xlc.lib.release">
name="%ConfigName.Rel"
cleanCommand="rm -rf"
artifactExtension="lib"
errorParsers="org.eclipse.cdt.errorparsers.xlc.XlcErrorParser"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider;${Toolchain};-org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser"
id="cdt.managedbuild.config.xlc.lib.release">
<toolChain
name="%ToolChainName.Rel"
targetTool="cdt.managedbuild.tool.xlc.archiver.lib.release"
id="cdt.managedbuild.toolchain.xlc.lib.release">
id="cdt.managedbuild.toolchain.xlc.lib.release"
languageSettingsProviders="org.eclipse.cdt.managedbuilder.xlc.core.XlcBuildCommandParser;org.eclipse.cdt.managedbuilder.xlc.core.XlcBuiltinSpecsDetector"
name="%ToolChainName.Rel"
targetTool="cdt.managedbuild.tool.xlc.archiver.lib.release">
<targetPlatform
id="cdt.managedbuild.target.xlc.platform.lib.release"
name="%PlatformName.Rel"
@ -3732,7 +3742,6 @@
id="cdt.managedbuild.tool.xlc.c.compiler.input"
name="%inputType.c.name"
primaryInput="true"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile"
sourceContentType="org.eclipse.cdt.core.cSource"
sources="c">
</inputType>
@ -3753,7 +3762,6 @@
id="cdt.managedbuild.tool.xlc.cpp.c.compiler.input"
name="%inputType.c.name.2"
primaryInput="true"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfile"
sourceContentType="org.eclipse.cdt.core.cSource"
sources="c">
</inputType>
@ -3763,7 +3771,6 @@
id="cdt.managedbuild.tool.xlc.cpp.compiler.input"
name="%inputType.cpp.name"
primaryInput="true"
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP"
sourceContentType="org.eclipse.cdt.core.cxxSource"
sources="c,C,cc,cxx,cpp">
</inputType>