mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
JavaDoc and clean-up
This commit is contained in:
parent
6411690b76
commit
58721c65b9
21 changed files with 954 additions and 565 deletions
|
@ -239,4 +239,4 @@ public class ManagedBuildDependencyCalculatorTests extends TestCase {
|
||||||
buildProjects(projects, makefiles);
|
buildProjects(projects, makefiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,6 +13,9 @@ package org.eclipse.cdt.managedbuilder.language.settings.providers.tests;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test suite to test language settings providers defined in cdt.managedbuilder.core.
|
||||||
|
*/
|
||||||
public class AllLanguageSettingsProvidersMBSTests extends TestSuite {
|
public class AllLanguageSettingsProvidersMBSTests extends TestSuite {
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
|
|
|
@ -44,6 +44,9 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test cases to test built-in specs detectors.
|
||||||
|
*/
|
||||||
public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
private static final String PROVIDER_ID = "provider.id";
|
private static final String PROVIDER_ID = "provider.id";
|
||||||
private static final String PROVIDER_NAME = "provider name";
|
private static final String PROVIDER_NAME = "provider name";
|
||||||
|
@ -56,6 +59,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
|
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
|
||||||
private static final String ATTR_CONSOLE = "console"; //$NON-NLS-1$
|
private static final String ATTR_CONSOLE = "console"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock built-in specs detector to test basic functionality of {@link AbstractBuiltinSpecsDetector}.
|
||||||
|
*/
|
||||||
private class MockBuiltinSpecsDetector extends AbstractBuiltinSpecsDetector {
|
private class MockBuiltinSpecsDetector extends AbstractBuiltinSpecsDetector {
|
||||||
@Override
|
@Override
|
||||||
protected List<String> parseOptions(String line) {
|
protected List<String> parseOptions(String line) {
|
||||||
|
@ -80,6 +86,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock built-in specs detector to test execute() functionality.
|
||||||
|
*/
|
||||||
private class MockBuiltinSpecsDetectorExecutedFlag extends AbstractBuiltinSpecsDetector {
|
private class MockBuiltinSpecsDetectorExecutedFlag extends AbstractBuiltinSpecsDetector {
|
||||||
@Override
|
@Override
|
||||||
protected List<String> parseOptions(String line) {
|
protected List<String> parseOptions(String line) {
|
||||||
|
@ -103,6 +112,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock built-in specs detector to test parsing functionality.
|
||||||
|
*/
|
||||||
private class MockConsoleBuiltinSpecsDetector extends AbstractBuiltinSpecsDetector {
|
private class MockConsoleBuiltinSpecsDetector extends AbstractBuiltinSpecsDetector {
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
private final AbstractOptionParser[] optionParsers = {
|
private final AbstractOptionParser[] optionParsers = {
|
||||||
|
@ -148,6 +160,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to fetch configuration descriptions.
|
||||||
|
*/
|
||||||
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
|
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
|
||||||
CoreModel coreModel = CoreModel.getDefault();
|
CoreModel coreModel = CoreModel.getDefault();
|
||||||
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
|
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
|
||||||
|
@ -160,6 +175,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
return cfgDescriptions;
|
return cfgDescriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test configure, getters and setters.
|
||||||
|
*/
|
||||||
public void testAbstractBuiltinSpecsDetector_GettersSetters() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_GettersSetters() throws Exception {
|
||||||
{
|
{
|
||||||
// provider configured with null parameters
|
// provider configured with null parameters
|
||||||
|
@ -206,6 +224,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test clone() and equals().
|
||||||
|
*/
|
||||||
public void testAbstractBuiltinSpecsDetector_CloneAndEquals() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_CloneAndEquals() throws Exception {
|
||||||
// define mock detector
|
// define mock detector
|
||||||
class MockDetectorCloneable extends MockBuiltinSpecsDetectorExecutedFlag implements Cloneable {
|
class MockDetectorCloneable extends MockBuiltinSpecsDetectorExecutedFlag implements Cloneable {
|
||||||
|
@ -302,8 +323,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test basic serialization functionality.
|
||||||
*/
|
*/
|
||||||
public void testAbstractBuiltinSpecsDetector_Serialize() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_SerializeDOM() throws Exception {
|
||||||
{
|
{
|
||||||
// create empty XML
|
// create empty XML
|
||||||
Document doc = XmlUtil.newDocument();
|
Document doc = XmlUtil.newDocument();
|
||||||
|
@ -344,6 +366,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smoke test exercising passing {@code null} to the functions.
|
||||||
|
*/
|
||||||
public void testAbstractBuiltinSpecsDetector_Nulls() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_Nulls() throws Exception {
|
||||||
{
|
{
|
||||||
// test AbstractBuiltinSpecsDetector.processLine(...) flow
|
// test AbstractBuiltinSpecsDetector.processLine(...) flow
|
||||||
|
@ -363,6 +388,9 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test basic parsing functionality.
|
||||||
|
*/
|
||||||
public void testAbstractBuiltinSpecsDetector_RunConfiguration() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_RunConfiguration() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
String projectName = getName();
|
String projectName = getName();
|
||||||
|
@ -373,6 +401,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
MockConsoleBuiltinSpecsDetector provider = new MockConsoleBuiltinSpecsDetector();
|
MockConsoleBuiltinSpecsDetector provider = new MockConsoleBuiltinSpecsDetector();
|
||||||
provider.setLanguageScope(new ArrayList<String>() {{add(LANGUAGE_ID);}});
|
provider.setLanguageScope(new ArrayList<String>() {{add(LANGUAGE_ID);}});
|
||||||
|
|
||||||
|
// Run provider
|
||||||
provider.startup(cfgDescription, null);
|
provider.startup(cfgDescription, null);
|
||||||
provider.runForEachLanguage(null);
|
provider.runForEachLanguage(null);
|
||||||
provider.shutdown();
|
provider.shutdown();
|
||||||
|
@ -382,26 +411,36 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
List<ICLanguageSettingEntry> noentries = provider.getSettingEntries(null, null, null);
|
List<ICLanguageSettingEntry> noentries = provider.getSettingEntries(null, null, null);
|
||||||
assertNull(noentries);
|
assertNull(noentries);
|
||||||
|
|
||||||
|
// Check parsed entries
|
||||||
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(cfgDescription, null, LANGUAGE_ID);
|
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(cfgDescription, null, LANGUAGE_ID);
|
||||||
ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
|
ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
|
||||||
assertEquals(expected, entries.get(0));
|
assertEquals(expected, entries.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smoke test running as global provider on workspace level.
|
||||||
|
*/
|
||||||
public void testAbstractBuiltinSpecsDetector_RunGlobal() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_RunGlobal() throws Exception {
|
||||||
|
// Create provider
|
||||||
MockConsoleBuiltinSpecsDetector provider = new MockConsoleBuiltinSpecsDetector();
|
MockConsoleBuiltinSpecsDetector provider = new MockConsoleBuiltinSpecsDetector();
|
||||||
provider.setLanguageScope(new ArrayList<String>() {{add(LANGUAGE_ID);}});
|
provider.setLanguageScope(new ArrayList<String>() {{add(LANGUAGE_ID);}});
|
||||||
|
|
||||||
|
// Run provider
|
||||||
provider.startup(null, null);
|
provider.startup(null, null);
|
||||||
provider.runForEachLanguage(null);
|
provider.runForEachLanguage(null);
|
||||||
provider.shutdown();
|
provider.shutdown();
|
||||||
|
|
||||||
assertFalse(provider.isEmpty());
|
assertFalse(provider.isEmpty());
|
||||||
|
|
||||||
|
// Check parsed entries
|
||||||
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, LANGUAGE_ID);
|
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, LANGUAGE_ID);
|
||||||
ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
|
ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
|
||||||
assertEquals(expected, entries.get(0));
|
assertEquals(expected, entries.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that entries get grouped by kinds by stock built-in specs detector.
|
||||||
|
*/
|
||||||
public void testAbstractBuiltinSpecsDetector_GroupSettings() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_GroupSettings() throws Exception {
|
||||||
// define benchmarks
|
// define benchmarks
|
||||||
final CIncludePathEntry includePath_1 = new CIncludePathEntry("/include/path_1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
|
final CIncludePathEntry includePath_1 = new CIncludePathEntry("/include/path_1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
|
||||||
|
@ -448,7 +487,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
// compare benchmarks, expected well-sorted
|
// compare benchmarks, expected well-sorted
|
||||||
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
|
List<ICLanguageSettingEntry> entries = provider.getSettingEntries(null, null, null);
|
||||||
|
|
||||||
int i=0;
|
int i = 0;
|
||||||
assertEquals(includePath_1, entries.get(i++));
|
assertEquals(includePath_1, entries.get(i++));
|
||||||
assertEquals(includePath_2, entries.get(i++));
|
assertEquals(includePath_2, entries.get(i++));
|
||||||
assertEquals(includeFile_1, entries.get(i++));
|
assertEquals(includeFile_1, entries.get(i++));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
* Copyright (c) 2009, 2012 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
|
||||||
|
@ -54,6 +54,9 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test cases to test build command parsers.
|
||||||
|
*/
|
||||||
public class GCCBuildCommandParserTest extends BaseTestCase {
|
public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
// ID of the parser taken from the extension point
|
// ID of the parser taken from the extension point
|
||||||
private static final String GCC_BUILD_COMMAND_PARSER_EXT = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$
|
private static final String GCC_BUILD_COMMAND_PARSER_EXT = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$
|
||||||
|
@ -70,6 +73,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
|
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
|
||||||
private static final String ATTR_KEEP_RELATIVE_PATHS = "keep-relative-paths"; //$NON-NLS-1$
|
private static final String ATTR_KEEP_RELATIVE_PATHS = "keep-relative-paths"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock build command parser.
|
||||||
|
*/
|
||||||
private class MockBuildCommandParser extends AbstractBuildCommandParser implements Cloneable {
|
private class MockBuildCommandParser extends AbstractBuildCommandParser implements Cloneable {
|
||||||
@Override
|
@Override
|
||||||
protected AbstractOptionParser[] getOptionParsers() {
|
protected AbstractOptionParser[] getOptionParsers() {
|
||||||
|
@ -100,6 +106,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to fetch configuration descriptions.
|
||||||
|
*/
|
||||||
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
|
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
|
||||||
CoreModel coreModel = CoreModel.getDefault();
|
CoreModel coreModel = CoreModel.getDefault();
|
||||||
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
|
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
|
||||||
|
@ -139,6 +148,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to set reference project.
|
||||||
|
*/
|
||||||
private void setReference(IProject project, final IProject projectReferenced) throws CoreException {
|
private void setReference(IProject project, final IProject projectReferenced) throws CoreException {
|
||||||
{
|
{
|
||||||
CoreModel coreModel = CoreModel.getDefault();
|
CoreModel coreModel = CoreModel.getDefault();
|
||||||
|
@ -169,6 +181,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test getters and setters.
|
||||||
|
*/
|
||||||
public void testAbstractBuildCommandParser_GettersSetters() throws Exception {
|
public void testAbstractBuildCommandParser_GettersSetters() throws Exception {
|
||||||
{
|
{
|
||||||
// provider configured with null parameters
|
// provider configured with null parameters
|
||||||
|
@ -206,6 +221,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test clone() and equals().
|
||||||
|
*/
|
||||||
public void testAbstractBuildCommandParser_CloneAndEquals() throws Exception {
|
public void testAbstractBuildCommandParser_CloneAndEquals() throws Exception {
|
||||||
// create instance to compare to
|
// create instance to compare to
|
||||||
MockBuildCommandParser parser = new MockBuildCommandParser();
|
MockBuildCommandParser parser = new MockBuildCommandParser();
|
||||||
|
@ -242,7 +260,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAbstractBuildCommandParser_Serialize() throws Exception {
|
/**
|
||||||
|
* Test basic serialization functionality.
|
||||||
|
*/
|
||||||
|
public void testAbstractBuildCommandParser_SerializeDOM() throws Exception {
|
||||||
{
|
{
|
||||||
// create empty XML
|
// create empty XML
|
||||||
Document doc = XmlUtil.newDocument();
|
Document doc = XmlUtil.newDocument();
|
||||||
|
@ -283,6 +304,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smoke test exercising passing {@code null} to the functions.
|
||||||
|
*/
|
||||||
public void testAbstractBuildCommandParser_Nulls() throws Exception {
|
public void testAbstractBuildCommandParser_Nulls() throws Exception {
|
||||||
MockBuildCommandParser parser = new MockBuildCommandParser();
|
MockBuildCommandParser parser = new MockBuildCommandParser();
|
||||||
parser.startup(null, null);
|
parser.startup(null, null);
|
||||||
|
@ -293,6 +317,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
assertNull(entries);
|
assertNull(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test basic parsing functionality.
|
||||||
|
*/
|
||||||
public void testAbstractBuildCommandParser_Basic() throws Exception {
|
public void testAbstractBuildCommandParser_Basic() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
String projectName = getName();
|
String projectName = getName();
|
||||||
|
@ -333,17 +360,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
assertEquals(expected, entries.get(0));
|
assertEquals(expected, entries.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void testGCCBuildCommandParser_Nulls() throws Exception {
|
|
||||||
// GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT);
|
|
||||||
// parser.startup(null);
|
|
||||||
// parser.processLine(null);
|
|
||||||
// parser.shutdown();
|
|
||||||
//
|
|
||||||
// List<ICLanguageSettingEntry> entries = parser.getSettingEntries(null, null, null);
|
|
||||||
// assertNull(entries);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test parsing of one typical entry.
|
||||||
*/
|
*/
|
||||||
public void testOneEntry() throws Exception {
|
public void testOneEntry() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -379,6 +397,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test possible variations of compiler command.
|
||||||
*/
|
*/
|
||||||
public void testGccFlavors() throws Exception {
|
public void testGccFlavors() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -450,6 +469,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parse variations of -I options.
|
||||||
*/
|
*/
|
||||||
public void testCIncludePathEntry() throws Exception {
|
public void testCIncludePathEntry() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -522,6 +542,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parse variations of -D options.
|
||||||
*/
|
*/
|
||||||
public void testCMacroEntry() throws Exception {
|
public void testCMacroEntry() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -600,6 +621,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parse -U option.
|
||||||
*/
|
*/
|
||||||
public void testCMacroEntry_undef() throws Exception {
|
public void testCMacroEntry_undef() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -630,6 +652,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parse variations of -include options.
|
||||||
*/
|
*/
|
||||||
public void testCIncludeFileEntry() throws Exception {
|
public void testCIncludeFileEntry() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -681,6 +704,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parse variations of -macros options.
|
||||||
*/
|
*/
|
||||||
public void testCMacroFileEntry() throws Exception {
|
public void testCMacroFileEntry() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -726,6 +750,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parse variations of -L options.
|
||||||
*/
|
*/
|
||||||
public void testCLibraryPathEntry() throws Exception {
|
public void testCLibraryPathEntry() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -770,6 +795,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parse variations of -l options.
|
||||||
*/
|
*/
|
||||||
public void testCLibraryFileEntry() throws Exception {
|
public void testCLibraryFileEntry() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -802,6 +828,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parse mixed options in the same command.
|
||||||
*/
|
*/
|
||||||
public void testMixedSettingEntries() throws Exception {
|
public void testMixedSettingEntries() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -856,6 +883,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parse command where resource is missing.
|
||||||
*/
|
*/
|
||||||
public void testFileMissing() throws Exception {
|
public void testFileMissing() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -877,6 +905,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parsing of absolute path to the file being compiled.
|
||||||
*/
|
*/
|
||||||
public void testFileAbsolutePath() throws Exception {
|
public void testFileAbsolutePath() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -910,6 +939,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parsing of absolute path to the file being compiled where provider is global.
|
||||||
*/
|
*/
|
||||||
public void testFileAbsolutePath_NoProject() throws Exception {
|
public void testFileAbsolutePath_NoProject() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -943,6 +973,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Parsing where the name of the file being compiled contains spaces.
|
||||||
*/
|
*/
|
||||||
public void testFileWithSpaces() throws Exception {
|
public void testFileWithSpaces() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -998,6 +1029,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Resolve disagreement between working directory and path to the file being compiled.
|
||||||
*/
|
*/
|
||||||
public void testFileIgnoreWrongBuildDir() throws Exception {
|
public void testFileIgnoreWrongBuildDir() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1015,6 +1047,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true);
|
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true);
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, null);
|
ErrorParserManager epm = new ErrorParserManager(project, null);
|
||||||
// Shift build directory, that could happen if Make Target from folder1 was run
|
// Shift build directory, that could happen if Make Target from folder1 was run
|
||||||
|
// Build directory points to /project/Folder1/
|
||||||
IFolder buildDir = folder1;
|
IFolder buildDir = folder1;
|
||||||
epm.pushDirectoryURI(buildDir.getLocationURI());
|
epm.pushDirectoryURI(buildDir.getLocationURI());
|
||||||
|
|
||||||
|
@ -1023,6 +1056,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
parser.processLine("gcc "
|
parser.processLine("gcc "
|
||||||
+ "-I/path0 "
|
+ "-I/path0 "
|
||||||
+ "-I. "
|
+ "-I. "
|
||||||
|
// This implies the build working directory is /project/
|
||||||
+ "Folder1/Folder2/file.cpp");
|
+ "Folder1/Folder2/file.cpp");
|
||||||
parser.shutdown();
|
parser.shutdown();
|
||||||
|
|
||||||
|
@ -1037,6 +1071,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test various ends of lines for the lines being parsed.
|
||||||
*/
|
*/
|
||||||
public void testEndOfLine() throws Exception {
|
public void testEndOfLine() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1084,6 +1119,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test parsing of paths located on a different drive on Windows.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_DriveLetter() throws Exception {
|
public void testPathEntry_DriveLetter() throws Exception {
|
||||||
// do not test on non-windows systems where drive letters are not supported
|
// do not test on non-windows systems where drive letters are not supported
|
||||||
|
@ -1117,6 +1153,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test various relative paths provided in options with resolving.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_ExpandRelativePath() throws Exception {
|
public void testPathEntry_ExpandRelativePath() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1157,6 +1194,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test various relative paths provided in options without resolving.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_DoNotExpandRelativePath() throws Exception {
|
public void testPathEntry_DoNotExpandRelativePath() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1194,6 +1232,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Ensure that duplicate paths are ignored.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_DuplicatePath() throws Exception {
|
public void testPathEntry_DuplicatePath() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1228,6 +1267,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test that working directory supplied by ErrorParserManager is considered.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_FollowCWD() throws Exception {
|
public void testPathEntry_FollowCWD() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1247,6 +1287,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
// create GCCBuildCommandParser
|
// create GCCBuildCommandParser
|
||||||
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true);
|
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true);
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, null);
|
ErrorParserManager epm = new ErrorParserManager(project, null);
|
||||||
|
// Set different working directory
|
||||||
epm.pushDirectoryURI(buildDir.getLocationURI());
|
epm.pushDirectoryURI(buildDir.getLocationURI());
|
||||||
|
|
||||||
// parse line
|
// parse line
|
||||||
|
@ -1272,6 +1313,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Determine working directory basing on file being compiled.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_GuessCWD() throws Exception {
|
public void testPathEntry_GuessCWD() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1303,6 +1345,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test case when build command indicates impossible working directory.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_NonExistentCWD_Workspace() throws Exception {
|
public void testPathEntry_NonExistentCWD_Workspace() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1320,6 +1363,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true);
|
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true);
|
||||||
|
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, null);
|
ErrorParserManager epm = new ErrorParserManager(project, null);
|
||||||
|
// define working directory
|
||||||
epm.pushDirectoryURI(buildDir.getLocationURI());
|
epm.pushDirectoryURI(buildDir.getLocationURI());
|
||||||
|
|
||||||
// parse line
|
// parse line
|
||||||
|
@ -1328,6 +1372,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
+ " -I."
|
+ " -I."
|
||||||
+ " -I.."
|
+ " -I.."
|
||||||
+ " -IFolder"
|
+ " -IFolder"
|
||||||
|
// indicates non-existing working directory
|
||||||
+ " ../file.cpp");
|
+ " ../file.cpp");
|
||||||
parser.shutdown();
|
parser.shutdown();
|
||||||
|
|
||||||
|
@ -1341,6 +1386,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test case when build command indicates impossible working directory and
|
||||||
|
* ErrorParserManager indicates non-existing working directory.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_NonExistentCWD_Filesystem() throws Exception {
|
public void testPathEntry_NonExistentCWD_Filesystem() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1358,6 +1405,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
|
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, null);
|
ErrorParserManager epm = new ErrorParserManager(project, null);
|
||||||
URI uriBuildDir = new URI("file:/non-existing/path");
|
URI uriBuildDir = new URI("file:/non-existing/path");
|
||||||
|
// define non-existing working directory
|
||||||
epm.pushDirectoryURI(uriBuildDir);
|
epm.pushDirectoryURI(uriBuildDir);
|
||||||
|
|
||||||
// parse line
|
// parse line
|
||||||
|
@ -1366,6 +1414,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
+ " -I."
|
+ " -I."
|
||||||
+ " -I.."
|
+ " -I.."
|
||||||
+ " -IFolder"
|
+ " -IFolder"
|
||||||
|
// indicates non-existing working directory
|
||||||
+ " ../file.cpp");
|
+ " ../file.cpp");
|
||||||
parser.shutdown();
|
parser.shutdown();
|
||||||
|
|
||||||
|
@ -1380,6 +1429,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Simulate mapping of a sub-folder in the project to remote URI.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_MappedRemoteFolder() throws Exception {
|
public void testPathEntry_MappedRemoteFolder() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1399,6 +1449,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true);
|
GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true);
|
||||||
|
|
||||||
ErrorParserManager epm = new ErrorParserManager(project, null);
|
ErrorParserManager epm = new ErrorParserManager(project, null);
|
||||||
|
// define working directory as URI pointing outside workspace
|
||||||
URI uriBuildDir = new URI("file:/BuildDir");
|
URI uriBuildDir = new URI("file:/BuildDir");
|
||||||
epm.pushDirectoryURI(uriBuildDir);
|
epm.pushDirectoryURI(uriBuildDir);
|
||||||
|
|
||||||
|
@ -1425,6 +1476,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test mapping folders heuristics - inside a project.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_MappedFolderInProject() throws Exception {
|
public void testPathEntry_MappedFolderInProject() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1475,6 +1527,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test mapping folders heuristics - mapping to another project.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_MappedFolderInAnotherProject() throws Exception {
|
public void testPathEntry_MappedFolderInAnotherProject() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1526,6 +1579,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test mapping folders heuristics - mapping to a referenced project.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_MappedFolderInReferencedProject() throws Exception {
|
public void testPathEntry_MappedFolderInReferencedProject() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1579,6 +1633,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test ".." in symbolic links where the symbolic link is present as absolute path.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_NavigateSymbolicLinkUpAbsolute() throws Exception {
|
public void testPathEntry_NavigateSymbolicLinkUpAbsolute() throws Exception {
|
||||||
// do not test on systems where symbolic links are not supported
|
// do not test on systems where symbolic links are not supported
|
||||||
|
@ -1619,6 +1674,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test ".." in symbolic links where the symbolic link is present as relative path.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_NavigateSymbolicLinkUpRelative() throws Exception {
|
public void testPathEntry_NavigateSymbolicLinkUpRelative() throws Exception {
|
||||||
// do not test on systems where symbolic links are not supported
|
// do not test on systems where symbolic links are not supported
|
||||||
|
@ -1659,6 +1715,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Determine working directory from configuration builder settings.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_BuildDirDefinedByConfiguration_RelativePath() throws Exception {
|
public void testPathEntry_BuildDirDefinedByConfiguration_RelativePath() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1702,6 +1759,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test where working directory from command line disagrees with configuration builder settings.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_BuildDirDefinedByConfiguration_AbsolutePath() throws Exception {
|
public void testPathEntry_BuildDirDefinedByConfiguration_AbsolutePath() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1746,6 +1804,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smoke test when non-C files appear in output, should not choke.
|
||||||
|
*/
|
||||||
public void testContentType_None() throws Exception {
|
public void testContentType_None() throws Exception {
|
||||||
MockBuildCommandParser parser = new MockBuildCommandParser() {
|
MockBuildCommandParser parser = new MockBuildCommandParser() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1762,6 +1823,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test that unsupported language is ignored.
|
||||||
*/
|
*/
|
||||||
public void testContentType_Mismatch() throws Exception {
|
public void testContentType_Mismatch() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1785,6 +1847,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test custom file extensions defined in content type.
|
||||||
*/
|
*/
|
||||||
public void testContentType_FileExtensions() throws Exception {
|
public void testContentType_FileExtensions() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1824,6 +1887,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test filenames appearing in upper-case.
|
||||||
*/
|
*/
|
||||||
public void testUpperCase() throws Exception {
|
public void testUpperCase() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1855,6 +1919,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test sample output of boost builder utility bjam.
|
||||||
*/
|
*/
|
||||||
public void testBoostBjam() throws Exception {
|
public void testBoostBjam() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1897,6 +1962,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test resource file residing on EFS file-system.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_Efs() throws Exception {
|
public void testPathEntry_Efs() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
@ -1935,6 +2001,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test mapping entries to EFS.
|
||||||
*/
|
*/
|
||||||
public void testPathEntry_EfsMappedFolder() throws Exception {
|
public void testPathEntry_EfsMappedFolder() throws Exception {
|
||||||
// Create model project and accompanied descriptions
|
// Create model project and accompanied descriptions
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010, 2011 Andrew Gvozdev and others.
|
* Copyright (c) 2010, 2012 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
|
||||||
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
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.Cygwin;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin;
|
import org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin;
|
||||||
import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
|
import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -31,9 +32,15 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test cases to test GCC built-in specs detector.
|
||||||
|
*/
|
||||||
public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
private static final String LANGUAGE_ID_C = GCCLanguage.ID;
|
private static final String LANGUAGE_ID_C = GCCLanguage.ID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock GCCBuiltinSpecsDetector to gain access to protected methods.
|
||||||
|
*/
|
||||||
class MockGCCBuiltinSpecsDetector extends GCCBuiltinSpecsDetector {
|
class MockGCCBuiltinSpecsDetector extends GCCBuiltinSpecsDetector {
|
||||||
@Override
|
@Override
|
||||||
public void startupForLanguage(String languageId) throws CoreException {
|
public void startupForLanguage(String languageId) throws CoreException {
|
||||||
|
@ -45,6 +52,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock GCCBuiltinSpecsDetectorCygwin to gain access to protected methods.
|
||||||
|
*/
|
||||||
class MockGCCBuiltinSpecsDetectorCygwin extends GCCBuiltinSpecsDetectorCygwin {
|
class MockGCCBuiltinSpecsDetectorCygwin extends GCCBuiltinSpecsDetectorCygwin {
|
||||||
@Override
|
@Override
|
||||||
public void startupForLanguage(String languageId) throws CoreException {
|
public void startupForLanguage(String languageId) throws CoreException {
|
||||||
|
@ -66,6 +76,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to fetch configuration descriptions.
|
||||||
|
*/
|
||||||
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
|
private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) {
|
||||||
CoreModel coreModel = CoreModel.getDefault();
|
CoreModel coreModel = CoreModel.getDefault();
|
||||||
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
|
ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager();
|
||||||
|
@ -78,6 +91,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
return cfgDescriptions;
|
return cfgDescriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test expansion of variables in build command.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_ResolvedCommand() throws Exception {
|
public void testGCCBuiltinSpecsDetector_ResolvedCommand() throws Exception {
|
||||||
class MockGCCBuiltinSpecsDetectorLocal extends GCCBuiltinSpecsDetector {
|
class MockGCCBuiltinSpecsDetectorLocal extends GCCBuiltinSpecsDetector {
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,6 +121,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro without value.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_NoValue() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_NoValue() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -119,6 +138,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, entries.size());
|
assertEquals(1, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro with ordinary value.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_Simple() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_Simple() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -133,6 +155,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, entries.size());
|
assertEquals(1, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro with value in round brackets.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_Const() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_Const() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -147,6 +172,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, entries.size());
|
assertEquals(1, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro definition with tabs.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_WhiteSpaces() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_WhiteSpaces() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -166,6 +194,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(index, entries.size());
|
assertEquals(index, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro definition with empty argument list.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_EmptyArgList() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_EmptyArgList() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -180,6 +211,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, entries.size());
|
assertEquals(1, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro definition with unused parameter.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_ParamUnused() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_ParamUnused() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -194,6 +228,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, entries.size());
|
assertEquals(1, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro definition with multiple parameters.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_ParamSpace() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_ParamSpace() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -208,6 +245,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, entries.size());
|
assertEquals(1, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro definition with multiple parameters and no value.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_ArgsNoValue() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_ArgsNoValue() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -222,6 +262,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, entries.size());
|
assertEquals(1, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro definition having white spaces in various places.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Macro_Args_WhiteSpaces() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Macro_Args_WhiteSpaces() throws Exception {
|
||||||
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
MockGCCBuiltinSpecsDetector detector = new MockGCCBuiltinSpecsDetector();
|
||||||
|
|
||||||
|
@ -241,6 +284,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(index, entries.size());
|
assertEquals(index, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of include directives.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Includes() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Includes() throws Exception {
|
||||||
// Create model project and folders to test
|
// Create model project and folders to test
|
||||||
String projectName = getName();
|
String projectName = getName();
|
||||||
|
@ -288,6 +334,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(index, entries.size());
|
assertEquals(index, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of macro definition of include directives having white spaces.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Includes_WhiteSpaces() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Includes_WhiteSpaces() throws Exception {
|
||||||
String loc = ResourceHelper.createTemporaryFolder().toString();
|
String loc = ResourceHelper.createTemporaryFolder().toString();
|
||||||
|
|
||||||
|
@ -316,6 +365,9 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(index, entries.size());
|
assertEquals(index, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of include directives incorporating symbolic links.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Includes_SymbolicLinkUp() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Includes_SymbolicLinkUp() throws Exception {
|
||||||
// do not test on systems where symbolic links are not supported
|
// do not test on systems where symbolic links are not supported
|
||||||
if (!ResourceHelper.isSymbolicLinkSupported())
|
if (!ResourceHelper.isSymbolicLinkSupported())
|
||||||
|
@ -347,15 +399,17 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, entries.size());
|
assertEquals(1, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of include directives for Cygwin for global provider.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Cygwin_NoProject() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Cygwin_NoProject() throws Exception {
|
||||||
String windowsLocation;
|
if (!Cygwin.isAvailable()) {
|
||||||
String cygwinLocation = "/usr/include";
|
|
||||||
try {
|
|
||||||
windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
// Skip the test if Cygwin is not available.
|
// Skip the test if Cygwin is not available.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String cygwinLocation = "/usr/include";
|
||||||
|
String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
|
||||||
assertTrue("windowsLocation=["+windowsLocation+"]", new Path(windowsLocation).getDevice()!=null);
|
assertTrue("windowsLocation=["+windowsLocation+"]", new Path(windowsLocation).getDevice()!=null);
|
||||||
|
|
||||||
MockGCCBuiltinSpecsDetectorCygwin detector = new MockGCCBuiltinSpecsDetectorCygwin();
|
MockGCCBuiltinSpecsDetectorCygwin detector = new MockGCCBuiltinSpecsDetectorCygwin();
|
||||||
|
@ -374,15 +428,17 @@ public class GCCBuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
assertEquals(1, entries.size());
|
assertEquals(1, entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing of include directives for Cygwin for provider running for a configuration.
|
||||||
|
*/
|
||||||
public void testGCCBuiltinSpecsDetector_Cygwin_Configuration() throws Exception {
|
public void testGCCBuiltinSpecsDetector_Cygwin_Configuration() throws Exception {
|
||||||
String windowsLocation;
|
if (!Cygwin.isAvailable()) {
|
||||||
String cygwinLocation = "/usr/include";
|
|
||||||
try {
|
|
||||||
windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
// Skip the test if Cygwin is not available.
|
// Skip the test if Cygwin is not available.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String cygwinLocation = "/usr/include";
|
||||||
|
String windowsLocation = ResourceHelper.cygwinToWindowsPath(cygwinLocation);
|
||||||
assertTrue("windowsLocation=["+windowsLocation+"]", new Path(windowsLocation).getDevice()!=null);
|
assertTrue("windowsLocation=["+windowsLocation+"]", new Path(windowsLocation).getDevice()!=null);
|
||||||
|
|
||||||
// Create model project and folders to test
|
// Create model project and folders to test
|
||||||
|
|
|
@ -30,6 +30,9 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test creation of a new project in respect with language settings providers.
|
||||||
|
*/
|
||||||
public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
|
public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
|
||||||
private static final String MBS_LANGUAGE_SETTINGS_PROVIDER_ID = ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID;
|
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 USER_LANGUAGE_SETTINGS_PROVIDER_ID = ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID;
|
||||||
|
@ -50,7 +53,7 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New Project Wizards do all these things
|
* Imitate a new Project Wizard. New Project Wizards really do these things in CDT.
|
||||||
*/
|
*/
|
||||||
private static IProject imitateNewProjectWizard(String name, String projectTypeId) throws CoreException {
|
private static IProject imitateNewProjectWizard(String name, String projectTypeId) throws CoreException {
|
||||||
IProject project = ManagedBuildTestHelper.createProject(name, projectTypeId);
|
IProject project = ManagedBuildTestHelper.createProject(name, projectTypeId);
|
||||||
|
@ -76,10 +79,13 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Test new GNU Executable project.
|
||||||
*/
|
*/
|
||||||
public void testGnuToolchainProviders() throws Exception {
|
public void testGnuToolchainProviders() throws Exception {
|
||||||
|
// create a new project imitating wizard
|
||||||
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
||||||
|
|
||||||
|
// check that the language settings providers are in place.
|
||||||
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false);
|
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false);
|
||||||
assertNotNull(prjDescription);
|
assertNotNull(prjDescription);
|
||||||
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
||||||
|
@ -114,37 +120,14 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
* Test that no unnecessary storage file is created for language settings for default set
|
||||||
public void testProjectPersistence_NoProviders() throws Exception {
|
* of language settings providers.
|
||||||
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 {
|
public void testProjectPersistence_Defaults() throws Exception {
|
||||||
|
// create a new project imitating wizard
|
||||||
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
||||||
|
|
||||||
|
// double-check that the project contains language settings providers
|
||||||
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false);
|
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false);
|
||||||
assertNotNull(prjDescription);
|
assertNotNull(prjDescription);
|
||||||
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
||||||
|
@ -161,13 +144,47 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
|
||||||
assertTrue(defaultIds.length > 0);
|
assertTrue(defaultIds.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no settings file in project area
|
||||||
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||||
assertEquals(false, xmlStorageFile.exists());
|
assertEquals(false, xmlStorageFile.exists());
|
||||||
assertEquals(false, xmlStorageFile.getParent().exists()); // .settings folder
|
assertEquals(false, xmlStorageFile.getParent().exists()); // .settings folder
|
||||||
|
|
||||||
|
// no settings file in workspace area
|
||||||
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||||
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
||||||
assertEquals(false, xmlStorageFilePrjWsp.exists());
|
assertEquals(false, xmlStorageFilePrjWsp.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that storage file is created for language settings for empty set of language settings providers.
|
||||||
|
*/
|
||||||
|
public void testProjectPersistence_NoProviders() throws Exception {
|
||||||
|
// create a new project imitating wizard
|
||||||
|
IProject project = imitateNewProjectWizard(this.getName(), PROJECT_TYPE_EXECUTABLE_GNU);
|
||||||
|
|
||||||
|
// remove language settings providers from the project
|
||||||
|
ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, true);
|
||||||
|
assertNotNull(prjDescription);
|
||||||
|
ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations();
|
||||||
|
for (ICConfigurationDescription cfgDescription : cfgDescriptions) {
|
||||||
|
assertNotNull(cfgDescription);
|
||||||
|
assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper);
|
||||||
|
|
||||||
|
((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(new ArrayList<ILanguageSettingsProvider>());
|
||||||
|
assertTrue(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders().size() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
CoreModel.getDefault().setProjectDescription(project, prjDescription);
|
||||||
|
|
||||||
|
// settings file appears in project area
|
||||||
|
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||||
|
assertEquals(true, xmlStorageFile.exists());
|
||||||
|
|
||||||
|
// no settings file in workspace area
|
||||||
|
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||||
|
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
||||||
|
assertEquals(false, xmlStorageFilePrjWsp.exists());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,5 +289,4 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
|
||||||
CfgInfoContext context, IPath workingDirectory, IMarkerGenerator markerGenerator) {
|
CfgInfoContext context, IPath workingDirectory, IMarkerGenerator markerGenerator) {
|
||||||
return ScannerInfoConsoleParserFactory.getScannerInfoConsoleParser(project, context.toInfoContext(), workingDirectory, map.get(context), markerGenerator, null);
|
return ScannerInfoConsoleParserFactory.getScannerInfoConsoleParser(project, context.toInfoContext(), workingDirectory, map.get(context), markerGenerator, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
|
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
|
||||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStateManager;
|
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStateManager;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DbgUtil;
|
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DbgUtil;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
|
import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
|
||||||
|
@ -27,7 +26,6 @@ import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
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.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
@ -285,10 +283,4 @@ public class ManagedBuilderCorePlugin extends Plugin {
|
||||||
ProjectConverter.convertOldStdMakeToNewStyle(project, monitor);
|
ProjectConverter.convertOldStdMakeToNewStyle(project, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @since 8.1
|
|
||||||
*/
|
|
||||||
public static IPath getWorkingDirectory() {
|
|
||||||
return MakeCorePlugin.getDefault().getStateLocation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,6 @@ 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();
|
||||||
|
|
|
@ -169,3 +169,15 @@ MultiResourceInfo.MultiResourceInfo.UnhandledIHoldsOptionsType=Unhandled parent
|
||||||
ResourceChangeHandler2.0=project build settings update job
|
ResourceChangeHandler2.0=project build settings update job
|
||||||
ToolInfo.0=conversion failure
|
ToolInfo.0=conversion failure
|
||||||
ToolInfo.1=the tool is removed
|
ToolInfo.1=the tool is removed
|
||||||
|
|
||||||
|
#Language settings providers messages
|
||||||
|
AbstractBuildCommandParser.SerializeJobName=Serialize CDT language settings entries
|
||||||
|
AbstractBuiltinSpecsDetector.AddScannerDiscoveryMarkers=Adding Scanner Discovery markers
|
||||||
|
AbstractBuiltinSpecsDetector.ClearingMarkers=Clearing markers for {0}
|
||||||
|
AbstractBuiltinSpecsDetector.DiscoverBuiltInSettingsJobName=Discover compiler built-in language settings
|
||||||
|
AbstractBuiltinSpecsDetector.RunningScannerDiscovery=Running scanner discovery: {0}
|
||||||
|
AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationPreferences=Preferences, C++/Build/Settings/Discovery, [{0}] options
|
||||||
|
AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationProperties=Project Properties, C++ Preprocessor Include.../Providers, [{0}] options
|
||||||
|
AbstractBuiltinSpecsDetector.ScannerDiscoveryTaskTitle=CDT Scanner Discovery
|
||||||
|
AbstractBuiltinSpecsDetector.SerializingResults=Serializing results
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
||||||
if (rc instanceof IFile) {
|
if (rc instanceof IFile) {
|
||||||
ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(projectPath, true);
|
ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(projectPath, true);
|
||||||
if (ls != null) {
|
if (ls != null) {
|
||||||
languageSettings = new ICLanguageSetting[] {ls};
|
languageSettings = new ICLanguageSetting[] { ls };
|
||||||
} else {
|
} else {
|
||||||
return getSettingEntries(cfgDescription, rc.getParent(), languageId);
|
return getSettingEntries(cfgDescription, rc.getParent(), languageId);
|
||||||
}
|
}
|
||||||
|
@ -54,26 +54,25 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
||||||
|
|
||||||
if (languageSettings != null) {
|
if (languageSettings != null) {
|
||||||
for (ICLanguageSetting langSetting : languageSettings) {
|
for (ICLanguageSetting langSetting : languageSettings) {
|
||||||
if (langSetting!=null) {
|
if (langSetting != null) {
|
||||||
String id = langSetting.getLanguageId();
|
String id = langSetting.getLanguageId();
|
||||||
if (id!=null && id.equals(languageId)) {
|
if (id != null && id.equals(languageId)) {
|
||||||
int kindsBits = langSetting.getSupportedEntryKinds();
|
int kindsBits = langSetting.getSupportedEntryKinds();
|
||||||
for (int kind=1;kind<=kindsBits;kind<<=1) {
|
for (int kind=1; kind <= kindsBits; kind <<= 1) {
|
||||||
if ((kindsBits & kind) != 0) {
|
if ((kindsBits & kind) != 0) {
|
||||||
list.addAll(langSetting.getSettingEntriesList(kind));
|
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);
|
return LanguageSettingsStorage.getPooledList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get language settings for resource description.
|
||||||
|
*/
|
||||||
private ICLanguageSetting[] getLanguageSettings(ICResourceDescription rcDescription) {
|
private ICLanguageSetting[] getLanguageSettings(ICResourceDescription rcDescription) {
|
||||||
ICLanguageSetting[] array = null;
|
ICLanguageSetting[] array = null;
|
||||||
switch (rcDescription.getType()) {
|
switch (rcDescription.getType()) {
|
||||||
|
@ -86,48 +85,16 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
||||||
case ICSettingBase.SETTING_FILE:
|
case ICSettingBase.SETTING_FILE:
|
||||||
ICFileDescription fiDes = (ICFileDescription)rcDescription;
|
ICFileDescription fiDes = (ICFileDescription)rcDescription;
|
||||||
ICLanguageSetting ls = fiDes.getLanguageSetting();
|
ICLanguageSetting ls = fiDes.getLanguageSetting();
|
||||||
if (ls!=null) {
|
if (ls != null) {
|
||||||
array = new ICLanguageSetting[] { ls };
|
array = new ICLanguageSetting[] { ls };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (array==null) {
|
if (array == null) {
|
||||||
array = new ICLanguageSetting[0];
|
array = new ICLanguageSetting[0];
|
||||||
}
|
}
|
||||||
return array;
|
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
|
@Override
|
||||||
public LanguageSettingsStorage copyStorage() {
|
public LanguageSettingsStorage copyStorage() {
|
||||||
class PretendStorage extends LanguageSettingsStorage {
|
class PretendStorage extends LanguageSettingsStorage {
|
||||||
|
|
|
@ -12,14 +12,10 @@
|
||||||
package org.eclipse.cdt.managedbuilder.language.settings.providers;
|
package org.eclipse.cdt.managedbuilder.language.settings.providers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.IErrorParser2;
|
import org.eclipse.cdt.core.IErrorParser2;
|
||||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||||
import org.eclipse.cdt.core.errorparsers.RegexErrorParser;
|
import org.eclipse.cdt.core.errorparsers.RegexErrorParser;
|
||||||
|
@ -27,20 +23,17 @@ import org.eclipse.cdt.core.errorparsers.RegexErrorPattern;
|
||||||
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
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.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
|
||||||
import org.eclipse.core.runtime.content.IContentTypeManager;
|
|
||||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for providers parsing compiler option from build command when it
|
* Abstract class for providers parsing compiler option from build command when present in build output.
|
||||||
* is present in build output.
|
|
||||||
*
|
*
|
||||||
* @since 8.1
|
* @since 8.1
|
||||||
*/
|
*/
|
||||||
|
@ -56,7 +49,7 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
|
||||||
* Note: design patterns to keep file group the same and matching {@link #FILE_GROUP}
|
* Note: design patterns to keep file group the same and matching {@link #FILE_GROUP}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
private static final String[] PATTERN_TEMPLATES = {
|
private static final String[] COMPILER_COMMAND_PATTERN_TEMPLATES = {
|
||||||
"${COMPILER_PATTERN}.*\\s" + "()([^'\"\\s]*\\.${EXTENSIONS_PATTERN})(\\s.*)?[\r\n]*", // compiling unquoted file
|
"${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
|
"${COMPILER_PATTERN}.*\\s" + "(['\"])(.*\\.${EXTENSIONS_PATTERN})\\${COMPILER_GROUPS+1}(\\s.*)?[\r\n]*" // compiling quoted file
|
||||||
};
|
};
|
||||||
|
@ -84,16 +77,25 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
|
||||||
setProperty(ATTR_PARAMETER, commandPattern);
|
setProperty(ATTR_PARAMETER, commandPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sub-expression for compiler command pattern accounting for spaces, quotes etc.
|
||||||
|
*/
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
private String getCompilerPatternExtended() {
|
private String getCompilerPatternExtended() {
|
||||||
String compilerPattern = getCompilerPattern();
|
String compilerPattern = getCompilerPattern();
|
||||||
return "\\s*\"?("+LEADING_PATH_PATTERN+")?(" + compilerPattern + ")\"?";
|
return "\\s*\"?("+LEADING_PATH_PATTERN+")?(" + compilerPattern + ")\"?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjust count for file group taking into consideration extra groups added by {@link #getCompilerPatternExtended()}.
|
||||||
|
*/
|
||||||
private int adjustFileGroup() {
|
private int adjustFileGroup() {
|
||||||
return countGroups(getCompilerPatternExtended()) + FILE_GROUP;
|
return countGroups(getCompilerPatternExtended()) + FILE_GROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make search pattern for compiler command based on template.
|
||||||
|
*/
|
||||||
private String makePattern(String template) {
|
private String makePattern(String template) {
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
String pattern = template
|
String pattern = template
|
||||||
|
@ -103,46 +105,13 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
|
||||||
return pattern;
|
return pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 String getPatternFileExtensions() {
|
|
||||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
|
||||||
|
|
||||||
Set<String> fileExts = new HashSet<String>();
|
|
||||||
|
|
||||||
IContentType contentTypeCpp = manager.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
|
|
||||||
fileExts.addAll(Arrays.asList(contentTypeCpp.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
|
|
||||||
|
|
||||||
IContentType contentTypeC = manager.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE);
|
|
||||||
fileExts.addAll(Arrays.asList(contentTypeC.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
|
|
||||||
|
|
||||||
String pattern = expressionLogicalOr(fileExts);
|
|
||||||
|
|
||||||
return pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String parseResourceName(String line) {
|
protected String parseResourceName(String line) {
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String template : PATTERN_TEMPLATES) {
|
for (String template : COMPILER_COMMAND_PATTERN_TEMPLATES) {
|
||||||
String pattern = makePattern(template);
|
String pattern = makePattern(template);
|
||||||
Matcher fileMatcher = Pattern.compile(pattern).matcher(line);
|
Matcher fileMatcher = Pattern.compile(pattern).matcher(line);
|
||||||
if (fileMatcher.matches()) {
|
if (fileMatcher.matches()) {
|
||||||
|
@ -171,12 +140,6 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is redundant but let us keep it here to navigate in java code easier
|
|
||||||
@Override
|
|
||||||
public boolean processLine(String line) {
|
|
||||||
return super.processLine(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
scheduleSerializingJob(currentCfgDescription);
|
scheduleSerializingJob(currentCfgDescription);
|
||||||
|
@ -185,7 +148,7 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
|
||||||
|
|
||||||
|
|
||||||
private void scheduleSerializingJob(final ICConfigurationDescription cfgDescription) {
|
private void scheduleSerializingJob(final ICConfigurationDescription cfgDescription) {
|
||||||
Job job = new Job("Serialize CDT language settings entries") {
|
Job job = new Job(ManagedMakeMessages.getResourceString("AbstractBuildCommandParser.SerializeJobName")) { //$NON-NLS-1$
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
return serializeLanguageSettings(cfgDescription);
|
return serializeLanguageSettings(cfgDescription);
|
||||||
|
@ -219,18 +182,25 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
|
||||||
/**
|
/**
|
||||||
* Trivial Error Parser which allows highlighting of output lines matching the patterns
|
* Trivial Error Parser which allows highlighting of output lines matching the patterns
|
||||||
* of this parser. Intended for better troubleshooting experience.
|
* of this parser. Intended for better troubleshooting experience.
|
||||||
* Implementers are supposed to add the error parser as an extension. Initialize with
|
* Implementers are supposed to add the error parser via extension point {@code org.eclipse.cdt.core.ErrorParser}.
|
||||||
* build command parser extension ID.
|
|
||||||
*/
|
*/
|
||||||
protected static abstract class AbstractBuildCommandPatternHighlighter extends RegexErrorParser implements IErrorParser2 {
|
protected static abstract class AbstractBuildCommandPatternHighlighter extends RegexErrorParser implements IErrorParser2 {
|
||||||
public AbstractBuildCommandPatternHighlighter(String buildCommandParserPluginExtension) {
|
/**
|
||||||
init(buildCommandParserPluginExtension);
|
* Constructor.
|
||||||
|
* @param parserId - build command parser ID specified in the extension {@code org.eclipse.cdt.core.LanguageSettingsProvider}.
|
||||||
|
*/
|
||||||
|
public AbstractBuildCommandPatternHighlighter(String parserId) {
|
||||||
|
init(parserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void init(String buildCommandParserId) {
|
/**
|
||||||
AbstractBuildCommandParser buildCommandParser = (AbstractBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(buildCommandParserId, false);
|
* Initialize the error parser.
|
||||||
|
* @param parserId - language settings provider (the build command parser) ID.
|
||||||
|
*/
|
||||||
|
protected void init(String parserId) {
|
||||||
|
AbstractBuildCommandParser buildCommandParser = (AbstractBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(parserId, false);
|
||||||
if (buildCommandParser != null) {
|
if (buildCommandParser != null) {
|
||||||
for (String template : PATTERN_TEMPLATES) {
|
for (String template : COMPILER_COMMAND_PATTERN_TEMPLATES) {
|
||||||
String pattern = buildCommandParser.makePattern(template);
|
String pattern = buildCommandParser.makePattern(template);
|
||||||
String fileExpr = "$"+buildCommandParser.adjustFileGroup(); //$NON-NLS-1$
|
String fileExpr = "$"+buildCommandParser.adjustFileGroup(); //$NON-NLS-1$
|
||||||
String descExpr = "$0"; //$NON-NLS-1$
|
String descExpr = "$0"; //$NON-NLS-1$
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.internal.core.BuildRunnerHelper;
|
||||||
import org.eclipse.cdt.internal.core.XmlUtil;
|
import org.eclipse.cdt.internal.core.XmlUtil;
|
||||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
|
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
|
||||||
import org.eclipse.cdt.utils.CommandLineUtil;
|
import org.eclipse.cdt.utils.CommandLineUtil;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -67,7 +68,6 @@ import org.w3c.dom.Element;
|
||||||
* @since 8.1
|
* @since 8.1
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSettingsOutputScanner implements ICListenerAgent {
|
public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSettingsOutputScanner implements ICListenerAgent {
|
||||||
// TODO - refine id after settling with the plugin
|
|
||||||
public static final String JOB_FAMILY_BUILTIN_SPECS_DETECTOR = "org.eclipse.cdt.managedbuilder.AbstractBuiltinSpecsDetector"; //$NON-NLS-1$
|
public static final String JOB_FAMILY_BUILTIN_SPECS_DETECTOR = "org.eclipse.cdt.managedbuilder.AbstractBuiltinSpecsDetector"; //$NON-NLS-1$
|
||||||
|
|
||||||
protected static final String COMPILER_MACRO = "${COMMAND}"; //$NON-NLS-1$
|
protected static final String COMPILER_MACRO = "${COMMAND}"; //$NON-NLS-1$
|
||||||
|
@ -75,6 +75,15 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
protected static final String SPEC_EXT_MACRO = "${EXT}"; //$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$
|
protected static final String SPEC_FILE_BASE = "spec"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String CDT_MANAGEDBUILDER_UI_PLUGIN_ID = "org.eclipse.cdt.managedbuilder.ui"; //$NON-NLS-1$
|
||||||
|
private static final String SCANNER_DISCOVERY_CONSOLE = "org.eclipse.cdt.managedbuilder.ScannerDiscoveryConsole"; //$NON-NLS-1$
|
||||||
|
private static final String SCANNER_DISCOVERY_GLOBAL_CONSOLE = "org.eclipse.cdt.managedbuilder.ScannerDiscoveryGlobalConsole"; //$NON-NLS-1$
|
||||||
|
private static final String DEFAULT_CONSOLE_ICON = "icons/obj16/inspect_system.gif"; //$NON-NLS-1$
|
||||||
|
private static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
|
||||||
|
private static final String ATTR_CONSOLE = "console"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final int MONITOR_SCALE = 100;
|
private static final int MONITOR_SCALE = 100;
|
||||||
private static final int TICKS_REMOVE_MARKERS = 1 * MONITOR_SCALE;
|
private static final int TICKS_REMOVE_MARKERS = 1 * MONITOR_SCALE;
|
||||||
private static final int TICKS_RUN_FOR_ONE_LANGUAGE = 10 * MONITOR_SCALE;
|
private static final int TICKS_RUN_FOR_ONE_LANGUAGE = 10 * MONITOR_SCALE;
|
||||||
|
@ -82,13 +91,6 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
private static final int TICKS_OUTPUT_PARSING = 1 * MONITOR_SCALE;
|
private static final int TICKS_OUTPUT_PARSING = 1 * MONITOR_SCALE;
|
||||||
private static final int TICKS_EXECUTE_COMMAND = 1 * MONITOR_SCALE;
|
private static final int TICKS_EXECUTE_COMMAND = 1 * MONITOR_SCALE;
|
||||||
|
|
||||||
private static final String CDT_MANAGEDBUILDER_UI_PLUGIN_ID = "org.eclipse.cdt.managedbuilder.ui"; //$NON-NLS-1$
|
|
||||||
private static final String DEFAULT_CONSOLE_ICON = "icons/obj16/inspect_system.gif"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser"; //$NON-NLS-1$
|
|
||||||
private static final String ATTR_PARAMETER = "parameter"; //$NON-NLS-1$
|
|
||||||
private static final String ATTR_CONSOLE = "console"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
protected URI mappedRootURI = null;
|
protected URI mappedRootURI = null;
|
||||||
protected URI buildDirURI = null;
|
protected URI buildDirURI = null;
|
||||||
protected java.io.File specFile = null;
|
protected java.io.File specFile = null;
|
||||||
|
@ -103,9 +105,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
private String currentCommandResolved = null;
|
private String currentCommandResolved = null;
|
||||||
|
|
||||||
private class SDMarkerGenerator implements IMarkerGenerator {
|
private class SDMarkerGenerator implements IMarkerGenerator {
|
||||||
// TODO - define own markers types after settling with the plugin
|
// Reuse scanner discovery markers defined in org.eclipse.cdt.managedbuilder.core plugin.xml
|
||||||
// Scanner discovery markers are defined in org.eclipse.cdt.managedbuilder.core plugin.xml
|
protected static final String SCANNER_DISCOVERY_PROBLEM_MARKER = "org.eclipse.cdt.managedbuilder.core.scanner.discovery.problem"; //$NON-NLS-1$
|
||||||
protected static final String SCANNER_DISCOVERY_PROBLEM_MARKER = "org.eclipse.cdt.managedbuilder.core.scanner.discovery.problem";
|
|
||||||
protected static final String ATTR_PROVIDER = "provider"; //$NON-NLS-1$
|
protected static final String ATTR_PROVIDER = "provider"; //$NON-NLS-1$
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,10 +119,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
public void addMarker(final ProblemMarkerInfo problemMarkerInfo) {
|
public void addMarker(final ProblemMarkerInfo problemMarkerInfo) {
|
||||||
final String providerName = getName();
|
final String providerName = getName();
|
||||||
final String providerId = getId();
|
final String providerId = getId();
|
||||||
// we have to add the marker in the job or we can deadlock other
|
// Add markers in a job to avoid deadlocks
|
||||||
// threads that are responding to a resource delta by doing something
|
Job markerJob = new Job(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.AddScannerDiscoveryMarkers")) { //$NON-NLS-1$
|
||||||
// that accesses the project description
|
|
||||||
Job markerJob = new Job("Adding Scanner Discovery markers") {
|
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
// Avoid duplicates as different languages can generate identical errors
|
// Avoid duplicates as different languages can generate identical errors
|
||||||
|
@ -147,9 +146,11 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
marker.setAttribute(SDMarkerGenerator.ATTR_PROVIDER, providerId);
|
marker.setAttribute(SDMarkerGenerator.ATTR_PROVIDER, providerId);
|
||||||
|
|
||||||
if (problemMarkerInfo.file instanceof IWorkspaceRoot) {
|
if (problemMarkerInfo.file instanceof IWorkspaceRoot) {
|
||||||
marker.setAttribute(IMarker.LOCATION, "Preferences, C++/Build/Settings/Discovery, [" + providerName + "] options");
|
String msgPreferences = ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationPreferences", providerName); //$NON-NLS-1$
|
||||||
|
marker.setAttribute(IMarker.LOCATION, msgPreferences);
|
||||||
} else {
|
} else {
|
||||||
marker.setAttribute(IMarker.LOCATION, "Project Properties, C++ Preprocessor Include.../Providers, [" + providerName + "] options");
|
String msgProperties = ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationProperties", providerName); //$NON-NLS-1$
|
||||||
|
marker.setAttribute(IMarker.LOCATION, msgProperties);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return new Status(Status.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Error adding markers.", e); //$NON-NLS-1$
|
return new Status(Status.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Error adding markers.", e); //$NON-NLS-1$
|
||||||
|
@ -163,6 +164,11 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
markerJob.schedule();
|
markerJob.schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete markers previously set by this provider for the resource.
|
||||||
|
*
|
||||||
|
* @param rc - resource to check markers.
|
||||||
|
*/
|
||||||
public void deleteMarkers(IResource rc) {
|
public void deleteMarkers(IResource rc) {
|
||||||
String providerId = getId();
|
String providerId = getId();
|
||||||
try {
|
try {
|
||||||
|
@ -180,7 +186,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This ICConsoleParser handles each individual run for one language TODO
|
* Internal ICConsoleParser to handle individual run for one language.
|
||||||
*/
|
*/
|
||||||
private class ConsoleParserAdapter implements ICBuildOutputParser {
|
private class ConsoleParserAdapter implements ICBuildOutputParser {
|
||||||
@Override
|
@Override
|
||||||
|
@ -198,16 +204,20 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* Compiler command without arguments. This value is used to replace macro ${COMMAND}.
|
||||||
* @param languageId
|
* In particular, this method is implemented in {@link ToolchainBuiltinSpecsDetector}
|
||||||
* @return
|
* which retrieves the command from tool-chain.
|
||||||
|
*
|
||||||
|
* @param languageId - language ID.
|
||||||
|
* @return compiler command without arguments, i.e. compiler program.
|
||||||
*/
|
*/
|
||||||
protected abstract String getCompilerCommand(String languageId);
|
protected abstract String getCompilerCommand(String languageId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The command to run. Some macros could be specified in there:
|
* The command to run. Some macros could be specified in there:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <b>${COMMAND}</b> - compiler command taken from the toolchain.<br>
|
* <b>${COMMAND}</b> - compiler command without arguments (compiler program).
|
||||||
|
* Normally would come from the tool-chain.<br>
|
||||||
* <b>${INPUTS}</b> - path to spec file which will be placed in workspace area.<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.
|
* <b>${EXT}</b> - file extension calculated from language ID.
|
||||||
* </ul>
|
* </ul>
|
||||||
|
@ -228,14 +238,30 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
setProperty(ATTR_PARAMETER, command);
|
setProperty(ATTR_PARAMETER, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConsoleEnabled(boolean enable) {
|
/**
|
||||||
isConsoleEnabled = enable;
|
* @return {@code true} if console output is enabled for this provider, {@code false} otherwise.
|
||||||
}
|
*/
|
||||||
|
|
||||||
public boolean isConsoleEnabled() {
|
public boolean isConsoleEnabled() {
|
||||||
return isConsoleEnabled;
|
return isConsoleEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable or disable console output for this provider.
|
||||||
|
*
|
||||||
|
* @param enable - {@code true} to enable console output or {@code false} to disable.
|
||||||
|
*/
|
||||||
|
public void setConsoleEnabled(boolean enable) {
|
||||||
|
isConsoleEnabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand macros specified in the compiler command. See {@link #getCommand()} for
|
||||||
|
* the recognized list of macros.
|
||||||
|
*
|
||||||
|
* @param languageId - language ID.
|
||||||
|
* @return - resolved command to run.
|
||||||
|
* @throws CoreException if something goes wrong.
|
||||||
|
*/
|
||||||
protected String resolveCommand(String languageId) throws CoreException {
|
protected String resolveCommand(String languageId) throws CoreException {
|
||||||
String cmd = getCommand();
|
String cmd = getCommand();
|
||||||
if (cmd != null) {
|
if (cmd != null) {
|
||||||
|
@ -258,12 +284,10 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected String parseResourceName(String line) {
|
protected String parseResourceName(String line) {
|
||||||
// Returning null works as if workspace-wide
|
// Normally built-in specs detectors are per-language and the result applies for the whole workspace.
|
||||||
|
// Returning null works workspace-wide here.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +299,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected URI getMappedRootURI(IResource sourceFile, String parsedResourceName) {
|
protected URI getMappedRootURI(IResource sourceFile, String parsedResourceName) {
|
||||||
|
// Do not calculate mappedRootURI for each line
|
||||||
if (mappedRootURI == null) {
|
if (mappedRootURI == null) {
|
||||||
mappedRootURI = super.getMappedRootURI(sourceFile, parsedResourceName);
|
mappedRootURI = super.getMappedRootURI(sourceFile, parsedResourceName);
|
||||||
}
|
}
|
||||||
|
@ -283,7 +308,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected URI getBuildDirURI(URI mappedRootURI) {
|
protected URI getBuildDirURI(URI mappedRootURI) {
|
||||||
if (buildDirURI==null) {
|
// Do not calculate buildDirURI for each line
|
||||||
|
if (buildDirURI == null) {
|
||||||
buildDirURI = super.getBuildDirURI(mappedRootURI);
|
buildDirURI = super.getBuildDirURI(mappedRootURI);
|
||||||
}
|
}
|
||||||
return buildDirURI;
|
return buildDirURI;
|
||||||
|
@ -320,6 +346,10 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
super.shutdown();
|
super.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute provider's command which is expected to print built-in compiler options (specs) to build output.
|
||||||
|
* The parser will parse output and generate language settings for corresponding resources.
|
||||||
|
*/
|
||||||
protected void execute() {
|
protected void execute() {
|
||||||
if (isExecuted) {
|
if (isExecuted) {
|
||||||
// AG FIXME - temporary log to remove before CDT Juno release
|
// AG FIXME - temporary log to remove before CDT Juno release
|
||||||
|
@ -328,7 +358,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
}
|
}
|
||||||
isExecuted = true;
|
isExecuted = true;
|
||||||
|
|
||||||
Job job = new Job("Discover compiler's built-in language settings") {
|
Job job = new Job(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.DiscoverBuiltInSettingsJobNam")) { //$NON-NLS-1$
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
IStatus status;
|
IStatus status;
|
||||||
|
@ -337,7 +367,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
status = runForEachLanguage(monitor);
|
status = runForEachLanguage(monitor);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
ManagedBuilderCorePlugin.log(e);
|
ManagedBuilderCorePlugin.log(e);
|
||||||
status = new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e);
|
status = new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e); //$NON-NLS-1$
|
||||||
} finally {
|
} finally {
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
|
@ -372,10 +402,14 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* Run built-in specs command for each language.
|
||||||
|
*
|
||||||
|
* @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
|
||||||
|
* has not been called yet.
|
||||||
|
* @return status of operation.
|
||||||
*/
|
*/
|
||||||
protected IStatus runForEachLanguage(IProgressMonitor monitor) {
|
protected IStatus runForEachLanguage(IProgressMonitor monitor) {
|
||||||
MultiStatus status = new MultiStatus(ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.OK, "Problem running CDT Scanner Discovery provider " + getId(), null);
|
MultiStatus status = new MultiStatus(ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.OK, "Problem running CDT Scanner Discovery provider " + getId(), null); //$NON-NLS-1$
|
||||||
|
|
||||||
if (monitor == null) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
|
@ -386,11 +420,12 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
|
|
||||||
List<String> languageIds = getLanguageScope();
|
List<String> languageIds = getLanguageScope();
|
||||||
if (languageIds != null) {
|
if (languageIds != null) {
|
||||||
monitor.beginTask("CDT Scanner Discovery", TICKS_REMOVE_MARKERS + languageIds.size()*TICKS_RUN_FOR_ONE_LANGUAGE + TICKS_SERIALIZATION);
|
monitor.beginTask(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.ScannerDiscoveryTaskTitle"), //$NON-NLS-1$
|
||||||
|
TICKS_REMOVE_MARKERS + languageIds.size()*TICKS_RUN_FOR_ONE_LANGUAGE + TICKS_SERIALIZATION);
|
||||||
|
|
||||||
IResource markersResource = currentProject != null ? currentProject : ResourcesPlugin.getWorkspace().getRoot();
|
IResource markersResource = currentProject != null ? currentProject : ResourcesPlugin.getWorkspace().getRoot();
|
||||||
|
|
||||||
monitor.subTask("Clearing markers for " + markersResource.getFullPath());
|
monitor.subTask(ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.ClearingMarkers", markersResource.getFullPath().toString())); //$NON-NLS-1$
|
||||||
markerGenerator.deleteMarkers(markersResource);
|
markerGenerator.deleteMarkers(markersResource);
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
throw new OperationCanceledException();
|
throw new OperationCanceledException();
|
||||||
|
@ -419,7 +454,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
monitor.subTask("Serializing results");
|
monitor.subTask(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.SerializingResults")); //$NON-NLS-1$
|
||||||
if (isChanged) { // avoids resource and settings change notifications
|
if (isChanged) { // avoids resource and settings change notifications
|
||||||
IStatus s = serializeLanguageSettings(currentCfgDescription);
|
IStatus s = serializeLanguageSettings(currentCfgDescription);
|
||||||
status.merge(s);
|
status.merge(s);
|
||||||
|
@ -429,7 +464,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
} catch (OperationCanceledException e) {
|
} catch (OperationCanceledException e) {
|
||||||
// user chose to cancel operation, do not threaten them with red error signs
|
// user chose to cancel operation, do not threaten them with red error signs
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
status.merge(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e));
|
status.merge(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e)); //$NON-NLS-1$
|
||||||
ManagedBuilderCorePlugin.log(status);
|
ManagedBuilderCorePlugin.log(status);
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
@ -438,16 +473,25 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize provider before running for a language.
|
||||||
|
*
|
||||||
|
* @param languageId - language ID.
|
||||||
|
* @throws CoreException if something goes wrong.
|
||||||
|
*/
|
||||||
protected void startupForLanguage(String languageId) throws CoreException {
|
protected void startupForLanguage(String languageId) throws CoreException {
|
||||||
currentLanguageId = languageId;
|
currentLanguageId = languageId;
|
||||||
|
|
||||||
specFile = null; // init *before* calling resolveCommand(), can be set there
|
specFile = null; // init specFile *before* calling resolveCommand(), can be changed in there
|
||||||
currentCommandResolved = resolveCommand(currentLanguageId);
|
currentCommandResolved = resolveCommand(currentLanguageId);
|
||||||
|
|
||||||
detectedSettingEntries = new ArrayList<ICLanguageSettingEntry>();
|
detectedSettingEntries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
collected = 0;
|
collected = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save collected entries and dispose temporary data used during run for the language.
|
||||||
|
*/
|
||||||
protected void shutdownForLanguage() {
|
protected void shutdownForLanguage() {
|
||||||
if (detectedSettingEntries != null && detectedSettingEntries.size() > 0) {
|
if (detectedSettingEntries != null && detectedSettingEntries.size() > 0) {
|
||||||
collected = detectedSettingEntries.size();
|
collected = detectedSettingEntries.size();
|
||||||
|
@ -469,6 +513,12 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
currentLanguageId = null;
|
currentLanguageId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run built-in specs command for one language.
|
||||||
|
*
|
||||||
|
* @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)}
|
||||||
|
* has not been called yet.
|
||||||
|
*/
|
||||||
private void runForLanguage(IProgressMonitor monitor) throws CoreException {
|
private void runForLanguage(IProgressMonitor monitor) throws CoreException {
|
||||||
buildRunnerHelper = new BuildRunnerHelper(currentProject);
|
buildRunnerHelper = new BuildRunnerHelper(currentProject);
|
||||||
|
|
||||||
|
@ -476,7 +526,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
monitor.beginTask("Running scanner discovery: " + getName(), TICKS_EXECUTE_COMMAND + TICKS_OUTPUT_PARSING);
|
monitor.beginTask(ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.RunningScannerDiscovery", getName()), //$NON-NLS-1$
|
||||||
|
TICKS_EXECUTE_COMMAND + TICKS_OUTPUT_PARSING);
|
||||||
|
|
||||||
IConsole console;
|
IConsole console;
|
||||||
if (isConsoleEnabled) {
|
if (isConsoleEnabled) {
|
||||||
|
@ -513,7 +564,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
buildRunnerHelper.setLaunchParameters(launcher, program, args, buildDirURI, envp);
|
buildRunnerHelper.setLaunchParameters(launcher, program, args, buildDirURI, envp);
|
||||||
buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, TICKS_OUTPUT_PARSING));
|
buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, TICKS_OUTPUT_PARSING));
|
||||||
|
|
||||||
buildRunnerHelper.greeting("Running scanner discovery: " + getName());
|
buildRunnerHelper.greeting(ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.RunningScannerDiscovery", getName())); //$NON-NLS-1$
|
||||||
|
|
||||||
OutputStream outStream = buildRunnerHelper.getOutputStream();
|
OutputStream outStream = buildRunnerHelper.getOutputStream();
|
||||||
OutputStream errStream = buildRunnerHelper.getErrorStream();
|
OutputStream errStream = buildRunnerHelper.getErrorStream();
|
||||||
|
@ -524,8 +575,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
buildRunnerHelper.goodbye();
|
buildRunnerHelper.goodbye();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Status status = new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Internal error running scanner discovery", e);
|
ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Error running Builtin Specs Detector" , e))); //$NON-NLS-1$
|
||||||
ManagedBuilderCorePlugin.log(new CoreException(status));
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
buildRunnerHelper.close();
|
buildRunnerHelper.close();
|
||||||
|
@ -540,31 +590,33 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
return buildRunnerHelper.build(monitor);
|
return buildRunnerHelper.build(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected void setSettingEntries(List<ICLanguageSettingEntry> entries) {
|
protected void setSettingEntries(List<ICLanguageSettingEntry> entries) {
|
||||||
// Builtin specs detectors collect entries not per line but for the whole output
|
// Built-in specs detectors collect entries not per line but for the whole output
|
||||||
if (entries != null)
|
// so collect them to save later when output finishes
|
||||||
|
if (entries != null) {
|
||||||
detectedSettingEntries.addAll(entries);
|
detectedSettingEntries.addAll(entries);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and start the provider console.
|
||||||
|
* @return CDT console.
|
||||||
|
*/
|
||||||
private IConsole startProviderConsole() {
|
private IConsole startProviderConsole() {
|
||||||
IConsole console = null;
|
IConsole console = null;
|
||||||
|
|
||||||
if (isConsoleEnabled && currentLanguageId != null) {
|
if (isConsoleEnabled && currentLanguageId != null) {
|
||||||
String extConsoleId;
|
String extConsoleId;
|
||||||
if (currentProject != null) {
|
if (currentProject != null) {
|
||||||
extConsoleId = "org.eclipse.cdt.managedbuilder.ScannerDiscoveryConsole";
|
extConsoleId = SCANNER_DISCOVERY_CONSOLE;
|
||||||
} else {
|
} else {
|
||||||
// TODO This console is not colored!
|
extConsoleId = SCANNER_DISCOVERY_GLOBAL_CONSOLE;
|
||||||
extConsoleId = "org.eclipse.cdt.managedbuilder.ScannerDiscoveryGlobalConsole";
|
|
||||||
}
|
}
|
||||||
ILanguage ld = LanguageManager.getInstance().getLanguage(currentLanguageId);
|
ILanguage ld = LanguageManager.getInstance().getLanguage(currentLanguageId);
|
||||||
if (ld != null) {
|
if (ld != null) {
|
||||||
String consoleId = ManagedBuilderCorePlugin.PLUGIN_ID + '.' + getId() + '.' + currentLanguageId;
|
String consoleId = ManagedBuilderCorePlugin.PLUGIN_ID + '.' + getId() + '.' + currentLanguageId;
|
||||||
String consoleName = getName() + ", " + ld.getName();
|
String consoleName = getName() + ", " + ld.getName(); //$NON-NLS-1$
|
||||||
URL defaultIcon = Platform.getBundle(CDT_MANAGEDBUILDER_UI_PLUGIN_ID).getEntry(DEFAULT_CONSOLE_ICON);
|
URL defaultIcon = Platform.getBundle(CDT_MANAGEDBUILDER_UI_PLUGIN_ID).getEntry(DEFAULT_CONSOLE_ICON);
|
||||||
if (defaultIcon == null) {
|
if (defaultIcon == null) {
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
|
@ -581,11 +633,16 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
console = CCorePlugin.getDefault().getConsole(ManagedBuilderCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$
|
console = CCorePlugin.getDefault().getConsole(ManagedBuilderCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return console;
|
return console;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get path to spec file which normally would be placed in workspace area.
|
||||||
|
* This value is used to replace macro ${INPUTS}.
|
||||||
|
*
|
||||||
|
* @param languageId - language ID.
|
||||||
|
* @return full path to the specs file.
|
||||||
|
*/
|
||||||
protected String getSpecFile(String languageId) {
|
protected String getSpecFile(String languageId) {
|
||||||
String specExt = getSpecFileExtension(languageId);
|
String specExt = getSpecFileExtension(languageId);
|
||||||
String ext = ""; //$NON-NLS-1$
|
String ext = ""; //$NON-NLS-1$
|
||||||
|
@ -594,7 +651,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
}
|
}
|
||||||
|
|
||||||
String specFileName = SPEC_FILE_BASE + ext;
|
String specFileName = SPEC_FILE_BASE + ext;
|
||||||
IPath workingLocation = ManagedBuilderCorePlugin.getWorkingDirectory();
|
IPath workingLocation = ManagedBuilderCorePlugin.getDefault().getStateLocation();
|
||||||
IPath fileLocation = workingLocation.append(specFileName);
|
IPath fileLocation = workingLocation.append(specFileName);
|
||||||
|
|
||||||
specFile = new java.io.File(fileLocation.toOSString());
|
specFile = new java.io.File(fileLocation.toOSString());
|
||||||
|
@ -602,6 +659,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
preserveSpecFile = specFile.exists();
|
preserveSpecFile = specFile.exists();
|
||||||
if (!preserveSpecFile) {
|
if (!preserveSpecFile) {
|
||||||
try {
|
try {
|
||||||
|
// In the typical case it is sufficient to have an empty file.
|
||||||
specFile.createNewFile();
|
specFile.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ManagedBuilderCorePlugin.log(e);
|
ManagedBuilderCorePlugin.log(e);
|
||||||
|
@ -614,6 +672,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
/**
|
/**
|
||||||
* Determine file extension by language id. This implementation retrieves first extension
|
* 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.
|
* from the list as there could be multiple extensions associated with the given language.
|
||||||
|
* This value is used to replace macro ${EXT}.
|
||||||
*
|
*
|
||||||
* @param languageId - given language ID.
|
* @param languageId - given language ID.
|
||||||
* @return file extension associated with the language or {@code null} if not found.
|
* @return file extension associated with the language or {@code null} if not found.
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
* Copyright (c) 2009, 2012 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
|
||||||
|
@ -16,6 +16,9 @@ import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsEditabl
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Build command parser capable to parse gcc command in build output and generate
|
||||||
|
* language settings per file being compiled.
|
||||||
|
*
|
||||||
* @since 8.1
|
* @since 8.1
|
||||||
*/
|
*/
|
||||||
public class GCCBuildCommandParser extends AbstractBuildCommandParser implements ILanguageSettingsEditableProvider {
|
public class GCCBuildCommandParser extends AbstractBuildCommandParser implements ILanguageSettingsEditableProvider {
|
||||||
|
@ -51,10 +54,17 @@ public class GCCBuildCommandParser extends AbstractBuildCommandParser implements
|
||||||
return (GCCBuildCommandParser) super.clone();
|
return (GCCBuildCommandParser) super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error Parser which allows highlighting of output lines matching the patterns of this parser.
|
||||||
|
* Intended for better troubleshooting experience.
|
||||||
|
*/
|
||||||
public static class GCCBuildCommandPatternHighlighter extends AbstractBuildCommandParser.AbstractBuildCommandPatternHighlighter {
|
public static class GCCBuildCommandPatternHighlighter extends AbstractBuildCommandParser.AbstractBuildCommandPatternHighlighter {
|
||||||
// ID of the parser taken from the existing extension point
|
// ID of the parser taken from the existing extension point
|
||||||
private static final String GCC_BUILD_COMMAND_PARSER_EXT = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$
|
private static final String GCC_BUILD_COMMAND_PARSER_EXT = "org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
public GCCBuildCommandPatternHighlighter() {
|
public GCCBuildCommandPatternHighlighter() {
|
||||||
super(GCC_BUILD_COMMAND_PARSER_EXT);
|
super(GCC_BUILD_COMMAND_PARSER_EXT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
* Copyright (c) 2009, 2012 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
|
||||||
|
@ -26,7 +26,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* @since 8.1
|
* @since 8.1
|
||||||
*/
|
*/
|
||||||
public class GCCBuiltinSpecsDetector extends ToolchainBuiltinSpecsDetector implements ILanguageSettingsEditableProvider {
|
public class GCCBuiltinSpecsDetector extends ToolchainBuiltinSpecsDetector implements ILanguageSettingsEditableProvider {
|
||||||
// ID must match the toolchain definition in org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point
|
// ID must match the tool-chain 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 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 enum State {NONE, EXPECTING_LOCAL_INCLUDE, EXPECTING_SYSTEM_INCLUDE, EXPECTING_FRAMEWORKS}
|
||||||
|
@ -51,12 +51,16 @@ public class GCCBuiltinSpecsDetector extends ToolchainBuiltinSpecsDetector imple
|
||||||
return optionParsers;
|
return optionParsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a list from one item.
|
||||||
|
*/
|
||||||
private List<String> makeList(String line) {
|
private List<String> makeList(String line) {
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
list.add(line);
|
list.add(line);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
@Override
|
@Override
|
||||||
protected List<String> parseOptions(String line) {
|
protected List<String> parseOptions(String line) {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
|
|
|
@ -31,7 +31,7 @@ public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecs
|
||||||
private Map<String, ITool> toolMap = new HashMap<String, ITool>();
|
private Map<String, ITool> toolMap = new HashMap<String, ITool>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concrete compiler specs detectors need to supply Toolchain ID.
|
* Concrete compiler specs detectors need to supply tool-chain ID.
|
||||||
*
|
*
|
||||||
* Tool-chain id must be supplied for global providers where we don't
|
* Tool-chain id must be supplied for global providers where we don't
|
||||||
* have configuration description to figure that out programmatically.
|
* have configuration description to figure that out programmatically.
|
||||||
|
@ -39,7 +39,7 @@ public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecs
|
||||||
protected abstract String getToolchainId();
|
protected abstract String getToolchainId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a tool handling given language in the tool-chain.
|
* Finds a tool handling given language in the tool-chain of the provider.
|
||||||
* This returns the first tool found.
|
* This returns the first tool found.
|
||||||
*/
|
*/
|
||||||
private ITool getTool(String languageId) {
|
private ITool getTool(String languageId) {
|
||||||
|
@ -55,10 +55,14 @@ public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecs
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ManagedBuilderCorePlugin.error("Unable to find tool in toolchain="+toolchainId+" for language="+languageId);
|
ManagedBuilderCorePlugin.error("Unable to find tool in toolchain=" + toolchainId + " for language=" + languageId); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a tool handling given language in the tool-chain.
|
||||||
|
* This returns the first tool found.
|
||||||
|
*/
|
||||||
private ITool getTool(String languageId, IToolChain toolchain) {
|
private ITool getTool(String languageId, IToolChain toolchain) {
|
||||||
ITool[] tools = toolchain.getTools();
|
ITool[] tools = toolchain.getTools();
|
||||||
for (ITool tool : tools) {
|
for (ITool tool : tools) {
|
||||||
|
@ -79,8 +83,7 @@ public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecs
|
||||||
ITool tool = getTool(languageId);
|
ITool tool = getTool(languageId);
|
||||||
String compilerCommand = tool.getToolCommand();
|
String compilerCommand = tool.getToolCommand();
|
||||||
if (compilerCommand.isEmpty()) {
|
if (compilerCommand.isEmpty()) {
|
||||||
String msg = "Unable to find compiler command in toolchain="+getToolchainId();
|
ManagedBuilderCorePlugin.error("Unable to find compiler command in toolchain=" + getToolchainId()); //$NON-NLS-1$
|
||||||
ManagedBuilderCorePlugin.error(msg);
|
|
||||||
}
|
}
|
||||||
return compilerCommand;
|
return compilerCommand;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +97,7 @@ public abstract class ToolchainBuiltinSpecsDetector extends AbstractBuiltinSpecs
|
||||||
ext = srcFileExtensions[0];
|
ext = srcFileExtensions[0];
|
||||||
}
|
}
|
||||||
if (ext == null || ext.isEmpty()) {
|
if (ext == null || ext.isEmpty()) {
|
||||||
ManagedBuilderCorePlugin.error("Unable to find file extension for language "+languageId);
|
ManagedBuilderCorePlugin.error("Unable to find file extension for language " + languageId); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return ext;
|
return ext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,12 @@ import org.eclipse.ui.console.IConsoleManager;
|
||||||
import org.eclipse.ui.console.MessageConsole;
|
import org.eclipse.ui.console.MessageConsole;
|
||||||
import org.eclipse.ui.console.MessageConsoleStream;
|
import org.eclipse.ui.console.MessageConsoleStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* Note that this console is not colored.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ScannerDiscoveryGlobalConsole implements ICConsole {
|
public class ScannerDiscoveryGlobalConsole implements ICConsole {
|
||||||
private MessageConsole console;
|
private MessageConsole console;
|
||||||
private ConsoleOutputStreamAdapter stream;
|
private ConsoleOutputStreamAdapter stream;
|
||||||
|
@ -56,14 +62,7 @@ public class ScannerDiscoveryGlobalConsole implements ICConsole {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
// FIXME - clean way of closing the streams. Currently the stream could get being used after closing
|
|
||||||
fConsoleStream.close();
|
fConsoleStream.close();
|
||||||
// if (!isOpen) {
|
|
||||||
// fConsoleStream.close();
|
|
||||||
// IStatus s = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Attempt to close stream second time", new Exception());
|
|
||||||
// MakeCorePlugin.log(s);
|
|
||||||
// flush();
|
|
||||||
// }
|
|
||||||
isOpen = false;
|
isOpen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,10 +334,8 @@ public class CDataUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method to create {@link ICLanguageSettingEntry} depending on kind.
|
* Convenience method to create {@link ICSettingEntry} depending on kind.
|
||||||
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
|
* Note that this method keeps the entries in the pool to avoid proliferation of duplicates.
|
||||||
*
|
|
||||||
* Note that the method always returns {@link ICLanguageSettingEntry}.
|
|
||||||
*/
|
*/
|
||||||
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags) {
|
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags) {
|
||||||
return createEntry(kind, name, value, exclusionPatterns, flags, null, null, null);
|
return createEntry(kind, name, value, exclusionPatterns, flags, null, null, null);
|
||||||
|
|
|
@ -31,13 +31,23 @@ public class Cygwin {
|
||||||
* Check if cygwin path conversion utilities are available in the path.
|
* Check if cygwin path conversion utilities are available in the path.
|
||||||
*
|
*
|
||||||
* @param envPath - list of directories to search for cygwin utilities separated
|
* @param envPath - list of directories to search for cygwin utilities separated
|
||||||
* by path separator (format of environment variable $PATH).
|
* by path separator (format of environment variable $PATH)
|
||||||
|
* or {@code null} to use current $PATH.
|
||||||
* @return {@code true} if cygwin is available, {@code false} otherwise.
|
* @return {@code true} if cygwin is available, {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
public static boolean isAvailable(String envPath) {
|
public static boolean isAvailable(String envPath) {
|
||||||
return Platform.getOS().equals(Platform.OS_WIN32) && findCygpathLocation(envPath) != null;
|
return Platform.getOS().equals(Platform.OS_WIN32) && findCygpathLocation(envPath) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if cygwin path conversion utilities are available in $PATH.
|
||||||
|
*
|
||||||
|
* @return {@code true} if cygwin is available, {@code false} otherwise.
|
||||||
|
*/
|
||||||
|
public static boolean isAvailable() {
|
||||||
|
return Platform.getOS().equals(Platform.OS_WIN32) && findCygpathLocation(null) != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conversion from Cygwin path to Windows path.
|
* Conversion from Cygwin path to Windows path.
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.cdt.managedbuilder.language.settings.providers.ToolchainBuilt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language settings provider to detect built-in compiler settings for IBM XLC compiler.
|
* Language settings provider to detect built-in compiler settings for IBM XLC compiler.
|
||||||
* Note that currently this class is hardwired to GCC toolchain {@code cdt.managedbuild.toolchain.gnu.base}.
|
|
||||||
*/
|
*/
|
||||||
public class XlcBuiltinSpecsDetector extends ToolchainBuiltinSpecsDetector implements ILanguageSettingsEditableProvider {
|
public class XlcBuiltinSpecsDetector extends ToolchainBuiltinSpecsDetector implements ILanguageSettingsEditableProvider {
|
||||||
// must match the toolchain definition in org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point
|
// must match the toolchain definition in org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point
|
||||||
|
|
Loading…
Add table
Reference in a new issue