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-01-26 15:49:49 -05:00
commit 7c3888bb63
140 changed files with 17525 additions and 1493 deletions

View file

@ -5,7 +5,8 @@ Bundle-SymbolicName: org.eclipse.cdt.make.core.tests;singleton:=true
Bundle-Version: 7.0.0.qualifier Bundle-Version: 7.0.0.qualifier
Bundle-Activator: org.eclipse.cdt.make.core.tests.MakeTestsPlugin Bundle-Activator: org.eclipse.cdt.make.core.tests.MakeTestsPlugin
Export-Package: org.eclipse.cdt.make.builder.tests, Export-Package: org.eclipse.cdt.make.builder.tests,
org.eclipse.cdt.make.core.tests org.eclipse.cdt.make.core.tests,
org.eclipse.cdt.make.scannerdiscovery;x-internal:=true
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: org.eclipse.core.runtime,
org.junit, org.junit,
org.eclipse.cdt.make.core, org.eclipse.cdt.make.core,

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="org.eclipse.cdt.make.core.tests.ErrorParsers"
name="org.eclipse.cdt.make.core.tests ErrorParsers"
point="org.eclipse.cdt.core.ErrorParser">
<errorparser
class="org.eclipse.cdt.make.internal.core.scannerconfig.GCCBuildCommandParser$GCCBuildCommandPatternHighlighter"
id="org.eclipse.cdt.core.tests.make.core.GCCBuildCommandPatternHighlighter"
name="Test Plugin GCC BOP Patterns Highlighter">
</errorparser>
</extension>
</plugin>

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2010, 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.make.scannerdiscovery;
import junit.framework.TestSuite;
public class AllLanguageSettingsProvidersMakeCoreTests extends TestSuite {
public static TestSuite suite() {
return new AllLanguageSettingsProvidersMakeCoreTests();
}
public AllLanguageSettingsProvidersMakeCoreTests() {
super(AllLanguageSettingsProvidersMakeCoreTests.class.getName());
addTestSuite(GCCBuildCommandParserTest.class);
addTestSuite(BuiltinSpecsDetectorTest.class);
}
}

View file

@ -0,0 +1,443 @@
/*******************************************************************************
* Copyright (c) 2010, 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.make.scannerdiscovery;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.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.XmlUtil;
import org.eclipse.cdt.make.core.scannerconfig.AbstractBuiltinSpecsDetector;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.Job;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class BuiltinSpecsDetectorTest extends BaseTestCase {
private static final String PROVIDER_ID = "provider.id";
private static final String PROVIDER_NAME = "provider name";
private static final String LANGUAGE_ID = "language.test.id";
private static final String CUSTOM_PARAMETER = "customParameter";
private static final String CUSTOM_PARAMETER_2 = "customParameter2";
private static final String ELEM_TEST = "test";
// those attributes must match that in AbstractBuiltinSpecsDetector
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
private static final String ATTR_CONSOLE = "console"; //$NON-NLS-1$
private class MockBuiltinSpecsDetector extends AbstractBuiltinSpecsDetector {
@Override
protected void startupForLanguage(String languageId) throws CoreException {
super.startupForLanguage(languageId);
}
@Override
protected void shutdownForLanguage() {
super.shutdownForLanguage();
}
@Override
protected List<String> parseForOptions(String line) {
return null;
}
@Override
protected AbstractOptionParser[] getOptionParsers() {
return null;
}
}
private class MockBuiltinSpecsDetectorExecutedFlag extends AbstractBuiltinSpecsDetector {
@Override
protected List<String> parseForOptions(String line) {
return null;
}
@Override
protected AbstractOptionParser[] getOptionParsers() {
return null;
}
@Override
protected void execute() {
super.execute();
}
protected boolean isExecuted() {
return isExecuted;
}
}
private class MockConsoleBuiltinSpecsDetector extends AbstractBuiltinSpecsDetector {
@SuppressWarnings("nls")
private final AbstractOptionParser[] optionParsers = {
new MacroOptionParser("#define (\\S*) *(\\S*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
};
@Override
protected boolean runProgram(String command, String[] env, IPath workingDirectory, IProgressMonitor monitor,
OutputStream consoleOut, OutputStream consoleErr) throws CoreException, IOException {
printLine(consoleOut, "#define MACRO VALUE");
consoleOut.close();
consoleErr.close();
return true;
}
@Override
protected IStatus runForEachLanguage(ICConfigurationDescription cfgDescription, IPath workingDirectory,
String[] env, IProgressMonitor monitor) {
return super.runForEachLanguage(cfgDescription, workingDirectory, env, monitor);
}
@Override
protected List<String> parseForOptions(final String line) {
return new ArrayList<String>() {{ add(line); }};
}
@Override
protected AbstractOptionParser[] getOptionParsers() {
return optionParsers;
}
}
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected void tearDown() throws Exception {
Job.getJobManager().join(AbstractBuiltinSpecsDetector.JOB_FAMILY_BUILTIN_SPECS_DETECTOR, null);
super.tearDown();
}
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
CoreModel coreModel = CoreModel.getDefault();
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
// project description
ICProjectDescription projectDescription = mngr.getProjectDescription(project, false);
assertNotNull(projectDescription);
assertEquals(1, projectDescription.getConfigurations().length);
// configuration description
ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
return cfgDescriptions;
}
public void testAbstractBuiltinSpecsDetector_GettersSetters() throws Exception {
{
// provider configured with null parameters
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, null, null, null);
assertEquals(PROVIDER_ID, provider.getId());
assertEquals(PROVIDER_NAME, provider.getName());
assertEquals(null, provider.getLanguageScope());
assertEquals(null, provider.getSettingEntries(null, null, null));
assertEquals("", provider.getCommand());
assertEquals(false, provider.isExecuted());
assertEquals(false, provider.isConsoleEnabled());
}
{
// provider configured with non-null parameters
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
List<String> languages = new ArrayList<String>();
languages.add(LANGUAGE_ID);
Map<String, String> properties = new HashMap<String, String>();
properties.put(ATTR_PARAMETER, CUSTOM_PARAMETER);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
entries.add(entry);
provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, languages, entries, properties);
assertEquals(PROVIDER_ID, provider.getId());
assertEquals(PROVIDER_NAME, provider.getName());
assertEquals(languages, provider.getLanguageScope());
assertEquals(entries, provider.getSettingEntries(null, null, null));
assertEquals(CUSTOM_PARAMETER, provider.getCommand());
assertEquals(false, provider.isConsoleEnabled());
assertEquals(false, provider.isExecuted());
// setters
provider.setCommand(CUSTOM_PARAMETER_2);
assertEquals(CUSTOM_PARAMETER_2, provider.getCommand());
provider.setConsoleEnabled(true);
assertEquals(true, provider.isConsoleEnabled());
provider.execute();
assertEquals(true, provider.isExecuted());
}
}
public void testAbstractBuiltinSpecsDetector_CloneAndEquals() throws Exception {
// define mock detector
class MockDetectorCloneable extends MockBuiltinSpecsDetectorExecutedFlag implements Cloneable {
@Override
public MockDetectorCloneable clone() throws CloneNotSupportedException {
return (MockDetectorCloneable) super.clone();
}
@Override
public MockDetectorCloneable cloneShallow() throws CloneNotSupportedException {
return (MockDetectorCloneable) super.cloneShallow();
}
}
// create instance to compare to
MockDetectorCloneable provider = new MockDetectorCloneable();
List<String> languages = new ArrayList<String>();
languages.add(LANGUAGE_ID);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
entries.add(entry);
// check clone after initialization
MockDetectorCloneable clone0 = provider.clone();
assertTrue(provider.equals(clone0));
// configure provider
Map<String, String> properties = new HashMap<String, String>();
properties.put(ATTR_PARAMETER, CUSTOM_PARAMETER);
provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, languages, entries, properties);
assertEquals(false, provider.isConsoleEnabled());
provider.setConsoleEnabled(true);
provider.execute();
assertEquals(true, provider.isExecuted());
assertFalse(provider.equals(clone0));
// check another clone after configuring
{
MockDetectorCloneable clone = provider.clone();
assertTrue(provider.equals(clone));
}
// check custom parameter
{
MockDetectorCloneable clone = provider.clone();
clone.setCommand("changed");
assertFalse(provider.equals(clone));
}
// check language scope
{
MockDetectorCloneable clone = provider.clone();
clone.setLanguageScope(null);
assertFalse(provider.equals(clone));
}
// check console flag
{
MockDetectorCloneable clone = provider.clone();
boolean isConsoleEnabled = clone.isConsoleEnabled();
clone.setConsoleEnabled( ! isConsoleEnabled );
assertFalse(provider.equals(clone));
}
// check isExecuted flag
{
MockDetectorCloneable clone = provider.clone();
assertEquals(true, clone.isExecuted());
clone.clear();
assertEquals(false, clone.isExecuted());
assertFalse(provider.equals(clone));
}
// check entries
{
MockDetectorCloneable clone = provider.clone();
clone.setSettingEntries(null, null, null, null);
assertFalse(provider.equals(clone));
}
// check cloneShallow()
{
MockDetectorCloneable provider2 = provider.clone();
MockDetectorCloneable clone = provider2.cloneShallow();
assertEquals(false, clone.isExecuted());
assertFalse(provider2.equals(clone));
provider2.setSettingEntries(null, null, null, null);
assertFalse(provider2.equals(clone));
clone.execute();
assertTrue(provider2.equals(clone));
}
}
/**
*/
public void testAbstractBuiltinSpecsDetector_Serialize() throws Exception {
{
// create empty XML
Document doc = XmlUtil.newDocument();
Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// load it to new provider
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
provider.load(rootElement);
assertEquals(false, provider.isConsoleEnabled());
}
Element elementProvider;
{
// define mock detector
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
assertEquals(false, provider.isConsoleEnabled());
// redefine the settings
provider.setConsoleEnabled(true);
assertEquals(true, provider.isConsoleEnabled());
// serialize in XML
Document doc = XmlUtil.newDocument();
Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
elementProvider = provider.serialize(rootElement);
String xmlString = XmlUtil.toString(doc);
assertTrue(xmlString.contains(ATTR_CONSOLE));
}
{
// create another instance of the provider
MockBuiltinSpecsDetectorExecutedFlag provider = new MockBuiltinSpecsDetectorExecutedFlag();
assertEquals(false, provider.isConsoleEnabled());
// load element
provider.load(elementProvider);
assertEquals(true, provider.isConsoleEnabled());
}
}
public void testAbstractBuiltinSpecsDetector_Nulls() throws Exception {
{
// test AbstractBuiltinSpecsDetector.processLine(...) flow
MockBuiltinSpecsDetector provider = new MockBuiltinSpecsDetector();
provider.startup(null);
provider.startupForLanguage(null);
provider.processLine(null, null);
provider.shutdownForLanguage();
provider.shutdown();
}
{
// test AbstractBuiltinSpecsDetector.processLine(...) flow
MockConsoleBuiltinSpecsDetector provider = new MockConsoleBuiltinSpecsDetector();
provider.runForEachLanguage(null, null, null, null);
}
}
public void testAbstractBuiltinSpecsDetector_RunConfiguration() throws Exception {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
MockConsoleBuiltinSpecsDetector provider = new MockConsoleBuiltinSpecsDetector();
provider.setLanguageScope(new ArrayList<String>() {{add(LANGUAGE_ID);}});
provider.runForEachLanguage(cfgDescription, null, null, null);
assertFalse(provider.isEmpty());
List<ICLanguageSettingEntry> noentries = provider.getSettingEntries(null, null, null);
assertNull(noentries);
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(cfgDescription, null, LANGUAGE_ID);
ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
assertEquals(expected, entries.get(0));
}
public void testAbstractBuiltinSpecsDetector_RunGlobal() throws Exception {
MockConsoleBuiltinSpecsDetector provider = new MockConsoleBuiltinSpecsDetector();
provider.setLanguageScope(new ArrayList<String>() {{add(LANGUAGE_ID);}});
provider.runForEachLanguage(null, null, null, null);
assertFalse(provider.isEmpty());
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, LANGUAGE_ID);
ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
assertEquals(expected, entries.get(0));
}
public void testAbstractBuiltinSpecsDetector_GroupSettings() throws Exception {
// define benchmarks
final CIncludePathEntry includePath_1 = new CIncludePathEntry("/include/path_1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CIncludePathEntry includePath_2 = new CIncludePathEntry("/include/path_2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CIncludeFileEntry includeFile_1 = new CIncludeFileEntry(new Path("/include.file1"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CIncludeFileEntry includeFile_2 = new CIncludeFileEntry(new Path("/include.file2"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CMacroEntry macro_1 = new CMacroEntry("MACRO_1", "", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CMacroEntry macro_2 = new CMacroEntry("MACRO_2", "", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY |ICSettingEntry.UNDEFINED);
final CMacroFileEntry macroFile_1 = new CMacroFileEntry(new Path("/macro.file1"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CMacroFileEntry macroFile_2 = new CMacroFileEntry(new Path("/macro.file2"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CLibraryPathEntry libraryPath_1 = new CLibraryPathEntry(new Path("/lib/path_1"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CLibraryPathEntry libraryPath_2 = new CLibraryPathEntry(new Path("/lib/path_2"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CLibraryFileEntry libraryFile_1 = new CLibraryFileEntry("lib_1.a", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
final CLibraryFileEntry libraryFile_2 = new CLibraryFileEntry("lib_2.a", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
// Define mock detector adding unorganized entries
MockBuiltinSpecsDetector provider = new MockBuiltinSpecsDetector() {
@Override
public boolean processLine(String line, ErrorParserManager epm) {
detectedSettingEntries.add(libraryFile_1);
detectedSettingEntries.add(libraryPath_1);
detectedSettingEntries.add(macroFile_1);
detectedSettingEntries.add(macro_1);
detectedSettingEntries.add(includeFile_1);
detectedSettingEntries.add(includePath_1);
detectedSettingEntries.add(includePath_2);
detectedSettingEntries.add(includeFile_2);
detectedSettingEntries.add(macro_2);
detectedSettingEntries.add(macroFile_2);
detectedSettingEntries.add(libraryPath_2);
detectedSettingEntries.add(libraryFile_2);
return true;
}
};
// run specs detector
provider.startup(null);
provider.startupForLanguage(null);
provider.processLine("", null);
provider.shutdownForLanguage();
provider.shutdown();
// compare benchmarks, expected well-sorted
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
int i=0;
assertEquals(includePath_1, entries.get(i++));
assertEquals(includePath_2, entries.get(i++));
assertEquals(includeFile_1, entries.get(i++));
assertEquals(includeFile_2, entries.get(i++));
assertEquals(macro_1, entries.get(i++));
assertEquals(macro_2, entries.get(i++));
assertEquals(macroFile_1, entries.get(i++));
assertEquals(macroFile_2, entries.get(i++));
assertEquals(libraryPath_1, entries.get(i++));
assertEquals(libraryPath_2, entries.get(i++));
assertEquals(libraryFile_1, entries.get(i++));
assertEquals(libraryFile_2, entries.get(i++));
assertEquals(12, entries.size());
}
}

View file

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. * Copyright (c) 2007, 2009 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Andrew Gvozdev - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.make.scannerdiscovery; package org.eclipse.cdt.make.scannerdiscovery;

View file

@ -182,5 +182,15 @@
class="org.eclipse.cdt.make.internal.core.dataprovider.MakeConfigurationDataProvider" class="org.eclipse.cdt.make.internal.core.dataprovider.MakeConfigurationDataProvider"
/> />
</extension> </extension>
<extension
point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider
class="org.eclipse.cdt.make.internal.core.scannerconfig.GCCBuildCommandParser"
id="org.eclipse.cdt.make.core.GCCBuildCommandParser"
name="CDT GCC Build Output Parser"
parameter="(gcc)|([gc]\+\+)"
prefer-non-shared="true">
</provider>
</extension>
</plugin> </plugin>

View file

@ -0,0 +1,222 @@
/*******************************************************************************
* Copyright (c) 2009, 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.make.core.scannerconfig;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICConsoleParser;
import org.eclipse.cdt.core.IErrorParser;
import org.eclipse.cdt.core.IErrorParser2;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.errorparsers.RegexErrorParser;
import org.eclipse.cdt.core.errorparsers.RegexErrorPattern;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
/**
* Abstract class for providers parsing compiler option from build command when it
* is present in build output.
*
* Note: IErrorParser interface is used here to work around {@link ConsoleOutputSniffer} having
* no access from CDT core to build packages. TODO - elaborate?
*
* @since 7.2
*/
public abstract class AbstractBuildCommandParser extends AbstractLanguageSettingsOutputScanner
implements ICConsoleParser, IErrorParser {
public static final Object JOB_FAMILY_BUILD_COMMAND_PARSER = "org.eclipse.cdt.make.core.scannerconfig.AbstractBuildCommandParser";
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
private static final String LEADING_PATH_PATTERN = "\\S+[/\\\\]"; //$NON-NLS-1$
private static final Pattern OPTIONS_PATTERN = Pattern.compile("-[^\\s\"']*(\\s*((\".*?\")|('.*?')|([^-\\s][^\\s]+)))?"); //$NON-NLS-1$
private static final int OPTION_GROUP = 0;
/**
* Note: design patterns to keep file group the same and matching {@link #FILE_GROUP}
*/
@SuppressWarnings("nls")
private static final String[] PATTERN_TEMPLATES = {
"${COMPILER_PATTERN}.*\\s" + "()([^'\"\\s]*\\.${EXTENSIONS_PATTERN})(\\s.*)?[\r\n]*", // compiling unquoted file
"${COMPILER_PATTERN}.*\\s" + "(['\"])(.*\\.${EXTENSIONS_PATTERN})\\${COMPILER_GROUPS+1}(\\s.*)?[\r\n]*" // compiling quoted file
};
private static final int FILE_GROUP = 2;
/**
* The compiler command pattern without specifying compiler options.
* The options are intended to be handled with option parsers,
* see {@link #getOptionParsers()}.
* This is regular expression pattern.
*
* @return the compiler command pattern.
*/
public String getCompilerPattern() {
return getProperty(ATTR_PARAMETER);
}
/**
* Set compiler command pattern for the provider. See {@link #getCompilerPattern()}.
* @param commandPattern - value of the command pattern to set.
* This is regular expression pattern.
*/
public void setCompilerPattern(String commandPattern) {
setProperty(ATTR_PARAMETER, commandPattern);
}
@SuppressWarnings("nls")
private String getCompilerPatternExtended() {
String compilerPattern = getCompilerPattern();
return "\\s*\"?("+LEADING_PATH_PATTERN+")?(" + compilerPattern + ")\"?";
}
private int adjustFileGroup() {
return countGroups(getCompilerPatternExtended()) + FILE_GROUP;
}
private String makePattern(String template) {
@SuppressWarnings("nls")
String pattern = template
.replace("${COMPILER_PATTERN}", getCompilerPatternExtended())
.replace("${EXTENSIONS_PATTERN}", getPatternFileExtensions())
.replace("${COMPILER_GROUPS+1}", new Integer(countGroups(getCompilerPatternExtended()) + 1).toString());
return pattern;
}
@Override
protected String parseForResourceName(String line) {
if (line==null) {
return null;
}
for (String template : PATTERN_TEMPLATES) {
String pattern = makePattern(template);
Matcher fileMatcher = Pattern.compile(pattern).matcher(line);
if (fileMatcher.matches()) {
int fileGroup = adjustFileGroup();
String sourceFileName = fileMatcher.group(fileGroup);
return sourceFileName;
}
}
return null;
}
@Override
protected List<String> parseForOptions(String line) {
if (line==null || currentResource==null) {
return null;
}
List<String> options = new ArrayList<String>();
Matcher optionMatcher = OPTIONS_PATTERN.matcher(line);
while (optionMatcher.find()) {
String option = optionMatcher.group(OPTION_GROUP);
if (option!=null) {
options.add(option);
}
}
return options;
}
@Override
public boolean processLine(String line) {
return processLine(line, null);
}
// This is redundant but let us keep it here to navigate in java code easier
@Override
public boolean processLine(String line, ErrorParserManager epm) {
return super.processLine(line, epm);
}
@Override
public void shutdown() {
scheduleSerializingJob(currentCfgDescription);
super.shutdown();
}
private void scheduleSerializingJob(final ICConfigurationDescription cfgDescription) {
Job job = new Job("Serialize CDT language settings entries") {
@Override
protected IStatus run(IProgressMonitor monitor) {
return serializeLanguageSettings(cfgDescription);
}
@Override
public boolean belongsTo(Object family) {
return family == JOB_FAMILY_BUILD_COMMAND_PARSER;
}
};
ISchedulingRule rule = null;
if (currentProject != null) {
IFolder settingsFolder = currentProject.getFolder(".settings");
if (!settingsFolder.exists()) {
try {
settingsFolder.create(true, true, null);
if (settingsFolder.isAccessible())
rule = currentProject.getFile(".settings/language.settings.xml");
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
}
if (rule == null) {
rule = ResourcesPlugin.getWorkspace().getRoot();
}
job.setRule(rule);
job.schedule();
}
/**
* Trivial Error Parser which allows highlighting of output lines matching the patterns
* of this parser. Intended for better troubleshooting experience.
* Implementers are supposed to add the error parser as an extension. Initialize with
* build command parser extension ID.
*/
protected static abstract class AbstractBuildCommandPatternHighlighter extends RegexErrorParser implements IErrorParser2 {
public AbstractBuildCommandPatternHighlighter(String buildCommandParserPluginExtension) {
init(buildCommandParserPluginExtension);
}
protected void init(String buildCommandParserId) {
AbstractBuildCommandParser buildCommandParser = (AbstractBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(buildCommandParserId, false);
if (buildCommandParser != null) {
for (String template : PATTERN_TEMPLATES) {
String pattern = buildCommandParser.makePattern(template);
String fileExpr = "$"+buildCommandParser.adjustFileGroup(); //$NON-NLS-1$
String descExpr = "$0"; //$NON-NLS-1$
addPattern(new RegexErrorPattern(pattern, fileExpr, null, descExpr, null, IMarkerGenerator.SEVERITY_WARNING, true));
}
}
}
@Override
public int getProcessLineBehaviour() {
return KEEP_LONGLINES;
}
}
}

View file

@ -0,0 +1,784 @@
/*******************************************************************************
* Copyright (c) 2009, 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.make.core.scannerconfig;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICConsoleParser;
import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.ProblemMarkerInfo;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.language.settings.providers.ICListenerAgent;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ILanguageDescriptor;
import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.resources.IConsole;
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.internal.core.ConsoleOutputSniffer;
import org.eclipse.cdt.internal.core.XmlUtil;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.StreamMonitor;
import org.eclipse.cdt.utils.CommandLineUtil;
import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.w3c.dom.Element;
/**
* Abstract parser capable to execute compiler command printing built-in compiler
* specs and parse built-in language settings out of it.
*
* @since 7.2
*/
public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSettingsOutputScanner implements ICListenerAgent {
public static final Object JOB_FAMILY_BUILTIN_SPECS_DETECTOR = "org.eclipse.cdt.make.core.scannerconfig.AbstractBuiltinSpecsDetector";
private static final int TICKS_STREAM_MONITOR = 100;
private static final int TICKS_CLEAN_MARKERS = 1;
private static final int TICKS_RUN_FOR_ONE_LANGUAGE = 10;
private static final int TICKS_SERIALIZATION = 1;
private static final int TICKS_SCALE = 100;
private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
private static final String PLUGIN_CDT_MAKE_UI_ID = "org.eclipse.cdt.make.ui"; //$NON-NLS-1$
private static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser"; //$NON-NLS-1$
private static final String PATH_ENV = "PATH"; //$NON-NLS-1$
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
private static final String ATTR_CONSOLE = "console"; //$NON-NLS-1$
protected static final String COMPILER_MACRO = "${COMMAND}"; //$NON-NLS-1$
protected static final String SPEC_FILE_MACRO = "${INPUTS}"; //$NON-NLS-1$
protected static final String SPEC_EXT_MACRO = "${EXT}"; //$NON-NLS-1$
protected static final String SPEC_FILE_BASE = "spec"; //$NON-NLS-1$
private String currentCommandResolved = null;
protected List<ICLanguageSettingEntry> detectedSettingEntries = null;
protected boolean isExecuted = false;
protected int collected = 0;
private boolean isConsoleEnabled = false;
protected java.io.File specFile = null;
protected boolean preserveSpecFile = false;
protected URI mappedRootURI = null;
protected URI buildDirURI = null;
private class SDMarkerGenerator implements IMarkerGenerator {
protected static final String SCANNER_DISCOVERY_PROBLEM_MARKER = MakeCorePlugin.PLUGIN_ID + ".scanner.discovery.problem"; //$NON-NLS-1$
protected static final String ATTR_PROVIDER = "provider"; //$NON-NLS-1$
@Override
public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
ProblemMarkerInfo info = new ProblemMarkerInfo(file, lineNumber, errorDesc, severity, errorVar);
addMarker(info);
}
@Override
public void addMarker(final ProblemMarkerInfo problemMarkerInfo) {
final String providerName = getName();
final String providerId = getId();
// we have to add the marker in the job or we can deadlock other
// threads that are responding to a resource delta by doing something
// that accesses the project description
Job markerJob = new Job("Adding Scanner Discovery markers") {
@Override
protected IStatus run(IProgressMonitor monitor) {
// Try to find matching markers and don't put in duplicates
try {
IMarker[] cur = problemMarkerInfo.file.findMarkers(SDMarkerGenerator.SCANNER_DISCOVERY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
if ((cur != null) && (cur.length > 0)) {
for (int i = 0; i < cur.length; i++) {
int sev = ((Integer) cur[i].getAttribute(IMarker.SEVERITY)).intValue();
String mesg = (String) cur[i].getAttribute(IMarker.MESSAGE);
if (sev == problemMarkerInfo.severity && mesg.equals(problemMarkerInfo.description)) {
return Status.OK_STATUS;
}
}
}
} catch (CoreException e) {
return new Status(Status.ERROR, MakeCorePlugin.getUniqueIdentifier(), "Error removing markers.", e);
}
// add new marker
try {
IMarker marker = problemMarkerInfo.file.createMarker(SDMarkerGenerator.SCANNER_DISCOVERY_PROBLEM_MARKER);
marker.setAttribute(IMarker.MESSAGE, problemMarkerInfo.description);
marker.setAttribute(IMarker.SEVERITY, problemMarkerInfo.severity);
marker.setAttribute(SDMarkerGenerator.ATTR_PROVIDER, providerId);
if (problemMarkerInfo.file instanceof IWorkspaceRoot) {
marker.setAttribute(IMarker.LOCATION, "SD90 Providers, [" + providerName + "] options in Preferences");
} else {
marker.setAttribute(IMarker.LOCATION, "SD90 Providers, [" + providerName + "] options in project properties");
}
} catch (CoreException e) {
return new Status(Status.ERROR, MakeCorePlugin.getUniqueIdentifier(), "Error adding markers.", e);
}
return Status.OK_STATUS;
}
};
markerJob.setRule(problemMarkerInfo.file);
markerJob.schedule();
}
}
/**
* This ICConsoleParser handles each individual run for one language from
* {@link AbstractBuiltinSpecsDetector#runForEachLanguage(ICConfigurationDescription, IPath, String[], IProgressMonitor)}
*
*/
private class ConsoleParser implements ICConsoleParser {
@Override
public void startup(ICConfigurationDescription cfgDescription) throws CoreException {
// not used here, see instead startupForLanguage() in AbstractBuiltinSpecsDetector.runForEachLanguage(...)
}
@Override
public boolean processLine(String line) {
return AbstractBuiltinSpecsDetector.this.processLine(line, errorParserManager);
}
@Override
public void shutdown() {
// not used here, see instead shutdownForLanguage() in AbstractBuiltinSpecsDetector.runForEachLanguage(...)
}
}
/**
* The command to run. Some macros could be specified in there:
* <ul>
* <b>${COMMAND}</b> - compiler command taken from the toolchain.<br>
* <b>${INPUTS}</b> - path to spec file which will be placed in workspace area.<br>
* <b>${EXT}</b> - file extension calculated from language ID.
* </ul>
* The parameter could be taken from the extension
* in {@code plugin.xml} or from property file.
*
* @return the command to run.
*/
public String getCommand() {
return getProperty(ATTR_PARAMETER);
}
/**
* Set custom command for the provider. See {@link #getCommand()}.
* @param command - value of custom command to set.
*/
public void setCommand(String command) {
setProperty(ATTR_PARAMETER, command);
}
public void setConsoleEnabled(boolean enable) {
isConsoleEnabled = enable;
}
public boolean isConsoleEnabled() {
return isConsoleEnabled;
}
protected String resolveCommand(String languageId) throws CoreException {
String cmd = getCommand();
if (cmd!=null && (cmd.contains(COMPILER_MACRO) || cmd.contains(SPEC_FILE_MACRO) || cmd.contains(SPEC_EXT_MACRO))) {
if (cmd.contains(COMPILER_MACRO)) {
String compiler = getCompilerCommand(languageId);
if (compiler!=null)
cmd = cmd.replace(COMPILER_MACRO, compiler);
}
if (cmd.contains(SPEC_FILE_MACRO)) {
String specFileName = getSpecFile(languageId);
if (specFileName!=null)
cmd = cmd.replace(SPEC_FILE_MACRO, specFileName);
}
if (cmd.contains(SPEC_EXT_MACRO)) {
String specFileExt = getSpecFileExtension(languageId);
if (specFileExt!=null)
cmd = cmd.replace(SPEC_EXT_MACRO, specFileExt);
}
}
return cmd;
}
/**
* TODO
*/
@Override
protected String parseForResourceName(String line) {
// This works as if workspace-wide
return null;
}
@Override
protected String determineLanguage() {
// language id is supposed to be set by run(), just return it
return currentLanguageId;
}
@Override
protected URI getMappedRootURI(IResource sourceFile, String parsedResourceName) {
if (mappedRootURI==null) {
mappedRootURI = super.getMappedRootURI(sourceFile, parsedResourceName);
}
return mappedRootURI;
}
@Override
protected URI getBuildDirURI(URI mappedRootURI) {
if (buildDirURI==null) {
buildDirURI = super.getBuildDirURI(mappedRootURI);
}
return buildDirURI;
}
@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);
}
protected void execute() {
if (isExecuted) {
// // TODO - remove me
// CCorePlugin.log(new Status(IStatus.INFO,CCorePlugin.PLUGIN_ID,
// getPrefixForLog() + "Already executed [" + System.identityHashCode(this) + "] " + this));
return;
}
isExecuted = true;
Job job = new Job("Discover compiler's built-in language settings") {
@Override
protected IStatus run(IProgressMonitor monitor) {
return runForEachLanguage(currentCfgDescription, null, null, monitor);
}
@Override
public boolean belongsTo(Object family) {
return family == JOB_FAMILY_BUILTIN_SPECS_DETECTOR;
}
};
IProject ownerProject = null;
if (currentCfgDescription != null) {
ICProjectDescription prjDescription = currentCfgDescription.getProjectDescription();
if (prjDescription != null) {
ownerProject = prjDescription.getProject();
}
}
ISchedulingRule rule = null;
if (ownerProject != null) {
rule = ownerProject.getFile(".settings/language.settings.xml");
}
if (rule == null) {
rule = ResourcesPlugin.getWorkspace().getRoot();
}
job.setRule(rule);
job.schedule();
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logInfo(getPrefixForLog() + "Execution scheduled [" + System.identityHashCode(this) + "] " + this);
}
/**
* TODO
*/
protected IStatus runForEachLanguage(ICConfigurationDescription cfgDescription, IPath workingDirectory,
String[] env, IProgressMonitor monitor) {
try {
startup(cfgDescription);
} catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error preparing to run Builtin Specs Detector", e);
MakeCorePlugin.log(status);
return status;
}
MultiStatus status = new MultiStatus(MakeCorePlugin.PLUGIN_ID, IStatus.OK, "Problem running CDT Scanner Discovery provider " + getId(), null);
boolean isChanged = false;
mappedRootURI = null;
buildDirURI = null;
if (monitor == null) {
monitor = new NullProgressMonitor();
}
try {
List<String> languageIds = getLanguageScope();
if (languageIds != null) {
int totalWork = TICKS_CLEAN_MARKERS + languageIds.size()*TICKS_RUN_FOR_ONE_LANGUAGE + TICKS_SERIALIZATION;
monitor.beginTask("CDT Scanner Discovery", totalWork * TICKS_SCALE);
IResource markersResource = currentProject!= null ? currentProject : ResourcesPlugin.getWorkspace().getRoot();
// clear old markers
monitor.subTask("Clearing stale markers");
try {
IMarker[] cur = markersResource.findMarkers(SDMarkerGenerator.SCANNER_DISCOVERY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
for (IMarker marker : cur) {
if (getId().equals(marker.getAttribute(SDMarkerGenerator.ATTR_PROVIDER))) {
marker.delete();
}
}
} catch (CoreException e) {
MakeCorePlugin.log(e);
}
if (monitor.isCanceled())
throw new OperationCanceledException();
monitor.worked(TICKS_CLEAN_MARKERS * TICKS_SCALE);
for (String languageId : languageIds) {
List<ICLanguageSettingEntry> oldEntries = getSettingEntries(cfgDescription, null, languageId);
try {
startupForLanguage(languageId);
if (monitor.isCanceled())
throw new OperationCanceledException();
runForLanguage(workingDirectory, env, new SubProgressMonitor(monitor, TICKS_RUN_FOR_ONE_LANGUAGE * TICKS_SCALE));
if (monitor.isCanceled())
throw new OperationCanceledException();
} catch (CoreException e) {
IStatus s = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e);
MakeCorePlugin.log(s);
status.merge(s);
} finally {
shutdownForLanguage();
}
List<ICLanguageSettingEntry> newEntries = getSettingEntries(cfgDescription, null, languageId);
isChanged = isChanged || newEntries != oldEntries;
}
}
monitor.subTask("Serializing results");
if (isChanged) { // avoids resource and settings change notifications
IStatus s = serializeLanguageSettings(currentCfgDescription);
status.merge(s);
// AG: FIXME - rather send event that ls settings changed
if (currentCfgDescription != null) {
ICProject icProject = CoreModel.getDefault().create(currentProject);
ICElement[] tuSelection = new ICElement[] {icProject};
try {
CCorePlugin.getIndexManager().update(tuSelection, IIndexManager.UPDATE_ALL | IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT);
} catch (CoreException e) {
IStatus s2 = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error updating CDT index", e);
MakeCorePlugin.log(s2);
status.merge(s2);
}
} else {
// TODO
}
}
if (monitor.isCanceled())
throw new OperationCanceledException();
monitor.worked(TICKS_SERIALIZATION * TICKS_SCALE);
} catch (OperationCanceledException e) {
if (!status.isOK()) {
MakeCorePlugin.log(status);
}
status.merge(new Status(IStatus.CANCEL, MakeCorePlugin.PLUGIN_ID, IStatus.OK, "Operation cancelled by user", e));
} finally {
monitor.done();
// release resources
buildDirURI = null;
mappedRootURI = null;
shutdown();
currentCfgDescription = cfgDescription; // current description gets cleared in super.shutdown(), keep it
}
return status;
}
protected void startupForLanguage(String languageId) throws CoreException {
currentLanguageId = languageId;
specFile = null; // can get set in resolveCommand()
currentCommandResolved = resolveCommand(currentLanguageId);
detectedSettingEntries = new ArrayList<ICLanguageSettingEntry>();
collected = 0;
}
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;
currentCommandResolved = null;
if (specFile!=null && !preserveSpecFile) {
specFile.delete();
specFile = null;
}
currentLanguageId = null;
}
/**
* TODO: test case for this function
*/
private void runForLanguage(IPath workingDirectory, String[] env, IProgressMonitor monitor) throws CoreException {
IConsole console;
if (isConsoleEnabled) {
console = startProviderConsole();
} else {
// that looks in extension points registry and won't find the id, this console is not shown
console = CCorePlugin.getDefault().getConsole(MakeCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$
}
console.start(currentProject);
OutputStream cos = console.getOutputStream();
// Using GMAKE_ERROR_PARSER_ID as it can handle shell error messages
errorParserManager = new ErrorParserManager(currentProject, new SDMarkerGenerator(), new String[] {GMAKE_ERROR_PARSER_ID});
errorParserManager.setOutputStream(cos);
if (monitor == null) {
monitor = new NullProgressMonitor();
}
try {
// StreamMonitor will do monitor.beginTask(...)
StreamMonitor streamMon = new StreamMonitor(monitor, errorParserManager, TICKS_STREAM_MONITOR);
OutputStream stdout = streamMon;
OutputStream stderr = streamMon;
String msg = "Running scanner discovery: " + getName();
printLine(stdout, "**** " + msg + " ****" + NEWLINE);
ConsoleParser consoleParser = new ConsoleParser();
ConsoleOutputSniffer sniffer = new ConsoleOutputSniffer(stdout, stderr, new IConsoleParser[] { consoleParser }, errorParserManager);
OutputStream consoleOut = sniffer.getOutputStream();
OutputStream consoleErr = sniffer.getErrorStream();
boolean isSuccess = false;
try {
isSuccess = runProgram(currentCommandResolved, env, workingDirectory, monitor, consoleOut, consoleErr);
} catch (Exception e) {
MakeCorePlugin.log(e);
}
if (!isSuccess) {
try {
consoleOut.close();
} catch (IOException e) {
MakeCorePlugin.log(e);
}
try {
consoleErr.close();
} catch (IOException e) {
MakeCorePlugin.log(e);
}
}
} finally {
// ensure monitor.done() is called in cases when StreamMonitor fails to do that
monitor.done();
}
}
/**
* TODO
* Note that progress monitor life cycle is handled elsewhere. This method assumes that
* monitor.beginTask(...) has already been called.
*/
protected boolean runProgram(String command, String[] env, IPath workingDirectory, IProgressMonitor monitor,
OutputStream consoleOut, OutputStream consoleErr) throws CoreException, IOException {
if (command==null || command.trim().length()==0) {
return false;
}
String errMsg = null;
ICommandLauncher launcher = new CommandLauncher();
launcher.setProject(currentProject);
// Print the command for visual interaction.
launcher.showCommand(true);
String[] cmdArray = CommandLineUtil.argumentsToArray(command);
IPath program = new Path(cmdArray[0]);
String[] args = new String[0];
if (cmdArray.length>1) {
args = new String[cmdArray.length-1];
System.arraycopy(cmdArray, 1, args, 0, args.length);
}
if (monitor==null) {
monitor = new NullProgressMonitor();
}
Process p = launcher.execute(program, args, env, workingDirectory, monitor);
if (p != null) {
// Before launching give visual cues via the monitor
monitor.subTask("Invoking command " + command);
if (launcher.waitAndRead(consoleOut, consoleErr, monitor) != ICommandLauncher.OK) {
errMsg = launcher.getErrorMessage();
}
} else {
errMsg = launcher.getErrorMessage();
}
if (errMsg!=null) {
String errorPrefix = MakeMessages.getString("ExternalScannerInfoProvider.Error_Prefix"); //$NON-NLS-1$
String msg = MakeMessages.getFormattedString("ExternalScannerInfoProvider.Provider_Error", command);
printLine(consoleErr, errorPrefix + msg + NEWLINE);
// Launching failed, trying to figure out possible cause
String envPath = getEnvVar(env, PATH_ENV);
if (!program.isAbsolute() && PathUtil.findProgramLocation(program.toString(), envPath) == null) {
printLine(consoleErr, errMsg);
msg = MakeMessages.getFormattedString("ExternalScannerInfoProvider.Working_Directory", workingDirectory); //$NON-NLS-1$
msg = MakeMessages.getFormattedString("ExternalScannerInfoProvider.Program_Not_In_Path", program); //$NON-NLS-1$
printLine(consoleErr, errorPrefix + msg + NEWLINE);
printLine(consoleErr, PATH_ENV + "=[" + envPath + "]" + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$
} else {
printLine(consoleErr, errorPrefix + errMsg);
msg = MakeMessages.getFormattedString("ExternalScannerInfoProvider.Working_Directory", workingDirectory); //$NON-NLS-1$
printLine(consoleErr, PATH_ENV + "=[" + envPath + "]" + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$
}
return false;
}
printLine(consoleOut, NEWLINE + "**** Collected " + detectedSettingEntries.size() + " entries. ****");
return true;
}
/**
* TODO
*/
@Override
protected void setSettingEntries(List<ICLanguageSettingEntry> entries) {
// Builtin specs detectors collect entries not per line but for the whole output
if (entries!=null)
detectedSettingEntries.addAll(entries);
}
private IConsole startProviderConsole() {
String extConsoleId;
if (currentProject != null) {
extConsoleId = "org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryConsole";
} else {
extConsoleId = "org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryGlobalConsole";
}
ILanguage ld = LanguageManager.getInstance().getLanguage(currentLanguageId);
String consoleId = MakeCorePlugin.PLUGIN_ID + '.' + getId() + '.' + currentLanguageId;
String consoleName = getName() + ", " + ld.getName();
URL defaultIcon = Platform.getBundle(PLUGIN_CDT_MAKE_UI_ID).getEntry("icons/obj16/inspect_system.gif");
IConsole console = CCorePlugin.getDefault().getConsole(extConsoleId, consoleId, consoleName, defaultIcon);
return console;
}
private String getEnvVar(String[] envStrings, String envVar) {
String envPath = null;
if (envStrings!=null) {
String varPrefix = envVar+'=';
for (String envStr : envStrings) {
boolean found = false;
// need to convert "Path" to "PATH" on Windows
if (Platform.getOS().equals(Platform.OS_WIN32)) {
found = envStr.substring(0,varPrefix.length()).toUpperCase().startsWith(varPrefix);
} else {
found = envStr.startsWith(varPrefix);
}
if (found) {
envPath = envStr.substring(varPrefix.length());
break;
}
}
} else {
envPath = System.getenv(envVar);
}
return envPath;
}
protected String getCompilerCommand(String languageId) {
IStatus status = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, "Provider "+getId()
+" unable to find the compiler tool for language " + languageId);
MakeCorePlugin.log(new CoreException(status));
return null;
}
protected String getSpecFile(String languageId) {
String specExt = getSpecFileExtension(languageId);
String ext = ""; //$NON-NLS-1$
if (specExt != null) {
ext = '.' + specExt;
}
String specFileName = SPEC_FILE_BASE + ext;
IPath workingLocation = MakeCorePlugin.getWorkingDirectory();
IPath fileLocation = workingLocation.append(specFileName);
specFile = new java.io.File(fileLocation.toOSString());
// will preserve spec file if it was already there otherwise will delete upon finishing
preserveSpecFile = specFile.exists();
if (!preserveSpecFile) {
try {
specFile.createNewFile();
} catch (IOException e) {
MakeCorePlugin.log(e);
}
}
return fileLocation.toString();
}
/**
* Determine file extension by language id. This implementation retrieves first extension
* from the list as there could be multiple extensions associated with the given language.
*
* @param languageId - given language ID.
* @return file extension associated with the language or {@code null} if not found.
*/
protected String getSpecFileExtension(String languageId) {
String ext = null;
ILanguageDescriptor langDescriptor = LanguageManager.getInstance().getLanguageDescriptor(languageId);
if (langDescriptor != null) {
IContentType[] contentTypes = langDescriptor.getContentTypes();
if (contentTypes != null && contentTypes.length > 0) {
String[] fileExtensions = contentTypes[0].getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
if (fileExtensions != null && fileExtensions.length > 0) {
ext = fileExtensions[0];
}
}
}
if (ext == null) {
MakeCorePlugin.log(new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, "Unable to find file extension for language "+languageId));
}
return ext;
}
protected void printLine(OutputStream stream, String msg) {
try {
stream.write((msg + NEWLINE).getBytes());
stream.flush();
} catch (IOException e) {
MakeCorePlugin.log(e);
}
}
@Override
public Element serializeAttributes(Element parentElement) {
Element elementProvider = super.serializeAttributes(parentElement);
elementProvider.setAttribute(ATTR_CONSOLE, Boolean.toString(isConsoleEnabled));
return elementProvider;
}
@Override
public void loadAttributes(Element providerNode) {
super.loadAttributes(providerNode);
String consoleValue = XmlUtil.determineAttributeValue(providerNode, ATTR_CONSOLE);
if (consoleValue!=null)
isConsoleEnabled = Boolean.parseBoolean(consoleValue);
}
@Override
public void loadEntries(Element providerNode) {
super.loadEntries(providerNode);
// TODO - test case for that or maybe introduce "isExecuted" attribute in XML?
if (!isEmpty())
isExecuted = true;
}
@Override
public void clear() {
super.clear();
isExecuted = false;
}
@Override
protected AbstractBuiltinSpecsDetector cloneShallow() throws CloneNotSupportedException {
AbstractBuiltinSpecsDetector clone = (AbstractBuiltinSpecsDetector) super.cloneShallow();
clone.isExecuted = false;
return clone;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + (isConsoleEnabled ? 1231 : 1237);
result = prime * result + (isExecuted ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (!(obj instanceof AbstractBuiltinSpecsDetector))
return false;
AbstractBuiltinSpecsDetector other = (AbstractBuiltinSpecsDetector) obj;
if (isConsoleEnabled != other.isConsoleEnabled)
return false;
if (isExecuted != other.isExecuted)
return false;
return true;
}
}

View file

@ -0,0 +1,872 @@
/*******************************************************************************
* Copyright (c) 2009, 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.make.core.scannerconfig;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider;
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.internal.core.XmlUtil;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.w3c.dom.Element;
/**
* Abstract class for providers capable to parse build output.
*
* @since 7.2
*/
public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSettingsSerializableProvider {
protected static final String ATTR_KEEP_RELATIVE_PATHS = "keep-relative-paths"; //$NON-NLS-1$
protected ICConfigurationDescription currentCfgDescription = null;
protected IProject currentProject = null;
protected IResource currentResource = null;
protected String currentLanguageId = null;
protected ErrorParserManager errorParserManager = null;
protected String parsedResourceName = null;
protected boolean isResolvingPaths = true;
protected static abstract class AbstractOptionParser {
protected final Pattern pattern;
protected final String patternStr;
protected String nameExpression;
protected String valueExpression;
protected int extraFlag = 0;
protected int kind = 0;
private String parsedName;
private String parsedValue;
public AbstractOptionParser(int kind, String pattern, String nameExpression, String valueExpression, int extraFlag) {
this.kind = kind;
this.patternStr = pattern;
this.nameExpression = nameExpression;
this.valueExpression = valueExpression;
this.extraFlag = extraFlag;
this.pattern = Pattern.compile(pattern);
}
public ICLanguageSettingEntry createEntry(String name, String value, int flag) {
return (ICLanguageSettingEntry) CDataUtil.createEntry(kind, name, value, null, flag | extraFlag);
}
/**
* TODO: explain
*/
protected String extractOption(String input) {
@SuppressWarnings("nls")
String option = input.replaceFirst("(" + patternStr + ").*", "$1");
return option;
}
protected String parseStr(Matcher matcher, String str) {
if (str != null)
return matcher.replaceAll(str);
return null;
}
protected boolean isPathKind() {
return kind == ICSettingEntry.INCLUDE_PATH || kind == ICSettingEntry.INCLUDE_FILE
|| kind == ICSettingEntry.MACRO_FILE || kind == ICSettingEntry.LIBRARY_PATH;
}
public boolean parseOption(String option) {
String opt = extractOption(option);
Matcher matcher = pattern.matcher(opt);
boolean isMatch = matcher.matches();
if (isMatch) {
parsedName = parseStr(matcher, nameExpression);
parsedValue = parseStr(matcher, valueExpression);
}
return isMatch;
}
}
protected static class IncludePathOptionParser extends AbstractOptionParser {
public IncludePathOptionParser(String pattern, String nameExpression) {
super(ICLanguageSettingEntry.INCLUDE_PATH, pattern, nameExpression, nameExpression, 0);
}
public IncludePathOptionParser(String pattern, String nameExpression, int extraFlag) {
super(ICLanguageSettingEntry.INCLUDE_PATH, pattern, nameExpression, nameExpression, extraFlag);
}
}
protected static class IncludeFileOptionParser extends AbstractOptionParser {
public IncludeFileOptionParser(String pattern, String nameExpression) {
super(ICLanguageSettingEntry.INCLUDE_FILE, pattern, nameExpression, nameExpression, 0);
}
public IncludeFileOptionParser(String pattern, String nameExpression, int extraFlag) {
super(ICLanguageSettingEntry.INCLUDE_FILE, pattern, nameExpression, nameExpression, extraFlag);
}
}
protected static class MacroOptionParser extends AbstractOptionParser {
public MacroOptionParser(String pattern, String nameExpression, String valueExpression) {
super(ICLanguageSettingEntry.MACRO, pattern, nameExpression, valueExpression, 0);
}
public MacroOptionParser(String pattern, String nameExpression, String valueExpression, int extraFlag) {
super(ICLanguageSettingEntry.MACRO, pattern, nameExpression, valueExpression, extraFlag);
}
public MacroOptionParser(String pattern, String nameExpression, int extraFlag) {
super(ICLanguageSettingEntry.MACRO, pattern, nameExpression, null, extraFlag);
}
}
protected static class MacroFileOptionParser extends AbstractOptionParser {
public MacroFileOptionParser(String pattern, String nameExpression) {
super(ICLanguageSettingEntry.MACRO_FILE, pattern, nameExpression, nameExpression, 0);
}
public MacroFileOptionParser(String pattern, String nameExpression, int extraFlag) {
super(ICLanguageSettingEntry.MACRO_FILE, pattern, nameExpression, nameExpression, extraFlag);
}
}
protected static class LibraryPathOptionParser extends AbstractOptionParser {
public LibraryPathOptionParser(String pattern, String nameExpression) {
super(ICLanguageSettingEntry.LIBRARY_PATH, pattern, nameExpression, nameExpression, 0);
}
public LibraryPathOptionParser(String pattern, String nameExpression, int extraFlag) {
super(ICLanguageSettingEntry.LIBRARY_PATH, pattern, nameExpression, nameExpression, extraFlag);
}
}
protected static class LibraryFileOptionParser extends AbstractOptionParser {
public LibraryFileOptionParser(String pattern, String nameExpression) {
super(ICLanguageSettingEntry.LIBRARY_FILE, pattern, nameExpression, nameExpression, 0);
}
public LibraryFileOptionParser(String pattern, String nameExpression, int extraFlag) {
super(ICLanguageSettingEntry.LIBRARY_FILE, pattern, nameExpression, nameExpression, extraFlag);
}
}
/**
* Parse the line returning the resource name as appears in the output.
* This is the resource where {@link ICLanguageSettingEntry} list is being added.
*
* @param line - one input line from the output stripped from end of line characters.
* @return the resource name as appears in the output or {@code null}.
* Note that {@code null} can have different semantics and can mean "no resource found"
* or "applicable to any resource". By default "no resource found" is used in this
* abstract class but extenders can handle otherwise.
*/
protected abstract String parseForResourceName(String line);
/**
* Parse the line returning the list of substrings to be treated each as input to
* the option parsers. It is assumed that each substring presents one
* {@link ICLanguageSettingEntry} (for example compiler options {@code -I/path} or
* {@code -DMACRO=1}.
*
* @param line - one input line from the output stripped from end of line characters.
* @return list of substrings representing language settings entries.
*/
protected abstract List<String> parseForOptions(String line);
/**
* @return array of option parsers defining how to parse a string to
* {@link ICLanguageSettingEntry}.
* See {@link AbstractOptionParser} and its specific extenders.
*/
protected abstract AbstractOptionParser[] getOptionParsers();
public boolean isResolvingPaths() {
return isResolvingPaths;
}
public void setResolvingPaths(boolean resolvePaths) {
this.isResolvingPaths = resolvePaths;
}
public void startup(ICConfigurationDescription cfgDescription) throws CoreException {
currentCfgDescription = cfgDescription;
currentProject = cfgDescription != null ? cfgDescription.getProjectDescription().getProject() : null;
}
public void shutdown() {
// release resources for garbage collector
currentCfgDescription = null;
currentProject = null;
currentResource = null;
currentLanguageId = null;
errorParserManager = null;
parsedResourceName = null;
}
public boolean processLine(String line, ErrorParserManager epm) {
errorParserManager = epm;
parsedResourceName = parseForResourceName(line);
currentResource = findResource(parsedResourceName);
currentLanguageId = determineLanguage();
if (!isLanguageInScope(currentLanguageId))
return false;
/**
* URI of directory where the build is happening. This URI could point to a remote filesystem
* for remote builds. Most often it is the same filesystem as for currentResource but
* it can be different filesystem (and different URI schema).
*/
URI buildDirURI = null;
/**
* Where source tree starts if mapped. This kind of mapping is useful for example in cases when
* the absolute path to the source file on the remote system is simulated inside a project in the
* workspace.
* This URI is rooted on the same filesystem where currentResource resides. In general this filesystem
* (or even URI schema) does not have to match that of buildDirURI.
*/
URI mappedRootURI = null;
if (isResolvingPaths) {
mappedRootURI = getMappedRootURI(currentResource, parsedResourceName);
buildDirURI = getBuildDirURI(mappedRootURI);
}
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
List<String> options = parseForOptions(line);
if (options!=null) {
for (String option : options) {
@SuppressWarnings("unused")
int i =0;
for (AbstractOptionParser optionParser : getOptionParsers()) {
try {
if (optionParser.parseOption(option)) {
ICLanguageSettingEntry entry = null;
if (isResolvingPaths && optionParser.isPathKind()) {
URI baseURI = new Path(optionParser.parsedName).isAbsolute() ? mappedRootURI : buildDirURI;
entry = createResolvedPathEntry(optionParser, optionParser.parsedName, 0, baseURI);
} else {
entry = optionParser.createEntry(optionParser.parsedName, optionParser.parsedValue, 0);
}
if (entry != null && !entries.contains(entry)) {
entries.add(entry);
break;
}
}
} catch (Throwable e) {
// protect from rogue parsers extending this class
MakeCorePlugin.log(e);
}
}
}
if (entries.size() > 0) {
setSettingEntries(entries);
} else {
setSettingEntries(null);
}
}
return false;
}
// TODO - 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 + ": ";
}
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);
}
protected String determineLanguage() {
IResource rc = currentResource;
if (rc == null && currentProject != null && parsedResourceName != null) {
String fileName = new Path(parsedResourceName).lastSegment().toString();
// use handle; resource does not need to exist
rc = currentProject.getFile("__" + fileName);
}
if (rc == null)
return null;
List<String> languageIds = LanguageSettingsManager.getLanguages(rc, currentCfgDescription);
if (languageIds.isEmpty())
return null;
return languageIds.get(0);
}
protected boolean isLanguageInScope(String languageId) {
List<String> languageIds = getLanguageScope();
return languageIds == null || languageIds.contains(languageId);
}
protected String getPatternFileExtensions() {
IContentTypeManager manager = Platform.getContentTypeManager();
Set<String> fileExts = new HashSet<String>();
IContentType contentTypeCpp = manager.getContentType("org.eclipse.cdt.core.cxxSource"); //$NON-NLS-1$
fileExts.addAll(Arrays.asList(contentTypeCpp.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
IContentType contentTypeC = manager.getContentType("org.eclipse.cdt.core.cSource"); //$NON-NLS-1$
fileExts.addAll(Arrays.asList(contentTypeC.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
String pattern = expressionLogicalOr(fileExts);
return pattern;
}
private ICLanguageSettingEntry createResolvedPathEntry(AbstractOptionParser optionParser,
String parsedPath, int flag, URI baseURI) {
ICLanguageSettingEntry entry;
String resolvedPath = null;
URI uri = determineMappedURI(parsedPath, baseURI);
IResource rc = null;
if (uri != null && uri.isAbsolute()) {
rc = findResourceForLocationURI(uri, optionParser.kind, currentProject);
}
if (rc != null) {
IPath path = rc.getFullPath();
resolvedPath = path.toString();
flag = flag | ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED;
} else {
IPath path = getFilesystemLocation(uri);
if (path != null && new File(path.toString()).exists()) {
resolvedPath = path.toString();
}
if (resolvedPath == null) {
Set<String> referencedProjectsNames = new LinkedHashSet<String>();
if (currentCfgDescription!=null) {
Map<String,String> refs = currentCfgDescription.getReferenceInfo();
referencedProjectsNames.addAll(refs.keySet());
}
IResource resource = resolveResourceInWorkspace(parsedPath, currentProject, referencedProjectsNames);
if (resource != null) {
path = resource.getFullPath();
resolvedPath = path.toString();
flag = flag | ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED;
}
}
if (resolvedPath==null && path!=null) {
resolvedPath = path.toString();
}
}
if (resolvedPath==null) {
resolvedPath = parsedPath;
}
entry = optionParser.createEntry(resolvedPath, resolvedPath, flag);
return entry;
}
private IResource findResource(String parsedResourceName) {
if (parsedResourceName==null)
return null;
IResource sourceFile = null;
// try ErrorParserManager
if (errorParserManager != null) {
sourceFile = errorParserManager.findFileName(parsedResourceName);
}
// try to find absolute path in the workspace
if (sourceFile == null && new Path(parsedResourceName).isAbsolute()) {
URI uri = org.eclipse.core.filesystem.URIUtil.toURI(parsedResourceName);
sourceFile = findFileForLocationURI(uri, currentProject);
}
// try path relative to build dir from configuration
if (sourceFile == null && currentCfgDescription != null) {
IPath builderCWD = currentCfgDescription.getBuildSetting().getBuilderCWD();
if (builderCWD!=null) {
IPath path = builderCWD.append(parsedResourceName);
URI uri = org.eclipse.core.filesystem.URIUtil.toURI(path);
sourceFile = findFileForLocationURI(uri, currentProject);
}
}
// try path relative to the project
if (sourceFile == null && currentProject != null) {
sourceFile = currentProject.findMember(parsedResourceName);
}
return sourceFile;
}
protected URI getBuildDirURI(URI mappedRootURI) {
URI buildDirURI = null;
URI cwdURI = null;
if (currentResource!=null && parsedResourceName!=null && !new Path(parsedResourceName).isAbsolute()) {
cwdURI = findBaseLocationURI(currentResource.getLocationURI(), parsedResourceName);
}
if (cwdURI == null && errorParserManager != null) {
cwdURI = errorParserManager.getWorkingDirectoryURI();
}
String cwdPath = cwdURI != null ? EFSExtensionManager.getDefault().getPathFromURI(cwdURI) : null;
if (cwdPath != null && mappedRootURI != null) {
buildDirURI = EFSExtensionManager.getDefault().append(mappedRootURI, cwdPath);
} else {
buildDirURI = cwdURI;
}
if (buildDirURI == null && currentCfgDescription != null) {
IPath pathBuilderCWD = currentCfgDescription.getBuildSetting().getBuilderCWD();
if (pathBuilderCWD != null) {
String builderCWD = pathBuilderCWD.toString();
try {
// TODO - here is a hack to overcome ${workspace_loc:/prj-name} returned by builder
ICdtVariableManager vmanager = CCorePlugin.getDefault().getCdtVariableManager();
builderCWD = vmanager.resolveValue(builderCWD, "", null, currentCfgDescription);
} catch (CdtVariableException e) {
MakeCorePlugin.log(e);
}
buildDirURI = org.eclipse.core.filesystem.URIUtil.toURI(builderCWD);
}
}
if (buildDirURI == null && currentProject != null) {
buildDirURI = currentProject.getLocationURI();
}
if (buildDirURI == null && currentResource != null) {
IContainer container;
if (currentResource instanceof IContainer) {
container = (IContainer) currentResource;
} else {
container = currentResource.getParent();
}
buildDirURI = container.getLocationURI();
}
return buildDirURI;
}
/**
* Determine URI on the local filesystem considering possible mapping.
*
* @param pathStr - path to the resource, can be absolute or relative
* @param baseURI - base {@link URI} where path to the resource is rooted
* @return {@link URI} of the resource
*/
private static URI determineMappedURI(String pathStr, URI baseURI) {
URI uri = null;
if (baseURI==null) {
if (new Path(pathStr).isAbsolute()) {
uri = resolvePathFromBaseLocation(pathStr, Path.ROOT);
}
} else if (baseURI.getScheme().equals(EFS.SCHEME_FILE)) {
// location on the local filesystem
IPath baseLocation = org.eclipse.core.filesystem.URIUtil.toPath(baseURI);
// careful not to use Path here but 'pathStr' as String as we want to properly navigate symlinks
uri = resolvePathFromBaseLocation(pathStr, baseLocation);
} else {
// location on a remote filesystem
IPath path = new Path(pathStr); // use canonicalized path here, in particular replace all '\' with '/' for Windows paths
URI remoteUri = EFSExtensionManager.getDefault().append(baseURI, path.toString());
if (remoteUri!=null) {
String localPath = EFSExtensionManager.getDefault().getMappedPath(remoteUri);
if (localPath!=null) {
uri = org.eclipse.core.filesystem.URIUtil.toURI(localPath);
}
}
}
if (uri == null) {
// if everything fails just wrap string to URI
uri = org.eclipse.core.filesystem.URIUtil.toURI(pathStr);
}
return uri;
}
private static IResource resolveResourceInWorkspace(String parsedName, IProject preferredProject, Set<String> referencedProjectsNames) {
IPath path = new Path(parsedName);
if (path.equals(new Path(".")) || path.equals(new Path(".."))) { //$NON-NLS-1$ //$NON-NLS-2$
return null;
}
// prefer current project
if (preferredProject!=null) {
List<IResource> result = findPathInFolder(path, preferredProject);
int size = result.size();
if (size==1) { // found the one
return result.get(0);
} else if (size>1) { // ambiguous
return null;
}
}
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
// then prefer referenced projects
if (referencedProjectsNames.size() > 0) {
IResource rc = null;
for (String prjName : referencedProjectsNames) {
IProject prj = root.getProject(prjName);
if (prj.isOpen()) {
List<IResource> result = findPathInFolder(path, prj);
int size = result.size();
if (size==1 && rc==null) {
rc = result.get(0);
} else if (size > 0) {
// ambiguous
rc = null;
break;
}
}
}
if (rc!=null) {
return rc;
}
}
// then check all other projects in workspace
IProject[] projects = root.getProjects();
if (projects.length > 0) {
IResource rc = null;
for (IProject prj : projects) {
if (!prj.equals(preferredProject) && !referencedProjectsNames.contains(prj.getName()) && prj.isOpen()) {
List<IResource> result = findPathInFolder(path, prj);
int size = result.size();
if (size==1 && rc==null) {
rc = result.get(0);
} else if (size > 0) {
// ambiguous
rc = null;
break;
}
}
}
if (rc!=null) {
return rc;
}
}
// not found or ambiguous
return null;
}
private static List<IResource> findPathInFolder(IPath path, IContainer folder) {
List<IResource> paths = new ArrayList<IResource>();
IResource resource = folder.findMember(path);
if (resource != null) {
paths.add(resource);
}
try {
for (IResource res : folder.members()) {
if (res instanceof IContainer) {
paths.addAll(findPathInFolder(path, (IContainer) res));
}
}
} catch (CoreException e) {
// ignore
}
return paths;
}
private static IResource findFileForLocationURI(URI uri, IProject preferredProject) {
IResource sourceFile;
IResource result = null;
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource[] resources = root.findFilesForLocationURI(uri);
if (resources.length > 0) {
result = resources[0];
if (preferredProject!=null) {
for (IResource rc : resources) {
if (rc.getProject().equals(preferredProject)) {
result = rc;
break;
}
}
}
}
sourceFile = result;
return sourceFile;
}
private static URI findBaseLocationURI(URI fileURI, String relativeFileName) {
URI cwdURI = null;
String path = fileURI.getPath();
String[] segments = relativeFileName.split("[/\\\\]"); //$NON-NLS-1$
// start removing segments from the end of the path
for (int i = segments.length - 1; i >= 0; i--) {
String lastSegment = segments[i];
if (lastSegment.length() > 0 && !lastSegment.equals(".")) { //$NON-NLS-1$
if (lastSegment.equals("..")) { //$NON-NLS-1$
// navigating ".." in the other direction is ambiguous, bailing out
return null;
} else {
if (path.endsWith("/" + lastSegment)) { //$NON-NLS-1$
int pos = path.lastIndexOf("/" + lastSegment); //$NON-NLS-1$
path = path.substring(0, pos);
continue;
} else {
// ouch, relativeFileName does not match fileURI, bailing out
return null;
}
}
}
}
try {
cwdURI = new URI(fileURI.getScheme(), fileURI.getUserInfo(), fileURI.getHost(),
fileURI.getPort(), path + '/', fileURI.getQuery(), fileURI.getFragment());
} catch (URISyntaxException e) {
// It should be valid URI here or something is wrong
MakeCorePlugin.log(e);
}
return cwdURI;
}
/**
* In case when absolute path is mapped to the source tree in a project
* this function will try to figure mapping and return "mapped root",
* i.e URI where the root path would be mapped. The mapped root will be
* used to prepend to other "absolute" paths where appropriate.
*
* @param sourceFile - a resource referred by parsed path
* @param parsedResourceName - path as appears in the output
* @return mapped path as URI
*/
protected URI getMappedRootURI(IResource sourceFile, String parsedResourceName) {
if (currentResource==null) {
return null;
}
URI fileURI = sourceFile.getLocationURI();
String mappedRoot = "/"; //$NON-NLS-1$
if (parsedResourceName!=null) {
IPath parsedSrcPath = new Path(parsedResourceName);
if (parsedSrcPath.isAbsolute()) {
IPath absPath = sourceFile.getLocation();
int absSegmentsCount = absPath.segmentCount();
int relSegmentsCount = parsedSrcPath.segmentCount();
if (absSegmentsCount >= relSegmentsCount) {
IPath ending = absPath.removeFirstSegments(absSegmentsCount - relSegmentsCount);
ending = ending.setDevice(parsedSrcPath.getDevice()).makeAbsolute();
if (ending.equals(parsedSrcPath.makeAbsolute())) {
mappedRoot = absPath.removeLastSegments(relSegmentsCount).toString();
}
}
}
}
URI uri = EFSExtensionManager.getDefault().createNewURIFromPath(fileURI, mappedRoot);
return uri;
}
/**
* The manipulations here are done to resolve "../" navigation for symbolic links where "link/.." cannot
* be collapsed as it must follow the real filesystem path. {@link java.io.File#getCanonicalPath()} deals
* with that correctly but {@link Path} or {@link URI} try to normalize the path which would be incorrect
* here.
*/
private static URI resolvePathFromBaseLocation(String name, IPath baseLocation) {
String pathName = name;
if (baseLocation != null && !baseLocation.isEmpty()) {
pathName = pathName.replace(File.separatorChar, '/');
String device = new Path(pathName).getDevice();
if (device==null || device.equals(baseLocation.getDevice())) {
if (device != null && device.length() > 0) {
pathName = pathName.substring(device.length());
}
baseLocation = baseLocation.addTrailingSeparator();
if (pathName.startsWith("/")) { //$NON-NLS-1$
pathName = pathName.substring(1);
}
pathName = baseLocation.toString() + pathName;
}
}
try {
File file = new File(pathName);
file = file.getCanonicalFile();
return file.toURI();
} catch (IOException e) {
// if error just leave it as is
}
URI uri = org.eclipse.core.filesystem.URIUtil.toURI(pathName);
return uri;
}
private static IResource findResourceForLocationURI(URI uri, int kind, IProject preferredProject) {
if (uri==null)
return null;
IResource resource = null;
switch (kind) {
case ICSettingEntry.INCLUDE_PATH:
case ICSettingEntry.LIBRARY_PATH:
resource = findContainerForLocationURI(uri, preferredProject);
break;
case ICSettingEntry.INCLUDE_FILE:
case ICSettingEntry.MACRO_FILE:
resource = findFileForLocationURI(uri, preferredProject);
break;
}
return resource;
}
private static IResource findContainerForLocationURI(URI uri, IProject preferredProject) {
IResource resource = null;
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource[] resources = root.findContainersForLocationURI(uri);
if (resources.length > 0) {
for (IResource rc : resources) {
if ((rc instanceof IProject || rc instanceof IFolder)) { // treat IWorkspaceRoot as non-workspace path
IProject prj = rc instanceof IProject ? (IProject)rc : rc.getProject();
if (prj.equals(preferredProject)) {
resource = rc;
break;
}
if (resource==null) {
resource=rc; // to be deterministic the first qualified resource has preference
}
}
}
}
return resource;
}
private static IPath getFilesystemLocation(URI uri) {
if (uri==null)
return null;
// EFSExtensionManager mapping
String pathStr = EFSExtensionManager.getDefault().getMappedPath(uri);
uri = org.eclipse.core.filesystem.URIUtil.toURI(pathStr);
try {
File file = new java.io.File(uri);
String canonicalPathStr = file.getCanonicalPath();
return new Path(canonicalPathStr);
} catch (Exception e) {
MakeCorePlugin.log(e);
}
return null;
}
@SuppressWarnings("nls")
private static String expressionLogicalOr(Set<String> fileExts) {
String pattern = "(";
for (String ext : fileExts) {
if (pattern.length() != 1)
pattern += "|";
pattern += "(" + Pattern.quote(ext) + ")";
ext = ext.toUpperCase();
if (!fileExts.contains(ext)) {
pattern += "|(" + Pattern.quote(ext) + ")";
}
}
pattern += ")";
return pattern;
}
protected static int countGroups(String str) {
@SuppressWarnings("nls")
int count = str.replaceAll("[^\\(]", "").length();
return count;
}
@Override
public Element serializeAttributes(Element parentElement) {
Element elementProvider = super.serializeAttributes(parentElement);
elementProvider.setAttribute(ATTR_KEEP_RELATIVE_PATHS, Boolean.toString( ! isResolvingPaths ));
return elementProvider;
}
@Override
public void loadAttributes(Element providerNode) {
super.loadAttributes(providerNode);
String expandRelativePathsValue = XmlUtil.determineAttributeValue(providerNode, ATTR_KEEP_RELATIVE_PATHS);
if (expandRelativePathsValue!=null)
isResolvingPaths = ! Boolean.parseBoolean(expandRelativePathsValue);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + (isResolvingPaths ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
AbstractLanguageSettingsOutputScanner other = (AbstractLanguageSettingsOutputScanner) obj;
if (isResolvingPaths != other.isResolvingPaths)
return false;
return true;
}
}

View file

@ -13,6 +13,8 @@ package org.eclipse.cdt.make.core.scannerconfig;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.resources.ACBuilder; import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
@ -75,6 +77,11 @@ public class ScannerConfigBuilder extends ACBuilder {
buildInfo2 = ScannerConfigProfileManager.createScannerConfigBuildInfo2(getProject()); buildInfo2 = ScannerConfigProfileManager.createScannerConfigBuildInfo2(getProject());
autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled(); autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled();
if (autodiscoveryEnabled2) {
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(getProject());
ICConfigurationDescription cfgDescription = projDesc.getActiveConfiguration();
autodiscoveryEnabled2 = ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
}
if (autodiscoveryEnabled2) { if (autodiscoveryEnabled2) {
monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$ monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$
@ -129,6 +136,11 @@ public class ScannerConfigBuilder extends ACBuilder {
protected boolean build(IProject project, InfoContext context, IScannerConfigBuilderInfo2 buildInfo2, IProgressMonitor monitor){ protected boolean build(IProject project, InfoContext context, IScannerConfigBuilderInfo2 buildInfo2, IProgressMonitor monitor){
boolean autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled(); boolean autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled();
if (autodiscoveryEnabled2) {
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(getProject());
ICConfigurationDescription cfgDescription = projDesc.getActiveConfiguration();
autodiscoveryEnabled2 = ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
}
if (autodiscoveryEnabled2) { if (autodiscoveryEnabled2) {
monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$ monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$

View file

@ -0,0 +1,72 @@
/*******************************************************************************
* Copyright (c) 2009, 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.make.internal.core.scannerconfig;
import org.eclipse.cdt.core.errorparsers.RegexErrorPattern;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsEditableProvider;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.make.core.scannerconfig.AbstractBuildCommandParser;
public class GCCBuildCommandParser extends AbstractBuildCommandParser implements ILanguageSettingsEditableProvider {
@SuppressWarnings("nls")
static final AbstractOptionParser[] optionParsers = {
new IncludePathOptionParser("-I\\s*([\"'])(.*)\\1", "$2"),
new IncludePathOptionParser("-I\\s*([^\\s\"']*)", "$1"),
new IncludeFileOptionParser("-include\\s*([\"'])(.*)\\1", "$2"),
new IncludeFileOptionParser("-include\\s*([^\\s\"']*)", "$1"),
new MacroOptionParser("-D\\s*([\"'])([^=]*)(=(.*))?\\1", "$2", "$4"),
new MacroOptionParser("-D\\s*([^\\s=\"']*)=(\\\\([\"']))(.*?)\\2", "$1", "$3$4$3"),
new MacroOptionParser("-D\\s*([^\\s=\"']*)=([\"'])(.*?)\\2", "$1", "$3"),
new MacroOptionParser("-D\\s*([^\\s=\"']*)(=([^\\s\"']*))?", "$1", "$3"),
new MacroOptionParser("-U\\s*([^\\s=\"']*)", "$1", ICSettingEntry.UNDEFINED),
new MacroFileOptionParser("-macros\\s*([\"'])(.*)\\1", "$2"),
new MacroFileOptionParser("-macros\\s*([^\\s\"']*)", "$1"),
new LibraryPathOptionParser("-L\\s*([\"'])(.*)\\1", "$2"),
new LibraryPathOptionParser("-L\\s*([^\\s\"']*)", "$1"),
new LibraryFileOptionParser("-l\\s*([^\\s\"']*)", "lib$1.a"), };
@Override
protected AbstractOptionParser[] getOptionParsers() {
return optionParsers;
}
@Override
public GCCBuildCommandParser cloneShallow() throws CloneNotSupportedException {
return (GCCBuildCommandParser) super.cloneShallow();
}
@Override
public GCCBuildCommandParser clone() throws CloneNotSupportedException {
return (GCCBuildCommandParser) super.clone();
}
public static class GCCBuildCommandPatternHighlighter extends AbstractBuildCommandParser.AbstractBuildCommandPatternHighlighter {
// ID of the parser taken from the existing extension point
private static final String GCC_BUILD_COMMAND_PARSER_EXT = "org.eclipse.cdt.make.core.GCCBuildCommandParser"; //$NON-NLS-1$
public GCCBuildCommandPatternHighlighter() {
super(GCC_BUILD_COMMAND_PARSER_EXT);
}
@Override
public Object clone() throws CloneNotSupportedException {
GCCBuildCommandPatternHighlighter that = new GCCBuildCommandPatternHighlighter();
that.setId(getId());
that.setName(getName());
for (RegexErrorPattern pattern : getPatterns()) {
that.addPattern((RegexErrorPattern)pattern.clone());
}
return that;
}
}
}

View file

@ -14,6 +14,10 @@ package org.eclipse.cdt.make.internal.core.scannerconfig;
import java.io.OutputStream; import java.io.OutputStream;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
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.internal.core.ConsoleOutputSniffer; import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
import org.eclipse.cdt.make.core.MakeBuilder; import org.eclipse.cdt.make.core.MakeBuilder;
import org.eclipse.cdt.make.core.MakeBuilderUtil; import org.eclipse.cdt.make.core.MakeBuilderUtil;
@ -118,9 +122,14 @@ public class ScannerInfoConsoleParserFactory {
// builder not installed or disabled // builder not installed or disabled
} }
} }
if (scBuildInfo != null && if (scBuildInfo != null) {
scBuildInfo.isAutoDiscoveryEnabled() && boolean autodiscoveryEnabled2 = scBuildInfo.isAutoDiscoveryEnabled();
scBuildInfo.isBuildOutputParserEnabled()) { if (autodiscoveryEnabled2) {
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(currentProject);
ICConfigurationDescription cfgDescription = projDesc.getActiveConfiguration();
autodiscoveryEnabled2 = ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
}
if (autodiscoveryEnabled2 && scBuildInfo.isBuildOutputParserEnabled()) {
// get the make builder console parser // get the make builder console parser
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId()); getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId());
@ -137,6 +146,7 @@ public class ScannerInfoConsoleParserFactory {
} }
} }
} }
}
// } // }
// catch (CoreException e) { // catch (CoreException e) {
// MakeCorePlugin.log(e.getStatus()); // MakeCorePlugin.log(e.getStatus());

View file

@ -35,7 +35,8 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional, org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
org.eclipse.compare;bundle-version="[3.3.0,4.0.0)", org.eclipse.compare;bundle-version="[3.3.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="1.2.0" org.eclipse.core.filesystem;bundle-version="1.2.0",
org.eclipse.ui.console;bundle-version="3.5.100"
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.ibm.icu.text Import-Package: com.ibm.icu.text

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: 347 B

View file

@ -44,6 +44,9 @@ PreferenceBuildSettings.name=Settings
ErrorParsersTab.name=Error Parsers ErrorParsersTab.name=Error Parsers
ErrorParsersTab.tooltip=Error Parsers scan build output and report errors in Problems view ErrorParsersTab.tooltip=Error Parsers scan build output and report errors in Problems view
LanguageSettingsProvidersTab.name=Discovery
LanguageSettingsProvidersTab.tooltip=Language settings providers
PreferenceMakeProject.name=New Make Projects PreferenceMakeProject.name=New Make Projects
PreferenceMake.name=Make Targets PreferenceMake.name=Make Targets
PreferenceMakefileEditor.name=Makefile Editor PreferenceMakefileEditor.name=Makefile Editor

View file

@ -470,6 +470,14 @@
tooltip="%ErrorParsersTab.tooltip" tooltip="%ErrorParsersTab.tooltip"
weight="020"> weight="020">
</tab> </tab>
<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>
<extension <extension
@ -532,4 +540,35 @@
</description> </description>
</fontDefinition> </fontDefinition>
</extension> </extension>
<extension
point="org.eclipse.cdt.ui.LanguageSettingsProviderAssociation">
<class-association
class="org.eclipse.cdt.make.core.scannerconfig.AbstractBuildCommandParser"
icon="icons/obj16/log_obj.gif"
page="org.eclipse.cdt.make.internal.ui.preferences.GCCBuildCommandParserOptionPage"
ui-clear-entries="true"
ui-edit-entries="false">
</class-association>
<class-association
class="org.eclipse.cdt.make.core.scannerconfig.AbstractBuiltinSpecsDetector"
icon="icons/obj16/inspect_system.gif"
page="org.eclipse.cdt.make.internal.ui.scannerconfig.BuiltinSpecsDetectorOptionPage"
ui-clear-entries="true"
ui-edit-entries="false">
</class-association>
</extension>
<extension
point="org.eclipse.cdt.core.CBuildConsole">
<CBuildConsole
id="org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryConsole"
class="org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryConsole">
</CBuildConsole>
</extension>
<extension
point="org.eclipse.cdt.core.CBuildConsole">
<CBuildConsole
id="org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryGlobalConsole"
class="org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryGlobalConsole">
</CBuildConsole>
</extension>
</plugin> </plugin>

View file

@ -0,0 +1,224 @@
/*******************************************************************************
* Copyright (c) 2009, 2010 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.make.internal.ui.preferences;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.internal.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
import org.eclipse.cdt.make.core.scannerconfig.AbstractBuildCommandParser;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
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.Label;
import org.eclipse.swt.widgets.Text;
/**
* Options page for TODO
*
*/
public final class GCCBuildCommandParserOptionPage extends AbstractLanguageSettingProviderOptionPage {
private boolean fEditable;
private Text inputCommand;
private StatusMessageLine fStatusLine;
private Button runOnceRadioButton;
private Button runEveryBuildRadioButton;
private Button expandRelativePathCheckBox;
private Button applyToProjectCheckBox;
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
// Composite optionsPageComposite = new Composite(composite, SWT.NULL);
fEditable = parent.isEnabled();
final 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);
}
AbstractBuildCommandParser provider = getRawProvider();
// Compiler specs command
{
Label label = ControlFactory.createLabel(composite, "Compiler command pattern:");
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 : "");
GridData 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 = getRawProvider();
if (!text.equals(provider.getCompilerPattern())) {
AbstractBuildCommandParser selectedProvider = getWorkingCopy(providerId);
selectedProvider.setCompilerPattern(text);
providerTab.refreshItem(selectedProvider);
}
}
});
}
// {
// Button button = ControlFactory.createPushButton(composite, "Browse...");
// button.setEnabled(fEditable);
// button.addSelectionListener(new SelectionAdapter() {
//
// @Override
// public void widgetSelected(SelectionEvent evt) {
//// handleAddr2LineButtonSelected();
// //updateLaunchConfigurationDialog();
// }
//
// });
//
// }
{
expandRelativePathCheckBox = new Button(composite, SWT.CHECK);
expandRelativePathCheckBox.setText("Use heuristics to resolve paths");
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 = getRawProvider();
if (enabled != provider.isResolvingPaths()) {
AbstractBuildCommandParser selectedProvider = getWorkingCopy(providerId);
selectedProvider.setResolvingPaths(enabled);
providerTab.refreshItem(selectedProvider);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
}
{
applyToProjectCheckBox = new Button(composite, SWT.CHECK);
applyToProjectCheckBox.setText("Apply discovered settings on project level");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
applyToProjectCheckBox.setLayoutData(gd);
// applyToProjectCheckBox.setSelection(provider.isExpandRelativePaths());
// applyToProjectCheckBox.setEnabled(fEditable);
applyToProjectCheckBox.setSelection(false);
applyToProjectCheckBox.setEnabled(false);
applyToProjectCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean enabled = applyToProjectCheckBox.getSelection();
AbstractBuildCommandParser provider = getRawProvider();
if (enabled != provider.isResolvingPaths()) {
AbstractBuildCommandParser selectedProvider = getWorkingCopy(providerId);
selectedProvider.setResolvingPaths(enabled);
providerTab.refreshItem(selectedProvider);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
}
// // Status line
// if (fEditable) {
// fStatusLine = new StatusMessageLine(composite, SWT.LEFT, 2);
// IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, "Note that currently not all options are persisted (FIXME)");
// fStatusLine.setErrorStatus(status);
// }
setControl(composite);
}
private AbstractBuildCommandParser getRawProvider() {
ILanguageSettingsProvider provider = LanguageSettingsManager.getRawProvider(providerTab.getProvider(providerId));
Assert.isTrue(provider instanceof AbstractBuildCommandParser);
return (AbstractBuildCommandParser) provider;
}
private AbstractBuildCommandParser getWorkingCopy(String providerId) {
ILanguageSettingsProvider provider = providerTab.getWorkingCopy(providerId);
Assert.isTrue(provider instanceof AbstractBuildCommandParser);
return (AbstractBuildCommandParser) provider;
}
@Override
public void performApply(IProgressMonitor monitor) throws CoreException {
// handled by LanguageSettingsProviderTab
}
@Override
public void performDefaults() {
// handled by LanguageSettingsProviderTab
}
}

View file

@ -0,0 +1,261 @@
/*******************************************************************************
* Copyright (c) 2009, 2010 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.make.internal.ui.scannerconfig;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.internal.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
import org.eclipse.cdt.make.core.scannerconfig.AbstractBuiltinSpecsDetector;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
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.Label;
import org.eclipse.swt.widgets.Text;
/**
* Options page for TODO
*
*/
public final class BuiltinSpecsDetectorOptionPage extends AbstractLanguageSettingProviderOptionPage {
private boolean fEditable;
private Text inputCommand;
private StatusMessageLine fStatusLine;
private Button allocateConsoleCheckBox;
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
// Composite optionsPageComposite = new Composite(composite, SWT.NULL);
fEditable = parent.isEnabled();
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);
}
AbstractBuiltinSpecsDetector provider = getRawProvider();
// Compiler specs command
{
Label label = ControlFactory.createLabel(composite, "Command to get compiler specs:");
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 : "");
inputCommand.setEnabled(fEditable);
inputCommand.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String text = inputCommand.getText();
AbstractBuiltinSpecsDetector provider = getRawProvider();
if (!text.equals(provider.getCommand())) {
AbstractBuiltinSpecsDetector selectedProvider = getWorkingCopy(providerId);
selectedProvider.setCommand(text);
providerTab.refreshItem(selectedProvider);
}
}
});
}
{
Button button = ControlFactory.createPushButton(composite, "Browse...");
button.setEnabled(fEditable);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
// handleAddr2LineButtonSelected();
//updateLaunchConfigurationDialog();
}
});
}
// {
// final Button button = new Button(composite, SWT.PUSH);
// button.setFont(parent.getFont());
// String text = fProvider.isEmpty() ? "Run Now (TODO)" : "Clear";
// button.setText(text);
//// button.addSelectionListener(this);
// GridData data = new GridData();
// data.horizontalSpan = 2;
//// data.horizontalAlignment = GridData.BEGINNING;
//// data.widthHint = 60;
// button.setLayoutData(data);
// // TODO
// button.setEnabled(fEditable && !fProvider.isEmpty());
//
// button.addSelectionListener(new SelectionAdapter() {
//
// @Override
// public void widgetSelected(SelectionEvent evt) {
// if (fProvider.isEmpty()) {
// // TODO
// } else {
// fProvider.clear();
// }
// // TODO
// button.setEnabled(fEditable && !fProvider.isEmpty());
// String text = fProvider.isEmpty() ? "Run Now (TODO)" : "Clear";
// button.setText(text);
// button.pack();
// }
//
// });
//
// }
// // Compiler specs command
// {
// Label label = ControlFactory.createLabel(composite, "Parsing rules:");
// GridData gd = new GridData();
// gd.horizontalSpan = 2;
// label.setLayoutData(gd);
//// Label newLabel = new Label(composite, SWT.NONE);
////// ((GridData) newLabel.getLayoutData()).horizontalSpan = 1;
//// newLabel.setText("Command to get compiler specs:");
// }
// createPatternsTable(group, composite);
// Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
// group.setText(DialogsMessages.RegexErrorParserOptionPage_Title);
//
// GridLayout gridLayout = new GridLayout(2, true);
// gridLayout.makeColumnsEqualWidth = false;
// gridLayout.marginRight = -10;
// gridLayout.marginLeft = -4;
// group.setLayout(gridLayout);
// group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
//
// Composite composite = new Composite(group, 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);
//
// if (!fEditable)
// createLinkToPreferences(composite);
//
// createPatternsTable(group, composite);
//
// if (fEditable) {
// createButtons(composite);
// }
{
allocateConsoleCheckBox = new Button(composite, SWT.CHECK);
allocateConsoleCheckBox.setText("Allocate console in the Console View");
allocateConsoleCheckBox.setSelection(provider.isConsoleEnabled());
allocateConsoleCheckBox.setEnabled(fEditable);
allocateConsoleCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean enabled = allocateConsoleCheckBox.getSelection();
AbstractBuiltinSpecsDetector provider = getRawProvider();
if (enabled != provider.isConsoleEnabled()) {
AbstractBuiltinSpecsDetector selectedProvider = getWorkingCopy(providerId);
selectedProvider.setConsoleEnabled(enabled);
providerTab.refreshItem(selectedProvider);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
}
// // Status line
// if (fEditable) {
// fStatusLine = new StatusMessageLine(composite, SWT.LEFT, 2);
// IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, "Note that currently not all options are persisted (FIXME)");
// fStatusLine.setErrorStatus(status);
// }
setControl(composite);
}
private AbstractBuiltinSpecsDetector getRawProvider() {
ILanguageSettingsProvider provider = LanguageSettingsManager.getRawProvider(providerTab.getProvider(providerId));
Assert.isTrue(provider instanceof AbstractBuiltinSpecsDetector);
return (AbstractBuiltinSpecsDetector) provider;
}
private AbstractBuiltinSpecsDetector getWorkingCopy(String providerId) {
ILanguageSettingsProvider provider = providerTab.getWorkingCopy(providerId);
Assert.isTrue(provider instanceof AbstractBuiltinSpecsDetector);
return (AbstractBuiltinSpecsDetector) provider;
}
@Override
public void performApply(IProgressMonitor monitor) throws CoreException {
// handled by LanguageSettingsProviderTab
}
@Override
public void performDefaults() {
// handled by LanguageSettingsProviderTab
}
}

View file

@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2010, 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.make.internal.ui.scannerconfig;
import java.net.URL;
import org.eclipse.cdt.internal.ui.buildconsole.CBuildConsole;
import org.eclipse.cdt.internal.ui.language.settings.providers.LanguageSettingsProviderAssociationManager;
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 = LanguageSettingsProviderAssociationManager.getImageUrl(consoleId);
if (iconUrl==null) {
iconUrl = defaultIconUrl;
}
super.init(consoleId, name, iconUrl);
}
}

View file

@ -0,0 +1,107 @@
/*******************************************************************************
* 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.make.internal.ui.scannerconfig;
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.internal.ui.language.settings.providers.LanguageSettingsProviderAssociationManager;
import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
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;
public class ScannerDiscoveryGlobalConsole implements ICConsole {
private MessageConsole console;
private ConsoleOutputStreamAdapter stream;
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 stream;
}
@Override
public ConsoleOutputStream getInfoStream() throws CoreException {
return stream;
}
@Override
public ConsoleOutputStream getErrorStream() throws CoreException {
return stream;
}
@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 = LanguageSettingsProviderAssociationManager.getImageUrl(consoleId);
if (iconUrl==null) {
iconUrl = defaultIconUrl;
}
console = new MessageConsole(name, CDTSharedImages.getImageDescriptor(iconUrl.toString()));
console.activate();
consoleManager.addConsoles(new IConsole[]{ console });
}
stream = new ConsoleOutputStreamAdapter(console.newMessageStream());
}
}

View file

@ -15,10 +15,13 @@ import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature; import org.eclipse.cdt.make.core.MakeProjectNature;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2; import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
@ -180,8 +183,14 @@ public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
((GridData)scEnabledButton.getLayoutData()).horizontalSpan = numColumns; ((GridData)scEnabledButton.getLayoutData()).horizontalSpan = numColumns;
((GridData)scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData)scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
// VMIR* old projects will have discovery disabled by default // VMIR* old projects will have discovery disabled by default
boolean autodiscoveryEnabled2 = getBuildInfo().isAutoDiscoveryEnabled();
if (autodiscoveryEnabled2) {
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(getProject());
ICConfigurationDescription cfgDescription = projDesc.getActiveConfiguration();
autodiscoveryEnabled2 = ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
}
scEnabledButton.setSelection(needsSCNature ? false scEnabledButton.setSelection(needsSCNature ? false
: (getBuildInfo().isAutoDiscoveryEnabled() : (autodiscoveryEnabled2
&& !getBuildInfo().getSelectedProfileId().equals(ScannerConfigProfileManager.NULL_PROFILE_ID))); && !getBuildInfo().getSelectedProfileId().equals(ScannerConfigProfileManager.NULL_PROFILE_ID)));
scEnabledButton.addSelectionListener(new SelectionAdapter() { scEnabledButton.addSelectionListener(new SelectionAdapter() {
@Override @Override

View file

@ -6,7 +6,8 @@ Bundle-Version: 8.1.0.qualifier
Bundle-Activator: org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin Bundle-Activator: org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin
Bundle-Vendor: Eclipse CDT Bundle-Vendor: Eclipse CDT
Bundle-Localization: plugin Bundle-Localization: plugin
Export-Package: org.eclipse.cdt.managedbuilder.core.tests, Export-Package: org.eclipse.cdt.build.core.scannerconfig.tests;x-internal:=true,
org.eclipse.cdt.managedbuilder.core.tests,
org.eclipse.cdt.managedbuilder.templateengine.tests, org.eclipse.cdt.managedbuilder.templateengine.tests,
org.eclipse.cdt.managedbuilder.testplugin, org.eclipse.cdt.managedbuilder.testplugin,
org.eclipse.cdt.managedbuilder.tests.suite, org.eclipse.cdt.managedbuilder.tests.suite,

View file

@ -15,6 +15,7 @@ package org.eclipse.cdt.managedbuilder.tests.suite;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.build.core.scannerconfig.tests.AllLanguageSettingsProvidersMBSTests;
import org.eclipse.cdt.build.core.scannerconfig.tests.CfgScannerConfigProfileManagerTests; import org.eclipse.cdt.build.core.scannerconfig.tests.CfgScannerConfigProfileManagerTests;
import org.eclipse.cdt.build.core.scannerconfig.tests.GCCSpecsConsoleParserTest; import org.eclipse.cdt.build.core.scannerconfig.tests.GCCSpecsConsoleParserTest;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
@ -61,6 +62,9 @@ public class AllManagedBuildTests {
suite.addTest(CfgScannerConfigProfileManagerTests.suite()); suite.addTest(CfgScannerConfigProfileManagerTests.suite());
suite.addTestSuite(GCCSpecsConsoleParserTest.class); suite.addTestSuite(GCCSpecsConsoleParserTest.class);
// language settings providers tests
suite.addTest(AllLanguageSettingsProvidersMBSTests.suite());
// managedbuilder.core.tests // managedbuilder.core.tests
suite.addTest(ManagedBuildDependencyLibsTests.suite()); suite.addTest(ManagedBuildDependencyLibsTests.suite());
suite.addTest(ManagedBuildCoreTests20.suite()); suite.addTest(ManagedBuildCoreTests20.suite());

View file

@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2010, 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.build.core.scannerconfig.tests;
import junit.framework.TestSuite;
public class AllLanguageSettingsProvidersMBSTests extends TestSuite {
public static TestSuite suite() {
return new AllLanguageSettingsProvidersMBSTests();
}
public AllLanguageSettingsProvidersMBSTests() {
super(AllLanguageSettingsProvidersMBSTests.class.getName());
addTestSuite(LanguageSettingsProvidersMBSTest.class);
addTestSuite(GCCBuiltinSpecsDetectorTest.class);
}
}

View file

@ -0,0 +1,410 @@
/*******************************************************************************
* Copyright (c) 2010, 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.build.core.scannerconfig.tests;
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.managedbuilder.internal.scannerconfig.GCCBuiltinSpecsDetector;
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.GCCBuiltinSpecsDetectorCygwin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
private static final String LANGUAGE_ID_C = GCCLanguage.ID;
class MockGCCBuiltinSpecsDetector extends GCCBuiltinSpecsDetector {
@Override
public void startupForLanguage(String languageId) throws CoreException {
super.startupForLanguage(languageId);
}
@Override
public void shutdownForLanguage() {
super.shutdownForLanguage();
}
}
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();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
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;
}
public void testGCCBuiltinSpecsDetector_ResolvedCommand() throws Exception {
class MockGCCBuiltinSpecsDetectorLocal extends GCCBuiltinSpecsDetector {
@Override
public String resolveCommand(String languageId) throws CoreException {
return super.resolveCommand(languageId);
}
}
{
MockGCCBuiltinSpecsDetectorLocal detector = new MockGCCBuiltinSpecsDetectorLocal();
detector.setLanguageScope(new ArrayList<String>() {{add(LANGUAGE_ID_C);}});
detector.setCommand("${COMMAND} -E -P -v -dD ${INPUTS}");
String resolvedCommand = detector.resolveCommand(LANGUAGE_ID_C);
assertTrue(resolvedCommand.startsWith("gcc -E -P -v -dD "));
assertTrue(resolvedCommand.endsWith("spec.c"));
}
{
MockGCCBuiltinSpecsDetectorLocal detector = new MockGCCBuiltinSpecsDetectorLocal();
detector.setLanguageScope(new ArrayList<String>() {{add(LANGUAGE_ID_C);}});
detector.setCommand("${COMMAND} -E -P -v -dD file.${EXT}");
String resolvedCommand = detector.resolveCommand(LANGUAGE_ID_C);
assertTrue(resolvedCommand.startsWith("gcc -E -P -v -dD "));
assertTrue(resolvedCommand.endsWith("file.c"));
}
}
public void testGCCBuiltinSpecsDetector_Macro_NoValue() throws Exception {
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#define MACRO", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CMacroEntry("MACRO", null, ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
public void testGCCBuiltinSpecsDetector_Macro_Simple() throws Exception {
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#define MACRO VALUE", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
public void testGCCBuiltinSpecsDetector_Macro_Const() throws Exception {
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#define MACRO (3)", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CMacroEntry("MACRO", "(3)", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
public void testGCCBuiltinSpecsDetector_Macro_WhiteSpaces() throws Exception {
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#define \t MACRO_1 VALUE", null);
detector.processLine("#define MACRO_2 \t VALUE", null);
detector.processLine("#define MACRO_3 VALUE \t", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
int index = 0;
assertEquals(new CMacroEntry("MACRO_1", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CMacroEntry("MACRO_2", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CMacroEntry("MACRO_3", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(index, entries.size());
}
public void testGCCBuiltinSpecsDetector_Macro_EmptyArgList() throws Exception {
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#define MACRO() VALUE", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CMacroEntry("MACRO()", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
public void testGCCBuiltinSpecsDetector_Macro_ParamUnused() throws Exception {
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#define MACRO(X) VALUE", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CMacroEntry("MACRO(X)", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
public void testGCCBuiltinSpecsDetector_Macro_ParamSpace() throws Exception {
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#define MACRO(P1, P2) VALUE(P1, P2)", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CMacroEntry("MACRO(P1, P2)", "VALUE(P1, P2)", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
public void testGCCBuiltinSpecsDetector_Macro_ArgsNoValue() throws Exception {
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#define MACRO(P1, P2) ", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CMacroEntry("MACRO(P1, P2)", null, ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
public void testGCCBuiltinSpecsDetector_Macro_Args_WhiteSpaces() throws Exception {
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#define \t MACRO_1(P1, P2) VALUE(P1, P2)", null);
detector.processLine("#define MACRO_2(P1, P2) \t VALUE(P1, P2)", null);
detector.processLine("#define MACRO_3(P1, P2) VALUE(P1, P2) \t", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
int index = 0;
assertEquals(new CMacroEntry("MACRO_1(P1, P2)", "VALUE(P1, P2)", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CMacroEntry("MACRO_2(P1, P2)", "VALUE(P1, P2)", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CMacroEntry("MACRO_3(P1, P2)", "VALUE(P1, P2)", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(index, entries.size());
}
public void testGCCBuiltinSpecsDetector_Includes() throws Exception {
// Create model project and folders to test
String projectName = getName();
IProject project = ResourceHelper.createCDTProject(projectName);
IPath tmpPath = ResourceHelper.createTemporaryFolder();
ResourceHelper.createFolder(project, "/misplaced/include1");
ResourceHelper.createFolder(project, "/local/include");
ResourceHelper.createFolder(project, "/usr/include");
ResourceHelper.createFolder(project, "/usr/include2");
ResourceHelper.createFolder(project, "/misplaced/include2");
ResourceHelper.createFolder(project, "/System/Library/Frameworks");
ResourceHelper.createFolder(project, "/Library/Frameworks");
ResourceHelper.createFolder(project, "/misplaced/include3");
String loc = tmpPath.toString();
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine(" "+loc+"/misplaced/include1", null);
detector.processLine("#include \"...\" search starts here:", null);
detector.processLine(" "+loc+"/local/include", null);
detector.processLine("#include <...> search starts here:", null);
detector.processLine(" "+loc+"/usr/include", null);
detector.processLine(" "+loc+"/usr/include/../include2", null);
detector.processLine(" "+loc+"/missing/folder", null);
detector.processLine(" "+loc+"/Library/Frameworks (framework directory)", null);
detector.processLine("End of search list.", null);
detector.processLine(" "+loc+"/misplaced/include2", null);
detector.processLine("Framework search starts here:", null);
detector.processLine(" "+loc+"/System/Library/Frameworks", null);
detector.processLine("End of framework search list.", null);
detector.processLine(" "+loc+"/misplaced/include3", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
int index = 0;
assertEquals(new CIncludePathEntry(loc+"/local/include", ICSettingEntry.LOCAL | ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CIncludePathEntry(loc+"/usr/include", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CIncludePathEntry(loc+"/usr/include2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CIncludePathEntry(loc+"/missing/folder", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CIncludePathEntry(loc+"/Library/Frameworks", ICSettingEntry.FRAMEWORKS_MAC | ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CIncludePathEntry(loc+"/System/Library/Frameworks", ICSettingEntry.FRAMEWORKS_MAC | ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(index, entries.size());
}
public void testGCCBuiltinSpecsDetector_Includes_WhiteSpaces() throws Exception {
String loc = ResourceHelper.createTemporaryFolder().toString();
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#include \"...\" search starts here:", null);
detector.processLine(" \t "+loc+"/local/include", null);
detector.processLine("#include <...> search starts here:", null);
detector.processLine(loc+"/usr/include", null);
detector.processLine(" "+loc+"/Library/Frameworks \t (framework directory)", null);
detector.processLine("End of search list.", null);
detector.processLine("Framework search starts here:", null);
detector.processLine(" "+loc+"/System/Library/Frameworks \t ", null);
detector.processLine("End of framework search list.", null);
detector.shutdownForLanguage();
detector.shutdown();
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
int index = 0;
assertEquals(new CIncludePathEntry(loc+"/local/include", ICSettingEntry.LOCAL | ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CIncludePathEntry(loc+"/usr/include", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CIncludePathEntry(loc+"/Library/Frameworks", ICSettingEntry.FRAMEWORKS_MAC | ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(new CIncludePathEntry(loc+"/System/Library/Frameworks", ICSettingEntry.FRAMEWORKS_MAC | ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(index++));
assertEquals(index, entries.size());
}
public void testGCCBuiltinSpecsDetector_Includes_SymbolicLinkUp() throws Exception {
// do not test on systems where symbolic links are not supported
if (!ResourceHelper.isSymbolicLinkSupported())
return;
// Create model project and folders to test
String projectName = getName();
@SuppressWarnings("unused")
IProject project = ResourceHelper.createCDTProject(projectName);
// create link on the filesystem
IPath dir1 = ResourceHelper.createTemporaryFolder();
IPath dir2 = dir1.removeLastSegments(1);
IPath linkPath = dir1.append("linked");
ResourceHelper.createSymbolicLink(linkPath, dir2);
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#include <...> search starts here:", null);
detector.processLine(" "+linkPath.toString()+"/..", null);
detector.processLine("End of search list.", null);
detector.shutdownForLanguage();
detector.shutdown();
// check populated entries
List<ICLanguageSettingEntry> entries = detector.getSettingEntries(null, null, null);
assertEquals(new CIncludePathEntry(dir2.removeLastSegments(1), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), entries.get(0));
assertEquals(1, entries.size());
}
public void testGCCBuiltinSpecsDetector_Cygwin_NoProject() throws Exception {
String windowsLocation;
String cygwinLocation = "/usr/include";
try {
windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
} catch (UnsupportedOperationException e) {
// Skip the test if Cygwin is not available.
return;
}
assertTrue("windowsLocation=["+windowsLocation+"]", new Path(windowsLocation).getDevice()!=null);
MockGCCBuiltinSpecsDetectorCygwin detector = new MockGCCBuiltinSpecsDetectorCygwin();
detector.startup(null);
detector.startupForLanguage(null);
detector.processLine("#include <...> search starts here:", null);
detector.processLine(" /usr/include", null);
detector.processLine("End of search list.", null);
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());
}
public void testGCCBuiltinSpecsDetector_Cygwin_Configuration() throws Exception {
String windowsLocation;
String cygwinLocation = "/usr/include";
try {
windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
} catch (UnsupportedOperationException e) {
// Skip the test if Cygwin is not available.
return;
}
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);
detector.startupForLanguage(null);
detector.processLine("#include <...> search starts here:", null);
detector.processLine(" /usr/include", null);
detector.processLine("End of search list.", null);
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,173 @@
/*******************************************************************************
* 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.build.core.scannerconfig.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;
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();
}
/**
* New Project Wizards do all these things
*/
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;
}
/**
*/
public void testGnuToolchainProviders() throws Exception {
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
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());
}
}
/**
*/
public void testProjectPersistence_NoProviders() throws Exception {
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
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);
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertEquals(true, xmlStorageFile.exists());
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
assertEquals(false, xmlStorageFilePrjWsp.exists());
}
/**
*/
public void testProjectPersistence_Defaults() throws Exception {
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
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);
}
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertEquals(false, xmlStorageFile.exists());
assertEquals(false, xmlStorageFile.getParent().exists()); // .settings folder
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

@ -15,6 +15,7 @@ Export-Package: org.eclipse.cdt.build.core.scannerconfig,
org.eclipse.cdt.managedbuilder.envvar, org.eclipse.cdt.managedbuilder.envvar,
org.eclipse.cdt.managedbuilder.internal.buildmodel;x-friends:="org.eclipse.cdt.managedbuilder.ui", org.eclipse.cdt.managedbuilder.internal.buildmodel;x-friends:="org.eclipse.cdt.managedbuilder.ui",
org.eclipse.cdt.managedbuilder.internal.core;x-friends:="org.eclipse.cdt.managedbuilder.ui", org.eclipse.cdt.managedbuilder.internal.core;x-friends:="org.eclipse.cdt.managedbuilder.ui",
org.eclipse.cdt.managedbuilder.internal.dataprovider;x-internal:=true,
org.eclipse.cdt.managedbuilder.internal.envvar;x-internal:=true, org.eclipse.cdt.managedbuilder.internal.envvar;x-internal:=true,
org.eclipse.cdt.managedbuilder.internal.macros;x-friends:="org.eclipse.cdt.managedbuilder.ui", org.eclipse.cdt.managedbuilder.internal.macros;x-friends:="org.eclipse.cdt.managedbuilder.ui",
org.eclipse.cdt.managedbuilder.internal.scannerconfig;x-internal:=true, org.eclipse.cdt.managedbuilder.internal.scannerconfig;x-internal:=true,

View file

@ -308,13 +308,14 @@
</managedBuildRevision> </managedBuildRevision>
<configuration <configuration
id="org.eclipse.cdt.build.core.emptycfg" id="org.eclipse.cdt.build.core.emptycfg"
languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;${Toolchain}"
name="%cfg1_empty"> name="%cfg1_empty">
</configuration> </configuration>
<configuration <configuration
id="org.eclipse.cdt.build.core.prefbase.cfg" id="org.eclipse.cdt.build.core.prefbase.cfg"
name="%cfg1_base" languageSettingsProviders="org.eclipse.cdt.ui.UserLanguageSettingsProvider;${Toolchain}"
> name="%cfg1_base">
<toolChain <toolChain
id="org.eclipse.cdt.build.core.prefbase.toolchain" id="org.eclipse.cdt.build.core.prefbase.toolchain"
name="%toolChain.name" name="%toolChain.name"
@ -597,6 +598,41 @@
</run> </run>
</application> </application>
</extension> </extension>
<extension
point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider
class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.MBSLanguageSettingsProvider"
id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider"
name="CDT Managed Build Setting Entries">
</provider>
<provider
class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.GCCBuiltinSpecsDetector"
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"
name="CDT GCC Builtin Compiler Settings"
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.internal.scannerconfig.GCCBuiltinSpecsDetectorCygwin"
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin"
name="CDT GCC Builtin Compiler Settings Cygwin"
parameter="sh -c &quot;${COMMAND} -E -P -v -dD ${INPUTS}&quot;">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
<extension
id="scanner.discovery.problem"
name="C/C++ Scanner Discovery Problem"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<persistent
value="true">
</persistent>
</extension>
<extension <extension
id="headlessSettings" id="headlessSettings"
name="HeadlessBuilder Additional Settings" name="HeadlessBuilder Additional Settings"

View file

@ -263,7 +263,16 @@ Specifying this attribute is fully equivalent to specifying the &quot;org.eclips
<attribute name="errorParsers" type="string"> <attribute name="errorParsers" type="string">
<annotation> <annotation>
<documentation> <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> </documentation>
</annotation> </annotation>
</attribute> </attribute>
@ -405,7 +414,15 @@ Specifying this attribute is fully equivalent to specifying the &quot;org.eclips
<attribute name="errorParsers" type="string"> <attribute name="errorParsers" type="string">
<annotation> <annotation>
<documentation> <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> </documentation>
</annotation> </annotation>
</attribute> </attribute>
@ -732,14 +749,14 @@ The pathConverter of a toolchain applies for all tools of the toolchain except i
<attribute name="customBuildStep" type="boolean"> <attribute name="customBuildStep" type="boolean">
<annotation> <annotation>
<documentation> <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> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="announcement" type="string"> <attribute name="announcement" type="string">
<annotation> <annotation>
<documentation> <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> </documentation>
<appInfo> <appInfo>
<meta.attribute translatable="true"/> <meta.attribute translatable="true"/>
@ -1066,7 +1083,7 @@ Overrides language id specified with the languageId attribute.
<attribute name="primaryInputType" type="string"> <attribute name="primaryInputType" type="string">
<annotation> <annotation>
<documentation> <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> </documentation>
</annotation> </annotation>
</attribute> </attribute>
@ -1080,7 +1097,7 @@ Overrides language id specified with the languageId attribute.
<attribute name="outputPrefix" type="string"> <attribute name="outputPrefix" type="string">
<annotation> <annotation>
<documentation> <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> </documentation>
</annotation> </annotation>
</attribute> </attribute>
@ -2035,11 +2052,11 @@ If the &quot;buildPathResolver&quot; attribute is specified, the &quot;pathDelim
<documentation> <documentation>
Represents the applicability type for this enablement. Represents the applicability type for this enablement.
Can contain the following values: Can contain the following values:
UI_VISIBILITY the given enablement expression specifies whether the option is to be visible in UI, 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, 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 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 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.: Several types could be specified simultaneously using the &quot;|&quot; as a delimiter, e.g.:
type=&quot;UI_VISIBILITY|CMD_USAGE&quot; type=&quot;UI_VISIBILITY|CMD_USAGE&quot;
@ -2173,7 +2190,7 @@ Default value is true.
<attribute name="value" type="string"> <attribute name="value" type="string">
<annotation> <annotation>
<documentation> <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 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> </documentation>
</annotation> </annotation>
@ -2188,14 +2205,14 @@ The expected value could be specified either as a string that may contain build
<attribute name="otherOptionId" type="string"> <attribute name="otherOptionId" type="string">
<annotation> <annotation>
<documentation> <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> </documentation>
</annotation> </annotation>
</attribute> </attribute>
<attribute name="otherHolderId" type="string"> <attribute name="otherHolderId" type="string">
<annotation> <annotation>
<documentation> <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> </documentation>
</annotation> </annotation>
</attribute> </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"> <attribute name="value" type="string" use="required">
<annotation> <annotation>
<documentation> <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 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. The way the value is specified and treated depends on the value of the isRegex attribute.
</documentation> </documentation>

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfil
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.resources.ACBuilder; import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -181,6 +182,10 @@ public class ScannerConfigBuilder extends ACBuilder {
IConfiguration cfg = context.getConfiguration(); IConfiguration cfg = context.getConfiguration();
IProject project = cfg.getOwner().getProject(); IProject project = cfg.getOwner().getProject();
boolean autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled(); boolean autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled();
if (autodiscoveryEnabled2) {
ICConfigurationDescription cfgDescription = ManagedBuildManager.getDescriptionForConfiguration(cfg);
autodiscoveryEnabled2 = ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
}
if (autodiscoveryEnabled2 || ((flags & FORCE_DISCOVERY) != 0)) { if (autodiscoveryEnabled2 || ((flags & FORCE_DISCOVERY) != 0)) {
monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$ monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$

View file

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

View file

@ -19,6 +19,7 @@ import java.util.Map.Entry;
import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext; import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set; import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgScannerConfigUtil; import org.eclipse.cdt.build.internal.core.scannerconfig.CfgScannerConfigUtil;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeCorePlugin;
@ -36,6 +37,7 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration; import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData; import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
@ -213,8 +215,13 @@ public class CfgScannerConfigInfoFactory2 {
} }
} }
if (id == null) { if (id == null) {
// Language Settings Providers are meant to replace legacy scanner discovery
// so do not try to find default profile
IProject project = cfg.getOwner().getProject();
if (!ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project)) {
id = CfgScannerConfigUtil.getDefaultProfileId(context, true); id = CfgScannerConfigUtil.getDefaultProfileId(context, true);
} }
}
InfoContext baseContext = context.toInfoContext(); InfoContext baseContext = context.toInfoContext();
if(info == null){ if(info == null){

View file

@ -25,10 +25,16 @@ import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager; import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.ICConsoleParser;
import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
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.ICModelMarker; import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.resources.RefreshScopeManager; import org.eclipse.cdt.core.resources.RefreshScopeManager;
@ -114,6 +120,18 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
break; break;
} }
URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
final String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI);
if(pathFromURI == null) {
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, ManagedMakeMessages.getString("ManagedMakeBuilder.message.error"), null)); //$NON-NLS-1$
}
IPath workingDirectory = new Path(pathFromURI);
// Set the environment
Map<String, String> envMap = getEnvironment(builder);
String[] env = getEnvStrings(envMap);
consoleHeader[1] = configuration.getName(); consoleHeader[1] = configuration.getName();
consoleHeader[2] = project.getName(); consoleHeader[2] = project.getName();
buf.append(NEWLINE); buf.append(NEWLINE);
@ -135,14 +153,6 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
if (markers != null) if (markers != null)
workspace.deleteMarkers(markers); workspace.deleteMarkers(markers);
URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(configuration, builder);
final String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI);
if(pathFromURI == null) {
throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, ManagedMakeMessages.getString("ManagedMakeBuilder.message.error"), null)); //$NON-NLS-1$
}
IPath workingDirectory = new Path(pathFromURI);
String[] targets = getTargets(kind, builder); String[] targets = getTargets(kind, builder);
if (targets.length != 0 && targets[targets.length - 1].equals(builder.getCleanBuildTarget())) if (targets.length != 0 && targets[targets.length - 1].equals(builder.getCleanBuildTarget()))
isClean = true; isClean = true;
@ -153,9 +163,6 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
// Print the command for visual interaction. // Print the command for visual interaction.
launcher.showCommand(true); launcher.showCommand(true);
// Set the environment
Map<String, String> envMap = getEnvironment(builder);
String[] env = getEnvStrings(envMap);
String[] buildArguments = targets; String[] buildArguments = targets;
String[] newArgs = CommandLineUtil.argumentsToArray(builder.getBuildArguments()); String[] newArgs = CommandLineUtil.argumentsToArray(builder.getBuildArguments());
@ -175,9 +182,15 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
OutputStream stderr = streamMon; OutputStream stderr = streamMon;
// Sniff console output for scanner info // Sniff console output for scanner info
ConsoleOutputSniffer sniffer = createBuildOutputSniffer(stdout, stderr, project, configuration, workingDirectory, markerGenerator, null); OutputStream consoleOut = stdout;
OutputStream consoleOut = (sniffer == null ? stdout : sniffer.getOutputStream()); OutputStream consoleErr = stderr;
OutputStream consoleErr = (sniffer == null ? stderr : sniffer.getErrorStream()); if (kind!=IncrementalProjectBuilder.CLEAN_BUILD) {
ConsoleOutputSniffer sniffer = createBuildOutputSniffer(stdout, stderr, project, configuration, workingDirectory, markerGenerator, null, epm);
if (sniffer!=null) {
consoleOut = sniffer.getOutputStream();
consoleErr = sniffer.getErrorStream();
}
}
Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory, monitor); Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory, monitor);
if (p != null) { if (p != null) {
try { try {
@ -337,10 +350,11 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
IConfiguration cfg, IConfiguration cfg,
IPath workingDirectory, IPath workingDirectory,
IMarkerGenerator markerGenerator, IMarkerGenerator markerGenerator,
IScannerInfoCollector collector){ IScannerInfoCollector collector,
ErrorParserManager epm){
ICfgScannerConfigBuilderInfo2Set container = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg); ICfgScannerConfigBuilderInfo2Set container = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
Map<CfgInfoContext, IScannerConfigBuilderInfo2> map = container.getInfoMap(); Map<CfgInfoContext, IScannerConfigBuilderInfo2> map = container.getInfoMap();
List<IScannerInfoConsoleParser> clParserList = new ArrayList<IScannerInfoConsoleParser>(); List<IConsoleParser> clParserList = new ArrayList<IConsoleParser>();
if(container.isPerRcTypeDiscovery()){ if(container.isPerRcTypeDiscovery()){
for (IResourceInfo rcInfo : cfg.getResourceInfos()) { for (IResourceInfo rcInfo : cfg.getResourceInfos()) {
@ -370,9 +384,27 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
contributeToConsoleParserList(project, map, new CfgInfoContext(cfg), workingDirectory, markerGenerator, collector, clParserList); contributeToConsoleParserList(project, map, new CfgInfoContext(cfg), workingDirectory, markerGenerator, collector, clParserList);
} }
ICConfigurationDescription cfgDescription = ManagedBuildManager.getDescriptionForConfiguration(cfg);
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
List<ILanguageSettingsProvider> lsProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
for (ILanguageSettingsProvider lsProvider : lsProviders) {
ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(lsProvider);
if (rawProvider instanceof ICConsoleParser) {
ICConsoleParser consoleParser = (ICConsoleParser) rawProvider;
try {
consoleParser.startup(cfgDescription);
clParserList.add(consoleParser);
} catch (CoreException e) {
ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID,
"Language Settings Provider failed to start up", e)); //$NON-NLS-1$
}
}
}
}
if(clParserList.size() != 0){ if(clParserList.size() != 0){
return new ConsoleOutputSniffer(outputStream, errorStream, IConsoleParser[] parsers = clParserList.toArray(new IConsoleParser[clParserList.size()]);
clParserList.toArray(new IScannerInfoConsoleParser[clParserList.size()])); return new ConsoleOutputSniffer(outputStream, errorStream, parsers, epm);
} }
return null; return null;
@ -385,13 +417,18 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
IPath workingDirectory, IPath workingDirectory,
IMarkerGenerator markerGenerator, IMarkerGenerator markerGenerator,
IScannerInfoCollector collector, IScannerInfoCollector collector,
List<IScannerInfoConsoleParser> parserList){ List<IConsoleParser> parserList){
IScannerConfigBuilderInfo2 info = map.get(context); IScannerConfigBuilderInfo2 info = map.get(context);
InfoContext ic = context.toInfoContext(); InfoContext ic = context.toInfoContext();
boolean added = false; boolean added = false;
if (info != null && if (info != null) {
info.isAutoDiscoveryEnabled() && boolean autodiscoveryEnabled2 = info.isAutoDiscoveryEnabled();
info.isBuildOutputParserEnabled()) { if (autodiscoveryEnabled2) {
IConfiguration cfg = context.getConfiguration();
ICConfigurationDescription cfgDescription = ManagedBuildManager.getDescriptionForConfiguration(cfg);
autodiscoveryEnabled2 = ScannerDiscoveryLegacySupport.isMbsLanguageSettingsProviderOn(cfgDescription);
}
if (autodiscoveryEnabled2 && info.isBuildOutputParserEnabled()) {
String id = info.getSelectedProfileId(); String id = info.getSelectedProfileId();
ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(id); ScannerConfigProfile profile = ScannerConfigProfileManager.getInstance().getSCProfileConfiguration(id);
@ -413,8 +450,8 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
} }
} }
}
return added; return added;
} }
} }

View file

@ -46,6 +46,8 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont
// Schema element names // Schema element names
public static final String CONFIGURATION_ELEMENT_NAME = "configuration"; //$NON-NLS-1$ public static final String CONFIGURATION_ELEMENT_NAME = "configuration"; //$NON-NLS-1$
public static final String ERROR_PARSERS = "errorParsers"; //$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 EXTENSION = "artifactExtension"; //$NON-NLS-1$
public static final String PARENT = "parent"; //$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(); 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 * 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 * 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 // The attribute name for the scanner info collector
public static final String SCANNER_CONFIG_PROFILE_ID = "scannerConfigDiscoveryProfileId"; //$NON-NLS-1$ 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. * 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); 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. * Returns the scanner config discovery profile id or <code>null</code> if none.
* *

View file

@ -13,14 +13,23 @@ package org.eclipse.cdt.managedbuilder.core;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.make.core.scannerconfig.AbstractBuildCommandParser;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager; import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildDescription;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStateManager; import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStateManager;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DescriptionBuilder; import org.eclipse.cdt.managedbuilder.internal.buildmodel.DescriptionBuilder;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.IBuildModelBuilder; import org.eclipse.cdt.managedbuilder.internal.buildmodel.IBuildModelBuilder;
@ -35,6 +44,7 @@ import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
@ -61,6 +71,21 @@ public class InternalBuildRunner extends AbstractBuildRunner {
private static final String NOTHING_BUILT = "ManagedMakeBuilder.message.no.build"; //$NON-NLS-1$ private static final String NOTHING_BUILT = "ManagedMakeBuilder.message.no.build"; //$NON-NLS-1$
private static final String BUILD_ERROR = "ManagedMakeBuilder.message.error"; //$NON-NLS-1$ private static final String BUILD_ERROR = "ManagedMakeBuilder.message.error"; //$NON-NLS-1$
// TODO: same function is present in CommandBuilder and BuildProcessManager
private String[] mapToStringArray(Map<String, String> map){
if(map == null)
return null;
List<String> list = new ArrayList<String>();
for (Entry<String, String> entry : map.entrySet()) {
list.add(entry.getKey() + '=' + entry.getValue());
}
return list.toArray(new String[list.size()]);
}
@Override @Override
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration, public boolean invokeBuild(int kind, IProject project, IConfiguration configuration,
IBuilder builder, IConsole console, IMarkerGenerator markerGenerator, IBuilder builder, IConsole console, IMarkerGenerator markerGenerator,
@ -96,6 +121,16 @@ public class InternalBuildRunner extends AbstractBuildRunner {
// Get a build console for the project // Get a build console for the project
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, cBS, delta, flags);
IPath workingDirectory = des.getDefaultBuildDirLocation();
String[] env = null;
if (des instanceof BuildDescription) {
Map<String, String> envMap = ((BuildDescription)des).getEnvironment();
env = mapToStringArray(envMap);
}
consoleOutStream = console.getOutputStream(); consoleOutStream = console.getOutputStream();
String[] consoleHeader = new String[3]; String[] consoleHeader = new String[3];
if(buildIncrementaly) if(buildIncrementaly)
@ -119,11 +154,29 @@ public class InternalBuildRunner extends AbstractBuildRunner {
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
} }
if (kind!=IncrementalProjectBuilder.CLEAN_BUILD) {
// TODO - AG - sanity check? elaborate
ICConfigurationDescription cfgDescription = ManagedBuildManager.getDescriptionForConfiguration(configuration);
if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
for (ILanguageSettingsProvider provider : providers) {
if (provider instanceof AbstractBuildCommandParser) {
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
String msg = ManagedMakeMessages.getFormattedString("BOP Language Settings Provider [{0}] is not supported by Internal Builder.", provider.getName());
buf.append("**** "+msg+" ****");
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
ManagedBuilderCorePlugin.error(msg);
}
}
}
}
consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.write(buf.toString().getBytes());
consoleOutStream.flush(); consoleOutStream.flush();
IBuildDescription des = BuildDescriptionManager.createBuildDescription(configuration, cBS, delta, flags);
DescriptionBuilder dBuilder = null; DescriptionBuilder dBuilder = null;
if (!isParallel) if (!isParallel)
dBuilder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr, cBS); dBuilder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr, cBS);
@ -192,6 +245,7 @@ public class InternalBuildRunner extends AbstractBuildRunner {
consoleOutStream.flush(); consoleOutStream.flush();
epmOutputStream.close(); epmOutputStream.close();
epmOutputStream = null; epmOutputStream = null;
// Generate any error markers that the build has discovered // Generate any error markers that the build has discovered
monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS)); monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS));
@ -238,5 +292,4 @@ public class InternalBuildRunner extends AbstractBuildRunner {
} }
return false; return false;
} }
} }

View file

@ -148,7 +148,6 @@ import org.w3c.dom.ProcessingInstruction;
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class ManagedBuildManager extends AbstractCExtension { public class ManagedBuildManager extends AbstractCExtension {
// private static final QualifiedName buildInfoProperty = new QualifiedName(ManagedBuilderCorePlugin.PLUGIN_ID, "managedBuildInfo"); //$NON-NLS-1$ // private static final QualifiedName buildInfoProperty = new QualifiedName(ManagedBuilderCorePlugin.PLUGIN_ID, "managedBuildInfo"); //$NON-NLS-1$
private static final String ROOT_NODE_NAME = "ManagedProjectBuildInfo"; //$NON-NLS-1$ private static final String ROOT_NODE_NAME = "ManagedProjectBuildInfo"; //$NON-NLS-1$
public static final String SETTINGS_FILE_NAME = ".cdtbuild"; //$NON-NLS-1$ public static final String SETTINGS_FILE_NAME = ".cdtbuild"; //$NON-NLS-1$

View file

@ -145,6 +145,7 @@ public class CommonBuilder extends ACBuilder {
private final IConfiguration fCfg; private final IConfiguration fCfg;
private final IBuilder fBuilder; private final IBuilder fBuilder;
private IConsole fConsole; private IConsole fConsole;
CfgBuildInfo(IBuilder builder, boolean isForegound){ CfgBuildInfo(IBuilder builder, boolean isForegound){
this.fBuilder = builder; this.fBuilder = builder;
this.fCfg = builder.getParent().getParent(); this.fCfg = builder.getParent().getParent();

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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache; 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.ErrorParserManager;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CLibraryFileEntry; import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
@ -86,8 +87,10 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Version; import org.osgi.framework.Version;
@ -95,6 +98,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
private static final String EMPTY_STRING = ""; //$NON-NLS-1$ 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 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 // Parent and children
private String parentId; private String parentId;
@ -105,6 +109,8 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
private String cleanCommand; private String cleanCommand;
private String artifactExtension; private String artifactExtension;
private String errorParserIds; private String errorParserIds;
private String defaultLanguageSettingsProvidersAttribute;
private String[] defaultLanguageSettingsProvidersIds;
private String prebuildStep; private String prebuildStep;
private String postbuildStep; private String postbuildStep;
private String preannouncebuildStep; private String preannouncebuildStep;
@ -784,6 +790,9 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
// Get the semicolon separated list of IDs of the error parsers // Get the semicolon separated list of IDs of the error parsers
errorParserIds = SafeStringInterner.safeIntern(element.getAttribute(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 // Get the artifact extension
artifactExtension = SafeStringInterner.safeIntern(element.getAttribute(EXTENSION)); artifactExtension = SafeStringInterner.safeIntern(element.getAttribute(EXTENSION));
@ -1456,6 +1465,55 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return set; 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) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#setArtifactExtension(java.lang.String) * @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.StringTokenizer;
import java.util.Vector; 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.ILanguage;
import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.ICStorageElement; 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.internal.core.SafeStringInterner;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput; import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IBuildObject; 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.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IInputOrder; import org.eclipse.cdt.managedbuilder.core.IInputOrder;
import org.eclipse.cdt.managedbuilder.core.IInputType; 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.internal.enablement.OptionEnablementExpression;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType; import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -1838,9 +1841,56 @@ public class InputType extends BuildObject implements IInputType {
return id; 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(){ public String getDiscoveryProfileIdAttribute(){
if(buildInfoDicsoveryProfileId == null && superClass != null) if (!isLanguageSettingsProvidersFunctionalityEnabled())
return ((InputType)superClass).getDiscoveryProfileIdAttribute(); 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; return buildInfoDicsoveryProfileId;
} }

View file

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

View file

@ -24,6 +24,7 @@ import java.util.SortedMap;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.PathInfoCache; 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.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData; import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; 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.dataprovider.ConfigurationDataProvider;
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression; import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier; 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.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtension;
@ -85,6 +88,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
private String targetToolIds; private String targetToolIds;
private String secondaryOutputIds; private String secondaryOutputIds;
private Boolean isAbstract; private Boolean isAbstract;
private String defaultLanguageSettingsProvidersIds;
private String scannerConfigDiscoveryProfileId; private String scannerConfigDiscoveryProfileId;
private String versionsSupported; private String versionsSupported;
private String convertToId; private String convertToId;
@ -554,6 +558,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
// Get the target tool id // Get the target tool id
targetToolIds = SafeStringInterner.safeIntern(element.getAttribute(TARGET_TOOL)); 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 // Get the scanner config discovery profile id
scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID)); scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID));
String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY); String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
@ -1529,15 +1536,69 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
setDirty(true); setDirty(true);
} }
/* (non-Javadoc) @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() * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getScannerConfigDiscoveryProfileId()
*/ */
@Override @Override
public String getScannerConfigDiscoveryProfileId() { public String getScannerConfigDiscoveryProfileId() {
if (scannerConfigDiscoveryProfileId == null) { if (!isLanguageSettingsProvidersFunctionalityEnabled())
if (getSuperClass() != null) { return getLegacyScannerConfigDiscoveryProfileId();
return getSuperClass().getScannerConfigDiscoveryProfileId();
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; return scannerConfigDiscoveryProfileId;
} }

View file

@ -19,6 +19,10 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigInfoFactory2; 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.ILanguageDescriptor;
import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -532,28 +536,74 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
} }
@Override @Override
public CConfigurationData loadConfiguration(ICConfigurationDescription des, public CConfigurationData loadConfiguration(ICConfigurationDescription cfgDescription, IProgressMonitor monitor) throws CoreException {
IProgressMonitor monitor) if(cfgDescription.isPreferenceConfiguration())
throws CoreException { return loadPreferences(cfgDescription);
if(des.isPreferenceConfiguration())
return loadPreferences(des);
IManagedBuildInfo info = getBuildInfo(des); IManagedBuildInfo info = getBuildInfo(cfgDescription);
Configuration cfg = load(des, (ManagedProject)info.getManagedProject(), false); Configuration cfg = load(cfgDescription, (ManagedProject)info.getManagedProject(), false);
if(cfg != null){ if(cfg != null){
cfg.setConfigurationDescription(des); cfg.setConfigurationDescription(cfgDescription);
info.setValid(true); info.setValid(true);
setPersistedFlag(des); setPersistedFlag(cfgDescription);
cacheNaturesIdsUsedOnCache(des); cacheNaturesIdsUsedOnCache(cfgDescription);
// Update the ManagedBuildInfo in the ManagedBuildManager map. Doing this creates a barrier for subsequent // Update the ManagedBuildInfo in the ManagedBuildManager map. Doing this creates a barrier for subsequent
// ManagedBuildManager#getBuildInfo(...) see Bug 305146 for more // ManagedBuildManager#getBuildInfo(...) see Bug 305146 for more
ManagedBuildManager.setLoaddedBuildInfo(des.getProjectDescription().getProject(), info); ManagedBuildManager.setLoaddedBuildInfo(cfgDescription.getProjectDescription().getProject(), info);
setDefaultLanguageSettingsProvidersIds(cfg, cfgDescription);
return cfg.getConfigurationData(); return cfg.getConfigurationData();
} }
return null; 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);
}
}
if (providers.isEmpty()) {
// Add MBS and User provider for unsuspecting toolchains (backward compatibility)
ILanguageSettingsProvider userProvider = LanguageSettingsManager.getExtensionProviderCopy(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, true);
ILanguageSettingsProvider mbsProvider = LanguageSettingsManager.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID);
providers.add(userProvider);
providers.add(mbsProvider);
}
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 cfgDes){ private boolean isPersistedCfg(ICConfigurationDescription cfgDes){
return cfgDes.getSessionProperty(CFG_PERSISTED_PROPERTY) != null; return cfgDes.getSessionProperty(CFG_PERSISTED_PROPERTY) != null;
} }

View file

@ -0,0 +1,125 @@
/*******************************************************************************
* Copyright (c) 2009, 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.managedbuilder.internal.scannerconfig;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsEditableProvider;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.managedbuilder.scannerconfig.ToolchainBuiltinSpecsDetector;
import org.eclipse.core.runtime.CoreException;
/**
* Language settings provider to detect built-in compiler settings for GCC compiler.
*/
public class GCCBuiltinSpecsDetector extends ToolchainBuiltinSpecsDetector implements ILanguageSettingsEditableProvider {
// ID must match the toolchain definition in org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point
private static final String GCC_TOOLCHAIN_ID = "cdt.managedbuild.toolchain.gnu.base"; //$NON-NLS-1$
private enum State {NONE, EXPECTING_LOCAL_INCLUDE, EXPECTING_SYSTEM_INCLUDE, EXPECTING_FRAMEWORKS}
private State state = State.NONE;
@SuppressWarnings("nls")
private static final AbstractOptionParser[] optionParsers = {
new IncludePathOptionParser("#include \"(\\S.*)\"", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.LOCAL),
new IncludePathOptionParser("#include <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
new IncludePathOptionParser("#framework <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.FRAMEWORKS_MAC),
new MacroOptionParser("#define\\s+(\\S*\\(.*?\\))\\s*(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
new MacroOptionParser("#define\\s+(\\S*)\\s*(\\S*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
};
@Override
protected String getToolchainId() {
return GCC_TOOLCHAIN_ID;
}
@Override
protected AbstractOptionParser[] getOptionParsers() {
return optionParsers;
}
private List<String> makeList(final String line) {
return new ArrayList<String>() {{ add(line); }};
}
@Override
protected List<String> parseForOptions(String line) {
line = line.trim();
// contribution of -dD option
if (line.startsWith("#define")) {
return makeList(line);
}
// contribution of includes
if (line.equals("#include \"...\" search starts here:")) {
state = State.EXPECTING_LOCAL_INCLUDE;
} else if (line.equals("#include <...> search starts here:")) {
state = State.EXPECTING_SYSTEM_INCLUDE;
} else if (line.startsWith("End of search list.")) {
state = State.NONE;
} else if (line.equals("Framework search starts here:")) {
state = State.EXPECTING_FRAMEWORKS;
} else if (line.startsWith("End of framework search list.")) {
state = State.NONE;
} else if (state==State.EXPECTING_LOCAL_INCLUDE) {
// making that up for the parser to figure out
line = "#include \""+line+"\"";
return makeList(line);
} else {
String frameworkIndicator = "(framework directory)";
if (state==State.EXPECTING_SYSTEM_INCLUDE) {
// making that up for the parser to figure out
if (line.contains(frameworkIndicator)) {
line = "#framework <"+line.replace(frameworkIndicator, "").trim()+">";
} else {
line = "#include <"+line+">";
}
return makeList(line);
} else if (state==State.EXPECTING_FRAMEWORKS) {
// making that up for the parser to figure out
line = "#framework <"+line.replace(frameworkIndicator, "").trim()+">";
return makeList(line);
}
}
return null;
}
@Override
public void startup(ICConfigurationDescription cfgDescription) throws CoreException {
super.startup(cfgDescription);
state = State.NONE;
}
@Override
public void shutdown() {
state = State.NONE;
super.shutdown();
}
@Override
public GCCBuiltinSpecsDetector cloneShallow() throws CloneNotSupportedException {
return (GCCBuiltinSpecsDetector) super.cloneShallow();
}
@Override
public GCCBuiltinSpecsDetector clone() throws CloneNotSupportedException {
return (GCCBuiltinSpecsDetector) super.clone();
}
}

View file

@ -0,0 +1,81 @@
/*******************************************************************************
* Copyright (c) 2009, 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.managedbuilder.internal.scannerconfig;
import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.core.resources.IResource;
/**
* Class to detect built-in compiler settings.
* The paths are converted to cygwin "filesystem" representation. Then
*
*/
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);
}
}
@SuppressWarnings("nls")
private static final AbstractOptionParser[] optionParsers = {
new IncludePathOptionParser("#include \"(\\S.*)\"", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.LOCAL),
new IncludePathOptionParser("#include <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
new MacroOptionParser("#define (\\S*\\(.*?\\)) *(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
new MacroOptionParser("#define (\\S*) *(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
};
@Override
protected AbstractOptionParser[] getOptionParsers() {
return optionParsers;
}
@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

@ -0,0 +1,151 @@
/*******************************************************************************
* Copyright (c) 2009, 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.managedbuilder.internal.scannerconfig;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsBroadcastingProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICFileDescription;
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.core.settings.model.ICSettingBase;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
/**
* Implementation of language settings provider for CDT Managed Build System.
*/
public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsBroadcastingProvider {
@Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
IPath projectPath = rc.getProjectRelativePath();
ICLanguageSetting[] languageSettings = null;
if (rc instanceof IFile) {
ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(projectPath, true);
if (ls != null) {
languageSettings = new ICLanguageSetting[] {ls};
} else {
return getSettingEntries(cfgDescription, rc.getParent(), languageId);
}
} else {
ICResourceDescription rcDescription = cfgDescription.getResourceDescription(projectPath, false);
languageSettings = getLanguageSettings(rcDescription);
}
List<ICLanguageSettingEntry> list = new ArrayList<ICLanguageSettingEntry>();
if (languageSettings != null) {
for (ICLanguageSetting langSetting : languageSettings) {
if (langSetting!=null) {
String id = langSetting.getLanguageId();
if (id!=null && id.equals(languageId)) {
int kindsBits = langSetting.getSupportedEntryKinds();
for (int kind=1;kind<=kindsBits;kind<<=1) {
if ((kindsBits & kind) != 0) {
list.addAll(langSetting.getSettingEntriesList(kind));
}
}
} else {
// System.err.println("languageSetting id=null: name=" + languageSetting.getName());
}
} else {
System.err.println("languageSetting=null: rc=" + rc);
}
}
}
return LanguageSettingsStorage.getPooledList(list);
}
private ICLanguageSetting[] getLanguageSettings(ICResourceDescription rcDescription) {
ICLanguageSetting[] array = null;
switch (rcDescription.getType()) {
case ICSettingBase.SETTING_PROJECT:
case ICSettingBase.SETTING_CONFIGURATION:
case ICSettingBase.SETTING_FOLDER:
ICFolderDescription foDes = (ICFolderDescription)rcDescription;
array = foDes.getLanguageSettings();
break;
case ICSettingBase.SETTING_FILE:
ICFileDescription fiDes = (ICFileDescription)rcDescription;
ICLanguageSetting ls = fiDes.getLanguageSetting();
if (ls!=null) {
array = new ICLanguageSetting[] { ls };
}
}
if (array==null) {
array = new ICLanguageSetting[0];
}
return array;
}
public void setSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId,
List<ICLanguageSettingEntry> entries) {
// lang.setSettingEntries(kind, entries);
IPath projectPath = rc.getProjectRelativePath();
ICResourceDescription rcDescription = cfgDescription.getResourceDescription(projectPath, false);
for (ICLanguageSetting languageSetting : getLanguageSettings(rcDescription)) {
if (languageSetting!=null) {
String id = languageSetting.getLanguageId();
if (id!=null && id.equals(languageId)) {
int kindsBits = languageSetting.getSupportedEntryKinds();
for (int kind=1;kind<=kindsBits;kind<<=1) {
if ((kindsBits & kind) != 0) {
List<ICLanguageSettingEntry> list = new ArrayList<ICLanguageSettingEntry>(entries.size());
for (ICLanguageSettingEntry entry : entries) {
if (entry.getKind()==kind) {
list.add(entry);
}
}
languageSetting.setSettingEntries(kind, list);
}
}
} else {
// System.err.println("languageSetting id=null: name=" + languageSetting.getName());
}
} else {
System.err.println("languageSetting=null: rcDescription=" + rcDescription.getName());
}
}
}
@Override
public LanguageSettingsStorage copyStorage() {
class PretendStorage extends LanguageSettingsStorage {
@Override
public boolean isEmpty() {
return false;
}
@Override
public LanguageSettingsStorage clone() throws CloneNotSupportedException {
return this;
}
@Override
public boolean equals(Object obj) {
// Note that this always triggers change event even if nothing changed in MBS
return false;
}
}
return new PretendStorage();
}
}

View file

@ -0,0 +1,88 @@
/*******************************************************************************
* Copyright (c) 2009, 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.managedbuilder.scannerconfig;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.make.core.scannerconfig.AbstractBuiltinSpecsDetector;
import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
/**
* Abstract parser capable to execute compiler command printing built-in compiler
* specs and parse built-in language settings out of it. The compiler to be used
* is taken from MBS tool-chain definition.
*
* @since 8.1
*/
public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecsDetector {
private Map<String, ITool> toolMap = new HashMap<String, ITool>();
/**
* TODO
*/
protected abstract String getToolchainId();
private ITool getTool(String languageId) {
ITool langTool = toolMap.get(languageId);
if (langTool != null) {
return langTool;
}
String toolchainId = getToolchainId();
IToolChain toolchain = ManagedBuildManager.getExtensionToolChain(toolchainId);
if (toolchain != null) {
ITool[] tools = toolchain.getTools();
for (ITool tool : tools) {
IInputType[] inputTypes = tool.getInputTypes();
for (IInputType inType : inputTypes) {
String lang = inType.getLanguageId(tool);
if (languageId.equals(lang)) {
toolMap.put(languageId, tool);
return tool;
}
}
}
}
ManagedBuilderCorePlugin.error("Unable to find tool in toolchain="+toolchainId+" for language="+languageId);
return null;
}
@Override
protected String getCompilerCommand(String languageId) {
ITool tool = getTool(languageId);
String compiler = tool.getToolCommand();
if (compiler.length() == 0) {
String msg = "Unable to find compiler command in toolchain="+getToolchainId();
ManagedBuilderCorePlugin.error(msg);
}
return compiler;
}
@Override
protected String getSpecFileExtension(String languageId) {
String ext = null;
ITool tool = getTool(languageId);
String[] srcFileExtensions = tool.getAllInputExtensions();
if (srcFileExtensions != null && srcFileExtensions.length > 0) {
ext = srcFileExtensions[0];
}
if (ext == null || ext.length() == 0) {
ManagedBuilderCorePlugin.error("Unable to find file extension for language "+languageId);
}
return ext;
}
}

View file

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

View file

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

View file

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

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,7 @@ Source.location=Source Location
Output.location=Output Location Output.location=Output Location
Binary.parsers=Binary Parsers Binary.parsers=Binary Parsers
Error.parsers=Error Parsers Error.parsers=Error Parsers
Language.settings.providers=Discovery
Data.hierarchy=Data Hierarchy Data.hierarchy=Data Hierarchy
Preferred.toolchains=Preferred Toolchains Preferred.toolchains=Preferred Toolchains
Wizard.defaults=Wizard Defaults Wizard.defaults=Wizard Defaults

View file

@ -648,5 +648,14 @@
</description> </description>
</wizard> </wizard>
</extension> </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>
</extension>
</plugin> </plugin>

View file

@ -211,6 +211,7 @@ public class Messages extends NLS {
public static String PropertyPageDefsTab_8; public static String PropertyPageDefsTab_8;
public static String PropertyPageDefsTab_9; public static String PropertyPageDefsTab_9;
public static String PropertyPageDefsTab_showIncludeFileTab; public static String PropertyPageDefsTab_showIncludeFileTab;
public static String PropertyPageDefsTab_showProvidersTab;
public static String RefreshPolicyExceptionDialog_addDialogLabel; public static String RefreshPolicyExceptionDialog_addDialogLabel;
public static String RefreshPolicyExceptionDialog_AddExceptionInfoDialog_message; public static String RefreshPolicyExceptionDialog_AddExceptionInfoDialog_message;
public static String RefreshPolicyExceptionDialog_AddExceptionInfoDialog_title; public static String RefreshPolicyExceptionDialog_AddExceptionInfoDialog_title;

View file

@ -273,6 +273,7 @@ PropertyPageDefsTab_7=Show disc. page names if they are unique. Else show profil
PropertyPageDefsTab_8=Always show names + profile IDs PropertyPageDefsTab_8=Always show names + profile IDs
PropertyPageDefsTab_9=Always show profile IDs only PropertyPageDefsTab_9=Always show profile IDs only
PropertyPageDefsTab_showIncludeFileTab=Display "Include Files" tab PropertyPageDefsTab_showIncludeFileTab=Display "Include Files" tab
PropertyPageDefsTab_showProvidersTab=Display new experimental Scanner Discovery Providers tabs
ProjectConvert_convertersList=Converters List ProjectConvert_convertersList=Converters List
AbstractPrefPage_0=\ Preference settings will be applied to new projects \n only when there were no toolchains selected. AbstractPrefPage_0=\ Preference settings will be applied to new projects \n only when there were no toolchains selected.

View file

@ -12,9 +12,9 @@
package org.eclipse.cdt.managedbuilder.ui.preferences; package org.eclipse.cdt.managedbuilder.ui.preferences;
import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab; import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.CDTPrefUtil; import org.eclipse.cdt.ui.newui.CDTPrefUtil;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
@ -38,6 +38,7 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
private Button show_mng; private Button show_mng;
private Button show_tool; private Button show_tool;
private Button show_exp; private Button show_exp;
private Button show_providers_tab; // temporary checkbox for scanner discovery Providers tab
private Button show_tipbox; private Button show_tipbox;
private Button b_0; private Button b_0;
@ -74,6 +75,11 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
show_exp.setText(Messages.PropertyPageDefsTab_10); show_exp.setText(Messages.PropertyPageDefsTab_10);
show_exp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); show_exp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
show_providers_tab = new Button(usercomp, SWT.CHECK);
show_providers_tab.setText(Messages.PropertyPageDefsTab_showProvidersTab + ", " //$NON-NLS-1$
+ org.eclipse.cdt.internal.ui.newui.Messages.CDTMainWizardPage_TrySD90);
show_providers_tab.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
show_tipbox = new Button(usercomp, SWT.CHECK); show_tipbox = new Button(usercomp, SWT.CHECK);
show_tipbox.setText(Messages.PropertyPageDefsTab_16); show_tipbox.setText(Messages.PropertyPageDefsTab_16);
show_tipbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 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_mng.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG));
show_tool.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOTOOLM)); show_tool.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOTOOLM));
show_exp.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_EXPORT)); show_exp.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_EXPORT));
show_providers_tab.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NO_SHOW_PROVIDERS));
show_tipbox.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_TIPBOX)); show_tipbox.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_TIPBOX));
switch (CDTPrefUtil.getInt(CDTPrefUtil.KEY_DISC_NAMES)) { 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_NOMNG, !show_mng.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOTOOLM, !show_tool.getSelection()); CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOTOOLM, !show_tool.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_EXPORT, show_exp.getSelection()); CDTPrefUtil.setBool(CDTPrefUtil.KEY_EXPORT, show_exp.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NO_SHOW_PROVIDERS, !show_providers_tab.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_TIPBOX, show_tipbox.getSelection()); CDTPrefUtil.setBool(CDTPrefUtil.KEY_TIPBOX, show_tipbox.getSelection());
int x = 0; int x = 0;
if (b_1.getSelection()) x = 1; if (b_1.getSelection()) x = 1;
@ -160,6 +168,7 @@ public class PropertyPageDefsTab extends AbstractCPropertyTab {
show_mng.setSelection(true); show_mng.setSelection(true);
show_tool.setSelection(true); show_tool.setSelection(true);
show_exp.setSelection(false); show_exp.setSelection(false);
show_providers_tab.setSelection(false);
show_tipbox.setSelection(false); show_tipbox.setSelection(false);
b_0.setSelection(true); b_0.setSelection(true);
b_1.setSelection(false); b_1.setSelection(false);

View file

@ -30,6 +30,7 @@ public class WizardDefaultsTab extends AbstractCPropertyTab {
private Button show_sup; private Button show_sup;
private Button show_oth; private Button show_oth;
private Button checkBoxTryNewSD;
@Override @Override
public void createControls(Composite parent) { public void createControls(Composite parent) {
@ -44,20 +45,27 @@ public class WizardDefaultsTab extends AbstractCPropertyTab {
show_oth.setText(Messages.WizardDefaultsTab_1); show_oth.setText(Messages.WizardDefaultsTab_1);
show_oth.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 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_sup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP));
show_oth.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_OTHERS)); show_oth.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_OTHERS));
checkBoxTryNewSD.setSelection(CDTPrefUtil.getBool(CDTPrefUtil.KEY_NEWSD));
} }
@Override @Override
protected void performOK() { protected void performOK() {
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOSUPP, !show_sup.getSelection()); CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOSUPP, !show_sup.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_OTHERS, show_oth.getSelection()); CDTPrefUtil.setBool(CDTPrefUtil.KEY_OTHERS, show_oth.getSelection());
CDTPrefUtil.setBool(CDTPrefUtil.KEY_NEWSD, checkBoxTryNewSD.getSelection());
} }
@Override @Override
protected void performDefaults() { protected void performDefaults() {
show_sup.setSelection(true); show_sup.setSelection(true);
show_oth.setSelection(false); show_oth.setSelection(false);
checkBoxTryNewSD.setSelection(true);
} }
@Override @Override

View file

@ -24,10 +24,12 @@ 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.CfgDiscoveredPathManager;
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgScannerConfigUtil; import org.eclipse.cdt.build.internal.core.scannerconfig.CfgScannerConfigUtil;
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager; 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.model.util.CDTListComparator;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.internal.ui.newui.StatusMessageLine;
import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2; import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2Set; import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2Set;
@ -46,7 +48,9 @@ import org.eclipse.cdt.managedbuilder.core.IInputType;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain; 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.managedbuilder.internal.ui.Messages;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.newui.CDTPrefUtil; import org.eclipse.cdt.ui.newui.CDTPrefUtil;
import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.cdt.utils.ui.controls.TabFolderLayout; import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
@ -103,6 +107,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
private Button reportProblemsCheckBox; private Button reportProblemsCheckBox;
private Combo profileComboBox; private Combo profileComboBox;
private Composite profileOptionsComposite; private Composite profileOptionsComposite;
private Button clearButton;
private ICfgScannerConfigBuilderInfo2Set cbi; private ICfgScannerConfigBuilderInfo2Set cbi;
private Map<InfoContext, IScannerConfigBuilderInfo2> baseInfoMap; private Map<InfoContext, IScannerConfigBuilderInfo2> baseInfoMap;
@ -116,6 +121,8 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
private DiscoveryPageWrapper wrapper = null; private DiscoveryPageWrapper wrapper = null;
private StatusMessageLine fStatusLine;
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -184,6 +191,9 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
profileOptionsComposite.setLayoutData(gd); profileOptionsComposite.setLayoutData(gd);
profileOptionsComposite.setLayout(new TabFolderLayout()); profileOptionsComposite.setLayout(new TabFolderLayout());
fStatusLine = new StatusMessageLine(usercomp, SWT.LEFT, 2);
setEnablement();
sashForm.setWeights(DEFAULT_SASH_WEIGHTS); sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
} }
@ -236,7 +246,7 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
Label clearLabel = ControlFactory.createLabel(autoDiscoveryGroup, Messages.DiscoveryTab_ClearDisoveredEntries); Label clearLabel = ControlFactory.createLabel(autoDiscoveryGroup, Messages.DiscoveryTab_ClearDisoveredEntries);
// "Clear" button // "Clear" button
Button clearButton = ControlFactory.createPushButton(autoDiscoveryGroup, Messages.DiscoveryTab_Clear); clearButton = ControlFactory.createPushButton(autoDiscoveryGroup, Messages.DiscoveryTab_Clear);
GridData gd = (GridData) clearButton.getLayoutData(); GridData gd = (GridData) clearButton.getLayoutData();
gd.grabExcessHorizontalSpace = true; gd.grabExcessHorizontalSpace = true;
//Bug 331783 - NLS: "Clear" button label in Makefile Project preferences truncated //Bug 331783 - NLS: "Clear" button label in Makefile Project preferences truncated
@ -334,6 +344,27 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
} else { } else {
setVisibility(Messages.DiscoveryTab_6); setVisibility(Messages.DiscoveryTab_6);
} }
setEnablement();
}
private void setEnablement() {
IStatus status = null;
ICConfigurationDescription cfgDescription = page.getResDesc().getConfiguration();
boolean isEnabled = 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) { private void setVisibility(String errMsg) {
@ -372,7 +403,13 @@ public class DiscoveryTab extends AbstractCBuildPropertyTab implements IBuildInf
buildInfo = (IScannerConfigBuilderInfo2) ti.getData("info"); //$NON-NLS-1$ buildInfo = (IScannerConfigBuilderInfo2) ti.getData("info"); //$NON-NLS-1$
String selectedProfileId = buildInfo.getSelectedProfileId(); String selectedProfileId = buildInfo.getSelectedProfileId();
iContext = (CfgInfoContext) ti.getData("cont"); //$NON-NLS-1$ 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.isMbsLanguageSettingsProviderOn(cfgDescription);
}
autoDiscoveryCheckBox.setSelection(autodiscoveryEnabled2
&& !selectedProfileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID)); && !selectedProfileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID));
reportProblemsCheckBox.setSelection(buildInfo.isProblemReportingEnabled()); reportProblemsCheckBox.setSelection(buildInfo.isProblemReportingEnabled());

View file

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

View file

@ -11,10 +11,17 @@
package org.eclipse.cdt.managedbuilder.ui.wizards; package org.eclipse.cdt.managedbuilder.ui.wizards;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
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.CoreModel; 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.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
@ -25,6 +32,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject; import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain; 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.internal.ui.Messages;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin; import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -69,6 +77,7 @@ public class NewMakeProjFromExisting extends Wizard implements IImportWizard, IN
final String locationStr = page.getLocation(); final String locationStr = page.getLocation();
final boolean isCPP = page.isCPP(); final boolean isCPP = page.isCPP();
final IToolChain toolChain = page.getToolChain(); final IToolChain toolChain = page.getToolChain();
final boolean isTryingNewSD = page.isTryingNewSD();
IRunnableWithProgress op = new WorkspaceModifyOperation() { IRunnableWithProgress op = new WorkspaceModifyOperation() {
@Override @Override
@ -110,7 +119,21 @@ public class NewMakeProjFromExisting extends Wizard implements IImportWizard, IN
IBuilder builder = config.getEditableBuilder(); IBuilder builder = config.getEditableBuilder();
builder.setManagedBuildOn(false); builder.setManagedBuildOn(false);
CConfigurationData data = config.getConfigurationData(); 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 {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(LanguageSettingsManager.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers);
}
} else {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false);
}
monitor.worked(1); monitor.worked(1);
pdMgr.setProjectDescription(project, projDesc); pdMgr.setProjectDescription(project, projDesc);

View file

@ -19,6 +19,8 @@ import java.util.Map;
import org.eclipse.cdt.managedbuilder.core.IToolChain; import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages; 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.IProject;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
@ -52,6 +54,9 @@ public class NewMakeProjFromExistingPage extends WizardPage {
List tcList; List tcList;
Map<String, IToolChain> tcMap = new HashMap<String, IToolChain>(); Map<String, IToolChain> tcMap = new HashMap<String, IToolChain>();
private Button checkBoxTryNewSD;
protected NewMakeProjFromExistingPage() { protected NewMakeProjFromExistingPage() {
super(Messages.NewMakeProjFromExistingPage_0); super(Messages.NewMakeProjFromExistingPage_0);
setTitle(Messages.NewMakeProjFromExistingPage_1); setTitle(Messages.NewMakeProjFromExistingPage_1);
@ -72,6 +77,21 @@ public class NewMakeProjFromExistingPage extends WizardPage {
addLanguageSelector(comp); addLanguageSelector(comp);
addToolchainSelector(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(CDTPrefUtil.KEY_NEWSD);
if (contains) {
isTryNewSD = CDTPrefUtil.getBool(CDTPrefUtil.KEY_NEWSD);
}
checkBoxTryNewSD.setSelection(isTryNewSD);
setControl(comp); setControl(comp);
} }
@ -213,4 +233,11 @@ public class NewMakeProjFromExistingPage extends WizardPage {
return selection.length != 0 ? tcMap.get(selection[0]) : null; 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,15 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.wizards; package org.eclipse.cdt.managedbuilder.ui.wizards;
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.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CoreModel; 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.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
@ -23,11 +31,14 @@ import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject; import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain; 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.internal.ui.Messages;
import org.eclipse.cdt.ui.wizards.CDTMainWizardPage;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
/** /**
@ -71,6 +82,7 @@ public class STDWizardHandler extends MBSWizardHandler {
private void setProjectDescription(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor) private void setProjectDescription(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor)
throws CoreException { throws CoreException {
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
ICProjectDescription des = mngr.createProjectDescription(project, false, !onFinish); ICProjectDescription des = mngr.createProjectDescription(project, false, !onFinish);
ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project); ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
@ -99,12 +111,35 @@ public class STDWizardHandler extends MBSWizardHandler {
} }
cfg.setArtifactName(mProj.getDefaultArtifactName()); cfg.setArtifactName(mProj.getDefaultArtifactName());
CConfigurationData data = cfg.getConfigurationData(); 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 {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(LanguageSettingsManager.getWorkspaceProvider(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID));
((ILanguageSettingsProvidersKeeper) cfgDes).setLanguageSettingProviders(providers);
}
} else {
ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, false);
}
monitor.worked(work); monitor.worked(work);
} }
mngr.setProjectDescription(project, des); mngr.setProjectDescription(project, des);
} }
public boolean canCreateWithoutToolchain() { return true; }
public boolean canCreateWithoutToolchain() {
return true;
}
@Override @Override
public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException { public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException {

View file

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2010, 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.core.internal.tests.filesystem.ram;
import java.net.URI;
import org.eclipse.cdt.core.EFSExtensionProvider;
/**
* Test stub to test EFSExtensionProvider mappings.
*
*/
public class MemoryEFSExtensionProvider extends EFSExtensionProvider {
public String getMappedPath(URI locationURI) {
String path = locationURI.getPath();
if (path.contains("/BeingMappedFrom/Folder")) {
return path.replaceFirst("/BeingMappedFrom/Folder", "/LocallyMappedTo/Folder");
}
return super.getMappedPath(locationURI);
}
}

View file

@ -28,6 +28,8 @@ public class AllLanguageSettingsProvidersCoreTests {
suite.addTest(LanguageSettingsManagerTests.suite()); suite.addTest(LanguageSettingsManagerTests.suite());
suite.addTest(LanguageSettingsSerializableProviderTests.suite()); suite.addTest(LanguageSettingsSerializableProviderTests.suite());
suite.addTest(LanguageSettingsPersistenceProjectTests.suite()); suite.addTest(LanguageSettingsPersistenceProjectTests.suite());
suite.addTest(LanguageSettingsListenersTests.suite());
suite.addTest(LanguageSettingsScannerInfoProviderTests.suite());
return suite; return suite;
} }
} }

View file

@ -399,4 +399,13 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
} }
} }
/**
* Check that LanguageSettingsGenericProvider extension defined in plugin.xml is accessible.
*/
public void testExtensionGenericProvider() throws Exception {
ILanguageSettingsProvider provider = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_USER_PROVIDER_ID, true);
assertNotNull("extension " + EXTENSION_USER_PROVIDER_ID + " not found", provider);
assertTrue(provider instanceof LanguageSettingsGenericProvider);
}
} }

View file

@ -17,15 +17,22 @@ import java.util.List;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.AbstractExecutableExtensionBase; 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.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CMacroEntry; import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; 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.ICSettingEntry;
import org.eclipse.cdt.core.testplugin.CModelMock; import org.eclipse.cdt.core.testplugin.CModelMock;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
@ -35,6 +42,7 @@ import org.eclipse.core.runtime.Path;
*/ */
public class LanguageSettingsManagerTests extends BaseTestCase { public class LanguageSettingsManagerTests extends BaseTestCase {
// Those should match ids of plugin extensions defined in plugin.xml // Those should match ids of plugin extensions defined in plugin.xml
private static final String EXTENSION_BASE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_ID;
private static final String EXTENSION_SERIALIZABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ID; private static final String EXTENSION_SERIALIZABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ID;
private static final String EXTENSION_SERIALIZABLE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_NAME; private static final String EXTENSION_SERIALIZABLE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_NAME;
private static final String EXTENSION_EDITABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_EDITABLE_PROVIDER_ID; private static final String EXTENSION_EDITABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_EDITABLE_PROVIDER_ID;
@ -48,6 +56,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
private static final String PROVIDER_NAME_2 = "test.provider.2.name"; private static final String PROVIDER_NAME_2 = "test.provider.2.name";
private static final String CFG_ID = "test.configuration.id"; private static final String CFG_ID = "test.configuration.id";
private static final String LANG_ID = "test.lang.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")); private static final IFile FILE_0 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0"));
/** /**
@ -158,6 +167,35 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
assertEquals(defaultProviders, cfgDescription.getDefaultLanguageSettingsProvidersIds()); assertEquals(defaultProviders, cfgDescription.getDefaultLanguageSettingsProvidersIds());
} }
/**
* Test to ensure uniqueness of ids for providers kept in configuration description.
*/
public void testConfigurationDescription_ProvidersUniqueId() throws Exception {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertTrue(cfgDescriptionWritable instanceof CConfigurationDescription);
// attempt to add duplicate providers
MockProvider dupe1 = new MockProvider(PROVIDER_0, PROVIDER_NAME_1, null);
MockProvider dupe2 = new MockProvider(PROVIDER_0, PROVIDER_NAME_2, null);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(dupe1);
providers.add(dupe2);
try {
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
fail("cfgDescription.setLanguageSettingProviders() should not accept duplicate providers");
} catch (Exception e) {
// Exception is welcome here
}
}
/** /**
* Test various cases of ill-defined providers. * Test various cases of ill-defined providers.
*/ */
@ -338,6 +376,117 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
} }
} }
/**
* Test getting entries from resource hierarchy.
*/
public void testProvider_ParentFolder() throws Exception {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertTrue(cfgDescriptionWritable instanceof CConfigurationDescription);
final IFolder parentFolder = ResourceHelper.createFolder(project, "/ParentFolder/");
assertNotNull(parentFolder);
final IFile emptySettingsPath = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/empty");
assertNotNull(emptySettingsPath);
// store the entries in parent folder
final List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) {
@Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
if (rc!=null && rc.equals(parentFolder)) {
return entries;
}
if (rc!=null && rc.equals(emptySettingsPath)) {
return new ArrayList<ICLanguageSettingEntry>(0);
}
return null;
}
};
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
{
// retrieve entries for a derived resource (in a subfolder)
IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource");
List<ICLanguageSettingEntry> actual = LanguageSettingsManager
.getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, derived, LANG_ID);
// taken from parent folder
assertEquals(entries.get(0),actual.get(0));
assertEquals(entries.size(), actual.size());
}
{
// retrieve entries for not related resource
IFile notRelated = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/AnotherFolder/Subfolder/resource"));
List<ICLanguageSettingEntry> actual = LanguageSettingsManager
.getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, notRelated, LANG_ID);
assertEquals(0, actual.size());
}
{
// test distinction between no settings and empty settings
List<ICLanguageSettingEntry> actual = LanguageSettingsManager
.getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, emptySettingsPath, LANG_ID);
// NOT taken from parent folder
assertEquals(0, actual.size());
}
}
/**
* Test getting entries from resource hierarchy up to default entries.
*/
public void testProvider_DefaultEntries() throws Exception {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertTrue(cfgDescriptionWritable instanceof CConfigurationDescription);
final IFolder parentFolder = ResourceHelper.createFolder(project, "/ParentFolder/");
assertNotNull(parentFolder);
final IFile emptySettingsPath = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/empty");
assertNotNull(emptySettingsPath);
// store the entries as default entries
final List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) {
@Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
if (cfgDescription==null && rc==null) {
return entries;
}
return null;
}
};
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
{
// retrieve entries for a resource
IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource");
List<ICLanguageSettingEntry> actual = LanguageSettingsManager
.getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, derived, LANG_ID);
// default entries given
assertEquals(entries.get(0),actual.get(0));
assertEquals(entries.size(), actual.size());
}
}
/** /**
* Test ability to get entries by kind. * Test ability to get entries by kind.
*/ */
@ -502,6 +651,59 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
assertEquals(3, includes.size()); assertEquals(3, includes.size());
} }
/**
* Test ability to serialize providers for a configuration.
*/
public void testConfigurationDescription_SerializeProviders() throws Exception {
// Create model project and accompanied descriptions
String projectName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(projectName);
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertTrue(cfgDescription instanceof CConfigurationDescription);
ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID);
assertNotNull(workspaceProvider);
{
// ensure no test provider is set yet
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(0, providers.size());
}
{
// set test provider
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(workspaceProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
}
{
// check that test provider got there
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(workspaceProvider, providers.get(0));
}
{
// serialize
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
// close and reopen the project
project.close(null);
project.open(null);
}
{
// check that test provider got loaded
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
ICConfigurationDescription[] loadedCfgDescriptions = prjDescription.getConfigurations();
ICConfigurationDescription loadedCfgDescription = loadedCfgDescriptions[0];
assertTrue(cfgDescription instanceof CConfigurationDescription);
List<ILanguageSettingsProvider> loadedProviders = ((ILanguageSettingsProvidersKeeper) loadedCfgDescription).getLanguageSettingProviders();
assertTrue(LanguageSettingsManager.isWorkspaceProvider(loadedProviders.get(0)));
}
}
/** /**
* Test a workspace provider basics. * Test a workspace provider basics.
*/ */
@ -605,4 +807,156 @@ public class LanguageSettingsManagerTests extends BaseTestCase {
assertSame(provider, providers.get(0)); 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,6 +12,7 @@
package org.eclipse.cdt.core.language.settings.providers; package org.eclipse.cdt.core.language.settings.providers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import junit.framework.TestSuite; import junit.framework.TestSuite;
@ -20,11 +21,14 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.core.testplugin.CModelMock; import org.eclipse.cdt.core.testplugin.CModelMock;
import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.XmlUtil;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -40,6 +44,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
private static final String EXTENSION_BASE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_NAME; private static final String EXTENSION_BASE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_NAME;
private static final String EXTENSION_SERIALIZABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ID; private static final String EXTENSION_SERIALIZABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ID;
private static final String EXTENSION_EDITABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_EDITABLE_PROVIDER_ID; private static final String EXTENSION_EDITABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_EDITABLE_PROVIDER_ID;
private static final String EXTENSION_USER_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_USER_PROVIDER_ID;
private static final ICLanguageSettingEntry EXTENSION_SERIALIZABLE_PROVIDER_ENTRY = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ENTRY; private static final ICLanguageSettingEntry EXTENSION_SERIALIZABLE_PROVIDER_ENTRY = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ENTRY;
// Constants from LanguageSettingsProvidersSerializer // Constants from LanguageSettingsProvidersSerializer
@ -50,8 +55,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
private static final String CFG_ID = "test.configuration.id.0"; private static final String CFG_ID = "test.configuration.id.0";
private static final String CFG_ID_2 = "test.configuration.id.2"; private static final String CFG_ID_2 = "test.configuration.id.2";
private static final String PROVIDER_0 = "test.provider.0.id"; private static final String PROVIDER_0 = "test.provider.0.id";
private static final String PROVIDER_1 = "test.provider.1.id";
private static final String PROVIDER_2 = "test.provider.2.id"; private static final String PROVIDER_2 = "test.provider.2.id";
private static final String PROVIDER_NAME_0 = "test.provider.0.name"; private static final String PROVIDER_NAME_0 = "test.provider.0.name";
private static final String PROVIDER_NAME_1 = "test.provider.1.name";
private static final String PROVIDER_NAME_2 = "test.provider.2.name"; private static final String PROVIDER_NAME_2 = "test.provider.2.name";
private static final String ATTR_PARAMETER = "parameter"; private static final String ATTR_PARAMETER = "parameter";
private static final String CUSTOM_PARAMETER = "custom parameter"; private static final String CUSTOM_PARAMETER = "custom parameter";
@ -145,6 +152,32 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
junit.textui.TestRunner.run(suite()); junit.textui.TestRunner.run(suite());
} }
/**
* Get read-only configuration descriptions.
*/
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
// project description
ICProjectDescription projectDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(projectDescription);
assertEquals(1, projectDescription.getConfigurations().length);
// configuration description
ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations();
assertNotNull(cfgDescriptions);
return cfgDescriptions;
}
/**
* Get first read-only configuration description.
*/
private ICConfigurationDescription getFirstConfigurationDescription(IProject project) {
ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
return cfgDescription;
}
/** /**
* Persist and reload when no customized providers are defined in the workspace. * Persist and reload when no customized providers are defined in the workspace.
*/ */
@ -156,6 +189,152 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// test passes if no exception was thrown // test passes if no exception was thrown
} }
/**
* Make sure providers in configuration cannot be modified accidentally outside of API.
*/
public void testProjectDescription_PreventBackDoorAccess() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
// get project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
int originalSize = originalProviders.size();
// create new provider list
LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_0, PROVIDER_NAME_0);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>(originalProviders);
providers.add(mockProvider);
assertTrue(originalSize != providers.size());
// changing providers shouldn't affect the original list
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
assertEquals(originalSize, originalProviders.size());
}
/**
* Test assigning providers to read-only vs. writable configuration descriptions.
*/
public void testProjectDescription_ReadWriteDescription() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
{
// get read-only description
ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescriptionReadOnly);
ICConfigurationDescription cfgDescriptionReadOnly = prjDescriptionReadOnly.getDefaultSettingConfiguration();
assertNotNull(cfgDescriptionReadOnly);
assertTrue(cfgDescriptionReadOnly instanceof ILanguageSettingsProvidersKeeper);
// try to write to it providers
try {
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).setLanguageSettingProviders(providers);
fail("WriteAccessException was expected but it was not throw.");
} catch (WriteAccessException e) {
// exception is expected
}
// try to write to it default providers ids
try {
((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
fail("WriteAccessException was expected but it was not throw.");
} catch (WriteAccessException e) {
// exception is expected
}
}
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
{
// get project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// create a provider and write to cfgDescription
LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true);
mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to cfgDescription default providers ids
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 });
// apply new project description to the project model
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
}
{
// get read-only project descriptions
ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
assertNotNull(prjDescriptionReadOnly);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionReadOnly.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionReadOnly = cfgDescriptions[0];
assertNotNull(cfgDescriptionReadOnly);
assertTrue(cfgDescriptionReadOnly instanceof ILanguageSettingsProvidersKeeper);
// double-check providers
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider);
assertEquals(PROVIDER_1, loadedProvider.getId());
assertEquals(PROVIDER_NAME_1, loadedProvider.getName());
// double-check provider's setting entries
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescriptionReadOnly, null, null);
assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
// double-check default providers ids
String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).getDefaultLanguageSettingsProvidersIds();
assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds));
}
{
// get writable project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// check providers
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider);
assertEquals(PROVIDER_1, loadedProvider.getId());
assertEquals(PROVIDER_NAME_1, loadedProvider.getName());
// check provider's setting entries
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescriptionWritable, null, null);
assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
// check default providers ids
String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getDefaultLanguageSettingsProvidersIds();
assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds));
}
}
/** /**
* Persist and reload a customized provider defined in the workspace. * Persist and reload a customized provider defined in the workspace.
*/ */
@ -397,6 +576,65 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
} }
/**
* Test User language settings provider defined as extension in cdt.ui.
*/
public void testProjectPersistence_UserProviderDOM() throws Exception {
Element rootElement = null;
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
{
// create a provider
MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
ILanguageSettingsProvider provider = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_USER_PROVIDER_ID, false);
assertTrue(provider instanceof LanguageSettingsGenericProvider);
LanguageSettingsGenericProvider serializableProvider = (LanguageSettingsGenericProvider) provider;
serializableProvider.setSettingEntries(null, null, null, entries);
LanguageSettingsManager.setStoringEntriesInProjectArea(serializableProvider, true);
ArrayList<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(serializableProvider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// prepare DOM storage
Document doc = XmlUtil.newDocument();
rootElement = XmlUtil.appendElement(doc, ELEM_TEST);
// serialize language settings to the DOM
LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription);
assertTrue(XmlUtil.toString(doc).contains(EXTENSION_USER_PROVIDER_ID));
assertTrue(XmlUtil.toString(doc).contains(LanguageSettingsGenericProvider.class.getName()));
}
{
// re-load and check language settings of the newly loaded provider
MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID));
LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription);
ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations();
assertNotNull(cfgDescriptions);
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescription = cfgDescriptions[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertNotNull(providers);
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
assertTrue(provider instanceof LanguageSettingsGenericProvider);
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(null, null, null);
assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
}
}
/** /**
* Test serialization of providers to project storage where the project has multiple configurations. * Test serialization of providers to project storage where the project has multiple configurations.
*/ */
@ -789,6 +1027,148 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
} }
/**
* Test serialization of real project.
*/
public void testProjectPersistence_RealProject() throws Exception {
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
String xmlStorageFileLocation;
String xmlOutOfTheWay;
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
{
// get project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// create a provider
LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true);
mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertTrue(xmlStorageFile.exists());
xmlStorageFileLocation = xmlStorageFile.getLocation().toOSString();
}
{
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
assertTrue(provider instanceof LanguageSettingsSerializableProvider);
assertEquals(PROVIDER_0, provider.getId());
assertEquals(PROVIDER_NAME_0, provider.getName());
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(cfgDescription, null, null);
assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
}
{
// Move storage out of the way
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
xmlOutOfTheWay = xmlStorageFileLocation+".out-of-the-way";
java.io.File xmlFileOut = new java.io.File(xmlOutOfTheWay);
xmlFile.renameTo(xmlFileOut);
assertFalse(xmlFile.exists());
assertTrue(xmlFileOut.exists());
}
{
// Should not pollute workspace area with file with no meaningful data
String xmlWspStorageFileLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
java.io.File xmlStorageFileWsp = new java.io.File(xmlWspStorageFileLocation);
assertFalse(xmlStorageFileWsp.exists());
}
{
// clear configuration
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(0, providers.size());
}
{
// re-check if it really took it
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(0, providers.size());
}
{
// close the project
project.close(null);
}
{
// open to double-check the data is not kept in some other kind of cache
project.open(null);
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(0, providers.size());
// and close
project.close(null);
}
{
// Move storage back
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
xmlFile.delete();
assertFalse("File "+xmlFile+ " still exist", xmlFile.exists());
java.io.File xmlFileOut = new java.io.File(xmlOutOfTheWay);
xmlFileOut.renameTo(xmlFile);
assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists());
assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists());
}
{
// Remove project from internal cache
CProjectDescriptionManager.getInstance().projectClosedRemove(project);
// open project and check if providers are loaded
project.open(null);
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof LanguageSettingsSerializableProvider);
assertEquals(PROVIDER_0, loadedProvider.getId());
assertEquals(PROVIDER_NAME_0, loadedProvider.getName());
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescription, null, null);
assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
}
}
/** /**
* Test case when the storage is split between project and workspace area. * Test case when the storage is split between project and workspace area.
*/ */
@ -850,6 +1230,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
} }
/** /**
* TODO: refactor with ErrorParserManager
*
* @param store - name of the store * @param store - name of the store
* @return location of the store in the plug-in state area * @return location of the store in the plug-in state area
*/ */
@ -858,6 +1240,171 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
return location.toString(); return location.toString();
} }
/**
* Test split storage in a real project.
*/
public void testProjectPersistence_RealProjectSplitStorage() throws Exception {
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
String xmlStorageFileLocation;
String xmlOutOfTheWay;
String xmlWspStorageFileLocation;
String xmlWspOutOfTheWay;
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(new CIncludePathEntry("path0", 0));
{
// get project descriptions
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
assertNotNull(prjDescriptionWritable);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
// create a provider
LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0);
LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, false);
mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(mockProvider);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers);
List<ILanguageSettingsProvider> storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(1, storedProviders.size());
// write to project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
assertTrue(xmlStorageFile.exists());
xmlStorageFileLocation = xmlStorageFile.getLocation().toOSString();
// TODO - cleanup names
xmlWspStorageFileLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
java.io.File xmlStorageFileWsp = new java.io.File(xmlWspStorageFileLocation);
assertTrue(xmlStorageFileWsp.exists());
}
{
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider provider = providers.get(0);
assertTrue(provider instanceof LanguageSettingsSerializableProvider);
assertEquals(PROVIDER_0, provider.getId());
assertEquals(PROVIDER_NAME_0, provider.getName());
List<ICLanguageSettingEntry> actual = provider.getSettingEntries(cfgDescription, null, null);
assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
}
// Move storages out of the way
{
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
xmlOutOfTheWay = xmlStorageFileLocation+".out-of-the-way";
java.io.File xmlFileOut = new java.io.File(xmlOutOfTheWay);
xmlFile.renameTo(xmlFileOut);
assertFalse(xmlFile.exists());
assertTrue(xmlFileOut.exists());
}
{
// TODO - workspace file
java.io.File xmlStorageFileWsp = new java.io.File(xmlWspStorageFileLocation);
assertTrue(xmlStorageFileWsp.exists());
xmlWspOutOfTheWay = xmlWspStorageFileLocation+".out-of-the-way";
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
boolean result = xmlStorageFileWsp.renameTo(xmlWspFileOut);
assertTrue(result);
assertFalse(xmlStorageFileWsp.exists());
assertTrue(xmlWspFileOut.exists());
}
{
// clear configuration
ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true);
ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations();
assertEquals(1, cfgDescriptions.length);
ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0];
assertNotNull(cfgDescriptionWritable);
assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper);
((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders();
assertEquals(0, providers.size());
}
{
// re-check if it really took it
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(0, providers.size());
}
{
// close the project
project.close(null);
}
{
// open to double-check the data is not kept in some other kind of cache
project.open(null);
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(0, providers.size());
// and close
project.close(null);
}
{
// Move storage back
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
xmlFile.delete();
assertFalse("File "+xmlFile+ " still exist", xmlFile.exists());
java.io.File xmlFileOut = new java.io.File(xmlOutOfTheWay);
xmlFileOut.renameTo(xmlFile);
assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists());
assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists());
}
{
// TODO
// Move storage back
java.io.File xmlWspFile = new java.io.File(xmlWspStorageFileLocation);
xmlWspFile.delete();
assertFalse("File "+xmlWspFile+ " still exist", xmlWspFile.exists());
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
xmlWspFileOut.renameTo(xmlWspFile);
assertTrue("File "+xmlWspFile+ " does not exist", xmlWspFile.exists());
assertFalse("File "+xmlWspFileOut+ " still exist", xmlWspFileOut.exists());
}
{
// Remove project from internal cache
CProjectDescriptionManager.getInstance().projectClosedRemove(project);
// open project and check if providers are loaded
project.open(null);
ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project);
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
assertEquals(1, providers.size());
ILanguageSettingsProvider loadedProvider = providers.get(0);
assertTrue(loadedProvider instanceof LanguageSettingsSerializableProvider);
assertEquals(PROVIDER_0, loadedProvider.getId());
assertEquals(PROVIDER_NAME_0, loadedProvider.getName());
List<ICLanguageSettingEntry> actual = loadedProvider.getSettingEntries(cfgDescription, null, null);
assertEquals(entries.get(0), actual.get(0));
assertEquals(entries.size(), actual.size());
}
}
/** /**
* Test serialization of providers referring to global shared instance. * Test serialization of providers referring to global shared instance.
*/ */

View file

@ -0,0 +1,951 @@
/*******************************************************************************
* Copyright (c) 2009, 2012 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.language.settings.providers;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CMacroEntry;
import org.eclipse.cdt.core.settings.model.CMacroFileEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
/**
* Test cases testing LanguageSettingsProvider functionality
*/
public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase {
private static final IFile FAKE_FILE = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0"));
private static final String PROVIDER_ID = "test.provider.id";
private static final String PROVIDER_ID_2 = "test.provider.id.2";
private static final String PROVIDER_NAME = "test.provider.name";
// constants for getProjectDescription()
private static final boolean READ_ONLY = false;
private static final boolean WRITEABLE = true;
private class MockProvider extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
private final List<ICLanguageSettingEntry> entries;
public MockProvider(String id, String name, List<ICLanguageSettingEntry> entries) {
super(id, name);
this.entries = entries;
}
@Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
return entries;
}
}
/**
* Constructor.
* @param name - name of the test.
*/
public LanguageSettingsScannerInfoProviderTests(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected void tearDown() throws Exception {
super.tearDown(); // includes ResourceHelper cleanup
}
/**
* @return - new TestSuite.
*/
public static TestSuite suite() {
return new TestSuite(LanguageSettingsScannerInfoProviderTests.class);
}
/**
* main function of the class.
*
* @param args - arguments
*/
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
/**
* Sets build working directory for DefaultSettingConfiguration being tested.
*/
private void setBuilderCWD(IProject project, IPath buildCWD) throws CoreException {
CProjectDescriptionManager manager = CProjectDescriptionManager.getInstance();
{
ICProjectDescription prjDescription = manager.getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
cfgDescription.getBuildSetting().setBuilderCWD(buildCWD);
manager.setProjectDescription(project, prjDescription);
// doublecheck builderCWD
IPath actualBuildCWD = cfgDescription.getBuildSetting().getBuilderCWD();
assertEquals(buildCWD, actualBuildCWD);
}
{
// triplecheck builderCWD for different project/configuration descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
}
}
/**
* Test cases when some objects are null.
*/
public void testNulls() throws Exception {
{
// Handle project==null
IResource root = ResourcesPlugin.getWorkspace().getRoot();
assertNull(root.getProject());
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(root);
assertEquals(0, info.getIncludePaths().length);
assertEquals(0, info.getDefinedSymbols().size());
assertEquals(0, info.getIncludeFiles().length);
assertEquals(0, info.getMacroFiles().length);
assertEquals(0, info.getLocalIncludePath().length);
}
{
// Handle prjDescription==null
IProject project = FAKE_FILE.getProject();
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
assertNull(prjDescription);
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(FAKE_FILE);
assertEquals(0, info.getIncludePaths().length);
assertEquals(0, info.getDefinedSymbols().size());
assertEquals(0, info.getIncludeFiles().length);
assertEquals(0, info.getMacroFiles().length);
assertEquals(0, info.getLocalIncludePath().length);
}
{
// Handle language==null
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
IFile file = ResourceHelper.createFile(project, "file");
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
assertNull(language);
// AG FIXME - temporarily ignore the entry in the log
setExpectedNumberOfLoggedNonOKStatusObjects(1);
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
assertEquals(0, info.getIncludePaths().length);
assertEquals(0, info.getDefinedSymbols().size());
assertEquals(0, info.getIncludeFiles().length);
assertEquals(0, info.getMacroFiles().length);
assertEquals(0, info.getLocalIncludePath().length);
}
}
/**
* Test empty scanner info.
*/
public void testEmpty() throws Exception {
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
IFile file = ResourceHelper.createFile(project, "file.c");
// confirm that language==null
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
assertNotNull(language);
// test that the info is empty
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
assertEquals(0, info.getIncludePaths().length);
assertEquals(0, info.getDefinedSymbols().size());
assertEquals(0, info.getIncludeFiles().length);
assertEquals(0, info.getMacroFiles().length);
assertEquals(0, info.getLocalIncludePath().length);
}
/**
* Test regular cases.
*/
public void testRegular() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// sanity test of language
ILanguage language = LanguageManager.getInstance().getLanguageForFile(file, cfgDescription);
assertNotNull(language);
// contribute the entries
IFolder includeFolder = ResourceHelper.createFolder(project, "/include-path");
IFolder includeLocalFolder = ResourceHelper.createFolder(project, "/local-include-path");
IFile macroFile = ResourceHelper.createFile(project, "macro-file");
IFile includeFile = ResourceHelper.createFile(project, "include-file");
CIncludePathEntry includePathEntry = new CIncludePathEntry(includeFolder, 0);
CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(includeLocalFolder, ICSettingEntry.LOCAL); // #include "..."
CMacroEntry macroEntry = new CMacroEntry("MACRO", "value",0);
CIncludeFileEntry includeFileEntry = new CIncludeFileEntry(includeFile, 0);
CMacroFileEntry macroFileEntry = new CMacroFileEntry(macroFile, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(includePathEntry);
entries.add(includeLocalPathEntry);
entries.add(macroEntry);
entries.add(includeFileEntry);
entries.add(macroFileEntry);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test that the scannerInfoProvider gets the entries
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
Map<String, String> actualDefinedSymbols = info.getDefinedSymbols();
String[] actualIncludeFiles = info.getIncludeFiles();
String[] actualMacroFiles = info.getMacroFiles();
String[] actualLocalIncludePath = info.getLocalIncludePath();
// include paths
assertEquals(includeFolder.getLocation(), new Path(actualIncludePaths[0]));
assertEquals(1, actualIncludePaths.length);
// macros
assertEquals(macroEntry.getValue(), actualDefinedSymbols.get(macroEntry.getName()));
assertEquals(1, actualDefinedSymbols.size());
// include file
assertEquals(includeFile.getLocation(), new Path(actualIncludeFiles[0]));
assertEquals(1, actualIncludeFiles.length);
// macro file
assertEquals(macroFile.getLocation(), new Path(actualMacroFiles[0]));
assertEquals(1, actualMacroFiles.length);
// local include files
assertEquals(includeLocalFolder.getLocation(), new Path(actualLocalIncludePath[0]));
assertEquals(1, actualLocalIncludePath.length);
}
/**
* Test "local" flag (#include "...").
*/
public void testLocal() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// contribute the entries
IFolder incFolder = ResourceHelper.createFolder(project, "include");
IFolder incFolder2 = ResourceHelper.createFolder(project, "include2");
CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder2, ICSettingEntry.LOCAL); // #include "..."
CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder2, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(includePathEntry);
entries.add(includeLocalPathEntry);
// reverse order for incPath2
entries.add(includeLocalPathEntry2);
entries.add(includePathEntry2);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test that the scannerInfoProvider gets the entries
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
String[] actualLocalIncludePath = info.getLocalIncludePath();
// include paths
assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
assertEquals(incFolder2.getLocation(), new Path(actualIncludePaths[1]));
assertEquals(2, actualIncludePaths.length);
// local include files
assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0]));
assertEquals(incFolder2.getLocation(), new Path(actualLocalIncludePath[1]));
assertEquals(2, actualLocalIncludePath.length);
}
/**
* Test Mac frameworks.
*/
public void testFramework() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// contribute the entries
IFolder frameworkFolder = ResourceHelper.createFolder(project, "Fmwk");
CIncludePathEntry frameworkPathEntry = new CIncludePathEntry(frameworkFolder, ICSettingEntry.FRAMEWORKS_MAC);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(frameworkPathEntry);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test that the scannerInfoProvider gets the entries
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
// include paths
assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/Headers/__header__"),
new Path(actualIncludePaths[0]));
assertEquals(frameworkFolder.getLocation().append("/__framework__.framework/PrivateHeaders/__header__"),
new Path(actualIncludePaths[1]));
assertEquals(2, actualIncludePaths.length);
}
/**
* Test duplicate entries.
*/
public void testDuplicate() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// contribute the entries
IFolder incFolder = ResourceHelper.createFolder(project, "include");
CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
CIncludePathEntry includePathEntry2 = new CIncludePathEntry(incFolder, 0);
CIncludePathEntry includeLocalPathEntry2 = new CIncludePathEntry(incFolder, ICSettingEntry.LOCAL); // #include "..."
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(includePathEntry);
entries.add(includeLocalPathEntry);
entries.add(includePathEntry2);
entries.add(includeLocalPathEntry2);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test that the scannerInfoProvider gets the entries
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
String[] actualLocalIncludePath = info.getLocalIncludePath();
// include paths
assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
assertEquals(1, actualIncludePaths.length);
// local include files
assertEquals(incFolder.getLocation(), new Path(actualLocalIncludePath[0]));
assertEquals(1, actualLocalIncludePath.length);
}
/**
* Test include path managed by eclipse as a workspace path.
*/
public void testWorkspacePath() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// create sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// eclipse-managed folder in workspace
IFolder incWorkspace_1 = ResourceHelper.createFolder(project, "include_1");
IPath incWorkspaceLocation_1 = incWorkspace_1.getLocation();
IFolder incWorkspace_2 = ResourceHelper.createFolder(project, "include_2");
IPath incWorkspacePath_2 = incWorkspace_2.getFullPath();
IPath incWorkspaceLocation_2 = incWorkspace_2.getLocation();
IFolder incWorkspace_3 = ResourceHelper.createFolder(project, "include_3");
// "relative" should make no difference for VALUE_WORKSPACE_PATH
IPath incWorkspaceRelativePath_3 = incWorkspace_3.getFullPath().makeRelative();
IPath incWorkspaceLocation_3 = incWorkspace_3.getLocation();
// folder defined by absolute path on the filesystem
IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem");
// contribute the entries
CIncludePathEntry incWorkspaceEntry_1 = new CIncludePathEntry(incWorkspace_1, 0);
CIncludePathEntry incWorkspaceEntry_2 = new CIncludePathEntry(incWorkspacePath_2, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
CIncludePathEntry incWorkspaceEntry_3 = new CIncludePathEntry(incWorkspaceRelativePath_3, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(incWorkspaceEntry_1);
entries.add(incWorkspaceEntry_2);
entries.add(incWorkspaceEntry_3);
entries.add(incFilesystemEntry);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test the entries received from the scannerInfoProvider
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
assertEquals(incWorkspaceLocation_1, new Path(actualIncludePaths[0]));
assertEquals(incWorkspaceLocation_2, new Path(actualIncludePaths[1]));
assertEquals(incWorkspaceLocation_3, new Path(actualIncludePaths[2]));
assertEquals(incFilesystem, new Path(actualIncludePaths[3]));
assertEquals(4, actualIncludePaths.length);
}
/**
* Confirm that device letter is prepended on filesystems that support that.
*/
public void testFilesystemPathNoDriveLetter() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
// change drive on build working directory
String buildCwdDevice = project.getLocation().getDevice();
// // Test manually with a device which is different from project location device (path should exist)
// IPath buildCWD = new Path("D:/build/path");
// String buildCwdDevice = buildCWD.getDevice();
// get project/configuration descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// create sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// contribute the entries
// no-drive-letter folder defined by absolute path on the filesystem
IPath incFilesystem = ResourceHelper.createWorkspaceFolder("includeFilesystem").setDevice(null);
CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(incFilesystemEntry);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test the entries received from the scannerInfoProvider
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
IPath expectedInclude = incFilesystem.setDevice(buildCwdDevice);
assertEquals(expectedInclude, new Path(actualIncludePaths[0]));
assertEquals(1, actualIncludePaths.length);
}
/**
* Test relative paths.
*/
public void testRelativePath() throws Exception {
// create a project
String prjName = getName();
IProject project = ResourceHelper.createCDTProjectWithConfig(prjName);
String relativePath = "include";
IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
IFolder relativeFolder = ResourceHelper.createFolder(project, "buildDir/"+relativePath);
IFolder relativeFolderProjName = ResourceHelper.createFolder(project, "buildDir/"+prjName);
String markedResolved = "-MarkedResolved";
IFolder relativeFolderProjNameResolved = ResourceHelper.createFolder(project, "buildDir/" + prjName+markedResolved);
IPath buildCWD=buildFolder.getLocation();
setBuilderCWD(project, buildCWD);
// get project/configuration descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// create sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// contribute the entries
CIncludePathEntry incRelativeEntry = new CIncludePathEntry(new Path(relativePath), 0);
CIncludePathEntry incProjNameEntry = new CIncludePathEntry(new Path("${ProjName}"), 0);
CIncludePathEntry incProjNameMarkedResolvedEntry = new CIncludePathEntry(new Path("${ProjName}"+markedResolved), ICSettingEntry.RESOLVED);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(incRelativeEntry);
entries.add(incProjNameEntry);
entries.add(incProjNameMarkedResolvedEntry);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test the entries received from the scannerInfoProvider
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
// pair of entries, one from build dir another relative path
assertEquals(relativeFolder.getLocation(), new Path(actualIncludePaths[0]));
assertEquals(new Path(relativePath), new Path(actualIncludePaths[1]));
// pair of entries, one resolved from build dir another expanded relative path
assertEquals(relativeFolderProjName.getLocation(), new Path(actualIncludePaths[2]));
assertEquals(new Path(prjName), new Path(actualIncludePaths[3]));
// if marked RESOLVED only that path stays
assertEquals(new Path("${ProjName}"+markedResolved), new Path(actualIncludePaths[4]));
assertEquals(5, actualIncludePaths.length);
}
/**
* Test relative paths - some combinations of dot paths.
*/
public void testRelativePathWithDots() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
// set build CWD
IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir");
IPath buildCWD=buildFolder.getLocation();
setBuilderCWD(project, buildCWD);
// define a few variations of paths
String relativePath_dot = ".";
String relativePath_dot_slash = "./";
String relativePath_dot_slash_path = "./include";
IFolder relativeFolder_dot_slash_path = ResourceHelper.createFolder(project, "buildDir/include");
String relativePath_dotdot = "..";
String relativePath_dotdot_slash = "../";
String relativePath_dotdot_slash_path = "../include";
IFolder relativeFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include");
String locationPath_dotdot_path = buildCWD.toString()+"/../include2";
IFolder incFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include2"); // "/ProjPath/buildDir/../include2"
// get project/configuration descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// create sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// contribute the entries
CIncludePathEntry incRelativeEntry_dot = new CIncludePathEntry(new Path(relativePath_dot), 0);
CIncludePathEntry incRelativeEntry_dot_slash_path = new CIncludePathEntry(new Path(relativePath_dot_slash_path), 0);
CIncludePathEntry incRelativeEntry_dotdot = new CIncludePathEntry(new Path(relativePath_dotdot), 0);
CIncludePathEntry incRelativeEntry_dotdot_slash_path = new CIncludePathEntry(new Path(relativePath_dotdot_slash_path), 0);
CIncludePathEntry incEntry_dotdot_path = new CIncludePathEntry(locationPath_dotdot_path, 0);
// use LOCAL flag not to clash with plain dot entries
CIncludePathEntry incRelativeEntry_dotdot_slash = new CIncludePathEntry(new Path(relativePath_dotdot_slash), ICSettingEntry.LOCAL);
CIncludePathEntry incRelativeEntry_dot_slash = new CIncludePathEntry(new Path(relativePath_dot_slash), ICSettingEntry.LOCAL);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(incRelativeEntry_dot);
entries.add(incRelativeEntry_dot_slash);
entries.add(incRelativeEntry_dot_slash_path);
entries.add(incRelativeEntry_dotdot);
entries.add(incRelativeEntry_dotdot_slash);
entries.add(incRelativeEntry_dotdot_slash_path);
entries.add(incEntry_dotdot_path);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test the entries received from the scannerInfoProvider
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
String[] actualLocalIncludePaths = info.getLocalIncludePath();
IPath expectedLocation_dot = buildFolder.getLocation();
IPath expectedLocation_dot_slash = buildFolder.getLocation();
IPath expectedLocation_dot_slash_path = relativeFolder_dot_slash_path.getLocation();
IPath expectedLocation_dotdot = project.getLocation();
IPath expectedLocation_dotdot_slash = project.getLocation();
IPath expectedLocation_dotdot_slash_path = relativeFolder_dotdot_slash_path.getLocation();
assertEquals(expectedLocation_dot, new Path(actualIncludePaths[0]));
assertEquals(".", actualIncludePaths[1]);
assertEquals(expectedLocation_dot_slash_path, new Path(actualIncludePaths[2]));
assertEquals(new Path(relativePath_dot_slash_path), new Path(actualIncludePaths[3]));
assertEquals(expectedLocation_dotdot, new Path(actualIncludePaths[4]));
assertEquals("..", actualIncludePaths[5]);
assertEquals(expectedLocation_dotdot_slash_path, new Path(actualIncludePaths[6]));
assertEquals(new Path(relativePath_dotdot_slash_path), new Path(actualIncludePaths[7]));
assertTrue(actualIncludePaths[7].startsWith(".."));
assertEquals(new Path(locationPath_dotdot_path), new Path(actualIncludePaths[8]));
assertTrue(actualIncludePaths[8].contains(".."));
assertEquals(9, actualIncludePaths.length);
assertEquals(expectedLocation_dot_slash, new Path(actualLocalIncludePaths[0]));
assertEquals(new Path(relativePath_dot_slash), new Path(actualLocalIncludePaths[1]));
assertTrue(actualLocalIncludePaths[1].startsWith("."));
assertEquals(expectedLocation_dotdot_slash, new Path(actualLocalIncludePaths[2]));
assertEquals(new Path(relativePath_dotdot_slash), new Path(actualLocalIncludePaths[3]));
assertTrue(actualLocalIncludePaths[3].startsWith(".."));
assertEquals(4, actualLocalIncludePaths.length);
}
/**
* Test if build/environment variables are expanded
*/
public void testEnvironmentVars() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
IFolder folder = ResourceHelper.createFolder(project, "Folder");
String envPathStr = "${ProjDirPath}/Folder";
// get project/configuration descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// create sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// contribute the entries
CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(incRelativeEntry);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test the entries received from the scannerInfoProvider
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
IPath expectedLocation = folder.getLocation();
assertEquals(expectedLocation, new Path(actualIncludePaths[0]));
assertEquals(1, actualIncludePaths.length);
}
/**
* Test from parent folder's entries.
*/
public void testParentFolder() throws Exception {
class MockProviderForResource extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
private IResource rc;
private final List<ICLanguageSettingEntry> entries;
public MockProviderForResource(IResource rc, List<ICLanguageSettingEntry> entries) {
this.rc = rc;
this.entries = entries;
}
@Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
if (this.rc.equals(rc))
return entries;
return null;
}
}
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// sample file
IFolder parentFolder = ResourceHelper.createFolder(project, "ParentFolder");
IFile file = ResourceHelper.createFile(project, "ParentFolder/file.c");
// contribute the entries
IFolder incFolder = ResourceHelper.createFolder(project, "include");
CIncludePathEntry includePathEntry = new CIncludePathEntry(incFolder, 0);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(includePathEntry);
// add provider for parent folder
ILanguageSettingsProvider provider = new MockProviderForResource(parentFolder, entries);
assertNull(provider.getSettingEntries(cfgDescription, file, null));
assertEquals(includePathEntry, provider.getSettingEntries(cfgDescription, parentFolder, null).get(0));
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test that the scannerInfoProvider gets the entries for
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
// include paths
assertEquals(incFolder.getLocation(), new Path(actualIncludePaths[0]));
assertEquals(1, actualIncludePaths.length);
}
/**
* Test resolved paths.
*/
public void testResolvedPath() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
IFolder folder = ResourceHelper.createFolder(project, "Folder");
String envPathStr = "${ProjDirPath}/Folder";
// get project/configuration descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// create sample file
IFile file = ResourceHelper.createFile(project, "file.c");
// contribute the entries
CIncludePathEntry incRelativeEntry = new CIncludePathEntry(envPathStr, ICSettingEntry.RESOLVED);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
entries.add(incRelativeEntry);
// add provider to the configuration
ILanguageSettingsProvider provider = new MockProvider(PROVIDER_ID, PROVIDER_NAME, entries);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test the entries received from the scannerInfoProvider
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(file);
String[] actualIncludePaths = info.getIncludePaths();
// test that RESOLVED entries are not modified
IPath expectedLocation = new Path(envPathStr);
assertEquals(expectedLocation, new Path(actualIncludePaths[0]));
assertEquals(1, actualIncludePaths.length);
}
/**
* Get languages for the folder.
*/
private List<String> getLanguages(IFolder folder, ICConfigurationDescription cfgDescription) {
IPath rcPath = folder.getProjectRelativePath();
ICFolderDescription rcDes = (ICFolderDescription) cfgDescription.getResourceDescription(rcPath, false);
ICLanguageSetting[] langSettings = rcDes.getLanguageSettings();
assertNotNull(langSettings);
List<String> languageIds = new ArrayList<String>();
for (ICLanguageSetting ls : langSettings) {
String langId = ls.getLanguageId();
if (langId!=null && !languageIds.contains(langId)) {
languageIds.add(langId);
}
}
return languageIds;
}
/**
* Test composition of 2 languages.
*/
public void testResourceLanguages() throws Exception {
class MockProviderLang extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider {
private final String langId;
private final List<ICLanguageSettingEntry> entries;
public MockProviderLang(String id, String name, String langId, List<ICLanguageSettingEntry> entries) {
super(id, name);
this.langId = langId;
this.entries = entries;
}
@Override
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
if (langId==null || langId.equals(languageId))
return entries;
return new ArrayList<ICLanguageSettingEntry>();
}
}
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
IFolder folder = ResourceHelper.createFolder(project, "Folder");
IFolder incFolderA = ResourceHelper.createFolder(project, "includeA");
IFolder incFolderB = ResourceHelper.createFolder(project, "includeB");
IFolder incFolderC = ResourceHelper.createFolder(project, "includeC");
// get project/configuration descriptions
ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
// find 2 languages applicable to the folder
List<String> languageIds = getLanguages(folder, cfgDescription);
assertTrue(languageIds.size() >= 2);
String langId1 = languageIds.get(0);
String langId2 = languageIds.get(1);
// define overlapping entries
CIncludePathEntry incEntryA = new CIncludePathEntry(incFolderA, 0);
CIncludePathEntry incEntryB = new CIncludePathEntry(incFolderB, 0);
CIncludePathEntry incEntryC = new CIncludePathEntry(incFolderC, 0);
List<ICLanguageSettingEntry> entries1 = new ArrayList<ICLanguageSettingEntry>();
entries1.add(incEntryA);
entries1.add(incEntryB);
List<ICLanguageSettingEntry> entries2 = new ArrayList<ICLanguageSettingEntry>();
entries2.add(incEntryC);
entries2.add(incEntryB);
// add providers to the configuration
ILanguageSettingsProvider provider1 = new MockProviderLang(PROVIDER_ID, PROVIDER_NAME, langId1, entries1);
ILanguageSettingsProvider provider2 = new MockProviderLang(PROVIDER_ID_2, PROVIDER_NAME, langId2, entries2);
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider1);
providers.add(provider2);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// set project description
CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescription);
// test the entries received from the scannerInfoProvider
LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider();
ExtendedScannerInfo info = scannerInfoProvider.getScannerInformation(folder);
String[] actualIncludePaths = info.getIncludePaths();
// Test that the result is the union of entries
assertEquals(incFolderA.getLocation(), new Path(actualIncludePaths[0]));
assertEquals(incFolderB.getLocation(), new Path(actualIncludePaths[1]));
assertEquals(incFolderC.getLocation(), new Path(actualIncludePaths[2]));
assertEquals(3, actualIncludePaths.length);
}
}

View file

@ -19,6 +19,9 @@ import java.util.Map;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
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.LanguageSettingsSerializableProvider;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.ResourceHelper;
@ -998,4 +1001,54 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
assertEquals(cfgDescription1.getName(), newSetting.getDefaultSettingConfiguration().getName()); assertEquals(cfgDescription1.getName(), newSetting.getDefaultSettingConfiguration().getName());
} }
public void testDelta_LANGUAGE_SETTINGS_PROVIDERS() throws Exception {
String projName = getName();
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
initListener(projName);
IProject project = ResourceHelper.createCDTProjectWithConfig(projName);
// Get writable project description and its configuration
ICProjectDescription prjDescription = mngr.getProjectDescription(project, true);
assertNotNull(prjDescription);
ICConfigurationDescription cfgDescription = prjDescription.getConfigurations()[0];
assertNotNull(cfgDescription);
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
List<ILanguageSettingsProvider> originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders();
// Modification LANGUAGE_SETTINGS_PROVIDERS
ILanguageSettingsProvider provider = new LanguageSettingsSerializableProvider("test.id", "test.name");
List<ILanguageSettingsProvider> providers = new ArrayList<ILanguageSettingsProvider>();
providers.add(provider);
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers);
// Write project description
listener.clearNotified();
mngr.setProjectDescription(project, prjDescription);
assertEquals(true, listener.isNotified());
// Analyze delta
ICDescriptionDelta rootDelta = listener.getDelta();
assertNotNull(rootDelta);
List<ICDescriptionDelta> deltas = findDeltas(rootDelta, ICDescriptionDelta.LANGUAGE_SETTINGS_PROVIDERS);
assertEquals(1, deltas.size());
ICDescriptionDelta delta = deltas.get(0);
assertNotNull(delta);
assertEquals(ICDescriptionDelta.LANGUAGE_SETTINGS_PROVIDERS, delta.getChangeFlags());
// Check old setting
assertTrue(delta.getOldSetting() instanceof ICConfigurationDescription);
assertTrue(delta.getOldSetting() instanceof ILanguageSettingsProvidersKeeper);
ILanguageSettingsProvidersKeeper oldSetting = (ILanguageSettingsProvidersKeeper)delta.getOldSetting();
List<ILanguageSettingsProvider> oldProviders = oldSetting.getLanguageSettingProviders();
assertEquals(originalProviders, oldProviders);
// Check new setting
assertTrue(delta.getNewSetting() instanceof ICConfigurationDescription);
assertTrue(delta.getNewSetting() instanceof ILanguageSettingsProvidersKeeper);
ILanguageSettingsProvidersKeeper newSetting = (ILanguageSettingsProvidersKeeper)delta.getNewSetting();
List<ILanguageSettingsProvider> newProviders = newSetting.getLanguageSettingProviders();
assertEquals(providers, newProviders);
}
} }

View file

@ -159,6 +159,13 @@
</run> </run>
</filesystem> </filesystem>
</extension> </extension>
<extension
point="org.eclipse.cdt.core.EFSExtensionProvider">
<EFSExtensionProvider
class="org.eclipse.cdt.core.internal.tests.filesystem.ram.MemoryEFSExtensionProvider"
scheme="mem">
</EFSExtensionProvider>
</extension>
<extension <extension
id="RegexErrorParserId" id="RegexErrorParserId"
name="Test Plugin RegexErrorParser" name="Test Plugin RegexErrorParser"

View file

@ -11,7 +11,9 @@
package org.eclipse.cdt.core.language.settings.providers; package org.eclipse.cdt.core.language.settings.providers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -42,6 +44,9 @@ public class ScannerDiscoveryLegacySupport {
private static final String PREFERENCES_QUALIFIER = CCorePlugin.PLUGIN_ID; private static final String PREFERENCES_QUALIFIER = CCorePlugin.PLUGIN_ID;
private static final String LANGUAGE_SETTINGS_PROVIDERS_NODE = "languageSettingsProviders"; //$NON-NLS-1$ private static final String LANGUAGE_SETTINGS_PROVIDERS_NODE = "languageSettingsProviders"; //$NON-NLS-1$
private static Map<String, String> legacyProfiles = null;
private static Preferences getPreferences(IProject project) { private static Preferences getPreferences(IProject project) {
if (project == null) if (project == null)
return InstanceScope.INSTANCE.getNode(PREFERENCES_QUALIFIER).node(LANGUAGE_SETTINGS_PROVIDERS_NODE); return InstanceScope.INSTANCE.getNode(PREFERENCES_QUALIFIER).node(LANGUAGE_SETTINGS_PROVIDERS_NODE);
@ -96,4 +101,37 @@ public class ScannerDiscoveryLegacySupport {
return false; return false;
} }
/**
* 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

@ -10,27 +10,29 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.settings.model; package org.eclipse.cdt.core.settings.model;
import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription;
import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionDelta; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionDelta;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
/** /**
* Events fired for the project delats. * Events fired for the project deltas.
* The ProjectDescription lifecycle looks like: * The ProjectDescription life-cycle looks like:
* <ul> * <ul>
* <li> * <li> {@link #LOADED} - configuration is loaded and read-only.
* - {@link #LOADED} - configuration is loaded and read-only * <li> {@link #COPY_CREATED} - Indicates new writable description has been created
* <li> * from the read-only description backing store.
* - {@link #COPY_CREATED} - Indicates new writable description has been created from * <li> {@link #ABOUT_TO_APPLY} - First event in the setProjectDescription flow.
* the read-only description backing store * New description writable, old description represents the cache.
* <li> * <li> {@link #DATA_APPLIED} - Event indicating that configuration data has been applied
* - {@link #ABOUT_TO_APPLY} - First event in the setProjectDescription flow. New description * by the build system.
* writable, old description represents the cache * <li> {@link #APPLIED} - setProjectDescription finished, newDescription is read-only.
* <li>
* - {@link #DATA_APPLIED} - Event indicating that configuration data has been applied by the build system
* <li>
* - {@link #APPLIED} - setProjectDescription finished, newDescription is read-only
* </ul> * </ul>
*
* @see ICConfigurationDescription
* @see CConfigurationDescription
* @see CConfigurationDescriptionCache
*/ */
public final class CProjectDescriptionEvent { public final class CProjectDescriptionEvent {

View file

@ -16,13 +16,29 @@ import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider; import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription;
import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
/** /**
* This is the element representing configuration and thus this is the root element * This is the class representing configuration and thus this is the root element
* for configuration-specific settings * for configuration-specific settings.
* <br><br>
* A typical (simplified) life-cycle of configuration description in CDT is as following:
* <br> 1. A project is created or opened. A new read-only configuration description is loaded.
* <br> 2. If a description needs to be changed, a client gets a copy as a writable configuration
* description first. Then, that instance can be edited.
* <br> 3. The changed writable configuration description gets applied to the model and becomes
* read-only.
* <br> 4. The project gets closed or removed. The configuration description gets disposed.
* <br><br>
* Typically read-only configuration description would be represented by {@link CConfigurationDescriptionCache}
* and writable one by {@link CConfigurationDescription}.
*
* @see CProjectDescriptionEvent
* @see CConfigurationDescriptionCache
*/ */
public interface ICConfigurationDescription extends ICSettingContainer, ICSettingObject, ICSettingsStorage { public interface ICConfigurationDescription extends ICSettingContainer, ICSettingObject, ICSettingsStorage {
/** /**

View file

@ -57,6 +57,7 @@ import org.eclipse.cdt.core.settings.model.extension.CResourceData;
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData; import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
import org.eclipse.cdt.core.settings.model.extension.impl.CDataFactory; import org.eclipse.cdt.core.settings.model.extension.impl.CDataFactory;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData; import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
import org.eclipse.cdt.internal.core.parser.util.WeakHashSet;
import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope; import org.eclipse.core.resources.ProjectScope;
@ -76,6 +77,14 @@ public class CDataUtil {
private static Random randomNumber; private static Random randomNumber;
public static final String[] EMPTY_STRING_ARRAY = new String[0]; public static final String[] EMPTY_STRING_ARRAY = new String[0];
private static WeakHashSet<ICSettingEntry> languageSettingsPool = new WeakHashSet<ICSettingEntry>() {
@Override
public synchronized ICSettingEntry add(ICSettingEntry entry) {
return super.add(entry);
}
};
public static int genRandomNumber(){ public static int genRandomNumber(){
if (randomNumber == null) { if (randomNumber == null) {
// Set the random number seed // Set the random number seed
@ -302,26 +311,37 @@ public class CDataUtil {
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, IPath srcPath, IPath srcRootPath, IPath srcPrefixMapping){ public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, IPath srcPath, IPath srcRootPath, IPath srcPrefixMapping){
ICSettingEntry entry = null;
switch (kind){ switch (kind){
case ICSettingEntry.INCLUDE_PATH: case ICLanguageSettingEntry.INCLUDE_PATH:
return new CIncludePathEntry(name, flags); entry = new CIncludePathEntry(name, flags);
case ICSettingEntry.MACRO: break;
return new CMacroEntry(name, value, flags); case ICLanguageSettingEntry.MACRO:
case ICSettingEntry.INCLUDE_FILE: entry = new CMacroEntry(name, value, flags);
return new CIncludeFileEntry(name, flags); break;
case ICSettingEntry.MACRO_FILE: case ICLanguageSettingEntry.INCLUDE_FILE:
return new CMacroFileEntry(name, flags); entry = new CIncludeFileEntry(name, flags);
case ICSettingEntry.LIBRARY_PATH: break;
return new CLibraryPathEntry(name, flags); case ICLanguageSettingEntry.MACRO_FILE:
case ICSettingEntry.LIBRARY_FILE: entry = new CMacroFileEntry(name, flags);
return new CLibraryFileEntry(name, flags, srcPath, srcRootPath, srcPrefixMapping); break;
case ICSettingEntry.OUTPUT_PATH: case ICLanguageSettingEntry.LIBRARY_PATH:
return new COutputEntry(name, exclusionPatterns, flags); entry = new CLibraryPathEntry(name, flags);
case ICSettingEntry.SOURCE_PATH: break;
return new CSourceEntry(name, exclusionPatterns, flags); case ICLanguageSettingEntry.LIBRARY_FILE:
} entry = new CLibraryFileEntry(name, flags, srcPath, srcRootPath, srcPrefixMapping);
break;
case ICLanguageSettingEntry.OUTPUT_PATH:
entry = new COutputEntry(name, exclusionPatterns, flags);
break;
case ICLanguageSettingEntry.SOURCE_PATH:
entry = new CSourceEntry(name, exclusionPatterns, flags);
break;
default:
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
return languageSettingsPool.add(entry);
}
public static String[] getSourceExtensions(IProject project, CLanguageData data) { public static String[] getSourceExtensions(IProject project, CLanguageData data) {
String[] exts = null; String[] exts = null;

View file

@ -26,6 +26,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable; import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager; import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.CoreModelUtil;
@ -68,6 +69,8 @@ import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.cdtvariables.CoreVariableSubstitutor; import org.eclipse.cdt.internal.core.cdtvariables.CoreVariableSubstitutor;
import org.eclipse.cdt.internal.core.cdtvariables.DefaultVariableContextInfo; import org.eclipse.cdt.internal.core.cdtvariables.DefaultVariableContextInfo;
import org.eclipse.cdt.internal.core.cdtvariables.ICoreVariableContextInfo; 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.APathEntry;
import org.eclipse.cdt.internal.core.model.CModelStatus; import org.eclipse.cdt.internal.core.model.CModelStatus;
import org.eclipse.cdt.internal.core.model.PathEntry; import org.eclipse.cdt.internal.core.model.PathEntry;
@ -2003,7 +2006,7 @@ public class PathEntryTranslator {
} }
} }
public static PathEntryCollector collectEntries(IProject project, ICConfigurationDescription des) { public static PathEntryCollector collectEntries(IProject project, final ICConfigurationDescription des) {
CConfigurationData data = getCfgData(des); CConfigurationData data = getCfgData(des);
ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des); ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des);
@ -2038,10 +2041,13 @@ public class PathEntryTranslator {
public boolean visit(PathSettingsContainer container) { public boolean visit(PathSettingsContainer container) {
CResourceData data = (CResourceData)container.getValue(); CResourceData data = (CResourceData)container.getValue();
if (data != null) { if (data != null) {
// AG FIXME - temporary log to remove before CDT Juno release
temporaryLog(des, kinds, data);
PathEntryCollector child = cr.createChild(container.getPath()); PathEntryCollector child = cr.createChild(container.getPath());
for (int kind : kinds) { for (int kind : kinds) {
List<ICLanguageSettingEntry> list = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> list = new ArrayList<ICLanguageSettingEntry>();
if (collectResourceDataEntries(kind, data, list)) { if (collectResourceDataEntries(des, kind, data, list)) {
ICLanguageSettingEntry[] entries = list.toArray(new ICLanguageSettingEntry[list.size()]); ICLanguageSettingEntry[] entries = list.toArray(new ICLanguageSettingEntry[list.size()]);
child.setEntries(kind, entries, exportedSettings); child.setEntries(kind, entries, exportedSettings);
} }
@ -2049,11 +2055,29 @@ public class PathEntryTranslator {
} }
return true; return true;
} }
// AG FIXME - temporary log to remove before CDT Juno release
@Deprecated
private void temporaryLog(final ICConfigurationDescription des, final int[] kinds, CResourceData data) {
String kindsStr="";
for (int kind : kinds) {
String kstr = LanguageSettingEntriesSerializer.kindToString(kind);
if (kindsStr.length()==0) {
kindsStr = kstr;
} else {
kindsStr += "|" + kstr;
}
}
final IProject prj = des.getProjectDescription().getProject();
String log_msg = "path="+prj+"/"+data.getPath()+", kind=["+kindsStr+"]"+" (PathEntryTranslator.collectEntries())";
LanguageSettingsLogger.logInfo(log_msg);
}
}); });
return cr; return cr;
} }
private static boolean collectResourceDataEntries(int kind, CResourceData data, List<ICLanguageSettingEntry> list) { private static boolean collectResourceDataEntries(ICConfigurationDescription des, int kind, CResourceData data, List<ICLanguageSettingEntry> list) {
CLanguageData[] lDatas = null; CLanguageData[] lDatas = null;
if (data instanceof CFolderData) { if (data instanceof CFolderData) {
lDatas = ((CFolderData)data).getLanguageDatas(); lDatas = ((CFolderData)data).getLanguageDatas();
@ -2070,6 +2094,17 @@ public class PathEntryTranslator {
return false; return false;
} }
IProject project = des.getProjectDescription().getProject();
if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project)) {
IResource rc = getResource(project, data.getPath());
for (CLanguageData lData : lDatas) {
list.addAll(LanguageSettingsProvidersSerializer.getSettingEntriesByKind(des, rc, lData.getLanguageId(), kind));
}
return list.size()>0;
}
// Legacy logic
boolean supported = false; boolean supported = false;
for (CLanguageData lData : lDatas) { for (CLanguageData lData : lDatas) {
if (collectLanguageDataEntries(kind, lData, list)) if (collectLanguageDataEntries(kind, lData, list))
@ -2094,4 +2129,14 @@ public class PathEntryTranslator {
PathEntryCollector cr = collectEntries(project, cfg); PathEntryCollector cr = collectEntries(project, cfg);
return cr.getEntries(flags, cfg); return cr.getEntries(flags, cfg);
} }
private static IResource getResource(IProject project, IPath workspacePath) {
IResource rc;
if (project!=null) {
rc = project.findMember(workspacePath);
} else {
rc = ResourcesPlugin.getWorkspace().getRoot().findMember(workspacePath);
}
return rc;
}
} }

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.LanguageSettingsSerializableProvider;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport; 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.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
@ -480,6 +482,9 @@ public class LanguageSettingsProvidersSerializer {
* @throws CoreException * @throws CoreException
*/ */
public static void serializeLanguageSettingsWorkspace() 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); URI uriStoreWsp = getStoreInWorkspaceArea(STORAGE_WORKSPACE_LANGUAGE_SETTINGS);
List<LanguageSettingsSerializableProvider> serializableWorkspaceProviders = new ArrayList<LanguageSettingsSerializableProvider>(); List<LanguageSettingsSerializableProvider> serializableWorkspaceProviders = new ArrayList<LanguageSettingsSerializableProvider>();
for (ILanguageSettingsProvider provider : rawGlobalWorkspaceProviders.values()) { for (ILanguageSettingsProvider provider : rawGlobalWorkspaceProviders.values()) {
@ -735,6 +740,9 @@ public class LanguageSettingsProvidersSerializer {
*/ */
public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException { public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException {
IProject project = prjDescription.getProject(); IProject project = prjDescription.getProject();
// AG FIXME - temporary log to remove before CDT Juno release
LanguageSettingsLogger.logWarning("LanguageSettingsProvidersSerializer.serializeLanguageSettings() for " + project);
try { try {
// Using side effect of adding the module to the storage // Using side effect of adding the module to the storage
prjDescription.getStorage(CPROJECT_STORAGE_MODULE, true); prjDescription.getStorage(CPROJECT_STORAGE_MODULE, true);
@ -1122,6 +1130,35 @@ public class LanguageSettingsProvidersSerializer {
return provider instanceof LanguageSettingsWorkspaceProvider; 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. * Check that this particular element is in the list.
*/ */
@ -1213,9 +1250,13 @@ public class LanguageSettingsProvidersSerializer {
*/ */
public static void reRegisterListeners(ICProjectDescription oldPrjDescription, ICProjectDescription newPrjDescription) { public static void reRegisterListeners(ICProjectDescription oldPrjDescription, ICProjectDescription newPrjDescription) {
if (oldPrjDescription == newPrjDescription) { if (oldPrjDescription == newPrjDescription) {
assertConsistency(oldPrjDescription);
return; return;
} }
assertConsistency(oldPrjDescription);
assertConsistency(newPrjDescription);
List<ICListenerAgent> oldListeners = getListeners(oldPrjDescription); List<ICListenerAgent> oldListeners = getListeners(oldPrjDescription);
List<ListenerAssociation> newAssociations = getListenersAssociations(newPrjDescription); List<ListenerAssociation> newAssociations = getListenersAssociations(newPrjDescription);
@ -1282,6 +1323,9 @@ public class LanguageSettingsProvidersSerializer {
* @param event - the {@link ILanguageSettingsChangeEvent} event to be broadcast. * @param event - the {@link ILanguageSettingsChangeEvent} event to be broadcast.
*/ */
private static void notifyLanguageSettingsChangeListeners(ILanguageSettingsChangeEvent event) { 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()) { for (Object listener : fLanguageSettingsChangeListeners.getListeners()) {
((ILanguageSettingsChangeListener) listener).handleEvent(event); ((ILanguageSettingsChangeListener) listener).handleEvent(event);
} }
@ -1485,4 +1529,109 @@ public class LanguageSettingsProvidersSerializer {
return new ArrayList<ILanguageSettingsProvider>(newProviders); 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

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

View file

@ -18,7 +18,10 @@ import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.settings.model.CConfigurationStatus; import org.eclipse.cdt.core.settings.model.CConfigurationStatus;
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
import org.eclipse.cdt.core.settings.model.ICBuildSetting; import org.eclipse.cdt.core.settings.model.ICBuildSetting;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -50,7 +53,15 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
public class CConfigurationDescription extends CDataProxyContainer implements ICConfigurationDescription, IProxyFactory, IInternalCCfgInfo { /**
* The writable configuration description.
*
* @see ICConfigurationDescription
* @see CConfigurationDescriptionCache
* @see CProjectDescriptionEvent
*/
public class CConfigurationDescription extends CDataProxyContainer
implements ICConfigurationDescription, IProxyFactory, IInternalCCfgInfo, ILanguageSettingsProvidersKeeper {
private CfgProxyCache fCache; private CfgProxyCache fCache;
// private ProxyProvider fFileProxyProvider; // private ProxyProvider fFileProxyProvider;
// private ProxyProvider fFolderProxyProvider; // private ProxyProvider fFolderProxyProvider;
@ -817,4 +828,42 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
CConfigurationStatus status = data.getStatus(); CConfigurationStatus status = data.getStatus();
return status != null ? status : CConfigurationStatus.CFG_STATUS_OK; return status != null ? status : CConfigurationStatus.CFG_STATUS_OK;
} }
@Override
public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) {
try {
getSpecSettings().setLanguageSettingProviders(providers);
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
@Override
public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
try {
return getSpecSettings().getLanguageSettingProviders();
} catch (CoreException e) {
CCorePlugin.log(e);
}
return null;
}
@Override
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
try {
getSpecSettings().setDefaultLanguageSettingsProvidersIds(ids);
} catch (CoreException e) {
CCorePlugin.log(e);
}
}
@Override
public String[] getDefaultLanguageSettingsProvidersIds() {
try {
return getSpecSettings().getDefaultLanguageSettingsProvidersIds();
} catch (CoreException e) {
CCorePlugin.log(e);
}
return null;
}
} }

View file

@ -16,7 +16,10 @@ import java.util.Map;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable; import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor; import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.settings.model.CConfigurationStatus; import org.eclipse.cdt.core.settings.model.CConfigurationStatus;
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
import org.eclipse.cdt.core.settings.model.ICBuildSetting; import org.eclipse.cdt.core.settings.model.ICBuildSetting;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@ -53,8 +56,42 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
/**
* CConfigurationDescriptionCache is a proxy class for serialization of configuration description data.
*
* An inspection of the scenario where user changes project properties and saves it yields
* following sequence of events:
* <ol>
* <li> Initialization:
* <ul>
* <li> After eclipse started a project is being opened. A new CConfigurationDescriptionCache is created
* with CConfigurationDescriptionCache(ICStorageElement storage, CProjectDescription parent) constructor.
* <li> Any clients needed ICConfigurationDescription get CConfigurationDescription using constructor
* CConfigurationDescription(CConfigurationData data, String buildSystemId, ICDataProxyContainer cr)
* where the CConfigurationDescriptionCache is passed as data. The reference to cache is kept in field fCfgCache.
* <li> fCfgCache is used to getSpecSettings() CConfigurationSpecSettings, after that fCfgCache is set to null.
* </ul>
* <li> User enters project properties/settings:
* <ul>
* <li> another CConfigurationDescription (settings configuration) created using the same constructor setting fCfgCache
* to the CConfigurationDescriptionCache.
* </ul>
* <li> User changes settings (in the settings configuration CConfigurationDescription) and saves it:
* <ul>
* <li> new CConfigurationDescriptionCache is created from the CConfigurationDescription via constructor
* CConfigurationDescriptionCache(ICConfigurationDescription baseDescription, ...) where
* baseDescription is saved as fBaseDescription.
* <li> CConfigurationDescriptionCache.applyData(...) is used to persist the data. at that point
* reference fBaseDescription gets set to null.
* </ul>
* </ol>
*
* @see ICConfigurationDescription
* @see CConfigurationDescription
* @see CProjectDescriptionEvent
*/
public class CConfigurationDescriptionCache extends CDefaultConfigurationData public class CConfigurationDescriptionCache extends CDefaultConfigurationData
implements ICConfigurationDescription, IInternalCCfgInfo, ICachedData { implements ICConfigurationDescription, IInternalCCfgInfo, ILanguageSettingsProvidersKeeper, ICachedData {
private CProjectDescription fParent; private CProjectDescription fParent;
private PathSettingsContainer fPathSettingContainer = PathSettingsContainer.createRootContainer(); private PathSettingsContainer fPathSettingContainer = PathSettingsContainer.createRootContainer();
private ResourceDescriptionHolder fRcHolder = new ResourceDescriptionHolder(fPathSettingContainer, true); private ResourceDescriptionHolder fRcHolder = new ResourceDescriptionHolder(fPathSettingContainer, true);
@ -580,4 +617,27 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
return status != null ? status : CConfigurationStatus.CFG_STATUS_OK; return status != null ? status : CConfigurationStatus.CFG_STATUS_OK;
} }
@Override
public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) {
if(!fInitializing)
throw ExceptionFactory.createIsReadOnlyException();
fSpecSettings.setLanguageSettingProviders(providers);
}
@Override
public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
return fSpecSettings.getLanguageSettingProviders();
}
@Override
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
if(!fInitializing)
throw ExceptionFactory.createIsReadOnlyException();
fSpecSettings.setDefaultLanguageSettingsProvidersIds(ids);
}
@Override
public String[] getDefaultLanguageSettingsProvidersIds() {
return fSpecSettings.getDefaultLanguageSettingsProvidersIds();
}
} }

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.settings.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -24,6 +25,7 @@ import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsBroadcastingProvider; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsBroadcastingProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; 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.LanguageSettingsManager;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsStorage;
import org.eclipse.cdt.core.settings.model.CExternalSetting; import org.eclipse.cdt.core.settings.model.CExternalSetting;
@ -44,6 +46,7 @@ import org.eclipse.cdt.internal.core.COwnerConfiguration;
import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables; import org.eclipse.cdt.internal.core.cdtvariables.StorableCdtVariables;
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsDelta; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsDelta;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.utils.envvar.StorableEnvironment; import org.eclipse.cdt.utils.envvar.StorableEnvironment;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.QualifiedName;
@ -55,7 +58,7 @@ import org.eclipse.core.runtime.QualifiedName;
* This corresponds to the <cconfiguration id="....> elements within * This corresponds to the <cconfiguration id="....> elements within
* the org.eclipse.cdt.core.settings storageModule in the project xml file * the org.eclipse.cdt.core.settings storageModule in the project xml file
*/ */
public class CConfigurationSpecSettings implements ICSettingsStorage{ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageSettingsProvidersKeeper {
static final String BUILD_SYSTEM_ID = "buildSystemId"; //$NON-NLS-1$ static final String BUILD_SYSTEM_ID = "buildSystemId"; //$NON-NLS-1$
// private final static String ELEMENT_REFERENCES = "references"; //$NON-NLS-1$ // private final static String ELEMENT_REFERENCES = "references"; //$NON-NLS-1$
private static final String PROJECT_EXTENSION_ATTR_POINT = "point"; //$NON-NLS-1$ private static final String PROJECT_EXTENSION_ATTR_POINT = "point"; //$NON-NLS-1$
@ -96,6 +99,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
private List<ILanguageSettingsProvider> fLanguageSettingsProviders = new ArrayList<ILanguageSettingsProvider>(0); private List<ILanguageSettingsProvider> fLanguageSettingsProviders = new ArrayList<ILanguageSettingsProvider>(0);
private LinkedHashMap<String /*provider*/, LanguageSettingsStorage> lspPersistedState = new LinkedHashMap<String, LanguageSettingsStorage>(); private LinkedHashMap<String /*provider*/, LanguageSettingsStorage> lspPersistedState = new LinkedHashMap<String, LanguageSettingsStorage>();
private String[] defaultLanguageSettingsProvidersIds = null;
private class DeltaSet { private class DeltaSet {
@ -190,6 +194,21 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fOwner = base.fOwner; fOwner = base.fOwner;
copyExtensionInfo(base); copyExtensionInfo(base);
fLanguageSettingsProviders = LanguageSettingsProvidersSerializer.cloneProviders(base.getLanguageSettingProviders());
for (String providerId : base.lspPersistedState.keySet()) {
try {
LanguageSettingsStorage clone = base.lspPersistedState.get(providerId).clone();
lspPersistedState.put(providerId, clone);
} catch (CloneNotSupportedException e) {
CCorePlugin.log("Not able to clone language settings storage:" + e); //$NON-NLS-1$
}
}
if (base.defaultLanguageSettingsProvidersIds != null) {
defaultLanguageSettingsProvidersIds = base.defaultLanguageSettingsProvidersIds.clone();
} else {
defaultLanguageSettingsProvidersIds = null;
}
} }
// private void copyRefInfos(Map infosMap){ // private void copyRefInfos(Map infosMap){
@ -989,6 +1008,46 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
ExtensionContainerFactory.updateReferencedProviderIds(fCfg, ids); ExtensionContainerFactory.updateReferencedProviderIds(fCfg, ids);
} }
/**
* Adds list of {@link ILanguageSettingsProvider} to the specs.
* Note that only unique IDs are accepted.
*
* @param providers - list of providers to keep in the specs.
*/
@Override
public void setLanguageSettingProviders(List<ILanguageSettingsProvider> providers) {
fLanguageSettingsProviders = new ArrayList<ILanguageSettingsProvider>(0);
Set<String> ids = new HashSet<String>();
for (ILanguageSettingsProvider provider : providers) {
String id = provider.getId();
if (provider==LanguageSettingsProvidersSerializer.getRawWorkspaceProvider(id)) {
throw new IllegalArgumentException("Error: Attempt to add to the configuration raw global provider " + id); //$NON-NLS-1$
}
if (!ids.contains(id)) {
fLanguageSettingsProviders.add(provider);
ids.add(id);
} else {
throw new IllegalArgumentException("Language Settings Providers must have unique ID. Duplicate ID=" + id); //$NON-NLS-1$
}
}
fIsModified = true;
}
@Override
public List<ILanguageSettingsProvider> getLanguageSettingProviders() {
return Collections.unmodifiableList(fLanguageSettingsProviders);
}
@Override
public void setDefaultLanguageSettingsProvidersIds(String[] ids) {
defaultLanguageSettingsProvidersIds = ids;
}
@Override
public String[] getDefaultLanguageSettingsProvidersIds() {
return defaultLanguageSettingsProvidersIds;
}
/** /**
* Returns delta and updates last persisted state to the new state. * Returns delta and updates last persisted state to the new state.
* That implies that the delta needs to be used to fire an event of it will * That implies that the delta needs to be used to fire an event of it will

View file

@ -50,6 +50,8 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta; import org.eclipse.cdt.core.model.ICElementDelta;
@ -1570,6 +1572,14 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
List<ILanguageSettingsProvider> newLSProviders = null;
if (newCfg instanceof ILanguageSettingsProvidersKeeper)
newLSProviders = ((ILanguageSettingsProvidersKeeper) newCfg).getLanguageSettingProviders();
List<ILanguageSettingsProvider> oldLSProviders = null;
if (oldCfg instanceof ILanguageSettingsProvidersKeeper)
oldLSProviders = ((ILanguageSettingsProvidersKeeper) oldCfg).getLanguageSettingProviders();
if(newLSProviders != oldLSProviders && (newLSProviders == null || !newLSProviders.equals(oldLSProviders)))
delta.addChangeFlags(ICDescriptionDelta.LANGUAGE_SETTINGS_PROVIDERS);
calculateCfgExtSettingsDelta(delta); calculateCfgExtSettingsDelta(delta);

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

View file

@ -16,10 +16,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySupport;
import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -34,6 +36,11 @@ public class ScannerInfoProviderProxy extends AbstractCExtensionProxy implements
@Override @Override
public IScannerInfo getScannerInformation(IResource resource) { public IScannerInfo getScannerInformation(IResource resource) {
if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(getProject())) {
LanguageSettingsScannerInfoProvider lsProvider = new LanguageSettingsScannerInfoProvider();
return lsProvider.getScannerInformation(resource);
}
// Legacy logic
providerRequested(); providerRequested();
return fProvider.getScannerInformation(resource); return fProvider.getScannerInformation(resource);
} }

View file

@ -34,6 +34,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.ICSettingsStorage; import org.eclipse.cdt.core.settings.model.ICSettingsStorage;
@ -42,6 +43,7 @@ import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.XmlUtil;
import org.eclipse.cdt.internal.core.envvar.ContributedEnvironment; import org.eclipse.cdt.internal.core.envvar.ContributedEnvironment;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.internal.core.settings.model.AbstractCProjectDescriptionStorage; import org.eclipse.cdt.internal.core.settings.model.AbstractCProjectDescriptionStorage;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescription; import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
@ -170,6 +172,7 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto
}, null, IWorkspace.AVOID_UPDATE, null); }, null, IWorkspace.AVOID_UPDATE, null);
// end Bug 249951 & Bug 310007 // end Bug 249951 & Bug 310007
serializingLock.acquire(); serializingLock.acquire();
LanguageSettingsManager.serializeLanguageSettings(fDes);
projectModificaitonStamp = serialize(fDes.getProject(), ICProjectDescriptionStorageType.STORAGE_FILE_NAME, fElement); projectModificaitonStamp = serialize(fDes.getProject(), ICProjectDescriptionStorageType.STORAGE_FILE_NAME, fElement);
((ContributedEnvironment) CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes); ((ContributedEnvironment) CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment()).serialize(fDes);
} finally { } finally {
@ -364,6 +367,7 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto
if (!overwriteIfExists && fProjectDescription.get() != null) if (!overwriteIfExists && fProjectDescription.get() != null)
return false; return false;
ICProjectDescription oldDes = fProjectDescription.get();
if (des != null) { if (des != null) {
if (project.exists() && project.isOpen()) { if (project.exists() && project.isOpen()) {
fProjectDescription = new SoftReference<ICProjectDescription>(des); fProjectDescription = new SoftReference<ICProjectDescription>(des);
@ -374,6 +378,8 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto
} else { } else {
fProjectDescription = new SoftReference<ICProjectDescription>(null); fProjectDescription = new SoftReference<ICProjectDescription>(null);
} }
LanguageSettingsProvidersSerializer.reRegisterListeners(oldDes, fProjectDescription.get());
return true; return true;
} }
@ -486,6 +492,8 @@ public class XmlProjectDescriptionStorage extends AbstractCProjectDescriptionSto
try { try {
setThreadLocalProjectDesc(des); setThreadLocalProjectDesc(des);
des.loadDatas(); des.loadDatas();
LanguageSettingsProvidersSerializer.loadLanguageSettings(des);
des.doneLoading(); des.doneLoading();
} finally { } finally {
setThreadLocalProjectDesc(null); setThreadLocalProjectDesc(null);

View file

@ -48,6 +48,7 @@ import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.index.IIndexerStateListener; import org.eclipse.cdt.core.index.IIndexerStateListener;
import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.index.IndexerSetupParticipant; import org.eclipse.cdt.core.index.IndexerSetupParticipant;
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICContainer;
@ -168,6 +169,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
private CModelListener fCModelListener= new CModelListener(this); private CModelListener fCModelListener= new CModelListener(this);
private ILanguageMappingChangeListener fLanguageChangeListener = new LanguageMappingChangeListener(this); private ILanguageMappingChangeListener fLanguageChangeListener = new LanguageMappingChangeListener(this);
private LanguageSettingsChangeListener fLanguageSettingsChangeListener = new LanguageSettingsChangeListener(this);
private final ICProjectDescriptionListener fProjectDescriptionListener; private final ICProjectDescriptionListener fProjectDescriptionListener;
private final JobChangeListener fJobChangeListener; private final JobChangeListener fJobChangeListener;
private final IPreferenceChangeListener fPreferenceChangeListener; private final IPreferenceChangeListener fPreferenceChangeListener;
@ -241,6 +243,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
ResourcesPlugin.getWorkspace().addResourceChangeListener(fCModelListener, IResourceChangeEvent.POST_BUILD); ResourcesPlugin.getWorkspace().addResourceChangeListener(fCModelListener, IResourceChangeEvent.POST_BUILD);
model.addElementChangedListener(fCModelListener); model.addElementChangedListener(fCModelListener);
LanguageManager.getInstance().registerLanguageChangeListener(fLanguageChangeListener); LanguageManager.getInstance().registerLanguageChangeListener(fLanguageChangeListener);
LanguageSettingsManager.registerLanguageSettingsChangeListener(fLanguageSettingsChangeListener);
final int types= CProjectDescriptionEvent.DATA_APPLIED; final int types= CProjectDescriptionEvent.DATA_APPLIED;
CCorePlugin.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(fProjectDescriptionListener, types); CCorePlugin.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(fProjectDescriptionListener, types);
@ -261,6 +264,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
final CoreModel model = CoreModel.getDefault(); final CoreModel model = CoreModel.getDefault();
model.removeElementChangedListener(fCModelListener); model.removeElementChangedListener(fCModelListener);
ResourcesPlugin.getWorkspace().removeResourceChangeListener(fCModelListener); ResourcesPlugin.getWorkspace().removeResourceChangeListener(fCModelListener);
LanguageSettingsManager.unregisterLanguageSettingsChangeListener(fLanguageSettingsChangeListener);
LanguageManager.getInstance().unregisterLanguageChangeListener(fLanguageChangeListener); LanguageManager.getInstance().unregisterLanguageChangeListener(fLanguageChangeListener);
PDOMIndexerJob jobToCancel= null; PDOMIndexerJob jobToCancel= null;
synchronized (fTaskQueue) { synchronized (fTaskQueue) {

View file

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

View file

@ -529,8 +529,10 @@ public class CCorePlugin extends Plugin {
* </code> * </code>
* *
* @return CDT console adapter. * @return CDT console adapter.
*
* @since 5.4
*/ */
private IConsole getConsole(String extConsoleId, String contextId, String name, URL iconUrl) { public IConsole getConsole(String extConsoleId, String contextId, String name, URL iconUrl) {
try { try {
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, "CBuildConsole"); //$NON-NLS-1$ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, "CBuildConsole"); //$NON-NLS-1$
if (extensionPoint != null) { if (extensionPoint != null) {

View file

@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2009, 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.core;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.core.runtime.CoreException;
/**
* Console parser interface extended to support configurations.
*
* @since 5.4
*/
public interface ICConsoleParser extends IConsoleParser {
/**
* Initialize console parser.
*
* @param cfgDescription - configuration description for the parser.
* @throws CoreException if anything goes wrong.
*/
public void startup(ICConfigurationDescription cfgDescription) throws CoreException;
@Override
public boolean processLine(String line);
@Override
public void shutdown();
}

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.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; 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.model.PathEntryManager;
import org.eclipse.cdt.internal.core.settings.model.ScannerInfoProviderProxy; 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.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -96,6 +98,13 @@ public class ScannerProvider extends AbstractCExtension implements IScannerInfoP
*/ */
@Override @Override
public IScannerInfo getScannerInformation(IResource resource) { 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(); IPath resPath = resource.getFullPath();
try { try {

View file

@ -13,7 +13,10 @@ package org.eclipse.cdt.internal.core;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IConsoleParser; import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.IErrorParser;
/** /**
@ -127,6 +130,8 @@ public class ConsoleOutputSniffer {
private OutputStream consoleErrorStream; private OutputStream consoleErrorStream;
private IConsoleParser[] parsers; private IConsoleParser[] parsers;
private ErrorParserManager errorParserManager = null;
public ConsoleOutputSniffer(IConsoleParser[] parsers) { public ConsoleOutputSniffer(IConsoleParser[] parsers) {
this.parsers = parsers; this.parsers = parsers;
} }
@ -137,6 +142,11 @@ public class ConsoleOutputSniffer {
this.consoleErrorStream = errorStream; this.consoleErrorStream = errorStream;
} }
public ConsoleOutputSniffer(OutputStream outputStream, OutputStream errorStream, IConsoleParser[] parsers, ErrorParserManager epm) {
this(outputStream, errorStream, parsers);
this.errorParserManager = epm;
}
/** /**
* Returns an output stream that will be sniffed. * Returns an output stream that will be sniffed.
* This stream should be hooked up so the command * This stream should be hooked up so the command
@ -166,7 +176,13 @@ public class ConsoleOutputSniffer {
public synchronized void closeConsoleOutputStream() throws IOException { public synchronized void closeConsoleOutputStream() throws IOException {
if (nOpens > 0 && --nOpens == 0) { if (nOpens > 0 && --nOpens == 0) {
for (int i = 0; i < parsers.length; ++i) { for (int i = 0; i < parsers.length; ++i) {
try {
parsers[i].shutdown(); parsers[i].shutdown();
} catch (Throwable e) {
// Report exception if any but let all the parsers chance to shutdown.
CCorePlugin.log(e);
} finally {
}
} }
} }
} }
@ -177,8 +193,18 @@ public class ConsoleOutputSniffer {
* @param line * @param line
*/ */
private synchronized void processLine(String line) { private synchronized void processLine(String line) {
for (int i = 0; i < parsers.length; ++i) { for (IConsoleParser parser : parsers) {
parsers[i].processLine(line); try {
if (parser instanceof IErrorParser) {
// IErrorParser interface is used here only with purpose to pass ErrorParserManager
// which keeps track of CWD and provides useful methods for locating files
((IErrorParser)parser).processLine(line, errorParserManager);
} else {
parser.processLine(line);
}
} catch (Throwable e) {
CCorePlugin.log(e);
}
} }
} }

View file

@ -0,0 +1,101 @@
/*******************************************************************************
* 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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.EFSExtensionProvider;
import org.eclipse.core.runtime.Platform;
public class CygwinEFSExtensionProvider extends EFSExtensionProvider {
@Override
public String getMappedPath(URI locationURI) {
String cygwinPath = getPathFromURI(locationURI);
String windowsPath = null;
try {
windowsPath = cygwinToWindowsPath(cygwinPath);
} catch (Exception e) {
CCorePlugin.log(e);
}
return windowsPath;
}
/**
* Conversion from Windows path to Cygwin path.
*
* @param windowsPath - Windows path.
* @return Cygwin style converted path.
* @throws UnsupportedOperationException if Cygwin is unavailable.
* @throws IOException on IO problem.
*
* See ResourceHelper.windowsToCygwinPath(...)
*/
public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException {
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
// Don't run this on non-windows platforms
throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable.");
}
@SuppressWarnings("nls")
String[] args = {"cygpath", "-u", windowsPath};
Process cygpath;
try {
cygpath = Runtime.getRuntime().exec(args);
} catch (IOException ioe) {
throw new UnsupportedOperationException("Cygwin utility cygpath is not in the system search path.");
}
BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpath.getInputStream()));
String cygwinPath = stdout.readLine();
if (cygwinPath == null) {
throw new UnsupportedOperationException("Cygwin utility cygpath is not available.");
}
return cygwinPath.trim();
}
/**
* Conversion from Cygwin path to Windows path.
*
* @param cygwinPath - Cygwin path.
* @return Windows style converted path.
* @throws UnsupportedOperationException if Cygwin is unavailable.
* @throws IOException on IO problem.
*
* * See ResourceHelper.cygwinToWindowsPath(...)
*/
public static String cygwinToWindowsPath(String cygwinPath) throws IOException, UnsupportedOperationException {
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
// Don't run this on non-windows platforms
throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable.");
}
@SuppressWarnings("nls")
String[] args = {"cygpath", "-w", cygwinPath};
Process cygpath;
try {
cygpath = Runtime.getRuntime().exec(args);
} catch (IOException ioe) {
throw new UnsupportedOperationException("Cygwin utility cygpath is not in the system search path.");
}
BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpath.getInputStream()));
String windowsPath = stdout.readLine();
if (windowsPath == null) {
throw new UnsupportedOperationException("Cygwin utility cygpath is not available.");
}
return windowsPath.trim();
}
}

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.includebrowser;x-internal:=true,
org.eclipse.cdt.internal.ui.indexview;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;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.navigator;x-internal:=true,
org.eclipse.cdt.internal.ui.newui;x-internal:=true, org.eclipse.cdt.internal.ui.newui;x-internal:=true,
org.eclipse.cdt.internal.ui.preferences;x-internal:=true, org.eclipse.cdt.internal.ui.preferences;x-internal:=true,

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

Some files were not shown because too many files have changed in this diff Show more